Chef and Easy Queries problem

Dont know why my code gets RE verdict on the smaller subtask? but passes the bigger subtask.

here is problem link
https://www.codechef.com/OCT20B/problems/CHEFEZQ

here is my solution

hello @tasfikrahman007
bro this is from live contest ,pls dont ask during the contest

sorry my bad, I wont