Whats Wrong ?

I am trying the FLIPCOIN question without lazy propagation through segmented tree.
My solution -:

However i am getting SIGGEV error please help.