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

Submission attempts (in order):
N,M = map(int, input().split())
C = sorted([list(map(int, input().split())) for m in range(M)])
A = (N+1)*[0]
D = {}

for p,y in C:
  A[p]+=1
  D[y]="%06d%06d" % (p,A[p])

for p,y in C:
  print(D[y])

N,M = map(int,input().split())
C = sorted([list(map(int,input().split())) for m in range(M)])
n = 1

for m in range(M-1):
  if C[m][0]==C[m+1][0]:
    C[m]+=[n]
    n+=1
  else:
    C[m]+=[n]
    n = 1

C[-1]+=[n]

for m in range(M):
  print("{:06d}{:06d}".format(C[m][0],C[m][2]))

N,M = map(int, input().split())
P = [list(map(int, input().split())) for m in range(M)]
C = (N+1)*[0]
D = {}

for p,y in sorted(P,key=lambda x: x[1]):
  C[p]+= 1
  D[y]="%06d%06d" % (p,C[p])

for p,y in P:
  print(D[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):
N, M = map(int, input().split())
PYlist = [tuple(map(int, input().split())) for _ in range(M)]
from copy import deepcopy
PYsorted = sorted(deepcopy(PYlist), key=lambda x: x[0])


def zero_ume(num: int) -> str:
    return (6 - len(str(num))) * "0" + str(num)


now_ken = 0
ans_dict = {}
for p, y in PYsorted:
    if p != now_ken:
        now_num = 1
        now_ken = p
    else:
        now_num += 1
    ans_dict[(p, y)] = zero_ume(p) + zero_ume(now_num)

for py in PYlist:
    print(ans_dict[py])


N, M = map(int, input().split())
PYlist = [tuple(map(int, input().split())) for _ in range(M)]
from copy import deepcopy
PYsorted = sorted(deepcopy(PYlist), key=lambda x: x[1])
print(PYlist)
print(PYsorted)


def zero_ume(num: int) -> str:
    return (6 - len(str(num))) * "0" + str(num)


now_ken = 0
ans_dict = {}
for p, y in PYsorted:
    if p != now_ken:
        now_num = 1
        now_ken = p
    else:
        now_num += 1
    ans_dict[(p, y)] = zero_ume(p) + zero_ume(now_num)

for py in PYlist:
    print(ans_dict[py])


N, M = map(int, input().split())
PYlist = [tuple(map(int, input().split())) for _ in range(M)]
from copy import deepcopy
PYsorted = sorted(deepcopy(PYlist))


def zero_ume(num: int) -> str:
    return (6 - len(str(num))) * "0" + str(num)


now_ken = -1
ans_dict = {}
now_num = 0
for p, y in PYsorted:
    if p != now_ken:
        now_num = 0
        now_ken = p
    now_num += 1
    ans_dict[(p, y)] = zero_ume(p) + zero_ume(now_num)

for py in PYlist:
    print(ans_dict[py])


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())
city=[]
for i in range(m):
    a=i
    b,c=map(int,input().split())
    city.append([a,b,c])
city=sorted(city,key=lambda x:(x[1],x[2]))
print(city)
city[0].append(1)
for i in range(1,m):
    if city[i][1]!=city[i-1][1]:
        city[i].append(1)
    else:
        city[i].append(city[i-1][3]+1)
print(city)
for i in range(m):
    city[i].append(str(city[i][1]).zfill(6)+str(city[i][3]).zfill(6))
city=sorted(city,key=lambda x:(x[0]))
for i in range(m):
    print(city[i][4])

n,m=map(int,input().split())
city=[]
for i in range(m):
    a=i
    b,c=map(int,input().split())
    city.append([a,b,c])
city=sorted(city,key=lambda x:(x[1],x[2]))
judge=1
count=1
for i in range(m):
    if city[i][1]==judge:
        city[i].append(count)
        count+=1
    else:
        city[i].append(1)
        judge=city[i][1]
        count=2
for i in range(m):
    city[i].append(str(city[i][1]).zfill(6)+str(city[i][3]).zfill(6))
city=sorted(city,key=lambda x:x[0])
for i in range(m):
    print(city[i][4])

Verdicts: Wrong Answer

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

Submission attempts (in order):
import bisect

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

