Help needed in Sqrt Decomposition

Question link :
I was searching for some questions on sqrt decomposition and got this one…
Solved this range query problem from codeforces using Sqrt Decomposition but it gives TLE .

Can someone tell me what better could be done in my code to remove TLE

here is my soln link :