Here is my accepted code : https://mirror.codeforces.com/contest/1791/submission/192106557
But this code should give TLE if the input is like :
1
200000 200000
a1 , a2 , a3 …… a200000
1 2 200000 (Update index 2 to 200000 and all 200000 queries are like this)
Your submission will likely fail after retesting. Although the original test set was weak, a few good test cases which eliminate most of the $$$\mathcal{O}(nq)$$$ solutions have been added during the hacking phase.
My original solution was with segment tree + lazy and that got accepted. Later I tried this and was surprised when this brute force got passed. Yeah I will be happy if this fails in the system test, but this is a very common way to solve this problem and there should be a test case in the main test in which this code should fail.