Why is it showing runtime error(sigsegv) in chandf problem

problem:
https://www.codechef.com/MAY20B/problems/CHANDF
my solution:
https://www.codechef.com/viewsolution/33192492