SIGSEGV in MAJOR of spoj

why is this code giving me run time error(SIGSEGV) on spoj while its working fine on ideone.com
The link to my code is S63Dsc - Online C Compiler & Debugging Tool - Ideone.com