RE for 3 test cases in SEAD problem

I am trying to solve SEAD problem according to the editorial (binarysearch+sparse tables) but i am getting Runtime error for 3 test cases in that?
I tried a lot and unable to figure out the reason for that. Please have a look at the code and help me. Thank you :slight_smile:

Link to the code : code

My submission : submission