cities = {}
prefs = []

for i in range(1, M + 1):
  p, y = list(map(int, input().split()))
  
  pref = {"city": p, "year": y}
  prefs.append(pref)

  if p not in cities:
    cities[p] = [pref]
  else:
    cities[p].append(pref)
print(cities)
for city in cities.values():
  city.sort(key=lambda p: p['year'])
  for idx, pref in enumerate(city):
    pref['pref_id'] = str(idx + 1).zfill(6)

[print("%s%s" % (
  str(int(pref['city'])).zfill(6), 
  pref['pref_id'])) for pref in prefs]


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

cities = {}
prefs = []

for i in range(1, M + 1):
  p, y = list(map(int, input().split()))
  
  pref = {"city": p, "year": y}
  prefs.append(pref)

  if p not in cities:
    cities[p] = [pref]
  else:
    cities[p].append(pref)

for city in cities.values():
  city.sort(key=lambda p: p['year'])
  for idx, pref in enumerate(city):
    pref['pref_id'] = str(idx + 1).zfill(6)

[print("%s%s" % (
  str(int(pref['city'])).zfill(6), 
  pref['pref_id'])) for pref in prefs]


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())
data=[list(map(int,input().split())) for i in range(M)]
data=sorted(data, key=lambda x: x[1])
prepri=-1
count=0
printdata=[]
for i in data:
    if prepri!=i[0]:
        prepri=i[0]
        count=1
    else:
        count+=1
    printdata.append("0"*(6 - len(str(prepri))) + str(prepri) + "0"*(6 - len(str(count))) + str(count) )
printdata.reverse()
for i in printdata:
    print(i)


N,M=map(int,input().split())
data=[list(map(int,input().split())) for i in range(M)]
data=sorted(data, key=lambda x: x[1])
prepri=-1
count=0
printdata=[]
for i in data:
    if prepri!=i[0]:
        prepri=i[0]
        count=1
    else:
        count+=1
    printdata.append("0"*(6 - len(str(prepri))) + str(prepri) + "0"*(6 - len(str(count))) + str(count) )
for i in printdata:
    print(i)


N,M=map(int,input().split())
data=[list(map(int,input().split()+[i])) for i in range(M)]
data=sorted(data,key=lambda x:x[1])
data=sorted(data,key=lambda x:x[0])
preP=None
count=None
printdata=[]
for i in data:
    if preP==i[0]:
        count+=1
    else:
        preP=i[0]
        count=1
    printdata.append(["0"*(6-len(str(preP)))+str(preP)+"0"*(6-len(str(count)))+str(count),i[2]])
printdata=sorted(printdata,key=lambda x:x[1])
for i in printdata:
    print(i)


N,M=map(int,input().split())
data=[list(map(int,input().split()+[i])) for i in range(M)]
data=sorted(data,key=lambda x:x[1])
data=sorted(data,key=lambda x:x[0])
preP=None
count=None
printdata=[]
for i in data:
    if preP==i[0]:
        count+=1
    else:
        preP=i[0]
        count=1
    printdata.append(["0"*(6-len(str(preP)))+str(preP)+"0"*(6-len(str(count)))+str(count),i[2]])
printdata=sorted(printdata,key=lambda x:x[1])
for i in printdata:
    print(i[0])


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):
import numpy as np
n, m = map(int, input().split())
p = []
y = []
d = {}
for n_ in range(n):
    d[n_ + 1] = []
for i in range(m):
    p_, y_ = map(int, input().split())
    p.append(p_)
    y.append(y_)
    d[p_].append(y_)
for i in d.keys():
    d[i] = np.argsort(d[i]) + 1
id_list = []
for key in d:
    for n_ in d[key]:
        id_list.append('{:06d}{:06d}'.format(key, n_))
id_list = sorted(id_list)
for id_ in id_list:
    print(id_)


import numpy as np
from bisect import bisect_right
from time import time
start = time()
n, m = map(int, input().split())
p = []
y = []
d = {i + 1: [] for i in range(n)}
# n, m = 10**5, 10**5
# p = [10**5]*m

for i in range(m):
    p_, y_ = map(int, input().split())
    # p_, y_ = p[i], y[i]
    p.append(p_)
    y.append(y_)
    d[p_].append(y_)
