#include #include using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < n; i++) #define all(a) a.begin(),a.end() #define SORT(a) sort(all(a)); #define MIN(a) *min_element(all(a)) #define MAX(a) *max_element(all(a)) #define SUM(a) accumulate(all(a),0LL) using ll=long long; using ld=long double; using ull=unsigned long; ll MOD=998244353; using mint = static_modint<998244353>; const int dx[]={0,1,0,-1,1,-1,1,-1};const int dy[]={1,0,-1,0,1,1,-1,-1}; const string ALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZ";const string alpha="abcdefghijklmnopqrstuvwxyz"; int main(){ cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); ll n,q;cin>>n>>q; ll pc=n; mapmp; //ratingからユーザーネームへ mapmp2; setrepair; setunrepair; ll cnt=0; rep(i,q){ ll num;cin>>num; if(num==1){ string s; ll r; cin>>s>>r; mp[r]=s; mp2[s]=r; unrepair.insert(r); cnt++; if(cnt>pc){ vectorans(0); while(cnt!=pc){ cnt--; if(unrepair.size()==0){ auto itr=repair.begin(); //cout<>x; pc-=x; if(cnt>pc){ vectorans(0); while(cnt!=pc){ cnt--; if(unrepair.size()==0){ auto itr=repair.begin(); //cout<>s>>x; unrepair.erase(mp2[s]); repair.insert(mp2[s]); pc+=x; } } }