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):
import collections
import bisect

N, M = map(int, input().split())
P = [list(map(int, input().split())) for i in range(M)]

ans = collections.defaultdict(list)

for p, y in sorted(P):
    ans[p] += [y]
for p, y in P:
    print("%06d%06d"%(p, bisect.bisect(a[p], y)))

import collections
import bisect

N, M = map(int, input().split())
P = [list(map(int, input().split())) for i in range(M)]

ans = collections.defaultdict(list)

for p, y in sorted(P):
    ans[p] += [y]
for p, y in P:
    print("%06d%06d"%(p, bisect.bisect(ans[p], y)))

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):
# -*- coding: utf-8 -*-

import sys
import itertools
import math

N,M=[int(x) for x in input().split()]
C=[[int(x) for x in input().split()] for i in range(M)]

ps=dict()
for c,(p,y) in enumerate(C):
    if not p in ps:
        ps[p]=[]
    ps[p].append((y,c))

qs=[]
for p,cs in ps.items():
    cs.sort()
    qs += [(c,p,i) for i,(y,c) in enumerate(cs)]

qs.sort()

for c,p,i in qs:
    print("{0:0=6}{1:0=6}".format(p,i))




# -*- coding: utf-8 -*-

import sys
import itertools
import math

N,M=[int(x) for x in input().split()]
C=[[int(x) for x in input().split()] for i in range(M)]

ps=dict()
for c,(p,y) in enumerate(C):
    if not p in ps:
        ps[p]=[]
    ps[p].append((y,c))

qs=[]
for p,cs in ps.items():
    cs.sort()
    qs += [(c,p,i) for i,(y,c) in enumerate(cs)]

qs.sort()

for c,p,i in qs:
    print("{0:0=6}{1:0=6}".format(p,i))




# -*- coding: utf-8 -*-

import sys
import itertools
import math

N,M=[int(x) for x in input().split()]
C=[[int(x) for x in input().split()] for i in range(M)]

ps=dict()
for c,(p,y) in enumerate(C):
    if not p in ps:
        ps[p]=[]
    ps[p].append((y,c))

qs=[]
for p,cs in ps.items():
    cs.sort()
    qs += [(c,p,i) for i,(y,c) in enumerate(cs)]

qs.sort()

for c,p,i in qs:
    print("{0:0=6}{1:0=6}".format(p,i+1))


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):
from bisect import bisect
L = list(map(int,input().split()))
N = L[0]
M = L[1]
P = list()
Y = list()
S = list()
for x in range(0,N):
    S.append(list())
for x in range(0,M):
    X = list(map(int,input().split()))
    P.append(X[0])
    Y.append(X[1])
    S[X[0]-1].append(X[1])
for y in range(0,M):
    n = 0
    n = bisect(S[P[y]-1],Y[y])
    nstr = str(n)
    Pstr = str(P[y])
    while len(nstr) < 6:
        nstr = '0' + nstr
    while len(Pstr) < 6:
        Pstr = '0' + Pstr
    number = Pstr + nstr
    print(number)

L = list(map(int,input().split()))
N = L[0]
M = L[1]
PY = list()

for x in range(0,M):
    X = list(map(int,input().split()))
    PY.append((X[0],X[1],x))

sortedPY = sorted(PY, key=lambda x:x[1])
ID = [0 for i in range(N)]

for y in range(0,M):
    n = sortedPY[y][0]
    n = n-1
    ID[n] = ID[n] + 1
    nstr = str(ID[n])
    Pstr = str(sortedPY[y][0])
    while len(nstr) < 6:
        nstr = '0' + nstr
    while len(Pstr) < 6:
        Pstr = '0' + Pstr
    PY[sortedPY[y][2]] = Pstr + nstr
    number = Pstr + nstr

for x in range(0,M):
    print(PY[x])

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 = [int(x) for x in input().split(' ')]
py = [tuple(input().split(' ')) for _ in range(m)]

d = defaultdict(list)

for x, y in py:
    d[x].append(int(y))

ans = {}

for k, v in d.items():
    print(k, v)
    for i, x in enumerate(sorted(v), start=1):
        ans[(k, str(x))] = k.zfill(6) + str(i).zfill(6)

