Getting Runtime error(SIGXFSZ) in KNPSK

Getting a runtime error named SIGXFSZ in my solution:
https://www.codechef.com/viewsolution/29907338

It works perfectly fine for any random inputs i put in.
When i comment out the last lines whcih are responsible for the output, the error disappears.

Any help would be great.
Thanks…