for i in d.keys():
    d[i] = sorted(d[i])
for i in range(m):
    # print('{:06d}{:06d}'.format(p[i], d[p[i]].index(y[i]) + 1))
    print('{:06d}{:06d}'.format(p[i], bisect_right(d[p[i]], y[i])))

print(time() - start)


from bisect import bisect_right
n, m = map(int, input().split())
p = []
y = []
d = {i + 1: [] for i in range(n)}
for i in range(m):
    p_, y_ = map(int, input().split())
    p.append(p_)
    y.append(y_)
    d[p_].append(y_)
for i in d.keys():
    d[i] = sorted(d[i])
for i in range(m):
    print('{:06d}{:06d}'.format(p[i], bisect_right(d[p[i]], y[i])))


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):
somelists=[]

for i in range(m):
    a,b=map(int,input().split())
    somelists.append([i,a,b])

somelists.sort(key=lambda x:(x[1],x[2]))

prefs=1
numbers=0

for x in somelists:
    
    if x[1]==prefs:
        numbers+=1
        
        x.append(numbers)
    if x[1]!=prefs:
        prefs=x[1]
        numbers=1
        x.append(numbers)

somelists.sort(key=lambda x:x[0])
for _ in range(m):
    print(str(somelists[_][1]).zfill(6)+str(somelists[_][3]).zfill(6))


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

for i in range(m):
    a,b=map(int,input().split())
    somelists.append([i,a,b])

somelists.sort(key=lambda x:(x[1],x[2]))

prefs=1
numbers=0

for x in somelists:
    
    if x[1]==prefs:
        numbers+=1
        
        x.append(numbers)
    if x[1]!=prefs:
        prefs=x[1]
        numbers=1
        x.append(numbers)

somelists.sort(key=lambda x:x[0])
for _ in range(m):
    print(str(somelists[_][1]).zfill(6)+str(somelists[_][3]).zfill(6))


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

from scipy.stats import rankdata
N,M = list(map(int,input().split()))

PY = []
P_Y = [[] for i in range(N)]

p_count = [0 for i in range(N)]

for i in range(M):
    p,y = list(map(int,input().split()))
    P_Y[p-1].append([y,p_count[p-1]])
    p_count[p-1]+=1
    PY.append([p,y])
    
import numpy as np

P_Y_arg = []
for i in range(N):
    P_Y_arg.append(rankdata(np.array(P_Y[i])))

    
p_count = [0 for i in range(N)]

for i in range(M):
    ps = str(1000000+PY[i][0])
    ys = str(1000000+int(P_Y_arg[PY[i][0]-1][p_count[PY[i][0]-1]]))
    p_count[PY[i][0]-1]+=1
    print(ps[1:]+ys[1:])
    

from scipy.stats import rankdata
N,M = list(map(int,input().split()))

PY = []
P_Y = [[] for i in range(N)]

p_count = [0 for i in range(N)]

for i in range(M):
    p,y = list(map(int,input().split()))
    P_Y[p-1].append([y,p_count[p-1]])
    p_count[p-1]+=1
    PY.append([p,y])
    
import numpy as np

P_Y_arg = []
for i in range(N):
    P_Y_arg.append(rankdata(np.array(P_Y[i])))

    
p_count = [0 for i in range(N)]

for i in range(M):
    ps = str(1000000+PY[i][0])
    ys = str(1000000+P_Y_arg[PY[i][0]-1][p_count[PY[i][0]-1]] + 1)
    p_count[PY[i][0]-1]+=1
    print(ps[1:]+ys[1:])
    

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

PY = []
P_Y = [[] for i in range(N)]

p_count = [0 for i in range(N)]

for i in range(M):
    p,y = list(map(int,input().split()))
    P_Y[p-1].append(y)
    p_count[p-1]+=1
    PY.append([p,y])
    
import numpy as np

P_Y_arg = []
for i in range(N):
    P_Y_arg.append(np.array(P_Y[i]).argsort().argsort())

    
p_count = [0 for i in range(N)]