for x in py:
    print(ans[x])


from collections import defaultdict

n, m = [int(x) for x in input().split(' ')]
py = sorted(
        sorted(
            [input().split(' ') + [i] for i, _ in enumerate(range(m))],
            key=lambda x: int(x[1])
        ),
        key=lambda x: x[2]
    )

d = defaultdict(int)

for p, _, _ in py:
    d[p] += 1
    print(p.zfill(6) + str(d[p]).zfill(6))


from collections import defaultdict
 
n, m = [int(x) for x in input().split(' ')]
py = [tuple(input().split(' ')) for _ in range(m)]
 
d = defaultdict(list)
 
for x, y in py:
    d[x].append(int(y))
 
ans = {}
 
for k, v in d.items():
    for i, x in enumerate(sorted(v), start=1):
        ans[(k, str(x))] = k.zfill(6) + str(i).zfill(6)
 
for x in py:
    print(ans[x])

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())
PY = []
for i in range(M):
    p,y = map(int,input().split())
    PY.append([p,y,i])
PY.sort()
print(PY)

ans = [0 for i in range(M)]
c = 1
d = 0
for i in range(M):
    
    if c == PY[i][0]:
        d += 1
    else:
        c = PY[i][0]
        d = 1
    ans[PY[i][2]] = '0'*(6-len(str(PY[i][0])))  + str(PY[i][0]) + '0'*(6-len(str(PY[i][1]))) + str(d)
for i in ans:
    print(i)

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


ans = [0 for i in range(M)]
c = 1
d = 0
for i in range(M):
    
    if c == PY[i][0]:
        d += 1
    else:
        c = PY[i][0]
        d = 1
    ans[PY[i][2]] = '0'*(6-len(str(PY[i][0])))  + str(PY[i][0]) + '0'*(6-len(str(PY[i][1]))) + str(d)
for i in ans:
    print(i)

N,M = map(int,input().split())
array=[]
for i in range(M):
    P,Y = list(map(int,input().split()))
    array.append([P,Y])
array2 = sorted(array)
arraysorted1 = []
j = 1
k = 0
while j != N+1:
    array3=[]
    while k <= M-1:
        if array2[k][0] == j:
            array3.append(array2[k][1])
        k += 1
    array3= sorted(array3)
    arraysorted1.append(array3)
    k = len(arraysorted1[j-1])
    j += 1
for n in range(M):
    for m in range(len(arraysorted1[array[n][0]-1])):
        if array[n] == [array[n][0], arraysorted1[array[n][0]-1][m]]:
            lenf = 6-len(str(array[n][0]))
            lenl = 6-len(str(array[n][1]))
            
            print('0'*lenf +str(array[n][0])+'0'*lenl + str(m+1))


N,M = map(int,input().split())
PYi = []
pmin = float('inf')
for i in range(M):
    p,y = map(int,input().split())
    PYi.append([p,y,i])
    pmin = min(pmin,p)
PYi.sort()
now = pmin
count = 1
for i in range(M):
    p,y,j = PYi[i]
    if now == p:
        PYi[i][1] = count
        count += 1
    else:
        now = p
        PYi[i][1] = 1
        count = 2
PYi.sort(key = lambda x:x[2])
for p,y,i in PYi:
    p = str(p)
    y = str(y)
    print('0'*(6-len(p)) + p + '0'*(6-len(y)) + y)

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())
l = [tuple(map(int,input().split())) for _ in range(m)]
d = [list() for _ in range(n)]
for x in l:
  d[x[0]-1].append(x[1])
for r in d:
  r.sort()
for x in l:
  p = x[0]
  y = d[x[0]-1].index(x[1]) + 1
  print("{:06}{:06}".format(p,y)

n,m = map(int,input().split())
l = [tuple(map(int,input().split())) for _ in range(m)]
d = [list() for _ in range(n)]
dic = [dict() for _ in range(n)]
for x in l:
  d[x[0]-1].append(x[1])
for r in range(n):
  d[r].sort()
  dic[r] = dict(zip(d[r],range(1,len(d[r])+1)))
for x in l:
  p = x[0]
  y = dic[x[0]-1][x[1]]
  print("{:06}{:06}".format(p,y))

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):
import numpy as np
N, M = map(int,input().split())
Ps = [[] for _ in range(N)]
for i in range(M):
    j, Y = map(int,input().split())
    Ps[j-1].append([i,Y])
