stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int n,m;

    cin>>n>>m;

    long long sum=0;

    vector<int> v[100001];

    priority_queue<int> pq ;

    for(int i=0 ; i<n ; i++)

    {

        int r , d ;

        cin>>d>>r;

        v[d].push_back(r);

    }

    for(int i=1 ; i<=m  ; i++)

    {

        for(int j=0 ; j<v[i].size() ; j++)

        {

           pq.push( v[i][j] );

        }

        if( pq.size() !=0 ){

        sum+=pq.top();

        pq.pop();}

    }

    cout<<sum<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.4849709904778243x):
#include <bits/stdc++.h>



using namespace std;



typedef long long          ll;

typedef unsigned long long ull;

typedef vector<int>	       vi;

typedef vector<bool>       vb;

typedef map<int, int>      mii;

typedef pair<int, int>     ii;



#define INF                0x3f3f3f3f

#define INFLL              0x3f3f3f3f3f3f3f3f

#define each(x, s)         for(auto& x : s)

#define loop(x)	           for(int i = 0;i < x;i++)

#define vloop(v, x)        for(int v = 0;v < x;v++)

#define avg(l, r)          l + (r - l) / 2

#define iter(a)            a.begin(), a.end()

#define riter(a)           a.rbegin(), a.rend()

#define endl               "\n"



const ll mod = 1000000007;



int main() {

	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);



	int n, m;

	cin >> n >> m;

	vector<ii> ps;

	int a, b;

	loop(n) {

		cin >> a >> b;

		ps.emplace_back(a, b);

	}

	sort(iter(ps));

	int ans = 0;

	priority_queue<int> q;

	for (int i = 1, j = 0;i <= m and (j < n or !q.empty());i++) {

		while (j < n and ps[j].first <= i) q.push(ps[j].second), j++;

		if (!q.empty()) {

			ans += q.top();

			q.pop();

		}

	}

	cout << ans << endl;

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<queue>

typedef long long ll;

using namespace std;

const int maxn = 1e5+10;

vector<int>ve[maxn];

//如果想要队列 从小到大排列 



int main()

