Chef and Left-Right wrong ans

Hello all,
I am doing chef and left-right. below is my submission.
Solution: 100594587 - CodeChef
I’m getting WA for this submission.

Now here is someone else’s code Solution: 99321995 - CodeChef

I think logic is same but still getting WA can someone point out where my code is breaking.