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

#include <algorithm>

#include <cstring>

#include <cstdio>

#include <vector>

#include <queue>

#include <stack>

#include <cstdlib>

#include <iomanip>

#include <cmath>

#include <cassert>

#include <ctime>

#include <cstdlib>

#include <map>

#include <set>

using namespace std;

#pragma comment(linker, "/stck:1024000000,1024000000")

#define lowbit(x) (x&(-x))

#define max(x,y) (x>=y?x:y)

#define min(x,y) (x<=y?x:y)

//#define MAX 100000000000000000

#define MOD 1000000007

#define pi acos(-1.0)

#define ei exp(1)

#define PI 3.1415926535897932384626433832

#define ios() ios::sync_with_stdio(true)

#define INF (1<<31)-1;

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

struct P{

    int x,y;

}H[200000];

vector<int>G[200000];

int POS(int k,int value){

    int mid;

    int left = 0;

    int len = G[k].size();

    int right = len - 1;

    //cout<<" "<<k<<"A"<<value<<endl;

    while(left <= right){

 

        // 确保中点靠近区间的起点

        mid = left + (right-left)/2;

        //cout<<mid<<endl;

        //cout<<"mid= "<<mid<<" "<<left<<" "<<right<<endl;

        // 如果找到则返回

        if(G[k][mid] == value) return mid;

        // 将中点赋给终点

        else if(G[k][mid] > value) right = mid;

        // 将中点加一赋给起点

        else left = mid + 1;

    }

    return -1;

}

set<int>::iterator it;

int main()

{

    set<int>s;

    int N,M;

    int x,y;

    cin>>N>>M;

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

        cin>>x>>y;

        H[i].x = x;

        H[i].y = y;

        G[x].push_back(y);

        s.insert(x);

    }

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

        sort(G[i].begin(),G[i].end());

    }

 

 

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

        cout<<setw(6)<<setfill('0')<<H[i].x;

        cout<<setw(6)<<setfill('0')<<POS(H[i].x,H[i].y)+1<<endl;

    }

    return 0;

}

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

#include<iostream>

#include<algorithm>



using namespace std;



struct temp

{

    int rank;

    int p;

    int y;

}a[100005];



int cmp(temp x, temp y)

{

    if(x.p != y.p)

        return x.p<y.p;

    else

        return x.y<y.y;

}



int main()

{

    int n,m;

    while(cin >> n >> m)

    {

        int b[100005];

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

    {

        a[i].rank = i;

        cin >> a[i].p >> a[i].y;

        b[i] = a[i].p;

    }



    sort(a,a+m,cmp);

    int f = a[0].p,flag = 1;

    int x[100005];



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

    {

        if(a[i].p != f)

        {

            flag = 1;

            f = a[i].p;

        }

        x[a[i].rank] = flag++;

    }



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

        printf("%06d%06d\n",b[i],x[i]);



    }

    return 0;

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

#include<algorithm>

#include<vector>

#include<map>

using namespace std;

const int maxn = 1e5 + 1;

struct node{

	int p,y;

	int num;

	int sub;

}no;

vector<node> v[maxn];

bool cmp(node a,node b){

	return a.y<b.y;

}

int main(){

	int n,m,p,y;

	cin>>n>>m;

	map<int,node> Map;

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

		cin>>p>>y;

		no.p=p;no.y=y;

		no.sub=i;

		Map[i]=no;

		v[p].push_back(no);

	}

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

		sort(v[i].begin(),v[i].end(),cmp);

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

        	Map[v[i][j].sub].num=j+1;

    	}

	}

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

		printf("%06d%06d\n",Map[i].p,Map[i].num);

	}

	return 0;

}

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

using namespace std;



const int N = 1e5+5;



struct node{

    int aa,bb;

};



int main()

{

    int n,m,i,j,k;

    cin>>n>>m;

    int p[m+2],y[m+2];

    //priority_queue < pair<int,int> > pq;

    //map < node ,int> mp;

    map < pair<int,int> ,int> mp;

    map < int, vector<int> > v;

    set <int> st;

    //node pp;

    pair <int,int> pp;



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

    {

        cin>>p[i]>>y[i];

        v[p[i]].push_back(y[i]);

        st.insert(p[i]);

    }



    for(auto ii: st)

    {

        sort(v[ii].begin(),v[ii].end());

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

        {

            //pp.aa=ii;

            //pp.bb=v[ii][i];

            pp= make_pair(ii,v[ii][i]);

            mp[pp]=i+1;

        }

    }





    string s;



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

    {

        s="000000000000";



        k=p[i];

        j=5;

        while(k)

        {

            s[j--]=(char) (k%10)+'0';

            k/=10;

        }

        ///////////////

        pp= make_pair(p[i],y[i]);

        //pp.aa=p[i];

        //pp.bb=y[i];

        k=mp[pp];

        j=11;

        while(k)

        {

            s[j--]=(char) (k%10)+'0';

            k/=10;

        }



        cout<<s<<endl;

    }





    return 0;

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

#include<algorithm>

#include<vector> 

#include<map>

using namespace std;

const int M=1e5+5;

struct node{

	int p,y;

	int k,num;

}q;

bool comp(node a,node b){

	return a.y<b.y;

}

vector<node> a[M];

map<int,node> Map;

int main(){

    int n,m;

    cin>>n>>m;

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

    	int p,y;

    	cin>>p>>y;

    	q.p=p; q.y=y;

    	q.k=i;

    	Map[i]=q;

    	a[p].push_back(q);

	}

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

		sort(a[i].begin(),a[i].end(),comp);

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

			Map[a[i][j].k].num=j+1;	

	}

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

		printf("%06d%06d\n",Map[i].p,Map[i].num);

}

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

using namespace std;



const int N = 1e5+5;



struct node{

    int aa,bb;

};



int main()

{

    int n,m,i,j,k;

    cin>>n>>m;

    int p[m+2],y[m+2];

    //priority_queue < pair<int,int> > pq;

    //map < node ,int> mp;

    map < pair<int,int> ,int> mp;

    map < int, vector<int> > v;

    set <int> st;

    //node pp;

    pair <int,int> pp;



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

    {

        cin>>p[i]>>y[i];

        v[p[i]].push_back(y[i]);

        st.insert(p[i]);

    }



    for(auto ii: st)

    {

        sort(v[ii].begin(),v[ii].end());

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

        {

            //pp.aa=ii;

            //pp.bb=v[ii][i];

            pp= make_pair(ii,v[ii][i]);

            mp[pp]=i+1;

        }

    }





    string s;



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

    {

        s="000000000000";



        k=p[i];

        j=5;

        while(k)

        {

            s[j--]=(char) (k%10)+'0';

            k/=10;

        }

        ///////////////

        pp= make_pair(p[i],y[i]);

        //pp.aa=p[i];

        //pp.bb=y[i];

        k=mp[pp];

        j=11;

        while(k)

        {

            s[j--]=(char) (k%10)+'0';

            k/=10;

        }



        cout<<s<<endl;

    }





    return 0;

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

#include <algorithm>

#include <cstring>

#include <cstdio>

#include <vector>

#include <queue>

#include <stack>

#include <cstdlib>

#include <iomanip>

#include <cmath>

#include <cassert>

#include <ctime>

#include <cstdlib>

#include <map>

#include <set>

using namespace std;

#pragma comment(linker, "/stck:1024000000,1024000000")

#define lowbit(x) (x&(-x))

#define max(x,y) (x>=y?x:y)

#define min(x,y) (x<=y?x:y)

//#define MAX 100000000000000000

#define MOD 1000000007

#define pi acos(-1.0)

#define ei exp(1)

#define PI 3.1415926535897932384626433832

#define ios() ios::sync_with_stdio(true)

#define INF (1<<31)-1;

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

struct P{

    int x,y;

}H[200000];

vector<int>G[200000];

int POS(int k,int value){

    int mid;

    int left = 0;

    int len = G[k].size();

    int right = len - 1;

    //cout<<" "<<k<<"A"<<value<<endl;

    while(left <= right){

 

        // 确保中点靠近区间的起点

        mid = left + (right-left)/2;

        //cout<<mid<<endl;

        //cout<<"mid= "<<mid<<" "<<left<<" "<<right<<endl;

        // 如果找到则返回

        if(G[k][mid] == value) return mid;

        // 将中点赋给终点

        else if(G[k][mid] > value) right = mid;

        // 将中点加一赋给起点

        else left = mid + 1;

    }

    return -1;

}

set<int>::iterator it;

int main()

{

    set<int>s;

    int N,M;

    int x,y;

    cin>>N>>M;

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

        cin>>x>>y;

        H[i].x = x;

        H[i].y = y;

        G[x].push_back(y);

        s.insert(x);

    }

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

        sort(G[i].begin(),G[i].end());

    }

 

 

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

        cout<<setw(6)<<setfill('0')<<H[i].x;

        cout<<setw(6)<<setfill('0')<<POS(H[i].x,H[i].y)+1<<endl;

    }

    return 0;

}

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

