TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
n, m = map(int, input().split())
py = []
s = '000000'
for i in range(m):
    p, y = map(int, input().split())
    py.append([p, y, i])
py.sort(key=lambda py:(py[0],py[1]))

py[0].append(1)
for i in range(m-1):
    a = 1
    if py[i][0] == py[i+1][0]:
        py[i+1].append(py[i][3]+1)
    else:
        py[i+1].append(1)
        
py.sort(key=lambda py:(py[2]))

for j in range(len(py)):
    print((s+str(py[j][0]))[-5:]+(s+str(py[j][3]))[-5:])

n, m = map(int, input().split())
py = []
s = '000000'
for i in range(m):
    p, y = map(int, input().split())
    py.append([p, y, i])
py.sort(key=lambda py:(py[0],py[1]))

py[0].append(1)
for i in range(m-1):
    a = 1
    if py[i][0] == py[i+1][0]:
        py[i+1].append(py[i][3]+1)
    else:
        py[i+1].append(1)
        
py.sort(key=lambda py:(py[2]))

for j in range(len(py)):
    print((s+str(py[j][0]))[-6:]+(s+str(py[j][3]))[-6:])

Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
#coding:utf-8


if __name__ == "__main__":
    N, M = map(int, input().split())
    city_list = []
    pref_dec = {}
    for m in range(M):
        p, y = map(int, input().split())
        city_list.append((p, y))
        if p not in pref_dec:
            pref_dec[p] = []
        pref_dec[p].append(y)

    for p in pref_dec.keys():
        pref_dec[p].sort()

    print(pref_dec)
    for m in range(M):
        p_id = city_list[m][0]
        y_id = pref_dec[p_id].index(city_list[m][1]) + 1
        print(str(p_id).zfill(6) + str(y_id).zfill(6))


#coding:utf-8



if __name__ == "__main__":
    N, M = map(int, input().split())
    city_list = []
    for i in range(M):
        p, y = map(int, input().split())
        city_list.append([i, p, y])

    city_count = {}
    order_dic = {}
    for i, p, y in sorted(city_list, key = lambda x: x[2]):
        if not p in city_count:
            city_count[p] = 0
        city_count[p] += 1
        order_dic[i, p] = city_count[p]

    for i, p, y in city_list:
        print("{:06}{:06}".format(p, order_dic[i,p]))


Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
N, M = map(int, input().split())

PY = []
for _ in range(M):
  py = list(map(int,input().split()))
  PY.append(py)

PY.sort()
cnt_pref = {}
for py in PY:
  p,y = py[0],py[1]
  if (p in cnt_pref):
    cnt_pref[p] += 1
  else:
    cnt_pref[p] = 1
  out = str(p).zfill(6) + str(cnt_pref[p]).zfill(6)
  print(out)

from operator import itemgetter

N, M = map(int, input().split())
PY = []

for i in range(M):
  PY.append([i, list(map(int,input().split())), 'x'])

PY.sort(key=itemgetter(1,2))
cnt_pref = {}

for i in range(M):  
  p, y = PY[i][1][0], PY[i][1][1]
  if (p in cnt_pref):
    cnt_pref[p] += 1
  else:
    cnt_pref[p] = 1
  PY[i][2] = str(p).zfill(6) + str(cnt_pref[p]).zfill(6)

PY.sort(key=itemgetter(0))
for i in PY:
  print(i[2])

Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
import bisect
from collections import defaultdict
n,m = map(int,input().split())
p = [list(map(int, input().split())) for _ in range(m)]

a = defaultdict(list)
for x,y in sorted(p):
    a[x].append(y)
for x,y in p:
    z=bisect.bisect(a[x],y)
    print("{0:06d}{0:06d}".format(x,z))

import bisect
from collections import defaultdict
n,m = map(int,input().split())
p = [list(map(int, input().split())) for _ in range(m)]
 
a = defaultdict(list)
for x,y in sorted(p):
    a[x].append(y)
for x,y in p:
    
    z=bisect.bisect(a[x],y)
    print("{0:06d}{1:06d}".format(x,z))

Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
#ABC113_C

N,M=map(int,input().split())
PYi=[]
for i in range(M):
    p,y=map(int,input().split())
    PYi.append([p,y,i])

PYi.sort()

prep=PYi[0][0]
cc=1#city code
PYi[0][1]=cc
for j in range(1,M):
    p=PYi[j][0]
    if prep==p:
        cc+=1
    else:
        cc=1
    PYi[j][1]=cc
    prep=p
        
PYi.sort(key=lambda x:x[2])

def padding(A):
    A=str(A)
    while len(A)<6:
        A=str(0)+A
    return A

for i in range(M):
    print(padding(PYi[i][0]),padding(PYi[i][1]))

#ABC113_C

N,M=map(int,input().split())
PYi=[]
for i in range(M):
    p,y=map(int,input().split())
    PYi.append([p,y,i])

PYi.sort()

prep=PYi[0][0]
cc=1#city code
PYi[0][1]=cc
for j in range(1,M):
    p=PYi[j][0]
    if prep==p:
        cc+=1
    else:
        cc=1
    PYi[j][1]=cc
    prep=p
        
PYi.sort(key=lambda x:x[2])

def padding(A):
    A=str(A)
    while len(A)<6:
        A=str(0)+A
    return A

for i in range(M):
    ansi=padding(PYi[i][0])+padding(PYi[i][1])
    print(ansi)

Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
p = [list(map(int, input().split()+[i])) for i in range(m)]

p.sort()
cnt = 1
pre = -1

for city in p:
    if city[0] == pre:
        cnt = cnt + 1
    else:
        pre = city[0]

    city.append("{:0>6}{:0>6}".format(city[0], cnt))

p.sort(key = lambda x: x[2])

for city in p:
    print(city[3])

import collections
import bisect
n,m=map(int,input().split())
p=[[int(j) for j in input().split()] for i in range(m)]
a=collections.defaultdict(list)
p.sort()
for x,y in p:
    a[x]+=[y]
for x,y in p:
    z=bisect.bisect(a[x],y)
    print("%06d%06d"%(x,z))

import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

n, m = map(int, input().split())

pre = [[] for _ in range(n)]
p = []

for i in range(m):
    p.append(list(map(int, input().split())))
    pre[p[i][0] - 1].append(p[i][1])

for i in range(m):
    pref = "{:0>6}".format(p[i][0])

    years = pre[p[i][0] - 1]
    years.sort()

    y = years.index(p[i][1]) + 1
    year = "{:0>6}".format(y)
    print(pref + year)


import collections
import bisect
n,m=map(int,input().split())
p=[[int(j) for j in input().split()] for i in range(m)]
a=collections.defaultdict(list)
for x,y in sorted(p):
    a[x]+=[y]
for x,y in p:
    z=bisect.bisect(a[x],y)
    print("%06d%06d"%(x,z))

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
import numpy as np
N, M = [int(_) for _ in input().split()]
PN = [[] for _ in range(M)]
Y = [[] for _ in range(N)]
P = [0 for _ in range(N)]
for i in range(M):
    p, y = [int(_) - 1 for _ in input().split()]
    PN[i] = [p, P[p]]
    Y[p].append(y)
    P[p] += 1
Y_rank = [np.argsort(_) for _ in Y]
print(PN)
print(Y)
print(Y_rank)
for i in range(M):
    print(str(PN[i][0] + 1).zfill(6) + str(Y_rank[PN[i][0]][PN[i][1]] + 1).zfill(6))


from scipy.stats import rankdata
N, M = [int(_) for _ in input().split()]
P = [M for _ in range(M)]
PY = [[100000000 for _ in range(M)] for _ in range(N)]
for i in range(M):
    p, y = [int(_) - 1 for _ in input().split()]
    P[i] = p
    PY[p][i] = y
PY2 = [[M for _ in range(M)] for _ in range(N)]
for i in range(N):
    PY2[i] = [int(_) for _ in rankdata(PY[i])]
print(P)
print(PY)
print(PY2)
for i in range(M):
    print(str(P[i] + 1).zfill(6) + str(PY2[P[i]][i]).zfill(6))

from scipy.stats import rankdata
N, M = [int(_) for _ in input().split()]
P = [M for _ in range(M)]
PY = [[100000000 for _ in range(M)] for _ in range(N)]
for i in range(M):
    p, y = [int(_) - 1 for _ in input().split()]
    P[i] = p
    PY[p][i] = y
PY2 = [[M for _ in range(M)] for _ in range(N)]
for i in range(N):
    PY2[i] = [int(_) for _ in rankdata(PY[i])]
print(P)
print(PY)
print(PY2)
for i in range(M):
    print(str(P[i] + 1).zfill(6) + str(PY2[P[i]][i]).zfill(6))

