Getting TLE in ENGXOR

I am getting TLE in ENGXOR even though it is O(n + q) solution.
https://www.codechef.com/viewsolution/30518860

Doesn’t count set bit again and again. It takes lot of time.

https://www.codechef.com/viewsolution/30331723
This is my sol. No Tle