void solve(){ int N,X; char ch[5]; scanf("%d",&N); Treap root; while(N--){ scanf("%s%d",ch,&X); if (ch[0] == 'I') root.Insert_unq(X);//, root.print(); else if (ch[0] == 'D') root.Erase(X); else if (ch[0] == 'C'){ int res = root.Count(X); printf("%d\n",res); } else { int res = root.Kth(X); if (res == INT_MIN) printf("invalid\n"); else printf("%d\n",res); } } }