N, M = [int(_) for _ in input().split()]
PY = [[int(_) for _ in input().split()] for _ in range(M)]
PYI = sorted([PY[i] + [i] for i in range(M)], key=lambda xs:xs[1])
count_p = {}
ans = [None] * M
for p, y, i in PYI:
    count_p[p] = count_p.get(p, 0) + 1
    ans[i] = [p, count_p[p]]
[print(str(p).zfill(6)+str(x).zfill(6)) for p, x in ans]


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
N, M = map(int, input().split())
birth_list = []
for i in range(M):
    Pi, Yi = map(int, input().split())
    birth_list.append([Pi, Yi])

counter = -1
prev_pref = -1
for city in sorted(birth_list, key=lambda x: (x[0], x[1])):
    print(city)
    if city[0] != prev_pref:
        counter = 1
    else:
        counter += 1
    identity_number = str(city[0]).zfill(6) + str(counter).zfill(6)
    city.append(identity_number)
    prev_pref = city[0]

for city in birth_list:
    print(city[2])

N, M = map(int, input().split())
birth_list = []
for i in range(M):
    Pi, Yi = map(int, input().split())
    birth_list.append([Pi, Yi])

counter = -1
prev_pref = -1
for city in sorted(birth_list, key=lambda x: (x[0], x[1])):
    # print(city)
    if city[0] != prev_pref:
        counter = 1
    else:
        counter += 1
    identity_number = str(city[0]).zfill(6) + str(counter).zfill(6)
    city.append(identity_number)
    prev_pref = city[0]

for city in birth_list:
    print(city[2])

Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
import collections
import bisect
n,m=map(int,input().split())
p=[[int(j) for j in input().split()] for i in range(m)]
a=collections.defaultdict(list)
for x,y in sorted(p):
    a[x]+=[y]
print(a)
for x,y in p:
    z=bisect.bisect(a[x],y)
    print("%06d%06d"%(x,z))

N, M = map(int,input().split())
PY = [list(map(int,input().split())) + [0] for _ in range(M)]
sort_PY = sorted(PY, key = lambda x: x[1])

city = {}
for i in range(M):
  p, y = sort_PY[i][0], sort_PY[i][1]
  if p in city:
    city[p] += 1
  else:
    city[p] = 1
  sort_PY[i][2] = city[p]
  print(city)
for p, y, z in PY:
  print(str(p).zfill(6)+str(z).zfill(6))

import collections
import bisect
n,m=map(int,input().split())
p=[[int(j) for j in input().split()] for i in range(m)]
a=collections.defaultdict(list)
for x,y in sorted(p):
    a[x]+=[y]
for x,y in p:
    z=bisect.bisect(a[x],y)
    print("%06d%06d"%(x,z))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
a,b=map(int,input().split())
L=[[] for i in range(a)]
l=[]
ll=[]
u=0
for i in range(b):
    u+=1
    c=list(map(int,input().split()))
    c.append(u)
    L[int(c[0])-1].append(c)
    print(c,L)
for i in L:
    i.sort(key=lambda x:x[1])
for i in L:
    e=0
    for j in i:
        e+=1
        j.append(e)
print(L)
q=[]
for w in L:
   q.extend(w) 
q.sort(key=lambda x:x[2])
for r in range(b):
        print('0'*(6-len(str(q[r][0])))+str(q[r][0])+'0'*(6-len(str(q[r][3])))+str(q[r][3]))

a,b=map(int,input().split())
L=[]
l=[]
ll=[]
u=0
for i in range(b):
    u+=1
    c=list(map(int,input().split()))
    c.append(u)
    L.append(c)
L.sort(key=lambda x:x[0])
for i in range(1,a+1):
    lll=[]
    for j in L:
        if j[0]==i:
            lll.append(j)
    ll.append(lll)
for i in ll:
    e=0
    for j in i:
        e+=1
        j.append(e)
q=[]
for w in ll:
   q.extend(w) 
q.sort(key=lambda x:x[2])
for r in range(b):
        print('0'*(6-len(str(q[r][0])))+str(q[r][0])+'0'*(6-len(str(q[r][3])))+str(q[r][3]))

a,b=map(int,input().split())
L=[[] for i in range(a)]
u=0

for i in range(b):
    u+=1
    c=list(map(int,input().split()))
    c.append(u)
    L[int(c[0])-1].append(c)

for i in L:
    i.sort(key=lambda x:x[1])

for i in L:
    e=0
    for j in i:
        e+=1
        j.append(e)
q=[]
for w in L:
   q.extend(w) #flatten
q.sort(key=lambda x:x[2])　
for r in range(b):
        print(str(q[r][0]).zfill(6)+str(q[r][3]).zfill(6))　#zfill

a,b=map(int,input().split())
L=[[] for i in range(a)]
u=0

for i in range(b):
    u+=1
    c=list(map(int,input().split()))
    c.append(u)
    L[int(c[0])-1].append(c)

for i in L:
    i.sort(key=lambda x:x[1])

for i in L:
    e=0
    for j in i:
        e+=1
        j.append(e)
q=[]
for w in L:
   q.extend(w)# flatten

q.sort(key=lambda x:x[2])
for r in range(b):
        print(str(q[r][0]).zfill(6)+str(q[r][3]).zfill(6))

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
import numpy as np

N,M = map(int, input().split())
X = np.ones((M,3), dtype=int)
for i in range(M):
    X[i, 0], X[i, 1] = map(int, input().split())
for i in range(N):
    print(np.argsort(X[X[:,0]==i, 1]))
    X[X[:,0]==i, 2] = np.argsort(X[X[:,0]==i, 1])+1
for i in range(M):
    print('{:06}{:06}'.format(X[i,0], X[i,2]))

import numpy as np

N,M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]
order = [[] for _ in range(N)]
for p,y in X:
    order[p-1].append(y)
#X = np.array(X, dtype=int)
for i in range(N):
    order[i] = np.argsort(np.argsort(order[i]))
cnts = [0 for _ in range(N)]
for i in range(M):
    p = X[i][0]
    print('{:06}{:06}'.format(p, order[p-1][cnts[p-1]]+1) )
    cnts[p-1] += 1

Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
N, M =map(int, input().split())
Ps =[]
Ys =[]
dic = {}
for i in range(M):
    p, y = map(int, input().split())
    Ps.append(p)
    Ys.append(y)
    ls = dic.get(p, [])
    ls.append(y)
    dic[p] = ls.sort()
for i in range(M):
    p = Ps[i]
    y = Ys[i]
    number = dic[p].index(y) + 1
    strp = str(p)
    strn = str(number)
    print(strp.zfill(6) + strn.zfill(6))


N, M =map(int, input().split())
Ps =[]
Ys =[]
dic = {}
for i in range(M):
    p, y = map(int, input().split())
    Ps.append(p)
    Ys.append(y)
    ls = dic.get(p, [])
    ls.append(y)
for p in Ps:
    ls = dic[p]
    ls.sort()
    dic[p] = ls
for i in range(M):
    p = Ps[i]
    y = Ys[i]
    number = dic[p].index(y) + 1
    strp = str(p)
    strn = str(number)
    print(strp.zfill(6) + strn.zfill(6))


N, M =map(int, input().split())
ls = []
pcount =[]
for i in range(N):
    pcount.append(0)
for i in range(M):
    p, y = map(int, input().split())
    ls.append([i, p, y])
ls.sort(key = lambda x:x[2])

for l in ls:
    pcount[l[1]-1] += 1
    l.append(pcount[l[1]-1])
ls.sort(key = lambda x:x[0])
for l in ls:
    print(str(l[1]).zfill(6) + str(l[3]).zfill(6))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
N, M = map(int, input().split())
P = []
Y = []
for i in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)

A = [[] for i in range(N)]

for i in range(M):
    A[P[i]-1].append([i, Y[i]])
    
for i in range(N):
    A[i] = sorted(A[i], key=lambda x:x[1])

R = [[] for i in range(M)]

cc = 0
for i in range(N):
    c = 1
    for j in A[i]:
        R[cc] = str(10**12 + (i+1) * (10**6) + c)[1:]
        c += 1
        cc += 1
for r in R:
    print(r)

N, M = map(int, input().split())
P = []
Y = []
for i in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)

A = [[] for i in range(N)]

for i in range(M):
    A[P[i]-1].append([i, Y[i]])
    
for i in range(N):
    A[i] = sorted(A[i], key=lambda x:x[1])

R = [[] for i in range(M)]

cc = 0
for i in range(N):
    c = 1
    for j in A[i]:
        R[j[0]] = str(10**12 + (i+1) * (10**6) + c)[1:]
        c += 1
        cc += 1
for r in R:
    print(r)

Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
N,M = map(int,input().split())
lis  = [list(input().split()) for _ in range(M)]
ans_lis = [0] * M
lis_sort = sorted(lis)
flag = lis_sort[0][0]
i = 1
for x in lis_sort:
    if x[0] != flag:
        flag = x[0]
        i=1
        print('if')
    x[1] = '0'*(6-len(str(i)))+str(i)
    i+=1
