stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
/*|In The Name Of Allah|*/



#include <bits/stdc++.h>



using namespace std;



const int N = 1e5+5;



const int mod = 1e9+7;



int n;

int m;

vector < int > profit[N];



int main(){

    scanf("%d%d" , &n , &m);

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

        int a , b;

        scanf("%d%d" , &a , &b);

        if(a > m)

            continue;

        profit[m - a].push_back(b);

    }

    int ans = 0;

    priority_queue < int > best;

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

        for(auto v : profit[i]){

            best.push(v);

        }

        if(best.size()){

            ans += best.top();

            best.pop();

        }

    }

    printf("%d\n" , ans);

}








// Optimized solution to the same problem (faster):
// D- Summer vacation- atcoder.cpp : This file contains the 'main' function. Program execution begins and ends there.

//



#include <iostream>

#include <deque>

#include <set>

#include <algorithm>

using namespace std;

const int N = 1e5 , M = 1e5  ;

int n, m , u , v;

deque <pair<int, int>> Q;

int ans = 0;



int main()

{

	cin >> n >> m ;



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

		cin >> u >> v;

		Q.push_back(make_pair(u, v));

	}



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

	multiset<int> s;

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

	{

		int size = Q.size();

		for(int j = 0 ; j < size ;j++){

			if (Q.front().first == i)

			{

				s.insert(Q.front().second);

				Q.pop_front();

			}

			else break;

		}

		if (!s.empty()) {

			ans += *--s.end() ;

			s.erase(--s.end()) ;

		}

	}

	cout << ans;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<vector>

#include<queue>



using namespace std;



struct node{

	int x,y;

}a[100009];

vector<int>ve[100009];



bool cmp(node x,node y)

{

	if(x.y !=y.y) return x.y >y.y ;

	else return x.x>y.x ;

}



int main()

{

	int m,n,x,y;

	cin>>n>>m;

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

	{

		cin>>x>>y;

		//cin>>a[i].x>>a[i].y ;

		if(x<=m)

		{

			ve[m-x+1].push_back(y);

		} 

	}

	//sort(a,a+n,cmp);

	priority_queue<int>q;

	int j=m;

	long long sum=0;

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

	{

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

		if(!q.empty())

		{

			sum+=1ll*q.top();

			q.pop();

		}

	}

	cout<<sum<<endl;

	return 0;

} 

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef int  ll;

typedef vector<ll> vl;

typedef pair<ll,ll> pll;

#define INF 1e8

bool sor(tuple<double,int,int>&x,tuple<double,int,int>&y)

{

    if(get<0>(x)>get<0>(y))

    {

        return 1;

    }

    else if(get<0>(x)<get<0>(y))

    {

        return 0;

    }

    else

    {

        if(get<1>(x)<get<1>(y))

        {

            return 1;

        }

        else if(get<1>(x)>get<1>(y))

        {

            return 0;

        }

        else

        {

            if(get<2>(x)>get<2>(y))

            {

                return 1;

            }

            else if(get<2>(x)>get<2>(y))

            {

                return 0;

            }

        }

    }

}



int main()

{

    int n,m,a,b;

    cin>>n>>m;

    map<int,vl>g;

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

    {

        cin>>a>>b;

        g[a].push_back(b);

    }

    priority_queue<int>q;

    ll ans=0,in=0;

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

    {

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

        {

               q.push(g[i][j]);

        }

        if(!q.empty()){ll t=q.top();

        q.pop();

        ans+=t;}

    }

    cout<<ans<<"\n";

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

const int INF = 1e9;

const int MOD = 1e9+7;

const long long LINF = 1e18;

#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

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

#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

typedef long long ll;

using namespace std;

typedef pair<ll, ll> P;



int main(int argc, char const *argv[]) {

    int n,m;cin>>n>>m;

    vector<vector<int>> x(114514);

    rep(i,n) {

        int a,b;cin>>a>>b;

        x[a].push_back(b);

    }



    priority_queue<ll> pq;

    ll ans = 0;



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

        for (auto &&e: x[i]) pq.push(e);

        if (!pq.empty()) ans += pq.top(), pq.pop();

    }



    cout << ans << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

const int INF = 1e9;

const int MOD = 1e9+7;

const long long LINF = 1e18;

#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

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

#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

typedef long long ll;

using namespace std;

typedef pair<ll, ll> P;



template<typename T>

void print(const vector<T> &x) {

    int n = x.size();

    rep(i,n) {

        cout << x[i];

        if (i!=n-1) cout<<" ";

        else cout << endl;

    }

}



template<typename T>

void print(const vector<vector<T>> &x) {

    int n = x.size();

    rep(i,n) {

        rep(j,x[i].size()) {

            cout << x[i][j] << " ";

        }

        cout << endl;

    }

}



template<typename T>

void print(const vector<T> &x, int n) {

    rep(i,n) {

        cout << x[i];

        if (i!=n-1) cout<<" ";

        else cout << endl;

    }

}



template<typename T>

void print(const vector<vector<T>> &x, int n, int m) {

    rep(i,n) {

        rep(j,m) {

            cout << x[i][j] << " ";

        }

        cout << endl;

    }

}



template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



void input_init() {

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

}



int main(int argc, char const *argv[]) {

    int n,m; cin>>n>>m;

    priority_queue<ll> pq;

    map<ll,vector<ll>> mp;

    ll ans = 0;

    rep(i,n) {

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

        mp[a].push_back(b);

    }



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

        int day = m-i;

        for (auto &&e: mp[day]) {

            pq.push(e);

        }

        if (pq.empty()) continue;

        ans += pq.top();

        pq.pop();

    }



    cout << ans << '\n';

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;

typedef long long LL;

typedef long double LD;

typedef unsigned long long ULL;



#ifdef _LOCAL

struct Tester {

    Tester() { freopen("sample.in", "r", stdin); }

    ~Tester() { fprintf(stderr, "\nTime: %d ms\n", int(1000.0 * clock() / CLOCKS_PER_SEC)); }

} _tester;

#endif



const int INF = 0x3F3F3F3F;

const LL INFLL = 0x3F3F3F3F3F3F3F3FLL;

const int N = 1e5 + 10;

const int Q = 1e5 + 10;



vector<int> v[N];



int main() {

    int n, m;

    cin >> n >> m;

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

        int time, reward;

        cin >> time >> reward;

        v[time].push_back(reward);

    }

    priority_queue<int> heap;

    LL res = 0;

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

        for (int val : v[i]) heap.push(val);

        if (!heap.empty()) {

            res += heap.top();

            heap.pop();

        }

    }

    cout << res;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <algorithm>