print(Ps)
rets = [""]*M
for i,P in enumerate(Ps):
    if len(P)==0:
        continue
    inds = np.array(P)[:,0]
    years = np.array(P)[:,1]
    sorts = np.argsort(years)
    for (j,y,s) in zip(inds,years,sorts):
        rets[j] = "{:06d}{:06d}".format(i+1,s+1)
for ret in rets:
    print(ret)

from collections import defaultdict
from bisect import bisect_left
N, M = map(int, input().split())
A = []
B = defaultdict(list)
 
for i in range(M):
    p, y = map(int, input().split())
    A.append([p, y])
    B[p].append(y)
 
for key in B.keys():
    B[key].sort()

print(A,B)
for a in A:
    print(a[0],a[1],B[a[0]],bisect_left(B[a[0]],a[1]))
for a in A:
    print("%06d%06d" % (a[0], bisect_left(B[a[0]], a[1])+1))

import numpy as np
N, M = map(int,input().split())
Ps = [[] for _ in range(N)]
for i in range(M):
    j, Y = map(int,input().split())
    Ps[j-1].append([i,Y])
rets = [""]*M
for i,P in enumerate(Ps):
    if len(P)==0:
        continue
    
    inds = np.array(P)[:,0]
    years = np.array(P)[:,1]
    sorts = np.argsort(years)
    
    
    for i,(ind,s) in enumerate(zip(inds,sorts)):
        a = np.where(sorts==i)[0][0]
        rets[ind] = "{:06d}{:06d}".format(i+1,a+1)



for ret in rets:
    print(ret)

from collections import defaultdict
from bisect import bisect_left
N, M = map(int, input().split())
A = []
B = defaultdict(list)
 
for i in range(M):
    p, y = map(int, input().split())
    A.append([p, y])
    B[p].append(y)
 
for key in B.keys():
    B[key].sort()


# for a in A:

for a in A:
    print("%06d%06d" % (a[0], bisect_left(B[a[0]], a[1])+1))

Verdicts: Wrong Answer

Runtime Error

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):
def main():
    import bisect
    n,m = map(int,input().split())
    d = [[] for i in range(n)]
    ans = [0 for i in range(m)]
    for i in range(m):
        p,y = map(int,input().split())
        d[p-1].append((y,i))
    for i,d_ in enumerate(d):
        d_.sort()
        for c, d__ in enumerate(d_):
            ans[d__[1]-1] = str(i+1).zfill(6) + str(c+1).zfill(6)
    for i in range(m):
        print(ans[i])

if __name__ == "__main__":
    main()


def main():
    import bisect
    n,m = map(int,input().split())
    ids = [0 for i in range(m)]
    his = [[] for i in range(n)]
    city = [[] for i in range(n)]
    for i in range(m):
        p,y = map(int,input().split())
        ids[i] = p
        b = bisect.bisect_right(city[p-1],y)
        city[p-1].insert(b,y)
        his[p-1].insert(b,len(his[p-1]))
    print(ids,city,his)
    c = [0 for i in range(n)]
    for i in range(m):
        nm = his[ids[i]-1][c[ids[i]-1]] + 1
        print(str(0) * (6 - len(str(ids[i])))+ str(ids[i])+str(0) * (6-len(str(nm))) + str(nm))
        c[ids[i]-1]+=1

if __name__ == "__main__":
    main()


def main():
    import bisect
    n,m = map(int,input().split())
    d = [[] for i in range(n)]
    ans = [0 for i in range(m)]
    for i in range(m):
        p,y = map(int,input().split())
        d[p-1].append((y,i))
    for i,d_ in enumerate(d):
        d_.sort()
        for c, d__ in enumerate(d_):
            ans[d__[1]] = str(i+1).zfill(6) + str(c+1).zfill(6)
    for i in range(m):
        print(ans[i])

if __name__ == "__main__":
    main()


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())

tmpsort = [[0]for i in range(n)]
p_list = []
y_list = []

for i in range(m):
    p,y = map(int,input().split())
    tmpsort[p-1].append(y)
    p_list.append(p)
    y_list.append(y)

