stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<vector>

#include<iostream>



using namespace std;



class Cake;



vector<Cake> pieces;



class Cake {

public:

  int w;

  int d;



  Cake(int w, int d) {

    this->w = w;

    this->d = d;

  }



  void cut(int s) {

    int t = s%(w+d);

    int a, b;

    if(t<w) {

      // vertical

      if(t<w-t) {

	a = t;

	b = w-t;

      } else {

	a = w-t;

	b = t;

      }

      pieces.push_back(Cake(a, d));

      pieces.push_back(Cake(b, d));

    }

    else {

      // horizontal

      t -= w;

      if(t<d-t) {

	a = t;

	b = d-t;

      } else {

	a = d-t;

	b = t;

      }

      pieces.push_back(Cake(w, a));

      pieces.push_back(Cake(w, b));

    }

  }

};



bool area(const Cake &a, const Cake &b) {

  return a.w*a.d < b.w*b.d;

}



int main() {

  while(1) {

    int n, w, d;

    cin >> n;

    cin >> w;

    cin >> d;



    if(n==0 && w==0 && d==0) break;



    pieces.clear();

    pieces.push_back(Cake(w, d));



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

      int p, s;

      cin >> p;

      cin >> s;

      // p Í 1` ÈÌÅ

      p-=1;

      vector<Cake>::iterator it = pieces.begin()+p;

      Cake cake = pieces.at(p);

      pieces.erase(it);

      cake.cut(s);

    }



    // sort

    int count=0;

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

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

	int s = pieces.at(j).w * pieces.at(j).d;

	if(s==i) {

	  cout << s;

	  count++;

	  if(pieces.size()!=count) {

	    cout << ' ';

	  }

	}

      }

      //sort(pieces.begin(), pieces.end(), area);

    }





    /*

    for(int i=0; i<pieces.size(); i++) {

      cout << (pieces.at(i).w * pieces.at(i).d);

      cout << ' ';

    }

    */

    cout << "\n";

  }

}

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

using namespace std;

typedef pair<int,int> pii;



int main(){

  int n,w,d;

  while(cin >> n >> w >> d, w){

    vector<pii> v;

    v.push_back(pii(w,d));



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

      int id,s;

      cin >> id >> s; id--;

      pii cut = v[id];

      w = cut.first, d = cut.second;

      v.erase(v.begin() + id);



      s %= w+d;

      if(s<w){

	int nw1 = min(s,w-s), nw2 = max(s,w-s);

	v.push_back(pii(nw1,d));

	v.push_back(pii(nw2,d));

      }else{

	int nd1 = min(s-w,d-s+w), nd2 = max(s-w,d-s+w);

	v.push_back(pii(w,nd1));

	v.push_back(pii(w,nd2));

      }

    }



    vector<int> p;

    for(int i=0;i<(int)v.size();i++)p.push_back(v[i].first*v[i].second);

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

    for(int i=0;i<(int)v.size();i++){

      cout << p[i] << (i+1==(int)p.size()?"\n":" ");

    }

  }

}
// Slower C++ solution:


#include<algorithm>

#include<iostream>

#include<vector>



using namespace std;



const int MAXN = 300010;

int cnt[MAXN];

int f[MAXN];

int main(){

    int n;

    cin >> n;

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

        int a;

        cin >> a;

        cnt[a]++;

    }



    vector<int> v;

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

        if(cnt[i] > 0){

            v.push_back(cnt[i]);

        }

    }



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



    int p = 0;

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

        while(p<v.size() && v[p]<i){

            p++;

        }



        f[i] = f[i-1] + v.size() - p;

    }



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

        f[i] /= i;

    }



    p = n;

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

        while(p>0 && f[p] < i)

            p--;

        cout << p<<"\n";

    }



}




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

#include <bits/stdc++.h>



using namespace std;

int a[500000],b[500000],n;

long long sums,ans;



int main()

{

    scanf("%d",&n);

    long long sums = 0;int tmp;

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

        scanf("%d",&tmp);++a[tmp-1];

    }



    vector<int> vn;

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

    int j = n-1;

    int rs = 0;

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

        while(j>=0&&a[j]<i){

            rs += a[j--];

        }

        b[i] = rs/i + (j+1);

    }



    j = n;

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

        while(j>=1&&b[j]<i) --j;

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

    }

    return 0;

}
// Slower C++ solution:


#include<algorithm>

#include<iostream>

#include<vector>



using namespace std;



const int MAXN = 300010;

int cnt[MAXN];

int f[MAXN];

int main(){

    int n;

    cin >> n;

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

        int a;

        cin >> a;

        cnt[a]++;

    }



    vector<int> v;

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

        if(cnt[i] > 0){

            v.push_back(cnt[i]);

        }

    }



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



    int p = 0;

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

        while(p<v.size() && v[p]<i){

            p++;

        }



        f[i] = f[i-1] + v.size() - p;

    }



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

        f[i] /= i;

    }



    p = n;

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

        while(p>0 && f[p] < i)

            p--;

        cout << p<<"\n";

    }



}




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

#include <queue>

#include <iostream>

#include <algorithm>

#include<cstring>

using namespace std;

int a[300010];

int cnt[300010];

int ans[300010];

int main()

{

    int n;

    cin >> n;

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

    {

        int x;

        cin >> x;

        a[x] ++ ;

    }

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

    {

        cnt[a[i]]++;

    }

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

    {

        cnt[i-1] += cnt[i]; 

    }

    int Ans = 0;

    long long sum=0;

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

    {

        while(sum+cnt[Ans+1]>=1ll*i*(Ans+1))

            sum+=cnt[++Ans];

        ans[i] = Ans;

    }

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

    {

        cout << ans[i] << endl;

    }

    return 0;

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

using namespace std;

inline void rd(int &x) {

	char ch; for(;!isdigit(ch=getchar()););

	for(x=ch-'0';isdigit(ch=getchar());)x=x*10+ch-'0';

}

typedef long long LL;

const int MAXN = 300005;

int N, n, a[MAXN], cnt[MAXN];

LL sum[MAXN];

int ans[MAXN];



inline bool chk(int k, int x) {

	int pos = upper_bound(a + 1, a + n + 1, x) - a;

	return sum[pos-1] + 1ll*(n-pos+1)*x >= 1ll*k*x;

}



int main() {

	rd(N);

	for(int i = 1, x; i <= N; ++i) rd(x), ++cnt[x];

	for(int i = 1; i <= 300000; ++i) if(cnt[i]) a[++n] = cnt[i];

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

	for(int i = 1; i <= n; ++i) sum[i] = sum[i-1] + a[i];

	int now = 0;

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

		while(now < N && chk(k, now+1)) ++now;

		ans[k] = now;

	}

	for(int i = 1; i <= N; ++i) printf("%d\n", ans[i]);

}

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

using namespace std;

inline void rd(int &x) {

	char ch; for(;!isdigit(ch=getchar()););

	for(x=ch-'0';isdigit(ch=getchar());)x=x*10+ch-'0';

}

typedef long long LL;

const int MAXN = 300005;

int n, cnt[MAXN];

LL sum[MAXN];

int ans[MAXN];



inline bool chk(int k, int x) { return sum[x] >= 1ll*k*x; }



int main() {

	rd(n);

	for(int i = 1, x; i <= n; ++i) rd(x), ++cnt[x], ++sum[cnt[x]];

	for(int i = 1; i <= n; ++i) sum[i] += sum[i-1];

	int now = 0;

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

		while(now < n && chk(k, now+1)) ++now;

		ans[k] = now;

	}

	for(int i = 1; i <= n; ++i) printf("%d\n", ans[i]);

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

#include<string>

#include<vector>

#include<algorithm>



using namespace std;



typedef struct

{

    string name;

    int point;

    int num;

}food;

food A[10001];

bool paixu(const food &a,const food &b)

{

    if(a.name != b.name)

        return a.name<b.name;

    return a.point > b.point;

    

}

int main()

{

    int n;

    cin>>n;

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

    {

        cin>>A[i].name>>A[i].point;

        A[i].num = i+1;

    }

    sort(A,A+n,paixu);

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

        cout<<A[i].num<<endl;

        return 0;

}

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



using namespace std;

const int N = 100 + 3;

char buffer[N];

int main() {

#ifndef ONLINE_JUDGE

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

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

#endif

	int n;

	scanf("%d", &n);

	pair<string, pair<int, int>> p[N];

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

		int a;

		scanf("%s %d", buffer, &a);

		p[i] = {buffer, make_pair(-a, i + 1)};

	}

	sort(p, p + n);

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

		printf("%d\n", p[i].second.second);

	return 0;

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

#include<string>

#include<vector>

#include<algorithm>



using namespace std;



typedef struct

{

    string name;

    int point;

    int num;

}food;

food A[10001];

bool paixu(const food &a,const food &b)

{

    if(a.name != b.name)

        return a.name<b.name;

    return a.point > b.point;

    

}

int main()

{

    int n;

    cin>>n;

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

    {

        cin>>A[i].name>>A[i].point;

        A[i].num = i+1;

    }

    sort(A,A+n,paixu);

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

        cout<<A[i].num<<endl;

        return 0;

}

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



using namespace std;



int main() {

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



    int n;

    cin >> n;



    vector<int> score(n);

    vector<string> name(n);

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

        cin >> name[i] >> score[i];





    vector<int> order(n);

    iota(order.begin() , order.end() , 0);



    sort(order.begin() , order.end() , [&](int i , int j){

        if (name[i] != name[j])

            return name[i] < name[j];

        return score[i] > score[j];

    });



    for (int x : order)

        cout << x + 1 << '\n';

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

#include<bits/stdc++.h>

using namespace std;

struct node

{

    string s;

    int x,num;

}a[100000];

int cmp1(node a,node b)

{

    if(a.s==b.s)

    {

        return a.x>b.x;

    }

    else

    {

        return a.s<b.s;

    }

}

int main()

{

    int n;

    scanf("%d",&n);

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

    {

        a[i].num=i;

        cin>>a[i].s;

        scanf("%d",&a[i].x);

    }

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

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

    {

        printf("%d\n",a[i].num);

    }



    return 0;

}


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



using namespace std;



int main() {

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



    int n;

    cin >> n;



    vector<int> score(n);

    vector<string> name(n);

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

        cin >> name[i] >> score[i];





    vector<int> order(n);

    iota(order.begin() , order.end() , 0);



    sort(order.begin() , order.end() , [&](int i , int j){

        if (name[i] != name[j])

            return name[i] < name[j];

        return score[i] > score[j];

    });



    for (int x : order)

        cout << x + 1 << '\n';

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

#include<string>

#include<vector>

#include<algorithm>



using namespace std;



typedef struct

{

    string name;

    int point;

    int num;

}food;

food A[10001];

bool paixu(const food &a,const food &b)

{

    if(a.name != b.name)

        return a.name<b.name;

    return a.point > b.point;

    

}

int main()

{

    int n;

    cin>>n;

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

    {

        cin>>A[i].name>>A[i].point;

        A[i].num = i+1;

    }

    sort(A,A+n,paixu);

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

        cout<<A[i].num<<endl;

        return 0;

}

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

#include <cstdio>

#include <cstring>

#include <algorithm>

#define LL long long

using namespace std;

struct Node{

    string name;

    int score;

    int loc;

}a[1000];

int cmp(const Node &a, const Node &b){

    if(a.name == b.name) return a.score > b.score;

    else return a.name < b.name;

}

int main(){

    ios::sync_with_stdio(false);

    int n; cin>>n;

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

        cin>>a[i].name>>a[i].score;

        a[i].loc = i;

    }

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

    for(int i = 1; i <= n; i++) cout<<a[i].loc<<endl;

    return 0;

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

#include<bits/stdc++.h>

using namespace std;

struct node

{

    string s;

    int x,num;

}a[100000];

int cmp1(node a,node b)

{

    if(a.s==b.s)

    {

        return a.x>b.x;

    }

    else

    {

        return a.s<b.s;

    }

}

int main()

{

    int n;

    scanf("%d",&n);

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

    {

        a[i].num=i;

        cin>>a[i].s;

        scanf("%d",&a[i].x);

    }

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

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

    {

        printf("%d\n",a[i].num);

    }



    return 0;

}


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

#include <cstdio>

#include <cstring>

#include <algorithm>

#define LL long long

using namespace std;

struct Node{

    string name;

    int score;

    int loc;

}a[1000];

int cmp(const Node &a, const Node &b){

    if(a.name == b.name) return a.score > b.score;

    else return a.name < b.name;

}

int main(){

    ios::sync_with_stdio(false);

    int n; cin>>n;

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

        cin>>a[i].name>>a[i].score;

        a[i].loc = i;

    }

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

    for(int i = 1; i <= n; i++) cout<<a[i].loc<<endl;

    return 0;

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

#include<string>

#include<vector>

#include<algorithm>



using namespace std;



typedef struct

{

    string name;

    int point;

    int num;

}food;

food A[10001];

bool paixu(const food &a,const food &b)

{

    if(a.name != b.name)

        return a.name<b.name;

    return a.point > b.point;

    

}

int main()

{

    int n;

    cin>>n;

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

    {

        cin>>A[i].name>>A[i].point;

        A[i].num = i+1;

    }

    sort(A,A+n,paixu);

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

        cout<<A[i].num<<endl;

        return 0;

}

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

#include<cstdio>

#include<cstdlib>

#include<cmath>

#include<cstring>

#include<algorithm>

#include<queue>

#define LL long long

#define inl inline

#define re register

#define MAXN 10100

using namespace std;

struct ji

{

	string s;

	int p,fl;

}h[1010];

int n;

bool cmp(const ji& a,const ji& b)

{

	if(a.s==b.s)return a.p>b.p;

	return a.s<b.s;

}

int main()

{

	cin>>n;

	for(int i=1;i<=n;i++)cin>>h[i].s>>h[i].p,h[i].fl=i;

	sort(h+1,h+n+1,cmp);

	for(int i=1;i<=n;i++)cout<<h[i].fl<<endl;

	return 0;

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

#include<bits/stdc++.h>

using namespace std;

struct node

{

    string s;

    int x,num;

}a[100000];

int cmp1(node a,node b)

{

    if(a.s==b.s)

    {

        return a.x>b.x;

    }

    else

    {

        return a.s<b.s;

    }

}

int main()

{

    int n;

    scanf("%d",&n);

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

    {

        a[i].num=i;

        cin>>a[i].s;

        scanf("%d",&a[i].x);

    }

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

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

    {

        printf("%d\n",a[i].num);

    }



    return 0;

}


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

#include<cstdio>

#include<cstdlib>

#include<cmath>

#include<cstring>

#include<algorithm>

#include<queue>

#define LL long long

#define inl inline

#define re register

#define MAXN 10100

using namespace std;

struct ji

{

	string s;

	int p,fl;

}h[1010];

int n;

bool cmp(const ji& a,const ji& b)

{

	if(a.s==b.s)return a.p>b.p;

	return a.s<b.s;

}

int main()

{

	cin>>n;

	for(int i=1;i<=n;i++)cin>>h[i].s>>h[i].p,h[i].fl=i;

	sort(h+1,h+n+1,cmp);

	for(int i=1;i<=n;i++)cout<<h[i].fl<<endl;

	return 0;

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

#include<iostream>

#include<string>

#include<algorithm>

using namespace std;

int n;

struct node{

	string nm; int sc,id;

	bool operator <(const node &j) const {

		return nm<j.nm||(nm==j.nm&&sc>j.sc);

	}

}re[200010];

int main(){

	scanf("%d",&n);

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

		cin>>re[i].nm>>re[i].sc;

		re[i].id=i;

	}

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

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

		cout<<re[i].id<<endl;

	}

	return 0;

}

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

#include<stdlib.h>

#include<iostream>

#include<algorithm>

#include<string.h>

using namespace std;

typedef struct{

	char str[101];

	int pri;

	int no;

}node;

node p[101];

bool cmp(node a,node b)

{

	if(a.str!=b.str)

    return strcmp(a.str,b.str)<0;

    else

    return a.pri<b.pri;

}

int main()

{

	int n;

	cin>>n;

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

		scanf("%s",&p[i].str);

		cin>>p[i].pri;

		p[i].no = i+1;

	}

	

	sort(p, p+n, cmp);

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

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

		if(strcmp(p[j].str,p[j+1].str)==0 && p[j].pri<p[j+1].pri)

			swap(p[j],p[j+1]);

	}

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

	cout<<p[i].no<<endl;

	return 0;

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

#include<iostream>

#include<string>

#include<algorithm>

using namespace std;

int n;

struct node{

	string nm; int sc,id;

	bool operator <(const node &j) const {

		return nm<j.nm||(nm==j.nm&&sc>j.sc);

	}

}re[200010];

int main(){

	scanf("%d",&n);

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

		cin>>re[i].nm>>re[i].sc;

		re[i].id=i;

	}

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

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

		cout<<re[i].id<<endl;

	}

	return 0;

}

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

