This is an R program, so in order to run it, you will need to download R (https://www.r-project.org/). I also recommend using RStudio as the console (https://rstudio.com/products/rstudio/download/).
To run, load the R file into RStudio. Highlight the code you want to run, then press the Run button above the script.
I chose to tackle this problem using R, as I find R intuitive for uses like spreadsheet manipulation. I started by breaking the problem into two sections and determining what data was needed for each problem. Then I spent some time examining the format the data was in and testing a few lines for cases. Next I wrote out all the steps I would need to take to solve the problem. After I felt I had a good idea of what I needed to do, I started coding.