Why is my code slow can someone suggest me

The problem I am facing is in these Question:Contest Page | CodeChef

My Solution is these
https://www.codechef.com/viewsolution/51521190

I just wanted to know why is my solution not getting me 100pts as it works which loop makes it slower