#include <bits/stdc++.h>
//_ ************************** Advanced PBDS ***********************************
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<class T>
using ordered_set = tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update
>;
//_ ****************************************************************************
#define int long long int
#define double long double
#define print(a) for(auto x : a) cout << x << " "; cout << endl
const int M = 1000000007;
const int N = 3e5+9;
const int INF = 2e9+1;
const int LINF = 2000000000000000001;
inline int power(int a, int b, int mod=M) {
int x = 1;
a %= mod;
while (b) {
if (b & 1) x = (x * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return x;
}
//_ ***************************** START Below *******************************
void solve() {
ordered_set<int> s;
for (auto x : {10LL, 5LL, 20LL, 15LL, 8LL, 2LL})
s.insert(x);
int n = s.size();
cout << "Index : ";
for (int i=0; i<=n; i++) cout << i << " "; cout << endl;
cout << "Elements : ";
for (auto x : s) cout << x << " "; cout << endl;
cout << endl;
int x = 10;
cout << "Index of "<< x <<" : " << s.order_of_key(x) << endl;
cout << "Count < "<< x <<" : " << s.order_of_key(x);
cout << " ";
cout << "Count <= "<< x <<" : " << s.order_of_key(x+1) << endl;
cout << "Count > "<< x <<" : " << n - s.order_of_key(x+1);
cout << " ";
cout << "Count >= "<< x <<" : " << n - s.order_of_key(x) << endl;
cout << endl;
// -------------------------------------------------
cout << "0th Smallest : " << *s.find_by_order(0);
cout << " ";
cout << "2nd Smallest : " << *s.find_by_order(2) << endl;
cout << "1st Largest : " << *s.find_by_order(n-1);
cout << " ";
cout << "2nd Largest : " << *s.find_by_order(n-2) << endl;
cout << "Median : " << *s.find_by_order(n / 2) << endl;
cout << endl;
// -------------------------------------------------
int L = 5, R = 15;
cout << "Elements in Range [" << L << "," << R << "] : "
<< s.order_of_key(R + 1) - s.order_of_key(L) << endl << endl;
// -------------------------------------------------
cout << "Iterate By Index : ";
for (int i = 0; i < n; i++) {
cout << *s.find_by_order(i) << " ";
}
cout << endl;
// -------------------------------------------------
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}