What's Wrong with my code?

working fine in my machine but codechef is showing WRONG ANSWER…
Here is the link to my solution:-https://www.codechef.com/viewsolution/18690441
Here is the link to problem:-https://www.codechef.com/LOCMAY18/problems/DSERIES/

you are using int to store results. Try using long long int for storing results.
Change data type of sum and pr to long long , that will do ( but this will only allow you to pass subtask 1 ).