SIGSEVG help

My solution on offline mode gets 30% AC and shows SIGSEGV
link CodeChef: Practical coding for everyone
Where do i made a mistake? . Can someone look into my code and please say that. Thanks in Advance

https://discuss.codechef.com/questions/136251/chefres-editorial/136286

Thanks it have corrrected it and got 100% AC.