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 = list(map(int, input().split()))
data = []
for i in range(m):
    data.append([i + 1] + list(map(int, input().split())))
data = sorted(data, key = lambda x: (x[1], x[2]))

ans = [[0,0,0] for i in range(m)]

pre = data[0][1]
num = 1
for i in range(m):
    if pre != data[i][1]:
        num = 1
        ans[i][0] = data[i][1]
        ans[i][1] = num
    else:
        ans[i][0] = data[i][1]
        ans[i][1] = num
        num += 1
    pre = data[i][1]
    ans[i][2] = data[i][0]
ans = sorted(ans, key = lambda x:x[2])
for i in range(m):
    print(ans[i][0], ans[i][1])
    print("{:0=6}{:0=6}".format(ans[i][0],ans[i][1]))


n, m = list(map(int, input().split()))
data = []
for i in range(m):
    data.append([i + 1] + list(map(int, input().split())))
data = sorted(data, key = lambda x: (x[1], x[2]))
print(data)
ans = [[0,0,0,0,0,0], [0,0,0,0,0,0] for i in range(m)]
print(ans)
for i in range(m):


n, m = list(map(int, input().split()))
data = []
for i in range(m):
    data.append([i + 1] + list(map(int, input().split())))
    #data[0::] = cityNumber,
    
    #data[::0] = year
data = sorted(data, key = lambda x: (x[1], x[2]))
#prefect => year
ans = [[0,0,0] for i in range(m)]
#ans[::0] = city Number

#ans[:0:] = ID

pre = data[0][1]
num = 0
for i in range(m):
    ans[i][0] = data[i][1] 
    ans[i][2] = data[i][0] #cityNumber
    if pre == data[i][1]:
        num += 1
    else:
        num = 1
    ans[i][1] = num
    pre = data[i][1]
ans = sorted(ans, key = lambda x:x[2])
for i in range(m):
    print("{:0=6}{:0=6}".format(ans[i][0],ans[i][1]))


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

PY = []
PYd = {i:[] for i in range(1, N+1)}

for i in range(M):
    x, y = [int(i) for i in input().split()]
    PYd[x].append(y)
    PY.append((x,y))
    
for i in PYd.keys():
    PYd[i].sort()
    
for p,y in PY:
    str_p = str(p).zfill(6)
    index = str(bisect.bisect(PYd[p], y)).zfill(6)
    print(str_p+index)

import bisect

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

PY = []
PYd = {i:[] for i in range(1, N+1)}

for i in range(M):
    x, y = [int(i) for i in input().split()]
    PYd[x].append(y)
    PY.append((x,y))
    
for i in PYd.keys():
    PYd[i].sort()
    
for p,y in PY:
    str_p = str(p).zfill(6)
    index = str(bisect.bisect(PYd[p], y)).zfill(6)
    print(str_p+index)

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


class City:
    
    def __init__(self,id,y):
        self.id = id
        self.year = y


def main():
    n,m = map(int,input().split())
    pre_lst = [[] for _ in range(n)]  
    city_tags = [0 for _ in range(m)] 

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

    for pre_num,pre in enumerate(pre_lst):
        if len(pre) <= 0:
            continue
        pre.sort(key = lambda x:x.year) 

        counter = 0 
        for city in pre:
            city_tags[city.id] = str(pre_num+1).zfill(6) + str(counter+1).zfill(6)
            counter += 1
    for tag in city_tags:
        print(tag)


if __name__ == '__main__':
    main()




class City:
    
    def __init__(self,id,y):
        self.id = id
        self.year = y


def main():
    n,m = map(int,input().split())
    pre_lst = [[] for _ in range(n)]  
    city_tags = [0 for _ in range(m)] 

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

    for pre_num,pre in enumerate(pre_lst):
        if len(pre) <= 0:
            continue
        pre.sort(key = lambda x:x.year) 

        counter = 0 
        for city in pre:
            city_tags[city.id] = str(pre_num+1).zfill(6) + str(counter+1).zfill(6)
            counter += 1
    for tag in city_tags:
        print(tag)


if __name__ == '__main__':
    main()


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

_number = []
P = []
Y = []
yp = [[] for i in range(N+1)]
_yp = []

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

# print(yp)

_l_yp = len(yp)

for i in range(_l_yp):
    yp[i].sort()


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

for i in range(_l_yp):
    nga_yp = len(yp[i])

    for j in range(nga_yp):
       print(i, j)
       print(yp[i][j][1])
       ans_yp[yp[i][j][1]].append(i)
       ans_yp[yp[i][j][1]].append(j+1)


__len = len(ans_yp)

for i in range(__len):
    buff = ''
    for d in range(2):
        ans = ''
        for j in range((6-len(str(ans_yp[i][d])))):
            ans += '0'

        buff += ans + str(ans_yp[i][d])

    print(buff)


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

_number = []
P = []
Y = []
yp = [[] for i in range(N+1)]
_yp = []

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

# print(yp)

_l_yp = len(yp)

for i in range(_l_yp):
    yp[i].sort()


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

for i in range(_l_yp):
    nga_yp = len(yp[i])

    for j in range(nga_yp):
    #    print(i, j)
    #    print(yp[i][j][1])
       ans_yp[yp[i][j][1]].append(i)
       ans_yp[yp[i][j][1]].append(j+1)


__len = len(ans_yp)

for i in range(__len):
    buff = ''
    for d in range(2):
        ans = ''
        for j in range((6-len(str(ans_yp[i][d])))):
            ans += '0'

        buff += ans + str(ans_yp[i][d])

    print(buff)


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())) for i in range(M)]

PYI=[PY[i]+[i] for i in range(M)]

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

Nu=[1]*(N+1)
ANS=[None]*M

for p,y,i in PYI:
    ANS[i]=(p,Nu[p])
    Nu[p]+=1

print(ANS)

def numb(x,y):
    x=str(x)
    y=str(y)
    l=len(x)
    m=len(y)

    return (6-l)*"0"+x+(6-m)*"0"+y

for a,b in ANS:
    print(numb(a,b))

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

PYI=[PY[i]+[i] for i in range(M)]

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

Nu=[1]*(N+1)
ANS=[None]*M

for p,y,i in PYI:
    ANS[i]=(p,Nu[p])
    Nu[p]+=1

#print(ANS)

def numb(x,y):
    x=str(x)
    y=str(y)
    l=len(x)
    m=len(y)

    return (6-l)*"0"+x+(6-m)*"0"+y

for a,b in ANS:
    print(numb(a,b))

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())
P=[[x] for x in range(N)]

for _ in range(M):
    p,y=map(int,input().split())
    P[p-1].append(y)
code=[]
for i in range(N):
    temp=sorted(P[i][1:])
    for j in range(len(temp)):
        code.append(str(i+1).zfill(6)+str(j+1).zfill(6))

code.sort()
for c in code:
    print(c)

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

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

ID=[0 for _ in range(M)]
for j in range(N):
    Pre[j].sort()
    for k in range(len(Pre[j])):
        ID[Pre[j][k][1]-1]=str(j+1).zfill(6)+str(k+1).zfill(6)

for d in ID:
    print(d)

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 -*-
a = int(input().split()[1])
c = [int(input().split()[0]) for i in range(a)]
import collections
c = collections.Counter(c)
for k,v in sorted(c.items()):
    for i in range(v):
        j = i+1
        print(f'{k:08}{j:08}')


# -*- coding: utf-8 -*-
a = int(input().split()[1])
c = [int(input().split()[0]) for i in range(a)]
import collections
c = collections.Counter(c)
for k,v in sorted(c.items()):
    for i in range(v):
        print('{k:08}{i:08}'.format(k=k,i=i+1))


# -*- coding: utf-8 -*-
n,m = list(map(int,input().split()))
d = [[i,tuple(map(int,input().split()))] for i,_ in enumerate(range(m))]
#print(d)

d.sort(key=lambda x:x[1][1])
p_cnt = [0] * (n+1)
ret_tuples = [0] * m 

for i,v in enumerate(d):
    p = v[1][0]
    x = p_cnt[p]+1
    p_cnt[p]+=1
    ret_tuples[i] = (v[0],"{:0=6}{:0=6}".format(p,x))

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

Verdicts: 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):
(n, m) = map(int, input().split())

cities = {}
for i in range(m):
    (i, j) = map(int, input().split())
    if not i in cities:
        cities[i] = []
    cities[i].append(j)
print(cities)
codes = []
for k, v in cities.items():
    v.sort()
    for i, j in enumerate(v):
        codes.append("{0:06d}".format(k) + "{0:06d}".format(i + 1))
for code in codes:
    print(code)

(n, m) = map(int, input().split())
cities = {}
for i in range(m):
    (pref, year) = map(int, input().split())
    if not pref in cities.keys():
        cities[pref] = []
    cities[pref].append((i, year))


def get_id(pref, index):
    return "{}{}".format(str(pref).zfill(6), str(index).zfill(6))


ids = []
for key, values in cities.items():
    values.sort(key=lambda x: x[1])
    for i, value in enumerate(values):
        ids.append((value[0], get_id(key, i + 1)))
ids.sort(key=lambda x: x[0])
for id in ids:
    print(id[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())
P = [[] for i in range(N)]
for i in range(M):
    p, y = map(int, input().split())
    P[p-1].append(len(P[p-1])+1)
for i in range(len(P)):
    for j in range(len(P[i])):
        print("{:0=6}{:0=6}".format(i+1, P[i][j]))


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

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

city = 0
for i in range(M):
    if data[i][0] != city:
        city = data[i][0]
        num = 1
    data[i][1] = num
    num += 1
    

data.sort(key=lambda x:x[2])
for d in data:
    print("{:0=6}{:0=6}".format(d[0],d[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())
index = 0
listForL = []
listForL2 = []
while index < m:
    p, y = map(int, input().split())
    listForL.append([p, y])
    listForL2.append([p, y])
    index+=1

listForL2.sort()
print(listForL2)
listForId=[]
index2 =0
count = 0
before=0
while index2 < len(listForL2):
    if before!=listForL2[index2][0]:
        count=1
        before = listForL2[index2][0]
    else:
        count+=1
    mojiR=str(listForL2[index2][0])
    mojiL=str(count)
    index3=0
    while index3 < 6:
        if len(mojiR)< 6:
            mojiR="0"+mojiR
        elif len(mojiR)==6:
            break
        index3+=1
    index4=0
    while index4 < 6:
        if len(mojiL)< 6:
            mojiL="0"+mojiL
        elif len(mojiL)==6:
            break
        index4+=1
    index2+=1
    listForId.append(mojiR+mojiL)

index5=0
while index5 < len(listForL):
    targetI = listForL2.index(listForL[index5])
    print(listForId[targetI])
    index5+=1
    

n, m = map(int, input().split())
index = 0
listForL = []
listForL2 = []
while index < m:
    p, y = map(int, input().split())
    listForL.append([p, y])
    listForL2.append([p, y, index])
    index+=1

listForL2.sort()
listForAns=[0]*m
index2 =0
count = 0
before=0
while index2 < len(listForL2):
    if before!=listForL2[index2][0]:
        count=1
        before = listForL2[index2][0]
    else:
        count+=1
    mojiR=str(listForL2[index2][0])
    mojiL=str(count)
    index3=0
    if len(mojiR)==1:
        mojiR="00000"+mojiR
    elif len(mojiR)==2:
        mojiR = "0000"+mojiR
    elif len(mojiR)==3:
        mojiR = "000"+mojiR
    elif len(mojiR)==4:
        mojiR = "00"+mojiR
    elif len(mojiR)==5:
        mojiR = "0"+mojiR
    if len(mojiL) == 1:
        mojiL = "00000"+mojiL
    elif len(mojiL) == 2:
        mojiL = "0000"+mojiL
    elif len(mojiL) == 3:
        mojiL = "000"+mojiL
    elif len(mojiL) == 4:
        mojiL = "00"+mojiL
    elif len(mojiL) == 5:
        mojiL = "0"+mojiL
    listForAns[listForL2[index2][2]]=mojiR+mojiL
    index2+=1

for ans in listForAns:
    print(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 = map(int, input().split())
cs = []
ps = {}
for _ in range(m):
  p, y = map(int, input().split())
  cs.appenyd([y, p])
css = sorted(cs)
for c in css:
  if c[1] in ps:
    ps[c[1]].append(c[0])
  else:
    ps[c[1]] = [c[0]]
[print('{:06}{:06}'.format(c[1], ps[c[1]].index(c[0])+1))for c in cs]

 
  
  


n, m = map(int, input().split())
cs = []
cd = {}
ps = {}
for _ in range(m):
  p, y = map(int, input().split())
  cs.append([p, y])
  if p in ps:
    ps[p].append(y)
  else:
    ps[p] = [y]
    
for p in ps:
  v = sorted(ps[p])
  for i, y in enumerate(v):
    cd[y] = i + 1
[print('{:06}{:06}'.format(c[0], cd[c[1]])) for c in cs]

 
  
  


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())
PY=[]
for i in range(M):
    PY.append(list(map(int,input().split()))+[i+1])
    PY.sort(key=lambda x:(x[0],x[1]))
print(PY)
id=[]
l=[]
while len(PY)>0:
    p=PY[0][0]
    print(p)
    i=0
    print(i)
    while PY[i][0]==p:
        i+=1
        id.append('0'*(6-len(str(p)))+str(p)+'0'*(6-len(str(i)))+str(i))
        l.append(PY[i-1][2])
        print(i)
        if i+1>len(PY):
            break
    del PY[:i]
    print(PY)
    print(l)
    print(id)
for i in range(1,M+1):
    print(id[l.index(i)])

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])
c={}
for i in range(M):
    p=sort_PY[i][0]
    if(p in c):
        c[p]+=1
    else:
        c[p]=1
    sort_PY[i][2]=c[p]
for p,y,z in PY:
    print(str(p).zfill(6)+str(z).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):
import math
import sys
from itertools import accumulate
from functools import reduce
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007



if __name__ == "__main__":
    N, M = map(int, sys.stdin.readline().split())
    L = [list(map(int,list(sys.stdin.readline().split()))) for i in range(M)]
    sL = sorted(L, key=lambda x : x[0])

    d = {}
    for l in sL:
        if l[0] not in d:
            d[l[0]] = [l[1]]
        else:
            d[l[0]].append(l[1])

    for v in d.values():
        v.sort()

    for l in L:
        key = l[0]
        val = l[1]
        num = d[key].index(val) + 1
        print("{}{}".format(str(key).zfill(6),str(num).zfill(6)))


import math
import sys
from itertools import accumulate
from functools import reduce
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007



if __name__ == "__main__":
    from time import time
    start = time()
    N, M = map(int, sys.stdin.readline().split())
    P = [0] * (N + 1)
    C = [0] * M

    for m in range(M):
        p, y = map(int, input().split())
        C[m] = [m, p, y, 0]
    C.sort(key=lambda x :x[2])

    for c in C:
        P[c[1]] += 1
        c[3] = P[c[1]]
    C.sort(key=lambda x :x[3])

    for c in C:
        print("{}{}".format(str(c[1]).zfill(6), str(c[3]).zfill(6)))

import sys

if __name__ == "__main__":
    N, M = map(int, sys.stdin.readline().split())
    P = [0] * (N + 1)
    C = [0] * M

    for m in range(M):
        p, y = map(int, input().split())
        C[m] = [m, p, y, 0]
    C.sort(key=lambda x :x[2])

    for c in C:
        P[c[1]] += 1
        c[3] = P[c[1]]
    C.sort(key=lambda x :x[0])

    for c in C:
        print("{}{}".format(str(c[1]).zfill(6), str(c[3]).zfill(6)))

Verdicts: Time Limit Exceeded

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(i) for i in input().split()]
pyList = [[int(i) for i in input().split()] for _ in range(M)]
pyList = sorted(pyList, key=lambda py: py[1])