using namespace std;

const int N=107;

struct node

{

	string s;

	int n;

	int x;

}a[N];

bool cmp(node a,node b)

{

	if(a.s!=b.s)return a.s<b.s;

	else return a.n>b.n;

}

int main()

{

	int t;

	cin>>t;

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

	{

		cin>>a[i].s>>a[i].n;

		a[i].x=i;

	}

	sort(a+1,a+1+t,cmp);

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

	{

		cout<<a[i].x<<endl;

	}

	return 0;

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

#include<iostream>

#include<string>

#include<algorithm>

using namespace std;

int n;

struct node{

	string nm; int sc,id;

	bool operator <(const node &j) const {

		return nm<j.nm||(nm==j.nm&&sc>j.sc);

	}

}re[200010];

int main(){

	scanf("%d",&n);

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

		cin>>re[i].nm>>re[i].sc;

		re[i].id=i;

	}

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

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

		cout<<re[i].id<<endl;

	}

	return 0;

}

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

* AUTHOR : RAJAGOPALAN *

* NICK : ARNO *

* INSTITUTION : VIT *

******************************************/

#include <bits/stdc++.h>

#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long

#define ull unsigned long long

#define pb push_back

#define mp make_pair

#define all(x) (x).begin(),(x).end()

#define alli(a, n, k) (a+k),(a+n+k)

