Getting SIGSEGV in treap

I am trying to solve CHEFDTRE Problem - CodeChef. This is my first attempt at treap and I chose this problem as it seemed simple for beginner. But I am getting SIGSEGV in all cases. It runs fine on my computer. I am unable to find my mistake. Please help.

My code : CodeChef: Practical coding for everyone

I am following e-maxx.ru for the concept.

I found the problem. I needed to update size of subtree at a lot of places. I don’t know why, but I am sure I can figure it out on my own :slight_smile: