We have a problem about how to quickly calculate the sums on the interval l...r in a static array a in less than O(n) asymptotics.
Let's divide the array a into k blocks of the same size and first calculate the sum of elements for each of them.
Now, when answering the request, we can go through the elements of the array a and add them to the result, also if one of the blocks lies inside the segment, then we can add its sum to the result and skip the elements of this block.
The maximum number of operations per query with this algorithm is n / k + k, so the optimal k is equal to the square root of n.
 

We have a problem about how to quickly calculate the sums on the segment l...r in the array a, in which the elements can change one at a time, in asymptotics less than O(n).
This task is solved similarly to the previous one, but when requesting a change, you need to change the amount in the corresponding block.

A task is given in which it is necessary to carry out bulk operations on a segment and recognize an element by index.
Mass operations are carried out as a sum calculation on a segment.
For each block, we store the change in that block, and when requesting an element from that block, we take that information into account.