#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)

#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)

#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define eps 1e-6

#define pi 3.141592653589793

using namespace std;

using namespace __gnu_pbds;



template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}

typedef vector<int> VII;

typedef vector<ll> VLL;

typedef pair<int, int> PII;

typedef vector< pair<int, int> > VPII;

typedef vector< pair<int, PII > > VPPI;

const int MOD = 1e9 + 7;

const int INF = 1e9;



inline ll modulo(ll a, ll m)

{

    return (a % m + m) % m;

}



inline ll modInverse(ll a, ll m)

{

    assert(__gcd(a, m) == 1);

    ll m0 = m;

    ll y = 0, x = 1;



    if (m == 1)

        return 0;



    while (a > 1)

    {

        ll q = a / m;

        ll t = m;



        m = a % m, a = t;

        t = y;



        y = x - q * y;

        x = t;

    }



    if (x < 0)

        x += m0;



    return x;

}



inline ll modPow(ll x, ll y, ll m)

{ //x^y % m

    if (y == 0)

        return 1LL;

    else if (y == 1)

        return x;

    else

    {

        ll ans = modPow(x, y / 2, m) % m;

        if (y & 1)

        {

            return (((ans * ans) % m) * x) % m;

        }

        else

        {

            return (ans * ans) % m;

        }

    }

}

struct dd

{

    string n;

    int sc;

    int id;

};

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

{

    ios::sync_with_stdio(false);

    cin.tie(NULL);

    int n;

    cin>>n;

    vector<dd> arr(n);

    int id=1;

    for(auto &x:arr)

    {

        x.id=id++;

        cin>>x.n>>x.sc;

    }

    sort(all(arr),[&](dd a,dd b){

        if(a.n==b.n){

            return a.sc>b.sc;

        }

        return a.n<b.n;

    });

    for(auto x:arr)

    cout<<x.id<<endl;

    return 0;

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

#include<iostream>

#include<string>

#include<algorithm>

using namespace std;

int n;

struct node{

	string nm; int sc,id;

	bool operator <(const node &j) const {

		return nm<j.nm||(nm==j.nm&&sc>j.sc);

	}

}re[200010];

int main(){

	scanf("%d",&n);

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

		cin>>re[i].nm>>re[i].sc;

		re[i].id=i;

	}

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

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

		cout<<re[i].id<<endl;

	}

	return 0;

}

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

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;



bool cmp(pair<string,pii> &a, pair<string,pii> &b){

	if(a.first==b.first)return (a.second.first > b.second.first); 

	else return a.first<b.first;

}



int main(){

	int t; cin>>t;

	vector<pair<string, pii>> v;

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

		string s; cin>>s;

		int x; cin>>x;

		v.push_back({s,{x,i+1}});

	}

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

	for(auto&x: v){

		cout<<x.second.second<<endl;

	}

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

#include<iostream>

#include<string>

#include<algorithm>

using namespace std;

int n;

struct node{

	string nm; int sc,id;

	bool operator <(const node &j) const {

		return nm<j.nm||(nm==j.nm&&sc>j.sc);

	}

}re[200010];

int main(){

	scanf("%d",&n);

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

		cin>>re[i].nm>>re[i].sc;

		re[i].id=i;

	}

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

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

		cout<<re[i].id<<endl;

	}

	return 0;

}

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

using namespace std;



typedef long long ll;

typedef unsigned long long ull;

typedef double dd;

typedef vector<int> vi;

typedef vector<ll> vl;

typedef pair<int,int> pii;



const int Mx=1e6+11;

const double PI = acos(-1);

#define MOD 1000000007



#define nl '\n'

#define pb push_back

#define F first

#define S second

#define I insert

#define mp make_pair



#define sz(x) x.size()

#define tt int t; cin>>t; while(t--)

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

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

#define mem(a,b) memset(a,b,sizeof(a))

#define yes cout<<"YES"<<nl

#define no cout<<"NO"<<nl



#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);



void f()

{

  int n,l;

  string s;

  cin>>n;

  pair<string, pair<int ,int> > p[n];

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

  {

    cin>>s>>l;

    p[i]=mp(s,mp(-1*l,i+1));

  }

  sort(p,p+n);

  for(auto i:p)

  {

    cout<<i.S.S<<nl;

  }

}



int main()

{

    su;

    f();

    return 0;

}