#include using namespace std; #define ALL(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const pair&p){ os< ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,pair&p){ is>>p.first>>p.second; return is; } template istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } #include #include using namespace __gnu_pbds; template using set_kth_less=tree,rb_tree_tag,tree_order_statistics_node_update>; template using set_kth_greater=tree,rb_tree_tag,tree_order_statistics_node_update>; signed main(){ int q,k;cin>>q>>k; map id; set_kth_less> st; while(q--){ int t;cin>>t; if(t==1){ ll x;cin>>x; int j=id[x]; id[x]++; st.insert({x,j}); } else{ if((int)st.size()first<