GROWGOLD error :/

It is giving me a run time error. However my program is working fine in visual studio. can anyone help me out?
The link is
http://www.codechef.com/viewsolution/5201713
Thanks in advance

I would simply add it saying try to solve some get started problem to understand the online judge as the trend on online judge is different…

No need to getchar(),no spaces in scanf(),etc