AMR15D: Please tell me what's wrong in my code? I've used Segment Trees for Prefix Sum

code here

I wanna know why is it giving wrong answer even though my solution is not much different than that mentioned in Editorial. Just the difference is that I’ve used Segment Trees for calculation of Prefix Sum in O(log(n)) (it isn’t TLE btw)