What's Wrong with my code?

working fine in my machine but codechef is showing WRONG ANSWER…
Here is the link to my solution:-CodeChef: Practical coding for everyone
Here is the link to problem:-CodeChef: Practical coding for everyone

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 ).