for x in lis:
    print('0'*(6-len(x[0])),x[0],x[1],sep='')

N,M = map(int,input().split())
flag = 0
lis  = [list(map(int,input().split())) for _ in range(M)]
ans_pra_lis = []
ans_beh_lis = [0] * M
lis_sort = sorted(lis)
for _ in lis:
    s = str(0)*(6-len(str(_[0]))) + str(_[0])
    ans_pra_lis.append(s)
i = 1
for _ in range(len(lis_sort)):
    if flag != lis_sort[_][0]:
        flag = lis_sort[_][0]
        i = 1
    ans_beh_lis[lis.index(lis_sort[_])] = str(0)*(6-len(str(i))) + str(i)
    i += 1
for x,y in zip(ans_pra_lis,ans_beh_lis):
    print(x,y)

N,M = map(int,input().split())
lis  = [list(map(int,input().split())) for _ in range(M)]
ans_lis = [0] * M
lis_sort = sorted(lis)
i = 1
flag = 0
for _ in range(len(lis_sort)):
    if flag != lis_sort[_][0]:
        flag = lis_sort[_][0]
        i = 1
    ans_lis[lis.index(lis_sort[_])] = str(i)
    i += 1
for x,y in zip(lis,ans_beh_lis):
    print('0'*(6-len(str(x[0]))),x[0],'0'*(6-len(y)),y,sep='')



N,M = map(int,input().split())
lis  = [list(map(int,input().split())) for _ in range(M)]
ans_lis = [0] * M
lis_sort = sorted(lis,key =lambda x:(x[0],x[1]))
flag = lis_sort[0][0]
i = 1
for x in lis_sort:
    if x[0] != flag:
        flag = x[0]
        i=1
    x[1] = '0'*(6-len(str(i)))+str(i)
    i+=1
for x in lis:
    print('0'*(6-len(str(x[0]))),str(x[0]),x[1],sep='')

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
n,m=[int(i) for i in input().split()]
id=[[int(i) for i in input().split()]+[j] for j in range(m)]

print(id)

pre_num=[0]*(n+1)
ans=[""]*m

id.sort(key=lambda x:x[1])

for p,y,i in id:
    pre_num[p]+=1
    ans[i]=str(p).zfill(6)+str(pre_num[p]).zfill(6)
    
print("\n".join(ans))


n,m=[int(i) for i in input().split()]
id=[[int(i) for i in input().split()]+[j] for j in range(m)]

pre_num=[0]*(n+1)
ans=[""]*m

id.sort(key=lambda x:x[1])

for p, y, i in id:
    pre_num[p] += 1
    ans[i] = str(p).zfill(6) + str(pre_num[p]).zfill(6)

print("\n".join(ans))

Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
PY = [tuple(map(int, input().split())) for _ in range(M)]

city_count = [0]*(N+1)
for p, y in PY:
    city_count[p] += 1
for ken, count in enumerate(city_count):
    [print(str(1*10**12+ken*10**6+count)[1:]) for i in range(1,count+1)]


import sys
input = sys.stdin.readline

N, M = map(int, input().split())
PY = [tuple(map(int, input().split())) for _ in range(M)]

city_count = [0]*(N+1)
for p, y in PY:
    city_count[p] += 1
for ken, count in enumerate(city_count):
    [print(str(1*10**12+ken*10**6+i)[1:]) for i in range(1,count+1)]


import sys
input = sys.stdin.readline

N, M = map(int, input().split())
PY = [map(int, input().split()) for i in range(M)]
PYI = sorted((p, y, i+1) for i, (p, y) in enumerate(PY))
def gen():
  pre = -1
  count = -1
  for p, y, i in PYI:
    if p == pre:
      count += 1
      yield (i, str(1*10**12+p*10**6+count)[1:])
    else:
      count = 1
      yield (i, str(1*10**12+p*10**6+count)[1:])
      pre = p
print('\n'.join(i[1] for i in sorted(gen())))
     

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
N,M = map(int,input().split())
ls = []
for i in range(M):
    P,Y = map(int,input().split())
    ls.append([i,P,Y])
ls.sort(key=lambda x:x[1])
num = 1
city = ls[0][1]
for i in range(M):
    if ls[i][1] == city:
        ls[i][2] = num
        num += 1
    else:
        num = 1
        ls[i][2] = num
        city = ls[i][1]
ls.sort(key=lambda x:x[0])
for i in range(M):
    print('{0:06d}'.format(ls[i][1])+'{0:06d}'.format(ls[i][2]))

N,M = map(int,input().split())
ls = []
for i in range(M):
    P,Y = map(int,input().split())
    ls.append([P,Y,i])
ls.sort()
num = 1
city = ls[0][0]
for i in range(M):
    if ls[i][0] == city:
        ls[i][1] = num
        num += 1
    else:
        num = 1
        ls[i][1] = num
        city = ls[i][0]
        num += 1
ls.sort(key=lambda x:x[2])
for i in range(M):
    print('{0:06d}'.format(ls[i][0])+'{0:06d}'.format(ls[i][1]))

Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
n,m=map(int,input().split())
py=[list(map(int,input().split()))+[i] for i in range(m)]

py.sort(key=lambda x: (x[0],x[1]))
print(py)
_dict = {}

ans=[]
for i in range(m):
    if not py[i][0] in _dict:
        _dict[py[i][0]]=1
    else:
        _dict[py[i][0]]+=1
    p="0"*(6-len(str(py[i][0])))+str(py[i][0])
    y="0"*(6-len(str(py[i][0])))+str(_dict[py[i][0]])
    ans.append([p+y,py[i][2]])

ans.sort(key=lambda x: x[1])
for i in range(m):
    print(ans[i][0])

n,m=map(int,input().split())
py=[list(map(int,input().split()))+[i] for i in range(m)]

py.sort(key=lambda x: (x[0],x[1]))
_dict = {}

ans=[]
for i in range(m):
    if not py[i][0] in _dict:
        _dict[py[i][0]]=1
    else:
        _dict[py[i][0]]+=1
    p="0"*(6-len(str(py[i][0])))+str(py[i][0])
    y="0"*(6-len(str(_dict[py[i][0]])))+str(_dict[py[i][0]])
    ans.append([p+y,py[i][2]])

ans.sort(key=lambda x: x[1])
for i in range(m):
    print(ans[i][0])

Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
N, M = [int(nm) for nm in input().split()]
PY = []
for m in range(M):
  PY.append([int(py) for py in input().split()])
PY.sort()
i = 1
print("0"*(6-len(str(PY[0][0]))) + str(PY[0][0]) + "0"*(6-len(str(i))) + str(i))
for m in range(1, M):
  if PY[m-1][0] == PY[m][0]:
    print("0"*(6-len(str(PY[m][0]))) + str(PY[m][0]) + "0"*(6-len(str(i+1))) + str(i+1))
  else:
    i = 1
    print("0"*(6-len(str(PY[m][0]))) + str(PY[m][0]) + "0"*(6-len(str(i))) + str(i))

N, M = [int(nm) for nm in input().split()]
PY = []
for m in range(M):
  PY.append([int(py) for py in input().split()] + [m])

PY.sort(key=lambda x: (x[0], x[1]))
p_ID = PY[0][0]
y_ID = 0
ID = []
for m in range(M):
  p, y, i = PY[m]
  if p == p_ID:
    y_ID += 1
  else: #p != p_ID:
    p_ID = p
    y_ID = 1
  iidd = "0"*(6-len(str(p_ID))) + str(p_ID) + "0"*(6-len(str(y_ID))) + str(y_ID)
  ID.append([iidd, i])

ID.sort(key=lambda x: x[1])
for m in range(M):
  print(ID[m][0])

Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
N, M = map(int,input().split())
PY = [list(map(int,input().split())) + [0] for _ in range(M)]
PY = sorted(PY, key = lambda x: (x[0], x[1]))
d = {}
for py in PY:
  if(py[0] not in d):
    d[py[0]] = 1
  else:
    d[py[0]] += 1
  py[2] = d[py[0]]
for py in PY:
  print(str(py[0]).zfill(6) + str(py[2]).zfill(6))

import sys

stdin = sys.stdin

sn = lambda : stdin.readline().rstrip()
an = lambda : map(int, stdin.readline().split())
ni = lambda : int(sn())

n, m = an()
py = []
for _ in range(m):
  py.append(list(an()) + [0])

sortPy = sorted(py, key = lambda x : (x[0], x[1]))

d = {}
for i, (p, y, n) in enumerate(sortPy):
  if p in d:
    d[p] += 1
  else:
    d[p] = 1
  sortPy[i][2] = d[p]

