C ++ program to implement the above approach
#include <bits/stdc++.h> NEW_LINE #include <ext/pb_ds/assoc_container.hpp> NEW_LINE #include <ext/pb_ds/tree_policy.hpp> NEW_LINE using namespace std ; using namespace __gnu_cxx ; using namespace __gnu_pbds ; template < typename T > using ordered_set = tree < T , null_type , less < T > , rb_tree_tag , tree_order_statistics_node_update > ;