{

	ios::sync_with_stdio(0);

	cin.tie(0);

	int n,m;

	cin>>n>>m;

	int a,b;

	for(int i=1;i<=n;i++)

	{

		cin>>a>>b;

		if(a<=m)

		{

			ve[m-a+1].push_back(b);

		}

	}

	ll ans = 0;

	priority_queue<int>que;//队列从小到大飘排列 

	for(int i=m;i>=1;i--)

	{

		for(auto v:ve[i])

			que.push(v);

		if(!que.empty())

		{

			ans+=que.top();	

			que.pop();

		}	

	}

	cout<<ans<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.533369039288733x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> pll;

vector< pll > pii;

int main(){

	ll n, m, rew = 0, next = 0; 

	cin >> n >> m;

	for(int i = 0; i < n; i++){

	    ll a, b; cin >> a >> b;

	    pii.push_back(pll(a,b));

	}

	sort(pii.begin(), pii.end());

	priority_queue<ll> fila;

	for(int i = 1; i < m+1; i++){

	    while(next < n && pii[next].first == i){

	        fila.push(pii[next].second);

	        next++;

	    }

	    if(!fila.empty()){

	        rew += fila.top();

	        fila.pop();

	    }

	}

	//for(int i = 0; i < pii.size(); i++)cout << pii[i].first << " " << pii[i].second << endl;

   cout << rew << endl;

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<queue>



using namespace std;



vector<int>ve[120000];



int main(){

//	ios::sync_with_stdio(false);

//	cin.tie(0);cout.tie(0);

	int n,k;

	cin>>n>>k;

	int x,y;

	for(int i=0;i<n;i++){

		cin>>x>>y;

		if(x>k) continue;

		int tt=k-x+1;

		ve[tt].push_back(y);

	}

	

	priority_queue<int>q;

	int ans=0;

	for(int i=k;i>=1;i--){

		for(int j=0;j<ve[i].size();j++) q.push(ve[i][j]);

		if(!q.empty()){

			ans+=q.top();

			q.pop();	

		}

	}

	cout<<ans<<"\n";

	

	return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 4.016864980924385x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> pll;

vector< pll > pii;

int main(){

	ll n, m, rew = 0, next = 0; 

	cin >> n >> m;

	for(int i = 0; i < n; i++){

	    ll a, b; cin >> a >> b;

	    pii.push_back(pll(a,b));

	}

	sort(pii.begin(), pii.end());

	priority_queue<ll> fila;

	for(int i = 1; i < m+1; i++){

	    while(next < n && pii[next].first == i){

	        fila.push(pii[next].second);

	        next++;

	    }

	    if(!fila.empty()){

	        rew += fila.top();

	        fila.pop();

	    }

	}

	//for(int i = 0; i < pii.size(); i++)cout << pii[i].first << " " << pii[i].second << endl;

   cout << rew << endl;

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

 

using namespace std;

 

const int maxn=1e5+10;

const int inf=0x3f3f3f3f;

 

typedef long long ll;

 

vector<int> ve[maxn];//vector最好定义在外面，不然可能爆栈

 

int main()

{

//	freopen("input.txt","r",stdin);

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	

	int n,k;

	cin>>n>>k;

	int a,b;

	for(int i=0;i<n;i++)

	{

		cin>>a>>b;

		if(a>k) continue;//要有这个条件，不然下面的vector可能会成负值

		ve[k-a+1].push_back(b);//表示只能在m-a+1天或者之前做

	}

	priority_queue<int> q;

	int earn=0;

	for(int i=k;i>=1;i--)

	{

		for(int v:ve[i]) q.push(v);

		if(!q.empty())

		{

			earn+=q.top();

			q.pop();

		}

	}

	cout<<earn;

	

	

	return 0;

 } 


// Faster C++ solution for the same problem (measured speedup: 3.5262327412609644x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> pll;

vector< pll > pii;

int main(){

	ll n, m, rew = 0, next = 0; 

	cin >> n >> m;

	for(int i = 0; i < n; i++){

	    ll a, b; cin >> a >> b;

	    pii.push_back(pll(a,b));

	}

	sort(pii.begin(), pii.end());

	priority_queue<ll> fila;

	for(int i = 1; i < m+1; i++){

	    while(next < n && pii[next].first == i){

	        fila.push(pii[next].second);

	        next++;

	    }

	    if(!fila.empty()){

	        rew += fila.top();

	        fila.pop();

	    }

	}

	//for(int i = 0; i < pii.size(); i++)cout << pii[i].first << " " << pii[i].second << endl;

   cout << rew << endl;

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int n,m;

    cin>>n>>m;

    long long sum=0;

    vector<int> v[100001];

    priority_queue<int> pq ;

    for(int i=0 ; i<n ; i++)

    {

        int r , d ;

        cin>>d>>r;

        v[d].push_back(r);

    }

    for(int i=1 ; i<=m  ; i++)

    {

        for(int j=0 ; j<v[i].size() ; j++)

        {

           pq.push( v[i][j] );

        }

        if( pq.size() !=0 ){

        sum+=pq.top();

        pq.pop();}

    }

    cout<<sum<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.5347958437018536x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> pll;

vector< pll > pii;

int main(){

	ll n, m, rew = 0, next = 0; 

	cin >> n >> m;

	for(int i = 0; i < n; i++){

	    ll a, b; cin >> a >> b;

	    pii.push_back(pll(a,b));

	}

	sort(pii.begin(), pii.end());

	priority_queue<ll> fila;

	for(int i = 1; i < m+1; i++){

	    while(next < n && pii[next].first == i){

	        fila.push(pii[next].second);

	        next++;

	    }

	    if(!fila.empty()){

	        rew += fila.top();

	        fila.pop();

	    }

	}

	//for(int i = 0; i < pii.size(); i++)cout << pii[i].first << " " << pii[i].second << endl;

   cout << rew << endl;

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<queue>



using namespace std;



vector<int>ve[120000];



int main(){

//	ios::sync_with_stdio(false);

//	cin.tie(0);cout.tie(0);

	int n,k;

	cin>>n>>k;

	int x,y;

	for(int i=0;i<n;i++){

		cin>>x>>y;

		if(x>k) continue;

		int tt=k-x+1;

		ve[tt].push_back(y);

	}

	

	priority_queue<int>q;

	int ans=0;

	for(int i=k;i>=1;i--){

		for(int j=0;j<ve[i].size();j++) q.push(ve[i][j]);

		if(!q.empty()){

			ans+=q.top();

			q.pop();	

		}

	}

	cout<<ans<<"\n";

	

	return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 1.1451751907239767x):
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

vector <int> ve[N];

priority_queue <int> qe;

int main()

{

	int n, m;

	cin >> n >> m;

	int a, b;

	for(int i = 0; i < n;i ++)

	{

		cin >> a >> b;

		if(m - a + 1 < 1) continue;

		ve[m - a + 1].push_back(b);

	}

	int anx = 0;

	for(int i = m;i >= 1; i --)

	{

		for(int j = 0; j < ve[i].size(); j ++)

		{

			qe.push(ve[i][j]);

		}

		if(!qe.empty())

		{

			anx += qe.top();

			qe.pop();

		}

	}

	cout << anx << "\n";

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<queue>



using namespace std;



vector<int>ve[120000];



int main(){

//	ios::sync_with_stdio(false);

//	cin.tie(0);cout.tie(0);

	int n,k;

	cin>>n>>k;

	int x,y;

	for(int i=0;i<n;i++){

		cin>>x>>y;

		if(x>k) continue;

		int tt=k-x+1;

		ve[tt].push_back(y);

	}

	

	priority_queue<int>q;

	int ans=0;

	for(int i=k;i>=1;i--){

		for(int j=0;j<ve[i].size();j++) q.push(ve[i][j]);

		if(!q.empty()){

			ans+=q.top();

			q.pop();	

		}

	}

	cout<<ans<<"\n";

	

	return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 1.1451751907239767x):
#include<iostream>

#include<vector>

#include<queue>

using namespace std;

const int N=1e5+5;

vector<int>ve[N];

priority_queue<int>qe;

int main()

{

	int n,m;

	cin>>n>>m;

	int a,b;

	for(int i=0;i<n;i++)

	{

		cin>>a>>b;

		if(m-a+1<1)continue;

		ve[m-a+1].push_back(b);

	}

	int anx=0;

	for(int i=m;i>=1;i--){

		for(int j=0;j<ve[i].size();j++){

			qe.push(ve[i][j]);

		}

		if(!qe.empty()){

			anx+=qe.top();qe.pop();

		}

	}

	cout<<anx<<"\n";

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<queue>



using namespace std;



vector<int>ve[120000];



int main(){

//	ios::sync_with_stdio(false);

//	cin.tie(0);cout.tie(0);

	int n,k;

	cin>>n>>k;

	int x,y;

	for(int i=0;i<n;i++){

		cin>>x>>y;

		if(x>k) continue;

		int tt=k-x+1;

		ve[tt].push_back(y);

	}

	

	priority_queue<int>q;

	int ans=0;

	for(int i=k;i>=1;i--){

		for(int j=0;j<ve[i].size();j++) q.push(ve[i][j]);

		if(!q.empty()){

			ans+=q.top();

			q.pop();	

		}

	}

	cout<<ans<<"\n";

	

	return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 1.1462726408758575x):
#include<bits/stdc++.h>

using namespace std;

const int N=1e5+5;

vector<int> ve[N];

priority_queue<int> qe;

int main()

{

	int n,m,sum=0;

	cin>>n>>m;

	int a,b;

	for(int i=1;i<=n;i++)

	{

		cin>>a>>b;

		if(m-a+1>0)ve[m-a+1].push_back(b);

	}

	for(int i=m;i>0;i--)

	{

		for(int j=0;j<ve[i].size();j++)qe.push(ve[i][j]);

		if(qe.size())

		{

			sum+=qe.top();qe.pop();

		}

	}cout<<sum;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<queue>



using namespace std;



vector<int>ve[120000];



int main(){

//	ios::sync_with_stdio(false);

//	cin.tie(0);cout.tie(0);

	int n,k;

	cin>>n>>k;

	int x,y;

	for(int i=0;i<n;i++){

		cin>>x>>y;

		if(x>k) continue;

		int tt=k-x+1;

		ve[tt].push_back(y);

	}

	

	priority_queue<int>q;

	int ans=0;

	for(int i=k;i>=1;i--){

		for(int j=0;j<ve[i].size();j++) q.push(ve[i][j]);

		if(!q.empty()){

			ans+=q.top();

			q.pop();	

		}

	}

	cout<<ans<<"\n";

	

	return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 1.1462726408758575x):
#include<bits/stdc++.h>

using namespace std;

const int N=1e5+5;

vector<int>ve[N];

priority_queue<int> qe;

int main()

{

	int n,m;

	cin>>n>>m;

	int a,b;

	for(int i=1;i<=n;i++)

	{

		cin>>a>>b;

		if(m-a+1>0)ve[m-a+1].push_back(b);

	}

	int sum=0;

	for(int i=m;i>=1;i--)

	{

		for(int j=0;j<ve[i].size();j++)qe.push(ve[i][j]);

		if(qe.size())

		{

			sum+=qe.top();

			qe.pop();

		}

	}

	cout<<sum;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<queue>



using namespace std;



vector<int>ve[120000];



int main(){

//	ios::sync_with_stdio(false);

//	cin.tie(0);cout.tie(0);

	int n,k;

	cin>>n>>k;

	int x,y;

	for(int i=0;i<n;i++){

		cin>>x>>y;

		if(x>k) continue;

		int tt=k-x+1;

		ve[tt].push_back(y);

	}

	

	priority_queue<int>q;

	int ans=0;

	for(int i=k;i>=1;i--){

		for(int j=0;j<ve[i].size();j++) q.push(ve[i][j]);

		if(!q.empty()){

			ans+=q.top();

			q.pop();	

		}

	}

	cout<<ans<<"\n";

	

	return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 1.1462726408758575x):
#include<bits/stdc++.h>

using namespace std;

const int N=1e5+5;

vector<int> ve[N];

priority_queue<int> qe;

int main()

{

	int n,m,sum=0;

	cin>>n>>m;

	int a,b;

	for(int i=1;i<=n;i++)

	{

		cin>>a>>b;

		if(m-a+1>0)ve[m-a+1].push_back(b);

	}

	for(int i=m;i>0;i--)

	{

		for(int j=0;j<ve[i].size();j++)qe.push(ve[i][j]);

		if(qe.size())

		{

			sum+=qe.top();qe.pop();

		}//djgldgsldgjdl

	}cout<<sum;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<queue>



using namespace std;



vector<int>ve[120000];



int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);cout.tie(0);

	int n,k;

	cin>>n>>k;

	int x,y;

	for(int i=0;i<n;i++){

		cin>>x>>y;

		if(x>k) continue;

		int tt=k-x+1;

		ve[tt].push_back(y);

	}

	

	priority_queue<int>q;

	int ans=0;

	for(int i=k;i>=1;i--){

		for(int j=0;j<ve[i].size();j++) q.push(ve[i][j]);

		if(!q.empty()){

			ans+=q.top();

			q.pop();	

		}

	}

	cout<<ans<<"\n";

	

	return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 1.1428916819911832x):
#include <iostream>

#include <fstream>

#include <sstream>

#include <iomanip>

#include <algorithm>

#include <numeric>

#include <vector>

#include <string>

#include <set>

#include <map>

#include <queue>

#include <stack>

#include <climits>

#include <cmath>

#include <cstring>

#include <unordered_set>

#include <unordered_map>

using namespace std;



#define pb push_back

#define fst first

#define snd second



typedef long long ll;

typedef pair<int,int> pii;

template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;



const ll MOD=1e9+7;



int N,M;

vector<int> c[100100];



int main(){

  ios::sync_with_stdio(0);cin.tie(0);



  cin>>N>>M;

  int a,b;

  for(int i=0;i<N;i++) cin>>a>>b, c[a].pb(b);



  priority_queue<int> q;

  int res=0;

  for(int i=1;i<=M;i++) {

    for(int k:c[i]) q.push(k);

    if (!q.empty()) {

      res+=q.top();

      q.pop();

    }

  }

  cout << res << endl;

  return 0;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<queue>



using namespace std;



vector<int>ve[120000];



int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);cout.tie(0);

	int n,k;

	cin>>n>>k;

	int x,y;

	for(int i=0;i<n;i++){

		cin>>x>>y;

		if(x>k) continue;

		int tt=k-x+1;

		ve[tt].push_back(y);

	}

	

	priority_queue<int>q;

	int ans=0;

	for(int i=k;i>=1;i--){

		for(int j=0;j<ve[i].size();j++) q.push(ve[i][j]);

		if(!q.empty()){

			ans+=q.top();

			q.pop();	

		}

	}

	cout<<ans<<"\n";

	

	return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 4.046848816622836x):
#include<bits/stdc++.h>



using namespace std;



int main()

{

    long long n,m,a,b,i,j=0;

    cin>>n>>m;

    vector < pair<int,int> > ab;

    for(i=0; i<n; i++)

    {

        cin>>a>>b;

        ab.push_back(make_pair(a,b));

    }

    priority_queue <long long> pq;

    sort(ab.begin(),ab.end());

    long long count=0;

    for(i=1; i<=m; i++)

    {

        for(; ab[j].first==i; j++)

        {

            pq.push(ab[j].second);

        }

        if(pq.size())

        {

            count+=pq.top();

            pq.pop();

        }

    }

    cout<<count;

}
// Slower C++ solution:
#include <iostream>

#include <fstream>

#include <sstream>

#include <iomanip>

#include <algorithm>

#include <numeric>

#include <vector>

#include <string>

#include <set>

#include <map>

#include <queue>

#include <stack>

#include <climits>

#include <cmath>

#include <cstring>

#include <unordered_set>

#include <unordered_map>

using namespace std;



#define pb push_back

#define fst first

#define snd second



typedef long long ll;

typedef pair<int,int> pii;

template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;



const ll MOD=1e9+7;



int N,M;

vector<int> c[100100];



int main(){

  ios::sync_with_stdio(0);cin.tie(0);



  cin>>N>>M;

  int a,b;

  for(int i=0;i<N;i++) cin>>a>>b, c[a].pb(b);



  priority_queue<int> q;

  int res=0;

  for(int i=1;i<=M;i++) {

    for(int k:c[i]) q.push(k);

    if (!q.empty()) {

      res+=q.top();

      q.pop();

    }

  }

  cout << res << endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.540885702809809x):
#include<bits/stdc++.h>



using namespace std;



int main()

{

    long long n,m,a,b,i,j=0;

    cin>>n>>m;

    vector < pair<int,int> > ab;

    for(i=0; i<n; i++)

    {

        cin>>a>>b;

        ab.push_back(make_pair(a,b));

    }

    priority_queue <long long> pq;

    sort(ab.begin(),ab.end());

    long long count=0;

    for(i=1; i<=m; i++)

    {

        for(; ab[j].first==i; j++)

        {

            pq.push(ab[j].second);

        }

        if(pq.size())

        {

            count+=pq.top();

            pq.pop();

        }

    }

    cout<<count;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

#define m long long

#define d(s,i,n) for(m i=s;i<n;i++)

#define z else

int main(){m n,a,b,o=1e9+7,x=90,l[x][x],r[x][x];cin>>n;d(0,i,x){l[i][0]=r[i][0]=1;d(1,j,x){if(i==j)r[i][j]=r[i][j-1]*2+l[i][j-1];z r[i][j]=r[i][j-1]+l[i][j-1];l[i][j]=r[i][j-1];}}d(0,i,n){cin>>a>>b;if(b>a)swap(a,b);m k=0;d(0,j,x)if(a>=r[0][j]&&b>=l[0][j])k=j;m g;if(k==0)k=1,g=1;z if(k==1)if(b==1)g=a;z g=4;z{g=1;if(b>=r[0][k]&&a>=l[0][k]&&l[0][k]<r[0][k])g++;d(1,j,k+1)if(r[j][k]<=a&&l[j][k]<=b)g+=1+(a-r[j][k])/l[j][k];d(1,j,k+1)if(r[j][k]<=b)g+=1+(b-r[j][k])/l[j][k];}cout<<k<<" "<<g%o<<" ";}}

// Faster C++ solution for the same problem (measured speedup: 1.1223476919458995x):
#include<iostream>

#define rep(i,n)for(int i=0;i<n;i++)

#define l int64_t

using namespace std;l q,x,y,f[99]={0,1},m=1e9+7;main(){cin>>q;rep(i,97)f[i+2]=f[i]+f[i+1];rep(i,q){cin>>x>>y;if(x>y)swap(x,y);if(y<=2){cout<<1<<" "<<(y==1?1:x==1?2:4)<<" ";continue;}rep(j,99){if(x<f[j]||y<f[j+1]){l a=x==1?2:1;rep(k,j-2){l n=f[j-1]+f[j-3-k]*f[k+2],m=f[j]+f[j-2-k]*f[k+2];if(n<=x&&m<=y)a+=(y-m)/n+1;}if(f[j]<=x){a++;rep(k,j-2)a+=(x-f[j])/(f[j-2-k]*f[k+2]);}cout<<j-2<<" "<<a%m<<" ";j=99;}}}}
// Slower C++ solution:
#include<iostream>

using namespace std;

#define m int64_t

#define d(s,i,n) for(m i=s;i<n;i++)

#define z else

main(){m n,a,b,o=1e9+7,x=90,l[x][x],r[x][x];cin>>n;d(0,i,x){l[i][0]=r[i][0]=1;d(1,j,x){if(i==j)r[i][j]=r[i][j-1]*2+l[i][j-1];z r[i][j]=r[i][j-1]+l[i][j-1];l[i][j]=r[i][j-1];}}d(0,i,n){cin>>a>>b;if(b>a)swap(a,b);m k=0;d(0,j,x)if(a>=r[0][j]&&b>=l[0][j])k=j;m g;if(k==0)k=1,g=1;z if(k==1)if(b==1)g=a;z g=4;z{g=1;if(b>=r[0][k]&&a>=l[0][k]&&l[0][k]<r[0][k])g++;d(1,j,k+1)if(r[j][k]<=a&&l[j][k]<=b)g+=1+(a-r[j][k])/l[j][k];d(1,j,k+1)if(r[j][k]<=b)g+=1+(b-r[j][k])/l[j][k];}cout<<k<<" "<<g%o<<" ";}}

// Faster C++ solution for the same problem (measured speedup: 1.12254045556919x):
#include<iostream>

#define rep(i,n)for(int i=0;i<n;i++)

#define l int64_t

using namespace std;l q,x,y,f[99]={0,1},m=1e9+7;main(){cin>>q;rep(i,97)f[i+2]=f[i]+f[i+1];rep(i,q){cin>>x>>y;if(x>y)swap(x,y);if(y<=2){cout<<1<<" "<<(y==1?1:x==1?2:4)<<" ";continue;}rep(j,99){if(x<f[j]||y<f[j+1]){l a=x==1?2:1;rep(k,j-2){l n=f[j-1]+f[j-3-k]*f[k+2],m=f[j]+f[j-2-k]*f[k+2];if(n<=x&&m<=y)a+=(y-m)/n+1;}if(f[j]<=x){a++;rep(k,j-2)a+=(x-f[j])/(f[j-2-k]*f[k+2]);}cout<<j-2<<" "<<a%m<<" ";j=99;}}}}
// Slower C++ solution:
#include<iostream>

using namespace std;

#define m long long

#define d(s,i,n) for(m i=s;i<n;i++)

#define z else

main(){m n,a,g,b,o=1e9+7,x=90,l[x][x],r[x][x];cin>>n;d(0,i,x){l[i][0]=r[i][0]=1;d(1,j,x){if(i==j)r[i][j]=r[i][j-1]*2+l[i][j-1];z r[i][j]=r[i][j-1]+l[i][j-1];l[i][j]=r[i][j-1];}}d(0,i,n){cin>>a>>b;if(b>a)swap(a,b);m k=0;d(0,j,x)if(a>=r[0][j]&&b>=l[0][j])k=j;if(k==0)k=1,g=1;z if(k==1)if(b==1)g=a;z g=4;z{g=1;if(b>=r[0][k]&&a>=l[0][k]&&l[0][k]<r[0][k])g++;d(1,j,k+1)if(r[j][k]<=a&&l[j][k]<=b)g+=1+(a-r[j][k])/l[j][k];d(1,j,k+1)if(r[j][k]<=b)g+=1+(b-r[j][k])/l[j][k];}cout<<k<<" "<<g%o<<" ";}}

// Faster C++ solution for the same problem (measured speedup: 1.1223476919458995x):
#include<iostream>

#define rep(i,n)for(int i=0;i<n;i++)

#define l int64_t

using namespace std;l q,x,y,f[99]={0,1},m=1e9+7;main(){cin>>q;rep(i,97)f[i+2]=f[i]+f[i+1];rep(i,q){cin>>x>>y;if(x>y)swap(x,y);if(y<=2){cout<<1<<" "<<(y==1?1:x==1?2:4)<<" ";continue;}rep(j,99){if(x<f[j]||y<f[j+1]){l a=x==1?2:1;rep(k,j-2){l n=f[j-1]+f[j-3-k]*f[k+2],m=f[j]+f[j-2-k]*f[k+2];if(n<=x&&m<=y)a+=(y-m)/n+1;}if(f[j]<=x){a++;rep(k,j-2)a+=(x-f[j])/(f[j-2-k]*f[k+2]);}cout<<j-2<<" "<<a%m<<" ";j=99;}}}}
// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <iostream>

#include <algorithm>

#include <vector>

#include <stack>

#include <queue>

#include <set>

#include <map>

#include <string>

#include <cmath>

#include <cstdlib>

using namespace std;



const int MAX = 13;

int n;

string cmd;

string s;

set<string> S;



int main() {

    //freopen("in.txt", "r", stdin);

    //freopen("out.txt", "w", stdout);

    ios::sync_with_stdio(false);

    cin >> n;

    for (int i = 0; i < n; i++) {

        cin >> cmd >> s;

        if (cmd == "insert") {

            S.insert(s);

        } else {

            if (S.count(s)) {

                cout << "yes" << endl;

            } else {

                cout << "no" << endl;

            }

        }

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.359764044215608x):
/*

//alds1_4_c:Dictionary

//算法:开放地址法散列表

//Time: 2018/1/8 星期一

*/

#include<stdio.h>

#include<string.h>



const int M=1000003;

const int L=14;



char H[M][L];



//对于每个字符返回的定义值

int getChar(char ch){

    if(ch=='A') return 1;

    if(ch=='C') return 2;

    if(ch=='D') return 3;

    if(ch=='T') return 4;

    return 0;

}

//对于字符串返回的初始散列值

long long getKey(char str[]){

    long long len=strlen(str),sum=0,p=1;

    for(int i=0;i<len;++i){

        sum+=p*getChar(str[i]);

        //每次获取定义值后p*5,相当于转换成五进制,不会冲突

        p*=5;

    }

    return sum;

}



//开放式散列值计算式: h(k,i)=(h1(k)+i*h2(k))%M

int h1(int key){

    return key%M;

}

//为了保证不会递归冲突(即往下算结果始终相同),必须使h2(key)与M互素

//TLE最好的情况就是改这个函数= =

//目前可以AC的: 1+(key%(M-1))

//(1+key)%(M-1)

int h2(int key){

    return (1+key)%(M-1);

}



//查找

//-1表示找到

//h表示找到第一个可插入点

int find(char str[]){

    long long key=getKey(str),i,h;

    for(i=0;;++i){

        h=(h1(key)+i*h2(key))%M;

        if(strcmp(H[h],str)==0) return -1;

        else if(strlen(H[h])==0) return h;

    }

    return 0;

}



//插入

void insert(char str[]){

    int key=find(str);

    if(key!=-1) strcpy(H[key],str);

}



int main(){

    for(int i=0;i<M;++i) H[M][0]='\0';

    char str[L],com[L];

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;++i){

        scanf("%s %s",com,str);



        if(com[0]=='i'){

            insert(str);

        }else{

            if(find(str)==-1)

                printf("yes\n");

            else

                printf("no\n");

        }

    }



    return 0;

}