using namespace std;



const int N = 1e5+5;



struct node{

    int aa,bb;

};



int main()

{

    int n,m,i,j,k;

    cin>>n>>m;

    int p[m+2],y[m+2];

    //priority_queue < pair<int,int> > pq;

    //map < node ,int> mp;

    map < pair<int,int> ,int> mp;

    map < int, vector<int> > v;

    set <int> st;

    //node pp;

    pair <int,int> pp;



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

    {

        cin>>p[i]>>y[i];

        v[p[i]].push_back(y[i]);

        st.insert(p[i]);

    }



    for(auto ii: st)

    {

        sort(v[ii].begin(),v[ii].end());

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

        {

            //pp.aa=ii;

            //pp.bb=v[ii][i];

            pp= make_pair(ii,v[ii][i]);

            mp[pp]=i+1;

        }

    }





    string s;



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

    {

        s="000000000000";



        k=p[i];

        j=5;

        while(k)

        {

            s[j--]=(char) (k%10)+'0';

            k/=10;

        }

        ///////////////

        pp= make_pair(p[i],y[i]);

        //pp.aa=p[i];

        //pp.bb=y[i];

        k=mp[pp];

        j=11;

        while(k)

        {

            s[j--]=(char) (k%10)+'0';

            k/=10;

        }



        cout<<s<<endl;

    }





    return 0;

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

#include<algorithm>

#include<vector>

#include<map>

using namespace std;

const int maxn = 1e5 + 1;

struct node{

	int p,y;

	int num;

	int sub;

}no;

vector<node> v[maxn];

bool cmp(node a,node b){

	return a.y<b.y;

}

int main(){

	int n,m,p,y;

	cin>>n>>m;

	map<int,node> Map;

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

		cin>>p>>y;

		no.p=p;no.y=y;

		no.sub=i;

		Map[i]=no;

		v[p].push_back(no);

	}

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

		sort(v[i].begin(),v[i].end(),cmp);

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

        	Map[v[i][j].sub].num=j+1;

    	}

	}

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

		printf("%06d%06d\n",Map[i].p,Map[i].num);

	}

	return 0;

}

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

using namespace std;

#define ll long long int

int main()

{

    ll n,m;

    cin>>n>>m;

    vector<pair<ll,ll> >pr(m);

    map<ll,pair<ll,ll> >mp;

    vector<ll>v(m);

    for(ll i=0;i<m;++i)

    {

        cin>>pr[i].first>>pr[i].second;

        v[i] = pr[i].second;

    }

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

    ll c=1;



    for(ll i=0;i<m;++i)

    {

        mp.insert({pr[i].second,{pr[i].first,c}});

        ++c;

    if(pr[i].first!=pr[i+1].first)

            c = 1;

    }



    for(ll i=0;i<m;++i)

    {

        printf("%.6lld%.6lld\n",mp[v[i]].first,mp[v[i]].second);

    }

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

#include<algorithm>

#include<vector> 

#include<map>

using namespace std;

const int M=1e5+5;

struct node{

	int p,y;

	int k,num;

}q;

bool comp(node a,node b){

	return a.y<b.y;

}

vector<node> a[M];

map<int,node> Map;

int main(){

    int n,m;

    cin>>n>>m;

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

    	int p,y;

    	cin>>p>>y;

    	q.p=p; q.y=y;

    	q.k=i;

    	Map[i]=q;

    	a[p].push_back(q);

	}

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

		sort(a[i].begin(),a[i].end(),comp);

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

			Map[a[i][j].k].num=j+1;	

	}

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

		printf("%06d%06d\n",Map[i].p,Map[i].num);

}

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

using namespace std;

#define ll long long int

int main()

{

    ll n,m;

    cin>>n>>m;

    vector<pair<ll,ll> >pr(m);

    map<ll,pair<ll,ll> >mp;

    vector<ll>v(m);

    for(ll i=0;i<m;++i)

    {

        cin>>pr[i].first>>pr[i].second;

        v[i] = pr[i].second;

    }

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

    ll c=1;



    for(ll i=0;i<m;++i)

    {

        mp.insert({pr[i].second,{pr[i].first,c}});

        ++c;

    if(pr[i].first!=pr[i+1].first)

            c = 1;

    }



    for(ll i=0;i<m;++i)

    {

        printf("%.6lld%.6lld\n",mp[v[i]].first,mp[v[i]].second);

    }

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

#include <algorithm>

#include <cstring>

#include <cstdio>

#include <vector>

#include <queue>

#include <stack>

#include <cstdlib>

#include <iomanip>

#include <cmath>

#include <cassert>

#include <ctime>

#include <cstdlib>

#include <map>

#include <set>

using namespace std;

#pragma comment(linker, "/stck:1024000000,1024000000")

#define lowbit(x) (x&(-x))

#define max(x,y) (x>=y?x:y)

#define min(x,y) (x<=y?x:y)

//#define MAX 100000000000000000

#define MOD 1000000007

#define pi acos(-1.0)

#define ei exp(1)

#define PI 3.1415926535897932384626433832

#define ios() ios::sync_with_stdio(true)

#define INF (1<<31)-1;

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

struct P{

    int x,y;

}H[200000];

vector<int>G[200000];

int POS(int k,int value){

    int mid;

    int left = 0;

    int len = G[k].size();

    int right = len - 1;

    //cout<<" "<<k<<"A"<<value<<endl;

    while(left <= right){

 

        // 确保中点靠近区间的起点

        mid = left + (right-left)/2;

        //cout<<mid<<endl;

        //cout<<"mid= "<<mid<<" "<<left<<" "<<right<<endl;

        // 如果找到则返回

        if(G[k][mid] == value) return mid;

        // 将中点赋给终点

        else if(G[k][mid] > value) right = mid;

        // 将中点加一赋给起点

        else left = mid + 1;

    }

    return -1;

}

set<int>::iterator it;

int main()

{

    set<int>s;

    int N,M;

    int x,y;

    cin>>N>>M;

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

        cin>>x>>y;

        H[i].x = x;

        H[i].y = y;

        G[x].push_back(y);

        s.insert(x);

    }

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

        sort(G[i].begin(),G[i].end());

    }

 

 

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

        cout<<setw(6)<<setfill('0')<<H[i].x;

        cout<<setw(6)<<setfill('0')<<POS(H[i].x,H[i].y)+1<<endl;

    }

    return 0;

}

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

using namespace std;

#define ll long long int

int main()