for i in range(m):
    tmpsort[i].sort()
for i in range(len(p_list)):
    idx = tmpsort[p_list[i]-1].index(y_list[i])
    print((str(p_list[i]).zfill(6) + str(idx).zfill(6)))

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

tmpsort = [[0]]*n
p_list = []
y_list = []

for i in range(m):
    p,y = map(int,input().split())
    tmpsort[p-1].append(y)
    p_list.append(p)
    y_list.append(y)

for i in range(n):
    tmpsort[i].sort()
for i in range(len(p_list)):
    idx = tmpsort[p_list[i]-1].index(y_list[i])
    print((str(p_list[i]).zfill(6) + str(idx).zfill(6)))

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

tmp_list = [[0]for i in range(n)]
p_list = []
y_list = []

for i in range(m):
    p,y = map(int,input().split())
    tmp_list[p-1].append(y)
    p_list.append(p)
    y_list.append(y)

import copy
tmpsort = copy.deepcopy(tmp_list)
for i in range(len(tmp_list)):
    sorted(tmpsort[i])
for i in range(len(p_list)):
    idx = tmpsort[p_list[i]-1].index(y_list[i])
    print((str(p_list[i]).zfill(6) + str(idx).zfill(6)))

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

ans = [None]*M  
for p,iys in enumerate(piys):  
    iys.sort()  
    for k,(y,i) in enumerate(iys):  
        ans[i] = "%06d%06d" % (p+1,k+1)  

for i in ans:  
    print(i) 

Verdicts: Runtime Error

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())
from collections import defaultdict
d = defaultdict(list)
l = [[] for i in range(M)]
for i in range(M):
    P,Y = map(str, input().split())
    P = "0" * len(P) + P
    d[P].append(int(Y))
    l[i] = [P,int(Y)]
for i in range(M):
    tmp = str((sorted(d[l[i][0]]).index(l[i][1]))+1)
    print(l[i][0] + "0" * (6-len(tmp)) + tmp)

N, M = map(int, input().split())
from collections import defaultdict
d = defaultdict(list)
for i in range(M):
    P,Y = map(int, input().split())
    d[P].append([Y,i])
l = [0 for i in range(M)] 
cnt = 0   
for key in d:
    data = sorted(d[key])
    tmp = 0
    for i in range(len(data)):
        l[cnt] = [str(key).zfill(6) + str(tmp+1).zfill(6), data[i][1]]
        cnt += 1
        tmp += 1
