I am trying to solve https://www.codechef.com/problems/CHEFDTRE. 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 : https://www.codechef.com/viewsolution/8566926
I am following e-maxx.ru for the concept.