{

    ll n,m;

    cin>>n>>m;

    vector<pair<ll,ll> >pr(m);

    map<ll,pair<ll,ll> >mp;

    vector<ll>v(m);

    for(ll i=0;i<m;++i)

    {

        cin>>pr[i].first>>pr[i].second;

        v[i] = pr[i].second;

    }

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

    ll c=1;



    for(ll i=0;i<m;++i)

    {

        mp.insert({pr[i].second,{pr[i].first,c}});

        ++c;

    if(pr[i].first!=pr[i+1].first)

            c = 1;

    }



    for(ll i=0;i<m;++i)

    {

        printf("%.6lld%.6lld\n",mp[v[i]].first,mp[v[i]].second);

    }

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

#include <cmath>

#include <algorithm>

#include <cstdio>

using namespace std;

struct node

{

	int num;

	int xian;

	int shi;

	int time;

}d[100005];

bool cmp1(node a,node b)

{

	if(a.xian<b.xian)return true;

	else if(a.xian==b.xian)

	{

		if(a.time<b.time)return true;

		else return false;

	}

	return false;

	

}

bool cmp2(node a,node b)

{

	return a.num<b.num;

}

int main()

{

	int n,m;

	cin>>n>>m;

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

	{

		cin>>d[i].xian>>d[i].time;

		d[i].num=i;

	}

	sort(d+1,d+m+1,cmp1);

	int cnt=1;

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

	{

		if(i!=1&&d[i].xian!=d[i-1].xian)cnt=1;

		d[i].shi=cnt;

		cnt++;

	}

	sort(d+1,d+m+1,cmp2);

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

	{

		printf("%06d%06d\n",d[i].xian,d[i].shi);

	}

	return 0;

}

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

#include <cmath>

#include <algorithm>

using namespace std;

const int maxn = 1e5 + 5;

typedef struct Node {

    int id, p, y, s;

} Node;

Node node[maxn] = { 0 };

bool cmp(Node &a, Node &b) {

    if (a.p == b.p) return a.y < b.y;

    return a.p < b.p;

}

bool cov(Node &a, Node &b) {

    return a.id < b.id;

}



int main() {

    int n, m;

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

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

        scanf("%d%d", &node[i].p, &node[i].y);

        node[i].id = i;

    }

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

    int cnt = 1;

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

        if (node[i].p == node[i - 1].p) node[i].s = ++cnt;

        else node[i].s = cnt = 1;

    sort(node + 1, node + n + 1, cov);

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

        printf("%06d%06d\n", node[i].p, node[i].s);

    return 0;

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

using namespace std;

 

struct node{

	int p,y;

}x[100005];

 

bool cmp(node a,node b)

{

	if(a.p==b.p) return a.y<b.y;

	return a.p<b.p;

}

 

int a[100005],b[100005];

 

map<pair<int , int >,int >m1;

 

int main()

{

	int n,m;

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

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

	{

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

		x[i].p=a[i];

		x[i].y=b[i];	

	}

	sort(x+1,x+m+1,cmp);

	int t=0,tt=1;

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

	{

		if(x[i].p==t){

			m1[make_pair(x[i].p,x[i].y)]=tt;

			tt++;

		}

		else{

			m1[make_pair(x[i].p,x[i].y)]=1;

			tt=2;

			t=x[i].p;

		}

	}

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

	{		

		printf("%06d%06d\n",a[i],m1[make_pair(a[i],b[i])]);

	}

	return 0;

} 

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

#include <cmath>

#include <algorithm>

using namespace std;

const int maxn = 1e5 + 5;

typedef struct Node {

    int id, p, y, s;

} Node;

Node node[maxn] = { 0 };

bool cmp(Node &a, Node &b) {

    if (a.p == b.p) return a.y < b.y;

    return a.p < b.p;

}

bool cov(Node &a, Node &b) {

    return a.id < b.id;

}



int main() {

    int n, m;

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

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

        scanf("%d%d", &node[i].p, &node[i].y);

        node[i].id = i;

    }

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

    int cnt = 1;

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

        if (node[i].p == node[i - 1].p) node[i].s = ++cnt;

        else node[i].s = cnt = 1;

    sort(node + 1, node + n + 1, cov);

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

        printf("%06d%06d\n", node[i].p, node[i].s);

    return 0;

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

#include<algorithm>

#include<vector>

#include<map>

using namespace std;

const int maxn = 1e5 + 1;

struct node{

	int p,y;

	int num;

	int sub;

}no;

vector<node> v[maxn];

bool cmp(node a,node b){

	return a.y<b.y;

}

int main(){

	int n,m,p,y;

	cin>>n>>m;

	map<int,node> Map;

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

		cin>>p>>y;

		no.p=p;no.y=y;

		no.sub=i;

		Map[i]=no;

		v[p].push_back(no);

	}

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

		sort(v[i].begin(),v[i].end(),cmp);

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

        	Map[v[i][j].sub].num=j+1;

    	}

	}

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

		printf("%06d%06d\n",Map[i].p,Map[i].num);

	}

	return 0;

}

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

#include <cmath>

#include <algorithm>

using namespace std;

