Fake binary search

The link of the problem is : FAKEBS Problem - CodeChef
I have written this code : CodeChef: Practical coding for everyone
It is giving wrong answer in just 3 test cases of small subtasks, I am not able to find the case where it fails, please help me out :slightly_frowning_face: