Can anyone please help me with this problem?

Here is the problem statement: https://www.codechef.com/problems/SUMTRIAN
Here is my code: https://www.codechef.com/viewsolution/26329783

Any help would be appreciated :smile: