Getting SIGSEGV error in MARBLEGF

I am repeatedly getting SIGSEGV error in MARBLEGF .The same problem when I am doing in C ,I am getting wrong answer.I have used segment tree to solve it.Can you please tell me what is the error in my code.
My code is :

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

for c++ solution
and
http://www.codechef.com/viewsolution/4339267

for c solution.