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 http://ideone.com/S63Dsc

//