SPOJ ABSYS Getting Runtime Error (segmentation fault) link to code : http://ideone.com/k2mM54

Although the code successfully compiles and execute on code blocks but getting runtime error on ideone and on spoj, problem link:http://www.spoj.com/problems/ABSYS/ link to code : http://ideone.com/k2mM54