Where is my logic wrong?

Link to question

Link to solution

All except one test case is passing. where is the logic flawed?

int overflowed

https://www.codechef.com/viewsolution/29886689

Tried with unsigned long long. Still the same test case is failing.

you need to change also these lines:

 if(len%2 == 0) 
    result += (len/2)*(len+1);
else
    result += len*((len+1)/2);

check this