Why my code is showing wrong answer?

I was solving “The Gray Similar Code” problem on CodeChef.

Problem Link: https://www.codechef.com/problems/GRAYSC

My solution: https://ide.codingblocks.com/s/240434

Why my code is showing the wrong answer?

@siddharth_1_3277
Put line 45 after line 46
It is inside for loop of i to n

Still, getting the wrong answer.

Here is my code: https://ide.codingblocks.com/s/240434

@siddharth_1_3277
Use unsigned long long
https://www.codechef.com/viewsolution/1285150