Editorial for SAC '21 Code Challenge P4 - Averaging Averages
                Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
                Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1
Maintaining the averages in an array and running a for-loop to sum up the grades and dividing by the total number of grades suffices.
Time Complexity: 
Subtask 2
A prefix sum array can be used to expedite these queries since the array is static.
Time Complexity: 
Comments
If you keep getting TLEs with Python, use PyPy instead.
I used C++ but still had trouble with TLE. Specific tips:
With these, you should be good to go!