#define MAX 100005
int tree[4*MAX];
int base;
voidinit(int n){
base = (1<<(int)(ceil(log2(n+2)))) -1;
for(int lx = 0;lx < 4*MAX;lx++)
tree[lx] = 0;
return;
}
voidtouch(int a){
int prc = a + base + 2;
tree[prc]++;
for(prc>>=1;prc;prc>>=1)
tree[prc] = tree[prc*2] + tree[prc*2 + 1];
return;
}
intqry(int a, int b){
int ret = 0;
for(a += base + 1, b += base+3;
a^b^1;a>>=1, b>>=1){
if(~a&1) ret += tree[a^1];
if(b&1) ret += tree[b^1];
}
return ret;
}
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
usingnamespace __gnu_pbds;
usingnamespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
tree_order_statistics_node_update>;
intmain(){
ordered_set<int> s;
s.insert(1);
s.insert(3);
cout << s.order_of_key(2) << endl;
// the number of elements in the s less than 2
cout << *s.find_by_order(0) << endl;
// print the 0-th smallest number in s(0-based)
return0;
}