for i in range(M):
    ps = str(1000000+PY[i][0])
    ys = str(1000000+int(P_Y_arg[PY[i][0]-1][p_count[PY[i][0]-1]])+1)
    p_count[PY[i][0]-1]+=1
    print(ps[1:]+ys[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):
N, M = map(int, input().split())

inputs = []
sorted_inputs = {}

for _ in range(M):
    P, Y = map(int, input().split())
    inputs.append((P, Y))
    if sorted_inputs.get(P) is None:
        sorted_inputs[P] = [Y]
    else:
        sorted_inputs[P].append(Y)

for input in sorted_inputs:
    sorted_inputs[input].sort()

for input in inputs:
    first = str(input[0]).rjust(8, '0')
    latter = str(sorted_inputs[input[0]].index(input[1])+1).rjust(8, '0')
    print(first + latter)


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

sorted_inputs = {}
ans = [None]*M

for i in range(M):
    P, Y = map(int, input().split())
    if sorted_inputs.get(P) is None:
        sorted_inputs[P] = [(Y, i)]
    else:
        sorted_inputs[P].append((Y, i))

for pref, l in sorted_inputs.items():
    l.sort() 
    for j, (Y, i) in enumerate(l):
        first = str(pref).rjust(6, '0')
        latter = str(j+1).rjust(6, '0')
        ans[i] = first + latter

for item in ans:
    print(item)

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 = [0]*M
Y = [0]*M
for i in range(M):
    P[i],Y[i] =  map(int, input().split())
Yx = Y  
Y.sort()
count = [1]*(N+1)
ans = [0]*M
for i in range(M):
    j = Yx.index(Y[i])
    ans[j] = str(P[j]).zfill(6) + str(count[P[j]]).zfill(6)
    count[P[j]] = count[P[j]] +1

for i in range (M):
    print(ans[i])

import numpy as np
N , M = map(int, input().split())
P = [0]*M
Y = [0]*M
for i in range(M):
    P[i],Y[i] =  map(int, input().split())

Y_ = np.argsort(Y)
count = [1]*(N+1)
ans = [0]*M
for i in range(M):
    ans[Y_[i]] = str(P[Y_[i]]).zfill(6) + str(count[P[Y_[i]]]).zfill(6)
    count[P[Y_[i]]] = count[P[Y_[i]]] +1
 
for i in range (M):
    print(ans[i])

Verdicts: Wrong Answer

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

Submission attempts (in order):
N,M=[int(i) for i in input().split()]
PY=[[] for _ in range(N)]
py=[]

for i in range(M):
    p,y=[int(i) for i in input().split()]
    py.append((p,y))
    PY[p-1].append(y)

for i in range(N):
    PY[i].sort()

for i in range(M):
    p,y=py.pop(0)
    #print(PY[p].index(y))
    p_zero=6-len(str(p))
    y_zero=6-len(str(PY[p].index(y)))
    print("0"*p_zero + str(p) + "0"*y_zero + str(PY[p].index(y)+1))


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

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

ans=[None]*M
for j,py in enumerate(PY): 
    py.sort()
    for k,(y,i) in enumerate(py):
        print(k,y,i) 
        ans[i]=str(j+1).zfill(6) + str(k+1).zfill(6)

print(*ans,sep="\n")

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

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

ans=[None]*M
for j,py in enumerate(PY): 
    py.sort()
    for k,(y,i) in enumerate(py):
        ans[i]=str(j+1).zfill(6) + str(k+1).zfill(6)

print(*ans,sep="\n")

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):
import numpy as np
n,m = map(int, input().split())
count = [0]*n
py = []

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

li = sorted(py)
count = np.cumsum(count)

for i in range(m):
    num = li.index(py[i]) + 1
    pref = str(py[i][0])
    if py[i][0] == 1:
        print(pref.zfill(6) + str(num).zfill(6))
    else:
        print(pref.zfill(6) + str(num - count[i]).zfill(6))

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()
li = [[0]*2 for i in range(m)]
s = 0
t = 0
for p,y,i in py:
    
    if s != p:
        s = p
        t = 1
    else:
        t += 1
    li[i][0] = s
    li[i][1] = t
for i in range(m):
    print(str(li[i][0]).zfill(6) + str(li[i][1]).zfill(6))

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(i) for i in input().split(" ")]
ps = []
pc = [0 for i in range(0, n + 1)]

for i in range(0, m):
    ps.append([i] + [int(i) for i in input().split(" ")] + [""])

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

for i in range(0, m):
    pc[ps[i][1]] += 1
    ps[i][3] = str(ps[i][1]).zfill(6) + str(pc[ps[i][1]]).zfill(6)

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

for i in range(0, m):
    print(ps[i][3])

n, m = [int(i) for i in input().split(" ")]
ps = []
pc = [0 for i in range(0, n + 1)]

for i in range(0, m):
    ps.append([i] + [int(i) for i in input().split(" ")] + [""])

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

for i in range(0, m):
    pc[ps[i][1]] += 1
    ps[i][3] = str(ps[i][1]).zfill(6) + str(pc[ps[i][1]]).zfill(6)

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

for i in range(0, m):
    print(ps[i])

n, m = [int(i) for i in input().split(" ")]
ps = []
pc = [0 for i in range(0, n + 1)]

for i in range(0, m):
    ps.append([i] + [int(i) for i in input().split(" ")] + [""])

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

for i in range(0, m):
    pc[ps[i][1]] += 1
    ps[i][3] = str(ps[i][1]).zfill(6) + str(pc[ps[i][1]]).zfill(6)

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

for i in range(0, m):
    print(ps[i][3])

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
# Your code here!
from operator import itemgetter

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

l=[[-1]*3 for i in range(M)]

for i in range(M):
    p,y=map(int,input().split())
    l[i]=[i,10**10*p+y]

l.sort(key=itemgetter(1))

pre_n=l[0][1]//10**6
count=1
for i in range(M):
    n=l[i][1]//10**6
    if n==pre_n:
        l[i][1]=n*10**6+count
        count+=1
    else:
        pre_n=n
        count=1
        l[i][1]=n*10**6+count
l.sort()

for i in range(M):
    s=str(l[i][1])
    print("0"*(12-len(s))+s)
    
    

# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
from operator import itemgetter

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

l=[[-1]*3 for i in range(M)]

for i in range(M):
    p,y=map(int,input().split())
    l[i]=[i,10**10*p+y]

l.sort(key=itemgetter(1))

pre_n=l[0][1]//10**10
count=0
for i in range(M):
    n=int(l[i][1]//(10**10))
    print(n,pre_n)
    if n==pre_n:
        count+=1
        l[i][1]=n*10**6+count
        
    else:
        pre_n=n
        count=1
        l[i][1]=n*10**6+count
l.sort()

for i in range(M):
    s=str(l[i][1])
    print("0"*(12-len(s))+s)
    
    



# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
from operator import itemgetter

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

l=[[-1]*3 for i in range(M)]

for i in range(M):
    p,y=map(int,input().split())
    l[i]=[i,10**10*p+y]

l.sort(key=itemgetter(1))

pre_n=l[0][1]//10**10
count=0
for i in range(M):
    n=int(l[i][1]//(10**10))
    if n==pre_n:
        count+=1
        l[i][1]=n*10**6+count
        
    else:
        pre_n=n
        count=1
        l[i][1]=n*10**6+count
l.sort()

for i in range(M):
    s=str(l[i][1])
    print("0"*(12-len(s))+s)
    
    



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

class ID:
    def __init__(self,p,y,i):
        self.p = p
        self.y = y
        self.i = i
        self.IDed = False
        self.ID1 = None
        self.ID2 = None

    def ID(self):
        for i in range(1,6):
            if self.ID1 < 10**i:
                self.ID1 = "0"*(6-i) + str(self.ID1)
                break
        for i in range(1,6):
            if int(self.ID2) < 10**i:
                self.ID2 = "0"*(6-i) + str(self.ID2)
                break
        
        return self.ID1 + self.ID2

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

for p in range(N+1,1,-1):
    pref = []
    for i in range(0,M):
        if not cities[i].IDed:
            if cities[i].p == p:
                pref.append([cities[i].y, cities[i].i])
                cities[i].IDed = True
    pref.sort()
    count = 1
    for i,j in pref:
        cities[j].ID2 = count
        count = count + 1
        cities[j].ID1 = p

for i in range(0,M):
    print(cities[i].ID())


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

class ID:
    def __init__(self,p,y,i):
        self.p = p
        self.y = y
        self.i = i
        self.ID1 = None
        self.ID2 = None

    def ID(self):
        for i in range(1,7):
            if self.ID1 < 10**i:
                self.ID1 = "0"*(6-i) + str(self.ID1)
                break
        for i in range(1,7):
            if int(self.ID2) < 10**i:
                self.ID2 = "0"*(6-i) + str(self.ID2)
                break
        
        return self.ID1 + self.ID2

cities = []
for i in range(0,M):
    P,Y = map(int,input().split())
    cities.append(ID(P,Y,i))
cities.sort(key = lambda x: x.y)
counter = [-1]

for i in range(0,N):
    counter.append(1)

for c in cities:
    c.ID1 = c.p
    c.ID2 = counter[c.p]
    counter[c.p] = counter[c.p] + 1

cities.sort(key = lambda x: x.i)

for i in range(0,M):
    print(cities[i].ID())


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())
base = [[int(l) for l in input().split()] for i in range(M)]
sort_target = sorted(base)
 
  
print(sort_target)
prefecture_index = sort_target[0][0]
i=0
result = []
for target in sort_target:
  i = i + 1 if prefecture_index == target[0] else 1
  prefecture_index = target[0]
  result.append([base.index(target), "{:0=6}{:0=6}".format(target[0], i)])

sorted_result = sorted(result) 
for result in sorted_result:
  print(result[1])

N, M = map(int, input().split())
base = []
for i in range(M):
  (a, b) = map(int, input().split())
  base.append((a, b, i))
sorted_target = sorted(base) 

prefecture_index = sorted_target[0][0]

i=0
result = {}

for target in sorted_target:
  if prefecture_index == target[0]:
    i+=1
  else:
    prefecture_index = target[0]
    i = 1
  result[target[2]] = [prefecture_index, i]

for i in range(M):
  print("{:0=6}{:0=6}".format(result[i][0], result[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):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    A=[]
    for i in range(m):
        p,y=map(int,input().split())
        A.append((p,y,i))
    A.sort()
    cunt=0
    pre=0
    ans=[]
    for a in A:
        s1=str(a[0])
        if pre!=a[0]:
            cunt=1
            pre=a[0]
        s2=str(cunt)
        ans.append((i,s1.zfill(6)+s2.zfill(6)))
        cunt+=1
    ans.sort()
    for s in ans:
        print(s[1])

if __name__=='__main__':
    main()

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    A=[]
    for i in range(m):
        p,y=map(int,input().split())
        A.append((p,y))
    A.sort()
    print(A)
    cunt=0
    pre=0
    ans=[]
    for a in A:
        s1=str(a[0])
        if pre!=a[0]:
            cunt=1
            pre=a[0]
        s2=str(cunt)
        ans.append(s1.zfill(6)+s2.zfill(6))
        cunt+=1
    ans.sort()
    for s in ans:
        print(s)

if __name__=='__main__':
    main()

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    A=[]
    for i in range(m):
        p,y=map(int,input().split())
        A.append((p,y))
    A.sort()
    cunt=0
    pre=0
    ans=[]
    for a in A:
        s1=str(a[0])
        if pre!=a[0]:
            cunt=1
            pre=a[0]
        s2=str(cunt)
        ans.append(s1.zfill(6)+s2.zfill(6))
        cunt+=1
    ans.sort()
    for s in ans:
        print(s)

if __name__=='__main__':
    main()

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    A=[]
    for i in range(m):
        p,y=map(int,input().split())
        A.append((p,y,i))
    A.sort()
    cunt,pre,ans=0,0,[]
    for a in A:
        s1=str(a[0])
        if pre!=a[0]:
            cunt=1
            pre=a[0]
        s2=str(cunt)
        ans.append((a[2],s1.zfill(6)+s2.zfill(6)))
        cunt+=1
    ans.sort()
    for s in ans:
        print(s[1])

if __name__=='__main__':
    main()

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 = list(map(int,input().split()))
py = [list(map(int,input().split())) + [i] for i in range(m)]

from operator import itemgetter
py = sorted(py,key=itemgetter(1),reverse = False)
py = sorted(py,key=itemgetter(0),reverse = False)
#print(py)

B = []
pref = 0
city = 0
for i in range(m):
    if py[i][0] != pref:
        pref += 1
        city = 1
        B.append(['0000' + str(py[i][0]) + '0000' + str(city) , py[i][2]])
    else:
        city += 1
        B.append(['0000' + str(py[i][0]) + '0000' + str(city) , py[i][2]])
B = sorted(B,key=itemgetter(1),reverse = False)

for i in range(m):
    print(B[i][0])

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

from operator import itemgetter
PY= sorted(PY,key=itemgetter(1),reverse = False)
PY = sorted(PY,key=itemgetter(0),reverse = False)

B= []
pre = 0
city = 0
for i in range(M):
    if pre != PY[i][0]:
        pre =  PY[i][0]
        city = 1
        B.append([str(pre).rjust(6, '0') + str(city).rjust(6, '0') ,PY[i][2]])
    else:
        city += 1
        B.append([str(pre).rjust(6, '0') + str(city).rjust(6, '0') ,PY[i][2]])

B= sorted(B,key=itemgetter(1),reverse = False)        
for i in range(M):
    print(B[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):
# coding: utf-8


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

v = [ [] for _ in range(N+1) ]

for i in range(M):
    p, y = map(int, input().split())
    ps += [p]; ys += [y];
    v[p].append(y)

for i in range(N):
    v[i+1].sort()


print (ps)
print (ys)

print (v)

for i in range(M):
    print("{:06d}".format(ps[i]), end="")
    print("{:06d}".format(v[ps[i]].index(ys[i])+1))


def index_bin(l, x):
    n = len(l)
    b = 0
    e = n
    while(b != e):
        if x > l[(b+e)//2]:
            b = (b+e)//2 + 1
        else:
            e = (b+e)//2
    return b


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

P = []
Y = []
PY = [[] for _ in range(M)]


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

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

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


from bisect import bisect_left

N, M = map(int, input().split())
P, Y = [], []
v = [[] for _ in range(N+1)]

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

for i in range(N+1):
    v[i].sort()

for x, y in zip(P, Y):
    print ("%06d" % x, end = "")
    print ("%06d" % int(bisect_left(v[x], y) + 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())
res = list([] for i in range(n))
p,y = [],[]
for i in range(m):
    tmp = list(int(i) for i in input().split())
    p.append(tmp[0])
    y.append(tmp[1])
    res[tmp[0]-1].append(tmp[1])

for i in range(n):
    res[i] = sorted(res[i])

for i in range(n):
    print("{0:06d}{1:06d}".format(p[i], res[p[i]-1].index(y[i])+1))


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

cs = [[] for i in range(N+1)]
for i,(p,y) in enumerate(src):
    cs[p].append((y,i))
for cc in cs:
    cc.sort()

ans = [None] * M
for p in range(len(cs)):
    for i,(_,j) in enumerate(cs[p]):
        s = str(p).zfill(6) + str(i+1).zfill(6)
        ans[j] = s
print(*ans, sep='\n')


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):
from collections import defaultdict
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for i in range(M)]
PY.sort(key=lambda x: x[1])
pydict = defaultdict(lambda: 0)

for i in PY:
    pydict[i[0]] += 1
    print(["{:0=6}".format(i[0]) + "{:0=6}".format(pydict.get(i[0]))])

from collections import defaultdict
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for i in range(M)]
PY.sort(key=lambda x: x[1])
pydict = defaultdict(lambda: 0)

for i in PY:
    pydict[i[0]] += 1
    print("{:0=6}".format(i[0]) + "{:0=6}".format(pydict.get(i[0])))

from collections import defaultdict
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for i in range(M)]
PY.sort(key=lambda x: x[1])
pydict = defaultdict(lambda: 0)

for i in PY:
    pydict[i[0]] += 1
    print(["{:0=10}".format(i[0]), "{:0=10}".format(pydict.get(i[0]))])

from collections import defaultdict
N, M = map(int, input().split())
py = [list(map(int, input().split())) for i in range(M)]
PY = sorted(py, key=lambda x: x[1])
pydict = defaultdict(lambda: 0)
ans = {}
for i in PY:
    pydict[i[0]] += 1
    ans[str(i[0]) + str(i[1])] = "{:0=6}".format(i[0]) + "{:0=6}".format(pydict.get(i[0]))

for i in py:
    print(ans.get(str(i[0]) + str(i[1])))


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):
from operator import itemgetter

n,m = map(int,input().split())
py = []
pyy = []

npy = []

for i in range(m):

    pyy=list(map(int,input().split()))
    pyy.append(i)
    py.append(pyy)

print(py)
py.sort(key=itemgetter(0,1))

print(py)

num = 1

npy.append([str(10**12+py[0][0]*(10**6)+num)[1:13],py[0][2]])


for i in range(m-1):
    if py[i+1][0] == py[i][0]:
        num = num + 1
        npy.append([str(10**12+py[i+1][0]*(10**6)+num)[1:13],py[i+1][2]])
    else:
        num = 1
        npy.append([str(10**12+py[i+1][0]*(10**6)+num)[1:13],py[i+1][2]])

npy.sort(key=itemgetter(1))

for j in range(m):
    print(npy[j][0])


from operator import itemgetter

n,m = map(int,input().split())
py = []
pyy = []

npy = []

for i in range(m):

    pyy=list(map(int,input().split()))
    pyy.append(i)
    py.append(pyy)

py.sort(key=itemgetter(0,1))


num = 1

npy.append([str(10**12+py[0][0]*(10**6)+num)[1:13],py[0][2]])


for i in range(m-1):
    if py[i+1][0] == py[i][0]:
        num = num + 1
        npy.append([str(10**12+py[i+1][0]*(10**6)+num)[1:13],py[i+1][2]])
    else:
        num = 1
        npy.append([str(10**12+py[i+1][0]*(10**6)+num)[1:13],py[i+1][2]])

npy.sort(key=itemgetter(1))

for j in range(m):
    print(npy[j][0])


Verdicts: Wrong Answer

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

Submission attempts (in order):
n,m = map(int,input().split())
py = {}
for i in range(m):
    p,y = map(int,input().split())
    py[i] = (p,y)
ans = sorted(py.items(),key=lambda x:x[1])
#print(ans[0][1][1])
count = 1
number = []
number.append(count)
#print(ans)
for i in range(1,m):
    if ans[i][1][0] == ans[i-1][1][0]:
        count += 1
    else:
        count = 1
    number.append(count)
#print(number)

for i in range(m):
    a = "{0:06d}".format(ans[i][1][0])
    b = "{0:06d}".format(number[i])
    print(a,end="")
    print(b)

n,m = map(int,input().split())
py = {}
for i in range(m):
    p,y = map(int,input().split())
    py[i] = [p,y]
ans = sorted(py.items(),key=lambda x:x[1])
#print(ans)
#print(ans[0][1])
count = 1
ans[0][1].append(count)
#print(ans)
for i in range(1,m):
    if ans[i][1][0] == ans[i-1][1][0]:
        count += 1
    else:
        count = 1
    ans[i][1].append(count)
#print(number)
ans = sorted(ans)
#print(ans)
for i in range(m):
    a = "{0:06d}".format(ans[i][1][0])
    b = "{0:06d}".format(ans[i][1][2])
    print(a,end="")
    print(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())
PY=[[0,0]]
ans=[]
for _ in range(M):
    PY.append(list(map(int,input().split())))
PY.sort(key=lambda x:(x[0],x[1]))

for i in range(M):
    number=""
    if PY[i+1][0]!=PY[i][0]:
        x=1
    else:
        x+=1
    number+=str(PY[i+1][0]).zfill(6)
    number+=str(x).zfill(6)
    ans.append(number)

for i in ans:
    print(i)

N,M=map(int,input().split())
PY=[[0,0]]
ans=[]
for m in range(M):
    L=list(map(int,input().split()))
    L.append(m+1)
    PY.append(L)
PY.sort(key=lambda x:(x[0],x[1]))

for i in range(M):
    number=""
    if PY[i+1][0]!=PY[i][0]:
        x=1
    else:
        x+=1
    number+=str(PY[i+1][0]).zfill(6)
    number+=str(x).zfill(6)
    ans.append([number,PY[i+1][2]])

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

for i in ans:
    print(i[0])


Verdicts: Wrong Answer

Accepted