l.sort(key = lambda x: x[1])
for i in range(M):
    print(l[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 = map(int,input().split())
A = [[] for i in range(N+1)]
B = []
d = {}
for i in range(M):
    p,y = map(int,input().split())
    B.append((p,y))
    A[p].append(y)
for i in range(N+1):
    A[i].sorted
    n = len(A[i])
    for j in range(n):
        d[A[i][j]] = j+1
for i in range(M):
    p,y = B[i]
    q = d[y]
    m = 6 - len(str(p))
    n = 6 - len(str(q))
    ans = "0"*m + str(p) + "0"*m + str(q)

N,M = map(int,input().split())
A = [[] for i in range(N+1)]
B = []
d = {}
for i in range(M):
    p,y = map(int,input().split())
    B.append((p,y))
    A[p].append(y)
for i in range(N+1):
    A[i].sorted
    n = len(A[i])
    for j in range(n):
        d[A[i][j]] = j+1
for i in range(M):
    p,y = B[i]
    q = d[y]
    m = 6 - len(str(p))
    n = 6 - len(str(q))
    ans = "0"*m + str(p) + "0"*m + str(q)
    print(ans)

N,M = map(int,input().split())
A = [[] for i in range(N+1)]
B = []
d = {}
for i in range(M):
    p,y = map(int,input().split())
    B.append((p,y))
    A[p].append(y)
for i in range(N+1):
    A[i].sort()
    n = len(A[i])
    for j in range(n):
        d[A[i][j]] = j+1
for i in range(M):
    p,y = B[i]
    q = d[y]
    m = 6 - len(str(p))
    n = 6 - len(str(q))
    ans = "0"*m + str(p) + "0"*n + str(q)
    print(ans)


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):
import collections
import bisect
n,m = map(int, input().split())
p = [list(map(int,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:
  print("%06d%06d"%(x,bisect.bisect(a[x],y))

n, m = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(m)]
r = [0]*n
for i in range(m):
    r[p[i][0]-1]+=1
    print(f"{p[i][0]:0>6}{r[p[i][0]-1]:0>6}")

import collections
import bisect
n,m = map(int, input().split())
p = [list(map(int,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:
  print("%06d%06d"%(x,bisect.bisect(a[x],y)))

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):
import numpy

N,M=map(int,input().split())
P=[]
Y=[]
for _ in range(M):
    data=[int(_) for _ in input().split()]
    P.append(data[0])
    Y.append(data[1])

y=[]
for x in range(1,N+1):
    for m in range(M):
        if P[m]==x:
            y.append(Y[m])

    ind=numpy.array(y)
    ind=ind.argsort()
    print(ind)
    for i,k in enumerate(y):
        Y[Y.index(k)]=ind[i]+1
    y=[]

for x in range(M):
    xx=str(P[x])
    yy=str(Y[x])
    print(xx.zfill(6)+yy.zfill(6))


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

city.sort(key = lambda t:t[2])
city.sort(key = lambda t:t[1])

id=1
old_city=0
for city_id in city:
    if city_id[1]!=old_city:
        id=1
    city_id[2]=id
    id+=1
    old_city=city_id[1]

city.sort(key = lambda t:t[0])

for x in city:
    ans=x[1]*1000000+x[2]
    print("{0:012d}".format(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):
n,m=list(map(int,input().split()))
city=[]
for i in range(m):
    city.append(list(map(int,input().split())))
city.sort()
ans=[]
count=0
precity=city[0][0]
for i in city:
    if i[0]==precity:
        count+=1
    else:
        count=1
    ans.append(str(i[0]).zfill(6)+str(count).zfill(6))
ans.sort()
for i in ans:
    print(i)

n,m=list(map(int,input().split()))
city=[]
for i in range(m):
    city.append(list(map(int,input().split()))+[i])
city.sort()
ans=[]
count=0
precity=city[0][0]
for i in city:
    if i[0]==precity:
        count+=1
    else:
        precity=i[0]
        count=1
    ans.append([i[2],str(i[0]).zfill(6)+str(count).zfill(6)])
ans.sort()
for i in ans:
    print(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):
from bisect import bisect_left

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

P = []
Y = []
PY = [[] for _ in range(N+1)]

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

for i in range(M+1):
    PY[i].sort()

for i in range(M):
    x = bisect_left(PY[P[i]], Y[i]) + 1
    print("%06d%06d" % (P[i], x))

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

sorted_P_Y = sorted(P_Y)
rank = 1
prev_p = -1
for p, y, i in sorted_P_Y:
    if prev_p != p:
        rank = 1
    else:
        rank += 1
    P_Y[i].append(rank)
    prev_p = p
for p, _, _, rank in P_Y:
    print(str(p).rjust(6, '0') + str(rank).rjust(6, '0'))

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):
n,m=map(int,input().split())
ken=[0 for i in range(n)]
for i in range(m):
    p,y=map(int,input().split())
    ken[p-1]+=1
ken0=[]
for i in range(n):
    for j in range(ken[i]):
        mae=str(i+1)
        ato=str(j+1)
        while len(mae)<6:
            mae='0'+mae
        while len(ato)<6:
            ato='0'+ato
        ken0.append(mae+ato)
for i in ken0:
    print(i)

n,m=map(int,input().split())
py=[]
ken=[]
number=[]
for i in range(m):
    py.append(list(map(int,input().split())))
for j in range(n):
    ken.append([])
    number.append([])
for k in py:
    ken[k[0]-1].append(k[1])
for l in ken:
    for q in range(len(l)):
        number[ken.index(l)-1].append(q+1)
for r in number:
    for s in range(len(r)):
        r[s]=str(r[s])
        while len(r[s])<6:
            r[s]='0'+r[s]
number1=[t+1 for t in range(n)]
for u in range(n):
    number1[u]=str(number1[u])
    while len(number1[u])<6:
        number1[u]='0'+number1[u]
for v in range(n):
    for w in number[v]:
        print(number1[v]+w)

n,m=map(int,input().split())
ken=[[] for i in range(n)]
for i in range(m):
    p,y=map(int,input().split())
    ken[p-1].append([i,y])
for i in range(n):
    ken[i].sort(key=lambda x:x[1])
ken0=[]
for i in range(n):
    for j in range(len(ken[i])):
        mae=str(i+1)
        ato=str(j+1)
        while len(mae)<6:
            mae='0'+mae
        while len(ato)<6:
            ato='0'+ato
        ken0.append([ken[i][j][0],mae+ato])
ken0.sort(key=lambda x:x[0])
for i in ken0:
    print(i[1])

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):
import numpy as np
N,M = map(int,input().split())
P = []
Y = []
index = range(1,M+1)
for i in range(M):
 a,b= map(int,input().split())
 P.append(a)
 Y.append(b)
for i in range(1,N+1):
 a = [j for j, x in enumerate(P) if x == i]
 for p in range(len(a)+1,1,-1):
  print('{0:04d}'.format(i)+'{0:04d}'.format(p-1))

import numpy as np
N,M = map(int,input().split())
P = []
Y = []
index = range(1,M+1)
for i in range(M):
 a,b= map(int,input().split())
 P.append(a)
 Y.append(b)
print(P)
print(Y)
for i in range(1,N+1):
 a = [j for j, x in enumerate(P) if x == i]
 for p in range(1,len(a)+1):
  print({0:04d}.format(i){0:04d}".format(p))

N,M = map(int,input().split())
city_list = sorted([[list(map(int,input().split())),i] for i in range(M)])
ID = city_list[0][0]
num = 0
ans = []
print(city_list)
for i in range(M):
  if ID != city_list[i][0][0]:
    ID = city_list[i][0][0]
    num = 0
  num += 1
  ans.append([city_list[i][1],'{0:06d}'.format(ID)+'{0:06d}'.format(num)])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i][1])

N,M = map(int,input().split())
city_list = sorted([[int(x) for x in input().split()] for i in range(M)])
ID = city_list[0][0]
num = 0
for i in range(M):
 if ID != city_list[i][0]:
  ID = city_list[i][0]
  num = 0
 num += 1
 print('{0:06d}'.format(ID)+'{0:06d}'.format(num))

N,M = map(int,input().split())
city_list = sorted([[int(x) for x in input().split()] for i in range(M)])
ID = city_list[0][0]
num = 0
for i in range(M):
 if ID != city_list[i][0]:
  ID = city_list[i][0]
  num = 0
 num += 1
 print('{0:04d}'.format(ID)+'{0:04d}'.format(num))

N,M = map(int,input().split())
city_list = sorted([[list(map(int,input().split())),i] for i in range(M)])
ID = city_list[0][0]
num = 0
ans = []
for i in range(M):
  if ID != city_list[i][0][0]:
    ID = city_list[i][0][0]
    num = 0
  num += 1
  ans.append([city_list[i][1],'{0:06d}'.format(ID)+'{0:06d}'.format(num)])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i][1])

Verdicts: Wrong Answer

Runtime Error

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):
#coding: utf-8
from copy import deepcopy


def main():
    N, M = map(int, input().split())
    p_dict = {}
    for i in range(M):
        p, y = map(int, input().split())
        if p not in p_dict.keys():
            p_dict[p] = [[y, p, i]]
        else:
            
            p_dict[p].append([y, p, i])
    ans = []
    for p in p_dict.keys():
        print(p)
        p_dict[p].sort()
        for i in range(len(p_dict[p])):
            
            p_dict[p][i].append(i+1)
            ans.append(p_dict[p][i])
    #print(p_dict[p_list[0][0]])
    print(p_dict)
    
    ans.sort(key=lambda x: x[2])
    print(ans)
    for y, p, oi, si in ans:
        print("{:06d}{:06d}".format(p, si))
if __name__ == "__main__":
    main()

# coding: utf-8

N, M = map(int, input().split())
p_dict = {}
for i in range(M):
	p, y = map(int, input().split())
	if p not in p_dict.keys():
		p_dict[p] = [[y, p, i]]
    else:
		
		p_dict[p].append([y, p, i])
ans = []
for p in p_dict.keys():
    p_dict[p].sort()
    for i in range(len(p_dict[p])):
        
        p_dict[p][i].append(i+1)
        ans.append(p_dict[p][i])
# ans = [y, p, input_index, sorted_index]
ans.sort(key=lambda x: x[2])
for y, p, oi, si in ans:
    print("{:06d}{:06d}".format(p, si))


# coding: utf-8

N, M = map(int, input().split())
p_dict = {}
for i in range(M):
    p, y = map(int, input().split())
    if p not in p_dict.keys():
        p_dict[p] = [[y, p, i]]
    else:
        
        p_dict[p].append([y, p, i])
ans = []
for p in p_dict.keys():
    p_dict[p].sort()
    for i in range(len(p_dict[p])):
        
        p_dict[p][i].append(i+1)
        ans.append(p_dict[p][i])
# ans = [y, p, input_index, sorted_index]
ans.sort(key=lambda x: x[2])
for y, p, oi, si in ans:
    print("{:06d}{:06d}".format(p, si))


Verdicts: 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 sys
input = sys.stdin.readline

import collections, 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 sorted(p):
  z = bisect.bisect(a[x], y)
  print("%06d%06d"%(x,z))
  


from collections import defaultdict
from bisect import bisect_right

dic_PY = defaultdict(list)
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(M)]
for p, y in sorted(PY):
  dic_PY[p] += [y]
  
for p, y in PY:
  z = bisect_right(dic_PY[p], y)
  print("%06d%06d"%(p,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):


if __name__ == '__main__':
    ken_num, city_num = list(map(int, input().split()))
    data = [list(map(int, input().split())).append(i) for i in range(city_num)]

    
    # data = [[1,32,0], [2,63,1],[1,12,2]]

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

    count = 1
    ken_num = 1
    ans_data = {}

    for i in range(city_num):
        number = data[i][2]
        if data[i][0] != ken_num:
            count = 1
            ken_num = data[i][0]
        chr = "{0:06d}".format(ken_num) + "{0:06d}".format(count)
        ans_data.update({number:chr})
        count += 1

    for i in range(city_num):
        print(ans_data[i])


if __name__ == '__main__':
    ken_num, city_num = list(map(int, input().split()))
    data = []
    for i in range(city_num):
        element = list(map(int, input().split()))
        element.append(i)
        data.append(element)

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

    count = 1
    ken_num = 1
    ans_data = {}

    for i in range(city_num):
        number = data[i][2]
        if data[i][0] != ken_num:
            count = 1
            ken_num = data[i][0]
        chr = "{0:06d}".format(ken_num) + "{0:06d}".format(count)
        ans_data.update({number:chr})
        count += 1

    for i in range(city_num):
        print(ans_data[i])

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):
N, M = map(int, input().split())
l = []
for i in range(M):
  	l.append(list(map(int, input().split())))

def FillZero(num,f=6):
    s = ""
    s += (f - len(str(num))) * "0"
    s += str(num)
    return(s)

for i in range(M):
    l[i].append(i)

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

key0 = l[0][0]
key1 = 0
for i in range(M):
    if key0 == l[i][0]:
      	key1 += 1
        l[i][1] = key1
    else:
        key1 = 1
        l[i][1] = key1
        key0 += 1

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

for i in range(M):
    print(FillZero(l[i][0]) + FillZero(l[i][1]))

def FillZero(num,f=6):
    s = ""
    s += (f - len(str(num))) * "0"
    s += str(num)
    return(s)

for i in range(M):
    l[i].append(i)

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

key0 = l[0][0]
key1 = 0
for i in range(M):
    if key0 == l[i][0]:
        key1 += 1
        l[i][1] = key1
    else:
        key1 = 1
        l[i][1] = key1
        key0 += 1

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

for i in range(M):
    print(FillZero(l[i][0]) + FillZero(l[i][1]))

N, M = map(int, input().split())
l = []
for i in range(M):
  	l.append(list(map(int, input().split())))

def FillZero(num,f=6):
    s = ""
    s += (f - len(str(num))) * "0"
    s += str(num)
    return(s)

for i in range(M):
    l[i].append(i)

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

key0 = l[0][0]
key1 = 0
for i in range(M):
    if key0 == l[i][0]:
        key1 += 1
        l[i][1] = key1
    else:
        key1 = 1
        l[i][1] = key1
        key0 = l[i][0]

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

for i in range(M):
    print(FillZero(l[i][0]) + FillZero(l[i][1]))

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):
a,b = map(int,input().split())

c = [[] for i in range(a)]
for _ in range(b):
  f,g = map(int,input().split())
  c[f - 1].append(g)

d = c.copy()


for i in range(a):
    if c[i] != []:
        c[i].sort()

#print(c)
h = []
x =''
y = ''
for j in range(a):                    
    x = str(j + 1)
    while len(x) <= 5:
        x = '0' + x
    if c[j] != []:
        for k in range(len(c[j])):
            for l in range(len(c[j])):
                if c[j][k] == d[j][l]:
                    y = str(k + 1)
                    while len(y) <= 5:
                        y = '0' + y
                    print(x+y)


from collections import deque

a,b = map(int,input().split())

c = [[] for i in range(a)]
d = [deque() for i in range(a)]
z = []
for _ in range(b):
  f,g = map(int,input().split())
  c[f - 1].append(g)
  d[f - 1].append(0)
  for num in range(len(c[f-1])):
      if c[f - 1][num] >= g:
          d[f-1][num] += 1
  z.append([f,g])

print(c,d)
x =''
y = ''
for j in range(b):                    
    x = str(z[j][0])
    x = '0' * (6 - len(x)) + x
    y = str(d[z[j][0] - 1].popleft())
    y = '0' * (6 - len(y)) + y
    print(x + y)

import bisect
a,b = map(int,input().split())

c = [[] for i in range(a)]
z = []
for _ in range(b):
  f,g = map(int,input().split())
  c[f - 1].append(g)
  z.append([f,g])

for i in range(a):
    if c[i] != []:
        c[i].sort()

x =''
y = ''
for j in range(b):                    
    x = str(z[j][0])
    x = '0' * (6 - len(x)) + x
    y = str(bisect.bisect(c[z[j][0] - 1], z[j][1]))
    y = '0' * (6 - len(y)) + y
    print(x + y)

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):
import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)




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

PREFECTURE = defaultdict(list)
for p, y in PY:
    PREFECTURE[p].append(y)

print(PREFECTURE)

for i in PREFECTURE.keys():
    ys = sorted(PREFECTURE[i])
    y_to_i = {y: i+1 for i, y in enumerate(ys)}
    PREFECTURE[i] = y_to_i

for p, y in PY:
    print('{:06}{:06}'.format(p, PREFECTURE[p][y]))


import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)




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

PREFECTURE = defaultdict(list)
for p, y in PY:
    PREFECTURE[p].append(y)

for i in PREFECTURE.keys():
    ys = sorted(PREFECTURE[i])
    y_to_i = {y: i+1 for i, y in enumerate(ys)}
    PREFECTURE[i] = y_to_i

for p, y in PY:
    print('{:06}{:06}'.format(p, PREFECTURE[p][y]))


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 bisect import bisect_left
import heapq

def solve():
    N,M = map(int, input().split())
    cities_in_prefecture = [[] for _ in range(N)]
    city_ids = []
    for _ in range(M):
        P,Y = map(int, input().split())
        x = bisect_left(cities_in_prefecture[P-1], Y)
        heapq.heappush(cities_in_prefecture[P-1], Y)
        print('{0:06d}{1:06d}'.format(P, x+1), flush=True)
        
solve()

from bisect import bisect_left

def solve():
    N,M = map(int, input().split())
    cities_in_prefecture = [[] for _ in range(N)]
    city_ids = []
    PYs = []
    for _ in range(M):
        P,Y = map(int, input().split())
        PYs.append((P,Y))
        cities_in_prefecture[P-1].append(Y)
    for p in range(N): cities_in_prefecture[p].sort()
    for P, Y in PYs:
        x = bisect_left(cities_in_prefecture[P-1], Y)
        
        print('{0:06d}{1:06d}'.format(P, x+1), flush=True)
        
solve()

Verdicts: Wrong Answer

Accepted