cityMap = {}
for py in pyList:
    if py[0] in cityMap.keys():
        cityMap[py[0]] += 1
    else:
        cityMap[py[0]] = 1

    prefCd = str(py[0]).zfill(6)
    cityCd = str(cityMap[py[0]]).zfill(3)
    print(prefCd + cityCd)


N, M = [int(i) for i in input().split()]
pyList = [[int(i) for i in input().split()] for _ in range(M)]
pyList = sorted(pyList, key=lambda py: py[1])

cityMap = {}
for py in pyList:
    if py[0] in cityMap.keys():
        cityMap[py[0]] += 1
    else:
        cityMap[py[0]] = 1

    prefCd = str(py[0]).zfill(6)
    cityCd = str(cityMap[py[0]]).zfill(6)
    print(prefCd + cityCd)


N, M = [int(i) for i in input().split()]
idx = 0
ipyList = []
for i in range(M):
    idx += 1
    ipy = [int(i) for i in input().split()]
    ipy.insert(0, idx)
    ipyList.append(ipy)

ipyList = sorted(ipyList, key=lambda ipy: ipy[2])
cityMap = {}
for ipy in ipyList:
    if ipy[1] in cityMap.keys():
        cityMap[ipy[1]] += 1
    else:
        cityMap[ipy[1]] = 1
    ipy[2] = cityMap[ipy[1]]

ipyList = sorted(ipyList, key=lambda ipy: ipy[0])
for ipy in ipyList:
    print(str(ipy[1]).zfill(6) + str(ipy[2]).zfill(6))

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
input = sys.stdin.readline
N, M = map(int,input().split())
P = []
for i in range(M) :
    p, y = map(int,input().split())
    P.append([p, y, i])

P.sort(key = lambda x: (x[0],x[1]))
print(P)

ans = [0 for i in range(M)]
count = 1

for i in range(M) :
    num = P[i][2]
    if i > 0 :
        if P[i][0] == P[i-1][0] :
            count += 1
        else :
            count = 1
    ans[num] = str(P[i][0]).zfill(6) + str(count).zfill(6)

for t in ans :
    print(t)


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

P.sort(key = lambda x: (x[0],x[1]))

ans = [0 for i in range(M)]
count = 1

for i in range(M) :
    num = P[i][2]
    if i > 0 :
        if P[i][0] == P[i-1][0] :
            count += 1
        else :
            count = 1
    ans[num] = str(P[i][0]).zfill(6) + str(count).zfill(6)

for t in ans :
    print(t)


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())
l = [dict() for i in range(N)]
ilist = [list(map(int, input().split())) for i in range(M)]
for i, y in ilist:
    l[i - 1][y] = 1
l = [dict(sorted(l[i].items())) for i in range(N)]
for i in range(N):
    for j, k in enumerate(l[i].keys()):
        l[i][k] = "{:06}{:06}".format(i + 1, j + 1)
for n, y in ilist:
    print(int(l[n - 1][y]))


N, M = map(int, input().split())
l = [dict() for i in range(N)]
ilist = [list(map(int, input().split())) for i in range(M)]
for i, y in ilist:
    l[i - 1][y] = 1
l = [dict(sorted(l[i].items())) for i in range(N)]
for i in range(N):
    for j, k in enumerate(l[i].keys()):
        l[i][k] = "{:06}{:06}".format(i + 1, j + 1)
for n, y in ilist[::-1]:
    print(l[n - 1][y])


N, M = map(int, input().split())
l=[list(map(int,input().split()))+[i] for i in range(M)]
l=sorted(l,key=lambda x:x[0]*1000000000+x[1])
cnt=0
for i,x in enumerate(l):
    if x[0]!=l[i-1][0]:cnt=0
    cnt+=1
    l[i][1]=cnt
for x in sorted(l,key=lambda x:x[2]):
    print("{:06}{:06}".format(x[0],x[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):
# -*- coding: utf-8 -*-
from collections import defaultdict


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

p, y = [], []
dic = {}
for _ in range(m):
    pi, yi = map(int, input().split())
    dic[yi] = pi

d = defaultdict(int)

for _, pi in sorted(dic.items()):
    d[pi] += 1
    print('{:0>6}{:0>6}'.format(pi, d[pi]))


# -*- coding: utf-8 -*-
from collections import defaultdict


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

y = []
dic = {}
for _ in range(m):
    pi, yi = map(int, input().split())
    y.append(yi)
    dic[yi] = pi

d = defaultdict(int)
id_dict = {}

for yi, pi in sorted(dic.items()):
    d[pi] += 1
    id_dict[yi] = '{:0>6}{:0>6}'.format(pi, d[pi])

for yi in y:
    print(id_dict[yi])


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())
lst = [None]*M
pre_lst = []
for i in range(M):
  lst[i] = list(map(int,input().split()))
  lst[i].append(i)
for k in range(M):
  lst[k][0] = str(lst[k][0])
  lst[k][0] = lst[k][0].zfill(6)
lst.sort(key = lambda x:x[0])



N,M = map(int,input().split())
lst = [None]*(M+1)
pre_count = 1
pre_current = ''
lst[0] = ['000000',0,0]
for i in range(1,M+1):
  lst[i] = list(map(int,input().split()))
  lst[i].append(i)
for k in range(1,M+1):
  lst[k][0] = str(lst[k][0])
  lst[k][0] = lst[k][0].zfill(6)
lst.sort(key = lambda x:x[1])
lst.sort(key = lambda x:x[0])
for j in range(1,M+1):
  if lst[j][0] == lst[j-1][0]:
    pre_count += 1
    lst[j].append(str(pre_count).zfill(6))
  else:
    pre_count = 1
    lst[j].append(str(pre_count).zfill(6))
lst.sort(key = lambda x:x[2])
for x in range(1,M+1):
  print(lst[x][0]+lst[x][3])

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):
I=lambda:list(map(int,input().split()));n,m=I();l=[I()+[i]for i in range(M)];c=[0]*-~N;a=[0]*M
for p,y,i in sorted(l,key=lambda x:x[1]):c[p]+=1;a[i]='%06d'%p+'%06d'%c[p]
for t in a:print(t)

I=lambda:list(map(int,input().split()[::-1]))
m,n=I()
c=[0]*-~n
a=[0]*m
for y,p,i in sorted(I()+[i]for i in range(m)):
  c[p]+=1
  a[i]='%06d%06d'%(p,c[p])
print('\n'.join(a))

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 = [int(x) for x in input().split()]

P, Y = [], []

Px = [0] * (N+1)
for _ in range(M):
    p, y = [int(x) for x in input().split()]
    Px[p]+=1
    print("%06d%06d" % (p, Px[p]))



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

PY = []

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

PY.sort(key=lambda x:x[2])
result = [None]*M
for i, p, y in PY:
    Px[p]+=1
    result[i] = "%06d%06d" % (p, Px[p])

for x in result:
    print(x)

# 2 3
# 1 32
# 2 63
# 1 12

# 000001000002
# 000002000001
# 000001000001


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())
city = [[] for i in range(n)]
def f(s):
    s = str(s)
    t  = 6 - len(s)
    s = "0"*t + s
    return s
for i in range(m):
    ken,year = map(int,input().split())
    city[ken-1].append(year)
for i in range(n):
    city[i].sort()
    for j in range(len(city[i])):
        ans = f(i+1) + f(j+1)
        print(ans)

n,m = map(int,input().split())
city = [[] for i in range(n)]
def f(s):
    s = str(s)
    t  = 6 - len(s)
    s = "0"*t + s
    return s
for i in range(m):
    ken,year = map(int,input().split())
    city[ken-1].append([year,i])
newcity = []
for i in range(n):
    city[i].sort()
    for j in range(len(city[i])):
        newcity.append([city[i][j][1],f(i+1) + f(j+1)])
