Issues in COLGLF2

I was trying to the COLGLF2 problem from February Starters 2021. I’m getting WA even though my solution is correct. I have compared it with other’s solution. This is the link : Solution: 43299005 | CodeChef

your sum and tmp will have to be long long.

I have explained why here if you want to know.