rt
#include <bits/stdc++.h>
#include <bits/extc++.h>
#define maxn 100010
using namespace __gnu_pbds;
tree<int, null_type,std::less<int>, rb_tree_tag,tree_order_statistics_node_update> t;
int n;
int opt,x;
int main(){
std::cin >> n;
for(int i = 1; i <= n; i++){
std::cin >> opt >> x;
if(opt == 1) t.insert(x);
else if(opt == 2) t.erase(x);
else if(opt == 3) std::cout << t.order_of_key(x) << std::endl;
else if(opt == 4) std::cout << *t.find_by_order(x) << std::endl;
else if(opt == 5) std::cout << *t.lower_bound(x) << std::endl;
else std::cout << *t.upper_bound(x) << std::endl;
}
return 0;
}
验证码rp pb(_ds)祭