SPOJ SIGABRT ERROR IN SPCS

My code is working fine for all the testcases in ideone and in mageia… but when i submit in spoj it shows SIGABRT error…
MY soln link :-- v0KuYL - Online C++ Compiler & Debugging Tool - Ideone.com
Question link :-- SPOJ.com - Problem SPCS
Thnx in advance for correction …