newcity.sort()
for i in range(m):
    print(newcity[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())
s = []
r = []
for n in range(n):
    s.append(list(map(int,input().split())))
for i in range(n):
    rank = 1
    for j in range(n):
        if s[i][0] == s[j][0] and s[i][1] > s[j][1]:
            rank += 1
    prefString = str(s[i][0])
    rankString = str(rank)
    Number1st = "0" * (6-len(prefString)) + prefString 
    Number2nd = "0" * (6-len(rankString)) + rankString
    print(Number1st+Number2nd)

n,m=map(int,input().split())
s = []
for i in range(m):
    pref,year=map(int,input().split())
    s.append([pref,year,i])
s.sort()
rank = 1
for i in range(m):
    if s[i][0] != s[i-1][0]:
        rank = 1
    s[i][1]=rank
    rank += 1
s.sort(key=lambda x: x[2]) 
for i in range(m):
    print("0"*(6-len(str(s[i][0])))+str(s[i][0])+"0"*(6-len(str(s[i][1])))+str(s[i][1]))

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 sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

L = sorted(L)

reset = 0
count = 0
for i in range(M):
    if L[i][0] != reset:
        reset = L[i][0]
        count = 1
    else:
        count += 1
    
    ans = str(reset).zfill(6) + str(count).zfill(6)
    print(ans)

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

L = sorted(L)

reset = 0
count = 0
ans = []
for i in range(M):
    if L[i][0] != reset:
        reset = L[i][0]
        count = 1
    else:
        count += 1
    
    ans.append([L[i][2], str(reset).zfill(6) + str(count).zfill(6)])

ans = sorted(ans)

for i in range(M):
    print(ans[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):
# coding:utf-8

import sys
from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, m = LI()
YP = [[y, p] for p, y in (LI() for _ in range(m))]

YP.sort()

P = defaultdict(int)
for y, p in YP:
    P[p] += 1
    l1, l2 = len(str(p)), len(str(P[p]))
    id = (6 - l1) * '0' + str(p) + (6 - l2) * '0' + str(P[p])
    print(id)


# coding:utf-8

import sys
from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, m = LI()
YP = [[y, p] for p, y in (LI() for _ in range(m))]

YP2 = sorted(YP)

P = defaultdict(int)
ans = {}
for y, p in YP2:
    P[p] += 1
    l1, l2 = len(str(p)), len(str(P[p]))
    id = '{:06d}{:06d}'.format(p, P[p])
    ans[y] = id

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

PY.sort()
print(PY)

pnow = PY[0][0]
c = 1

ans = [-1 for i in range(M)]

for i in range(M):
    if pnow != PY[i][0]:
        c = 1
        pnow = PY[i][0]
    ans[PY[i][2]] = str(PY[i][0]).zfill(6) + str(c).zfill(6)
    c += 1

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


import bisect
N,M = map(int,input().split())
PtoY = [[] for n in range(N)]
check = []
for m in range(M):
    P,Y = map(int,input().split())
    PtoY[P-1].append(Y)
    check.append([P,Y])
print(check)
for n in range(N):
    PtoY[n].sort()
print(PtoY)
for m in range(M):
    p,y = check[m][0],check[m][1]
    a = bisect.bisect_left(PtoY[p-1],y)+1
    string = str(p).zfill(6) + str(a).zfill(6)
    print(string)


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

PY.sort()

pnow = PY[0][0]
c = 1

ans = [-1 for i in range(M)]

for i in range(M):
    if pnow != PY[i][0]:
        c = 1
        pnow = PY[i][0]
    ans[PY[i][2]] = str(PY[i][0]).zfill(6) + str(c).zfill(6)
    c += 1

print('\n'.join(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())
shi_lst = [list(map(int,input().split())) for i in range(M)]
shi_sorted = sorted(shi_lst)
#print(shi_lst)


tmp = shi_sorted[0][0] 
count = 0
for i in range(M):
  count += 1
  if tmp != shi_sorted[i][0]:
    count = 1
    tmp = shi_sorted[i][0]
#  ans.append( ("%06d"%tmp) + ("%06d"%count))
  print( ("%06d"%tmp) + ("%06d"%count))

#print(ans)

N,M = map(int,input().split())
shi_lst = [list(map(int,input().split())) for i in range(M)]
shi_sorted = sorted(shi_lst)
#print(shi_lst)

ans = {}
tmp = shi_sorted[0][0] 
count = 0
for i in range(M):
  count += 1
  if tmp != shi_sorted[i][0]:
    count = 1
    tmp = shi_sorted[i][0]
  ans[str(shi_sorted[i][1])] = ("%06d"%tmp) + ("%06d"%count) 
#  ans.append( ("%06d"%tmp) + ("%06d"%count))
#  print( ("%06d"%tmp) + ("%06d"%count))

#print(ans)
for i in range(M):
  print(ans[str(shi_lst[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()) 
city_info = [] 
Pref_info = [[] for _ in range(N)] 
for i in range(M):
    P,Y = map(int,input().split())
    city_info.append([P-1, Y])
    Pref_info[P - 1].append(Y)
for i in Pref_info:
    i.sort()
    
print("city_info = " + str(city_info))
print("Pref_info = " + str(Pref_info))
for p,y in city_info:
    x = Pref_info[p].index(y) + 1 
    print("{0:0>6}".format(p+1) + "{0:0>6}".format(x))

N,M = map(int,input().split()) 
city_info = [] 
Pref_info = [[] for _ in range(N)] 
for i in range(M):
    P,Y = map(int,input().split())
    city_info.append([P-1, Y])
    Pref_info[P - 1].append(Y)
    
#print("city_info = " + str(city_info))
#print("Pref_info = " + str(Pref_info))
for p,y in city_info:
    x = Pref_info[p].index(y) + 1 
    print("{0:0>6}".format(p+1) + "{0:0>6}".format(x))

N,M = map(int,input().split()) 
Pref_info = [[] for _ in range(N)] 
for i in range(M):
    P,Y = map(int,input().split())
    Pref_info[P - 1].append([Y,i])
ans = [""]* M 
for i in range(N): 
    Pref_info[i].sort()
    for index, p in enumerate(Pref_info[i]):
        ans[p[1]] = "{0}{1}".format(str(i+1).zfill(6),str(index+1).zfill(6))
for i in ans:
    print(i)

Verdicts: Wrong Answer

Wrong Answer

Accepted