WA in DP Question Frogv

Someone plz explain why am I getting WA in this code.
https://www.codechef.com/viewsolution/33235561
The link to the question:

I have no idea how your code doesn’t TLE, the test cases must be terrible. But your code will fail for a query where A > B.

Thanks for pointing out this query and it gives TLE after swapping A and B :disappointed_relieved:.
Btw I have figured out another approach :slightly_smiling_face: .