const int maxn = 1e5 + 5;

typedef struct Node {

    int id, p, y, s;

} Node;

Node node[maxn] = { 0 };

bool cmp(Node &a, Node &b) {

    if (a.p == b.p) return a.y < b.y;

    return a.p < b.p;

}

bool cov(Node &a, Node &b) {

    return a.id < b.id;

}



int main() {

    int n, m;

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

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

        scanf("%d%d", &node[i].p, &node[i].y);

        node[i].id = i;

    }

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

    int cnt = 1;

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

        if (node[i].p == node[i - 1].p) node[i].s = ++cnt;

        else node[i].s = cnt = 1;

    sort(node + 1, node + n + 1, cov);

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

        printf("%06d%06d\n", node[i].p, node[i].s);

    return 0;

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

#include <algorithm>

#include <string>

#include <cstdio>

#include <cstring>

#include <cmath>

using namespace std;

const int MAX=1e5+5;

struct city

{

	int P;

	int Y;

	int num;

	int x;

}c[MAX];

bool cmp1(city a,city b)

{

	if(a.P==b.P)

		return a.Y<b.Y;

	else

		return a.P<b.P;

}

bool cmp2(city a,city b)

{

	return a.num<b.num;

}

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

{

	int n,m;

	cin>>n>>m;

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

		{cin>>c[i].P>>c[i].Y;c[i].num=i+1;}

	sort(c,c+m,cmp1);

	int x=c[1].P;

	int y=1;

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

	{

		if(x!=c[i].P)

		{

			x=c[i].P;

			y=1;

		}

		c[i].x=y;

		y++;

	}

	sort(c,c+m,cmp2);

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

		printf("%06d%06d\n",c[i].P,c[i].x);

	return 0;

}

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

#include <cmath>

#include <algorithm>

using namespace std;

const int maxn = 1e5 + 5;

typedef struct Node {

    int id, p, y, s;

} Node;

Node node[maxn] = { 0 };

bool cmp(Node &a, Node &b) {

    if (a.p == b.p) return a.y < b.y;

    return a.p < b.p;

}

bool cov(Node &a, Node &b) {

    return a.id < b.id;

}



int main() {

    int n, m;

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

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

        scanf("%d%d", &node[i].p, &node[i].y);

        node[i].id = i;

    }

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

    int cnt = 1;

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

        if (node[i].p == node[i - 1].p) node[i].s = ++cnt;

        else node[i].s = cnt = 1;

    sort(node + 1, node + n + 1, cov);

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

        printf("%06d%06d\n", node[i].p, node[i].s);

    return 0;

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

#include<algorithm>

#include<vector> 

#include<map>

using namespace std;

const int M=1e5+5;

struct node{

	int p,y;

	int k,num;

}q;

bool comp(node a,node b){

	return a.y<b.y;

}

vector<node> a[M];

map<int,node> Map;

int main(){

    int n,m;

    cin>>n>>m;

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

    	int p,y;

    	cin>>p>>y;

    	q.p=p; q.y=y;

    	q.k=i;

    	Map[i]=q;

    	a[p].push_back(q);

	}

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

		sort(a[i].begin(),a[i].end(),comp);

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

			Map[a[i][j].k].num=j+1;	

	}

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

		printf("%06d%06d\n",Map[i].p,Map[i].num);

}

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

#include <cmath>

#include <algorithm>

using namespace std;

const int maxn = 1e5 + 5;

typedef struct Node {

    int id, p, y, s;

} Node;

Node node[maxn] = { 0 };

bool cmp(Node &a, Node &b) {

    if (a.p == b.p) return a.y < b.y;

    return a.p < b.p;

}

bool cov(Node &a, Node &b) {

    return a.id < b.id;

}



int main() {

    int n, m;

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

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

        scanf("%d%d", &node[i].p, &node[i].y);

        node[i].id = i;

    }

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

    int cnt = 1;

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

        if (node[i].p == node[i - 1].p) node[i].s = ++cnt;

        else node[i].s = cnt = 1;

    sort(node + 1, node + n + 1, cov);

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

        printf("%06d%06d\n", node[i].p, node[i].s);

    return 0;

}