#include <cstdio>

#include <cstring>

#include <iostream>

using namespace std;

using LL = long long;



const int N = 1e5 + 10;



struct Node {

    int w, t;



    bool operator<(const Node &b) const {

        return w > b.w;

    }

} a[N];



int fa[N];



void init(int n) {

    for (int i = 0; i <= n; ++i) fa[i] = i;

}



int find(int x) {

    return fa[x] == x ? x : fa[x] = find(fa[x]);

}



int main() {

#ifdef _LOCAL

    freopen("sample.in", "r", stdin);

#endif

    int n, m;

    scanf("%d%d", &n, &m);

    int Max = 0, tot = 0;

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

        int t, w;

        scanf("%d%d", &t, &w);

        t = m - t + 1;

        if (t >= 1) a[++tot] = {w, t};

        if (a[tot].t > Max) Max = a[tot].t;

    }

    n = tot;

    init(Max);

    sort(a + 1, a + n + 1);

    LL ans = 0;

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

        int pos = find(fa[a[i].t]);

        if (pos > 0) {

            fa[pos] = find(fa[pos] - 1);

            // printf("[%d,%d]\n", m - a[i].t + 1, a[i].w);

            ans += a[i].w;

        }

    }

    printf("%lld\n", ans);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

} 

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



int main() {

	int n, m;

	cin >> n >> m;

	multiset<int, greater<int> > s;

	vector<pair<int, int>> v;

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

		int A, B;

		cin >> A >> B;

		v.push_back( { A, B });



	}

	int j = 0;

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

	long long res = 0;

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

		while (j < n && v[j].first == i) {

			s.insert(v[j].second);

			j++;

		}

		if (s.size()) {

			res += *s.begin();

			s.erase(s.begin());

		}

	}

	cout << res;

	return 0;

}

/*

 *

 * 1 4

 * 1 4

 * 1 2

 * 2 3

 * 2 2

 * 2 1

 * 3 3 j

 * 3 4

 * 3 1

 1=>  4 2

 2=>

 3=> 3 4 1 2 3 1 2

 4+4+4

 */


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



int main() {

	int n, m;

	cin >> n >> m;

	multiset<int, greater<int> > s;

	vector<pair<int, int>> v;

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

		int A, B;

		cin >> A >> B;

		v.push_back( { A, B });



	}

	int j = 0;

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

	long long res = 0;

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

		while (j < n && v[j].first == i) {

			s.insert(v[j].second);

			j++;

		}

		if (s.size()) {

			res += *s.begin();

			s.erase(s.begin());

		}

	}

	cout << res;

	return 0;

}

/*

 *

 * 1 4

 * 1 4

 * 1 2

 * 2 3

 * 2 2

 * 2 1

 * 3 3 j

 * 3 4

 * 3 1

 1=>  4 2

 2=>

 3=> 3 4 1 2 3 1 2

 4+4+4

 */


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

 } 


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



int main() {

	int n, m;

	cin >> n >> m;

	multiset<int, greater<int> > s;

	vector<pair<int, int>> v;

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

		int A, B;

		cin >> A >> B;

		v.push_back( { A, B });



	}

	int j = 0;

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

	long long res = 0;

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

		while (j < n && v[j].first == i) {

			s.insert(v[j].second);

			j++;

		}

		if (s.size()) {

			res += *s.begin();

			s.erase(s.begin());

		}

	}

	cout << res;

	return 0;

}

/*

 *

 * 1 4

 * 1 4

 * 1 2

 * 2 3

 * 2 2

 * 2 1

 * 3 3 j

 * 3 4

 * 3 1

 1=>  4 2

 2=>

 3=> 3 4 1 2 3 1 2

 4+4+4

 */


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

} 

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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<<" ";}}

// Optimized solution to the same problem (faster):
#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;}}}}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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<<" ";}}

// Optimized solution to the same problem (faster):
#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;}}}}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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<<" ";}}

// Optimized solution to the same problem (faster):
#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;}}}}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
/*

//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;

}




// Fastest known solution for this problem: