I was solving https://www.codechef.com/COOK74/problems/TALAZY
First submission (Wrong answer): https://www.codechef.com/viewsolution/11557512
Second submission (Accepted): https://www.codechef.com/viewsolution/11560985
The change was changing
if(n % 2){ ...
to
if(n & 1){ ...
Does it make the difference?
Edit: After people pointed out the change about 'long' to 'long long', I have edited the question.