Getting SIGSEGV error in GCDQ

http://www.codechef.com/viewsolution/5891418