Can anyone help me out, or tell me why am I getting a WA ?

Solution Approach : I’ve used standard sparse table approach to solve the problem. You could easily figure that out from the implementation.

I know this is hard-core optimization problem, but I’m unable to get even 70 points. It’d be really helpful if anyone could point out my mistake, or tell me where I’m possibly going wrong.