for p, y, n in py:
  print(str(p).zfill(6) + str(n).zfill(6))

Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
from collections import defaultdict
n, m = map(int, input().split())
l = []
dic = defaultdict(list)
for i in range(m):
    p, y = map(int, input().split())
    dic[p].append(y)
    l.append([p, y])
for key, value in dic.items():
    dic[key] = sorted(value)
for p, y in l:
    print(str(p).zfill(6)+str(dic[p].index(y)+1).zfill(8))


from collections import defaultdict
n, m = map(int, input().split())
l = []
dic = defaultdict(list)
for i in range(m):
    p, y = map(int, input().split())
    dic[p].append(y)
    l.append([p, y])
for key, value in dic.items():
    dic[key] = {num: index+1 for index,num in enumerate(sorted(value))}
for p, y in l:
    print(str(p).zfill(6)+str(dic[p][y]).zfill(6))


Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
N,M=map(int,input().split())

mp = {}
for i in range(M):
    P,Y=map(int,input().split())
    if not P in mp:
        mp[P] = []
    mp[P].append(Y)

for k,li in sorted(mp.items()):
    for i, _ in enumerate(li):
        print('{:06d}{:06d}'.format(k, i+1))


N,M=map(int,input().split())

mp = {}
for i in range(M):
    P,Y=map(int,input().split())
    if not P in mp:
        mp[P] = []
    mp[P].append((Y,i))

res = ['']*M
for k, li in sorted(mp.items()):
    for i, (y, l) in enumerate(sorted(li)):
        res[l] = '{:06d}{:06d}'.format(k, i+1)

for st in res: print(st)


Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
n = input().split()
l1 = []
for i in range(int(n[1])):
    l1.append(input().split())

for i in range(int(n[1])):
    for j in range(2):
        l1[i][j] = int(l1[i][j])

print(l1)
m = 0
for k in l1:
    k.append(m)
    m += 1

print(l1)
l3 = sorted(l1)
print(l3)

l3[0][1] = 1
for i in range(1,len(l3)):
    if l3[i][0]==l3[i-1][0]:
        l3[i][1]=l3[i-1][1]+1
    else:
        l3[i][1]=1

for i in range(len(l3)):
    l3[i][2],l3[i][0]=l3[i][0],l3[i][2]
for i in range(len(l3)):
    l3[i][1],l3[i][2]=l3[i][2],l3[i][1]
l3.sort()


for i in range(int(n[1])):
    for j in range(2):
        l3[i][j] = str(l3[i][j])

for i in range(len(l3)):
    print(str(l3[i][1]).zfill(6)+str(l3[i][2]).zfill(6))

n = input().split()
l1 = []
for i in range(int(n[1])):
    l1.append(input().split())

for i in range(int(n[1])):
    for j in range(2):
        l1[i][j] = int(l1[i][j])


m = 0
for k in l1:
    k.append(m)
    m += 1


l3 = sorted(l1)


l3[0][1] = 1
for i in range(1,len(l3)):
    if l3[i][0]==l3[i-1][0]:
        l3[i][1]=l3[i-1][1]+1
    else:
        l3[i][1]=1

for i in range(len(l3)):
    l3[i][2],l3[i][0]=l3[i][0],l3[i][2]
for i in range(len(l3)):
    l3[i][1],l3[i][2]=l3[i][2],l3[i][1]
l3.sort()


for i in range(int(n[1])):
    for j in range(2):
        l3[i][j] = str(l3[i][j])

for i in range(len(l3)):
    print(str(l3[i][1]).zfill(6)+str(l3[i][2]).zfill(6))

Verdicts: Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
#C-ID
n,m=map(int,input().split())
L={}
lp=[[] for _ in range(n)]
for cn in range(m):
  p,y=map(int,input().split())
  lp[p-1].append([y,cn])
  lp[p-1]=sorted(lp[p-1])
for pre in range(n):
  k=len(lp[pre])
  if k>0:
    for d in range(k):
      cn=lp[pre][k][1]
      ans="0"*(6-len(str(pre)))+str(pre)+"0"*(6-len(str(d+1)))+str(d+1)
      L[cn]=ans
for h in range(m):
  print(L[h])

#C-ID
n,m=map(int,input().split())
L={}
lp=[list() for _ in range(n)]
for cn in range(m):
  p,y=map(int,input().split())
  lp[p-1].append([y,cn])
for pre in range(n):
  k=len(lp[pre])
  if k>0:
    sd=lp[pre]
    asd=sorted(sd)
    for d in range(k):
      cn=asd[d][1]
      ans="0"*(6-len(str(pre+1)))+str(pre+1)+"0"*(6-len(str(d+1)))+str(d+1)
      L[cn]=ans
for h in range(m):
  print(L[h])

Verdicts: Runtime Error

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):

# C - ID

n, m = list(map(int, input().split()))
py_list = []

for _ in range(m):
    p, y = list(map(int, input().split()))
    py_list.append((p, y))

py_list = sorted(py_list, key=lambda x: (x[0], x[1]))

p_no = py_list[0][0]
y_index = 1
no_list = []

for i, py in enumerate(py_list):
    p, y = py

    if p != p_no:
        p_no = p
        y_index = 1

    no = str(p).zfill(6) + str(y_index).zfill(6)
    no_list.append(no)
    y_index += 1


ans = '\n'.join(no_list)
print(ans)



# C - ID

n, m = list(map(int, input().split()))
py_list = []

for _ in range(m):
    p, y = list(map(int, input().split()))
    py_list.append((p, y))

py_list = sorted(py_list, key=lambda x: (x[0], x[1]))

p_no = py_list[0][0]
p_index = 1
y_index = 1
no_list = []

for i, py in enumerate(py_list):
    p, y = py

    if p != p_no:
        p_no = p
        p_index += 1
        y_index = 1

    no = str(p_index).zfill(6) + str(y_index).zfill(6)
    no_list.append(no)
    y_index += 1


ans = '\n'.join(no_list)
print(ans)



# C - ID

n, m = list(map(int, input().split()))
py_list = []

for _ in range(m):
    p, y = list(map(int, input().split()))
    py_list.append((p, y))

sorted_py_list = sorted(py_list, key=lambda x: (x[0], x[1]))

p_no = sorted_py_list[0][0]
y_index = 1
no_dict = {}

for i, py in enumerate(sorted_py_list):
    p, y = py

    if p != p_no:
        p_no = p
        y_index = 1

    no = str(p).zfill(6) + str(y_index).zfill(6)
    no_dict[(p, y)] = no
    y_index += 1

print_list = []

for p, y in py_list:
    print_list.append(no_dict[(p, y)])

ans = '\n'.join(print_list)
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
N, M = map(int, input().split())
P = []
Y = []
var = []
for i in range(M):
    p, y = map(int, input().split())
    if p not in P:
        var.append(p)
    P.append(p)
    Y.append(y)

L = zip(range(M), P, Y)     

Order = [None]*M

for v in var:
    l = filter(lambda x:x[1] == v, L)
    l_ = sorted(l, key = lambda x:x[2])
    
    for n in l_:
        Order[n[0]] = l_.index(n)+1
        
for (p, od) in zip(P, Order):
    print('{0:0>6d}{1:0>6d}'.format(p, od))

N, M = map(int, input().split())
P = []
Y = []
#var = []
for i in range(M):
    p, y = map(int, input().split())
    #if p not in P:
    #    var.append(p)
    P.append(p)
    Y.append(y)

L = zip(range(M), P, Y)     

Order = [None]*M

for v in set(P):
    l = filter(lambda x:x[1] == v, L)
    l_ = sorted(l, key = lambda x:x[2])
    
    for n in l_:
        Order[n[0]] = l_.index(n)+1
        
for (p, od) in zip(P, Order):
    print('{0:0>6d}{1:0>6d}'.format(p, od))

N, M = map(int, input().split())
P = []
Y = []
var = []
for i in range(M):
    p, y = map(int, input().split())
    if p in P:
        var.append(p)
    P.append(p)
    Y.append(y)

L = zip(range(M), P, Y)     

Order = [None]*M

for v in var:
    l = filter(lambda x:x[1] == v, L)
    l_ = sorted(l, key = lambda x:x[2])
    
    for n in l_:
        Order[n[0]] = l_.index(n)+1
        
for (p, od) in zip(P, Order):
    print('{0:0>6d}{1:0>6d}'.format(p, od))

N, M = map(int, input().split())
L = []
P = [0]*(N+1)
for i in range(M):
    p, y = map(int, input().split())
    L.append([i, p, y, 0])

L = sorted(L, key = lambda x:x[2])

for l in L:
    P[l[1]] += 1
    l[3] = P[l[1]]    
        
for l in sorted(L, key = lambda x:x[0]):
    print('{0:0>6d}{1:0>6d}'.format(l[1], l[3]))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted