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())
Y = [[] for _ in range(n)]
L = []
for i in range(m):
    p,yi = map(int, input().split())
    Y[p-1].append(yi)
    L.append(yi)
for i in range(n):
    Y[i].sort()
    for k in range(len(Y[i])):
        print(0)

n,m = map(int, input().split())
Y = [[] for _ in range(n)]
L = []
for i in range(m):
    p,yi = map(int, input().split())
    Y[p-1].append(yi)
    L.append(yi)
for i in range(n):
    Y[i].sort()
    for k in range(len(Y[i])):
        L[L.index(Y[i][k])] = str(i+1).rjust(6,"0") + str(k+1).rjust(6,"0")


n,m = map(int, input().split())
Y = [[] for _ in range(n)]
for i in range(m):
    p,yi = map(int, input().split())
    Y[p-1].append((yi,i))
ans = [-1 for _ in range(m)]
for i,d in enumerate(Y):
    d.sort()
    for k,(a,b) in enumerate(d):
        ans[b] = str(i+1).rjust(6,"0") + str(k+1).rjust(6,"0")
for i in range(m):
    print(ans[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):
N, M = map(int,input().split())
py = []
for i in range(M):
  py.append(list(map(int,input().split())))
  py[i].append(i)
sorted_py = sorted(py, key=lambda x: x[1])
P = [0]*N
p_num = 0
num = 0
output = ''
output2 = []
outputs = []
for i in range(M):
  P[sorted_py[i][0]-1] += 1
  p_num = sorted_py[i][0]
  num = P[sorted_py[i][0]-1]
  output = str(p_num).zfill(6) + str(num).zfill(8)
  output2 = [output, sorted_py[i][2]]
  outputs.append(output2)
sorted_outputs = sorted(outputs, key=lambda x: x[1])
for out in sorted_outputs:
  print(out[0])

  

N, M = map(int,input().split())
py = []
for i in range(M):
  py.append(list(map(int,input().split())))
  py[i].append(i)
sorted_py = sorted(py, key=lambda x: x[1])
P = [0]*N
p_num = 0
num = 0
output = ''
output2 = []
outputs = []
for i in range(M):
  P[sorted_py[i][0]-1] += 1
  p_num = sorted_py[i][0]
  num = P[sorted_py[i][0]-1]
  output = str(p_num).zfill(6) + str(num).zfill(6)
  output2 = [output, sorted_py[i][2]]
  outputs.append(output2)
sorted_outputs = sorted(outputs, key=lambda x: x[1])
for out in sorted_outputs:
  print(out[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):
from operator import itemgetter
N, M = map(int, input().split())
c=[]
for i in range(M):
	c.append(input().split())
for i in range(M):
	c[i].append(i)
C = sorted(sorted(c,key=itemgetter(1)), key=itemgetter(0))
x = 1
for i in range(M):
	if i > 0  and int(C[i][0]) - int(C[i-1][0]) > 0:
		x = 1
	else:
		x += 1
	C[i].append(x)
c = sorted(C, key=itemgetter(2))
for i in range(M):
	print("{:06d}{:06d}".format(int(c[i][0]), int(c[i][3])))

from operator import itemgetter
N, M = map(int, input().split())
c=[]
for i in range(M):
	c.append(list(map(int, input().split())))
for i in range(M):
	c[i].append(i)
C = sorted(sorted(c,key=itemgetter(1)), key=itemgetter(0))
x = 0
for i in range(M):
	if i > 0  and C[i][0] - C[i-1][0] != 0:
		x = 1
	else:
		x += 1
	C[i].append(x)
c = sorted(C, key=itemgetter(2))
for i in range(M):
	print("{:06d}{:06d}".format(c[i][0], c[i][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):
N,M = map(int,input().split())
d=[0]*M
res = []
for i in range(M):
    P,Y = map(int,input().split())
    res.append((P,Y,i))
c=1
print(res)
for i in sorted(res):
    x = str(i[0])
    y = str(i[1])
    tmp = (6-len(x))*'0'+x+(6-len(str(c)))*'0'+str(c)
    if(tmp in d):
        c+=1
        d[i[2]] = (6-len(x))*'0'+x+(6-len(str(c)))*'0'+str(c)
    else:
        c = 1
        d[i[2]] = (6-len(x))*'0'+x+(6-len(str(c)))*'0'+str(c)

for i in d:
    print(i)

N,M = map(int,input().split())
d=[0]*M
res = []
for i in range(M):
    P,Y = map(int,input().split())
    res.append((P,Y,i))
c=0
res.sort()
t = str(res[0][0])
for i in res:
    x = str(i[0])
    if x == t:
        c+=1
    else:
        c=1
        t = x
    d[i[2]] = (6-len(x))*'0'+x+(6-len(str(c)))*'0'+str(c)

for i in d:
    print(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=map(int,input().split())
pre=[[] for _ in range(n)]
for _ in range(m):
    p,y=map(int,input().split())
    pre[p-1].append([y,_,p])
for p in range(n):
    pre[p].sort(key=lambda x:x[0])
    for i in range(len(pre[p])):
        pre[p][i].append(i)
lis=[]
for i in pre:
    for j in i:
        lis.append(j)
lis.sort(key=lambda x:x[1])
for i in lis: print("{:06}{:06}".format(i[3]+1,i[2]))

n,m=map(int,input().split())
pre=[[] for _ in range(n)]
for _ in range(m):
    p,y=map(int,input().split())
    pre[p-1].append([y,_,p])
for p in range(n):
    pre[p].sort(key=lambda x:x[0])
    for i in range(len(pre[p])):
        pre[p][i].append(i)
lis=[]
for i in pre:
    for j in i:
        lis.append(j)
lis.sort(key=lambda x:x[1])
for i in lis: print("{:06}{:06}".format(i[2],i[3]+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())
D = [[] for i in range(N)]

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

ans = [None]*M

for i, d in enumerate(D): 
  d.sort()
  print(d)
  for k, (y, j) in enumerate(d): 
    ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep = '\n') 

import sys
input = sys.stdin.readline
n, m = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(m)]
def make_id(num):
  s = len(str(num))
  add_zero = '0'*(6-s)
  return add_zero + str(num)

P = [[] for _ in range(m)]
for i in range(len(PY)):
  P[PY[i][0]-1].append(PY[i][1])
  P[PY[i][0]-1].sort()
print(P)
for i in range(len(PY)):
  p,y=PY[i][0],PY[i][1]
  ord = P[p-1].index(y)+1
  print(make_id(p)+make_id(ord))


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

ans = [None]*M
 
for i, d in enumerate(D): 
  d.sort()
  for k, (y, j) in enumerate(d): 
    ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep = '\n') 

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=map(int,input().split())
num=[1]*(n+1)
ansl=[]
for i in range(m):
    p,y=map(int,input().split())
    ans="%06d"%p+"%06d"%num[p]
    num[p]+=1
    ansl.append(ans)
print(*ansl,sep="\n")


import bisect
import heapq
n,m=map(int,input().split())
py_i=[[int(x) for x in input().split()] for _ in range(m)]
y_p=[[] for i in range(n+1)]
for x,y in sorted(py_i):
    print(x)
    y_p[x].append(y)
for x,y in py_i:
    z=bisect.bisect_right(y_p[x],y)
    print("%06d"%x+"%06d"%z)

#print(y_p)

import bisect
import heapq
n,m=map(int,input().split())
py_i=[[int(x) for x in input().split()] for _ in range(m)]
y_p=[[] for i in range(n+1)]
for x,y in sorted(py_i):
    #print(x)
    y_p[x].append(y)
for x,y in py_i:
    z=bisect.bisect_right(y_p[x],y)
    print("%06d"%x+"%06d"%z)

#print(y_p)

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
n, m =map(int, input().split())
py_array = [[int(x) for x in input().split()]+[y] for x, y in enumerate(range(m), 0)]
py_array = sorted(py_array, key=lambda x:(x[0], x[1]))

base = 1
base2 = 0
res_array = []
for i, j, k in py_array:
    if base == i:
        base2 += 1
        print(i)
    else:
        base = i
        base2 = 1
    res_array.append([str(base).zfill(6), str(base2).zfill(6), k])

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

for i, j, k in res_array:
    print(i, j)

n, m =map(int, input().split())
py_array = [[int(x) for x in input().split()]+[y] for x, y in enumerate(range(m), 0)]
py_array = sorted(py_array, key=lambda x:(x[0], x[1]))

base = 1
base2 = 0
res_array = []
for i, j, k in py_array:
    if base == i:
        base2 += 1
        print(i)
    else:
        base = i
        base2 = 1
    res_array.append([str(base).zfill(6), str(base2).zfill(6), k])

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

for i, j, k in res_array:
    print(i+j)

n, m =map(int, input().split())
py_array = [[int(x) for x in input().split()]+[y] for x, y in enumerate(range(m), 0)]
py_array = sorted(py_array, key=lambda x:(x[0], x[1]))

base = 1
base2 = 0
res_array = []
for i, j, k in py_array:
    if base == i:
        base2 += 1
    else:
        base = i
        base2 = 1
    res_array.append([str(base).zfill(6), str(base2).zfill(6), k])

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

for i, j, k in res_array:
    print(i+j)

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

D = [[] for i in range(N)]
#print(P.sort())
for i in range(M):
    p,y = map(int,input().split())
    D[p-1].append((y,i))
    

#D = [[(32,0),(12,2)],[(63,1)]]
#print(D)
submit = [0]*M
for i,d in enumerate(D):
    #print(d)
    d.sort()
    #print(i,d)
    for k, (y,j) in enumerate(d):
        #print(k,y,j)
        submit[j] = str(i+1).zfill(6)+str(k+1).zfill(6)
        
print(submit)
print(*submit,sep = '\n')

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

lst = [list(map(int,input().split())) for _ in range(M)]
D = [[] for i in range(N)]
#print(lst)
submit =[0]*M
for i in range(M):
    D[lst[i][0]-1].append((lst[i][1],i))

#print(D)

for i,d in enumerate(D):
    #print(i,d)
    d.sort(key=lambda x: x[0])
    #print(d)
    for k,(y,j) in enumerate(d):
        #print(i,k,y,j)
        submit[j] = str(i+1).zfill(6)+str(k+1).zfill(6)

print(*submit,sep = '\n')

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 = [list(map(int, input().split())) + [i] for i in range(M)]
p.sort()
print(p)
i = 0
for n in range(1, N + 1):
    count = 1
    print(i, p[2][0])
    while not(i > n or p[i][0] != n):
        p[i] += [str(n).zfill(6) + str(count).zfill(6)]
        i += 1
        count += 1
p.sort(key=lambda x: x[2])
for a in p:
    print(a[3])

N, M = map(int, input().split())
p = [list(map(int, input().split())) + [i] for i in range(M)]
p.sort()
i = 0
for n in range(1, N + 1):
    count = 1
    while not(i >= M or p[i][0] != n):
        p[i] += [str(n).zfill(6) + str(count).zfill(6)]
        i += 1
        count += 1
p.sort(key=lambda x: x[2])
for a in p:
    print(a[3])

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())
question_dic = defaultdict(list)
question_dics = defaultdict(list)
for _ in range(M):
    city,value = map(int,input().split())
    question_dic[city].append(value)
for key,value in question_dic.items():
    question_dics[key] = sorted(value)
for key,value in question_dic.items():
    for v in value:
        print("%06d%06d"%(key,question_dics[key].index(v)+1))



from collections import defaultdict

N,M = map(int,input().split())
question = []
number = {}
counts = defaultdict(int)
for i in range(M):
    city,value = map(int,input().split())
    question.append([i,city,value])
sorted_question = sorted(question,key=lambda x: x[2])
for i,city,value in sorted_question:
    counts[city] += 1
    number[i] = "{:06}{:06}".format(city,counts[city])
for i in range(M):
    print(number[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):
nm_lst = list(map(int, input().split()))
city_lst = [list(map(int, (str(i)+' '+input()).split())) for i in range(nm_lst[1])]

city_lst = sorted(city_lst, key = lambda x: x[1]*10**7 + x[2])

ans_lst = []
num_num = 0
for n, city in enumerate(city_lst):
    prefec_num = city[1]
    prefec_str = '0' * (6-len(str(prefec_num))) + str(prefec_num)
    if n = 0 or (prefec_num != city_lst[n-1][1]):
        num_str = '000001'
        num_num = 1
    else:
        num_num += 1
        num_str = '0' * (6-len(str(num_num))) + str(num_num)
    ans_lst.append([city[0], prefec_str, num_str])
    
ans_lst = sorted(ans_lst, key = lambda x:x[0])

for city in ans_lst:
    print(city[1]+city[2])

nm_lst = list(map(int, input().split()))
city_lst = [list(map(int, (str(i)+' '+input()).split())) for i in range(nm_lst[1])]

city_lst = sorted(city_lst, key = lambda x: x[1]*(10**12) + x[2])

ans_lst = []
num_num = 0
for n, city in enumerate(city_lst):
    prefec_num = city[1]
    prefec_str = '0' * (6-len(str(prefec_num))) + str(prefec_num)
    if n == 0 or (prefec_num != city_lst[n-1][1]):
        num_num = 1
    else:
        num_num += 1
    num_str = '0' * (6-len(str(num_num))) + str(num_num)
    ans_lst.append([city[0], prefec_str, num_str])
    
ans_lst = sorted(ans_lst, key = lambda x:x[0])

for city in ans_lst:
    print(city[1]+city[2])

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):
def mks(num):
  s=str(num)
  if len(s)<6:
    s='0'*(6-len(s))+s
  return s

n,m=map(int,input().split())
arr=[]
for i in range(m):
  p,y=map(int,input().split)
  arr.append([p,y,i])
ans=[0]*m
arr=sorted(arr,key=lambda x:x[1])
arr=sorted(arr,key=lambda x:x[0])
tmp=arr[0][0]
cnt=1
for i in range(m):
  if arr[i][0]==tmp:
    s1,s2=mks(tmp),mks(cnt)
    ans[arr[i][2]]=s1+s2
    cnt+=1
  else:
    cnt=1
    tmp=arr[i][0]
    s1,s2=mks(tmp),mks(cnt)
    ans[arr[i][2]]=s1+s2
for i in range(m):
  print(ans[i])

def mks(num):
  s=str(num)
  if len(s)<6:
    s='0'*(6-len(s))+s
  return s

n,m=map(int,input().split())
arr=[]
for i in range(m):
  p,y=map(int,input().split())
  arr.append([p,y,i])
ans=[0]*m
arr=sorted(arr,key=lambda x:x[1])
arr=sorted(arr,key=lambda x:x[0])
tmp=arr[0][0]
cnt=1
for i in range(m):
  if arr[i][0]==tmp:
    s1,s2=mks(tmp),mks(cnt)
    ans[arr[i][2]]=s1+s2
    cnt+=1
  else:
    cnt=1
    tmp=arr[i][0]
    s1,s2=mks(tmp),mks(cnt)
    ans[arr[i][2]]=s1+s2
    cnt+=1
for i in range(m):
  print(ans[i])

Verdicts: Runtime Error

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

Submission attempts (in order):
n, m = map(int, input().split())
a = [0] * (n+1)
b = [list(map(int, input().split())) + [i] + [0] for i in range(m)]
b.sort(key= lambda x:x[1])
for i, (v, x, y, z) in enumerate(b):
    a[v-1] += 1
    b[i][3] = a[v-1]
b.sort(key = lambda x:x[2])
for v,x,y,z in b:
    print("{0:06d}{0:06d}".format(v,z))

n, m = map(int, input().split())
a = [0] * (n)
b = [list(map(int, input().split())) + [i] + [0] for i in range(m)]
b.sort(key= lambda x:x[1])
for i, (v, x, y, z) in enumerate(b):
    a[v-1] += 1
    b[i][3] = a[v-1]
b.sort(key = lambda x:x[2])
for v,x,y,z in b:
    print("{0:06d}{0:06d}".format(v,z))

n, m = map(int, input().split())
pli = [1 for x in range(n)]
for i in range(m):
    p, y = input().split()
    P = "0" * (6 - int(p)) + p
    Y =  "0" * (6 - len(str(pli[(int(p) - 1)]))) + str(pli[(int(p) - 1)])
    print(P + Y)
    pli[(int(p) - 1)] += 1



n, m = map(int, input().split())
a = [0] * (n+1)
b = [list(map(int, input().split())) + [i] + [0] for i in range(m)]
b.sort(key= lambda x:x[1])
for i, (v, x, y, z) in enumerate(b):
    a[v-1] += 1
    b[i][3] = a[v-1]
b.sort(key = lambda x:x[2])
for v,x,y,z in b:
    print("{0:06d}{1:06d}".format(v,z))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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

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

py.sort(key=lambda x:(x[1],x[2]))
sorted_py = py
num = 1
prev_p = str(sorted_py[0][1])
for i in range(m):
    if prev_p != sorted_py[i][1]:
        num = 1
    p = str(sorted_py[i][1])
    prev_p = p
    str_num = str(num)
    if len(p)!=6:
        p = '0'*(6-len(p))+p
    if len(str_num)!=6:
        str_num = '0'*(6-len(str_num))+str_num
    sorted_py[i].append(p+str_num)
    num+=1
sorted_py.sort()
for i in range(m):
    print(sorted_py[i][3])

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

py.sort(key=lambda x:(x[1],x[2]))
sorted_py = py
num = 1
prev_p = str(sorted_py[0][1])
for i in range(m):
    if prev_p != sorted_py[i][1]:
        num = 1
    p = str(sorted_py[i][1])
    str_num = str(num)
    if len(p)!=6:
        p = '0'*(6-len(p))+p
    if len(str_num)!=6:
        str_num = '0'*(6-len(str_num))+str_num
    sorted_py[i].append(p+str_num)
    prev_p = p
    num+=1
sorted_py.sort()
for i in range(m):
    print(sorted_py[i][3])

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

py.sort(key=lambda x:(x[1],x[2]))
sorted_py = py
num = 1
prev_p = str(sorted_py[0][1])
for i in range(m):
    p = str(sorted_py[i][1])
    if prev_p != p:
        num = 1
        prev_p = p
    str_num = str(num)
    if len(p)!=6:
        p = '0'*(6-len(p))+p
    if len(str_num)!=6:
        str_num = '0'*(6-len(str_num))+str_num
    sorted_py[i].append(p+str_num)
    num+=1
sorted_py.sort()
for i in range(m):
    print(sorted_py[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):
n, m= map(int, (input().split()))
pyi = [list(map(int, (input().split()))) + [i] for i in range(m)]
pyi.sort(key=itemgetter(1))
pyi.sort(key=itemgetter(0))
cityflag = 0
ans = []
for rep in range(m):
    if pyi[rep][0] != pyi[rep - 1][0]:
        cityflag = 0

    cityflag += 1
    ans += [[pyi[rep][0] , cityflag, pyi[rep][2]]]

for i in sorted(ans, key=itemgetter(2)):
    print(str(i[0]).zfill(6) + str(i[1]).zfill(6))

from operator import itemgetter

n, m= map(int, (input().split()))
pyi = [list(map(int, (input().split()))) + [i] for i in range(m)]
pyi.sort(key=itemgetter(1))
pyi.sort(key=itemgetter(0))
cityflag = 0
ans = []
for rep in range(m):
    if pyi[rep][0] != pyi[rep - 1][0]:
        cityflag = 0

    cityflag += 1
    ans += [[pyi[rep][0] , cityflag]]

for i in sorted(ans):
    print(str(i[0]).zfill(6) + str(i[1]).zfill(6))

from operator import itemgetter

n, m= map(int, (input().split()))
pyi = [list(map(int, (input().split()))) + [i] for i in range(m)]
pyi.sort(key=itemgetter(1))
pyi.sort(key=itemgetter(0))
cityflag = 0
ans = []
for rep in range(m):
    if pyi[rep][0] != pyi[rep - 1][0]:
        cityflag = 0

    cityflag += 1
    ans += [[pyi[rep][0] , cityflag, pyi[rep][2]]]

for i in sorted(ans, key=itemgetter(2)):
    print(str(i[0]).zfill(6) + str(i[1]).zfill(6))

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())
PY = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
    PY[i].append(i)
PY.sort(key=lambda x:x[1])
ans = [0]*M
num = [0]*N
for p,y,i in PY:
    ans[i] = str(p).zfill(6) + str(num[p]+1).zfill(6)
    num[p] += 1
for s in ans:print(s)

N,M = map(int,input().split())
PY = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
    PY[i].append(i)
PY.sort(key=lambda x:x[1])
ans = [0]*M
num = [0]*N
for p,y,i in PY:
    ans[i] = str(p).zfill(6) + str(num[p-1]+1).zfill(6)
    num[p-1] += 1
for s in ans:print(s)

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 itertools


def solve():
    n, m = map(int, input().split())
    py = list(list(map(int, input().split())) for _ in range(m))
    py_with_key = sorted([(idx, pyi) for idx, pyi in enumerate(py)], key=lambda x: x[1])
    pref_no = 1
    cnt = 0
    ids = []
    for idx, p_y in py_with_key:
        if pref_no == p_y[0]:
            cnt += 1
        else:
            pref_no = p_y[0]
            cnt = 1
        city_id = '{0:06d}{1:06d}'.format(p_y[0], cnt)
        ids.append((idx, city_id))
    print("\n".join([x[1] for x in sorted(ids, key=lambda x: x[0])]))


if __name__ == "__main__":
    print(solve())


def solve():
    n, m = map(int, input().split())
    py = list(list(map(int, input().split())) for _ in range(m))
    py_with_key = sorted([(idx, pyi) for idx, pyi in enumerate(py)], key=lambda x: x[1])
    pref_no = 1
    cnt = 0
    ids = []
    for idx, p_y in py_with_key:
        if pref_no == p_y[0]:
            cnt += 1
        else:
            pref_no = p_y[0]
            cnt = 1
        city_id = '{0:06d}{1:06d}'.format(p_y[0], cnt)
        ids.append((idx, city_id))
    return "\n".join([x[1] for x in sorted(ids, key=lambda x: x[0])])


if __name__ == "__main__":
    print(solve())


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()]
a = [[]for i in range(n)]
b = []

for i in range(m):
    c,d = [int(i)for i in input().split()]
    a =[c-1].append((d,i))
ans = [None]*m
for j,b in enumerate(a):
    b.sort()
    for k,(d,i) in enumerate(b):
        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()]
a = [[]for i in range(n)]


for i in range(m):
    c,d = map(int,input().split())
    a =[c-1].append((d,i))
ans = [0]*m
for i,b in enumerate(a):
    b.sort()
    for k,(d,j) in enumerate(b):
        ans[j] = str(i+1).zfill(6)+str(k+1).zfill(6)
print(*ans,sep="\n")

N,M=map(int, input().split())
A=[[] for i in range(N)]
 
for i in range(M):
  p,y=map(int, input().split())
  A[p-1].append((y, i))
 
X=[0]*M
for i,d in enumerate(A):
  d.sort()
  for k,(y,j) in enumerate(d):
    X[j]=str(i+1).zfill(6)+str(k+1).zfill(6)
print(*X,sep='\n')

Verdicts: Runtime Error

Runtime Error

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

Submission attempts (in order):
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
buf = [None] * m
cnt = {k: [] for k in range(n + 1)}
for i in range(m):
    p, y = na()
    cnt[p].append((y, i))
for p, l in cnt.items():
    if not l:
        continue
    l.sort()
    print(l)
    for j, (y, i) in enumerate(l):
        buf[i] = '{:06d}{:06d}'.format(p, j + 1)

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



import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
buf = [None] * m
cnt = {k: [] for k in range(n + 1)}
for i in range(m):
    p, y = na()
    cnt[p].append((y, i))
print(cnt)
for p, l in cnt.items():
    if not l:
        continue
    l.sort()
    print(l)
    for j, (y, i) in enumerate(l):
        buf[i] = '{:06d}{:06d}'.format(p, j + 1)

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



import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
buf = [None] * m
cnt = {k: [] for k in range(n + 1)}
for i in range(m):
    p, y = na()
    cnt[p].append((y, i))
for p, l in cnt.items():
    if not l:
        continue
    l.sort()
    for j, (y, i) in enumerate(l):
        buf[i] = '{:06d}{:06d}'.format(p, j + 1)

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



Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
N,M=map(int,input().split())
PY=[]
for i in range(M):
    array=list(map(int,input().strip().split()))
    PY.append(array)

PY.sort()
city=0
order=0
for i in range(M):
    newcity=PY[i][0]
    if(newcity!=city):
        city=newcity
        order=1
    strcity=str(PY[i][0])
    strorder=str(order)
    upper='0'*(6-len(strcity))+strcity
    lower='0'*(6-len(strorder))+strorder
    order=order+1
    print(upper+lower)

for i in range(M):
    array=list(map(int,input().strip().split()))
    PY.append(array)

PY.sort()
city=0
order=0
for i in range(M):
    newcity=PY[i][0]
    if(newcity!=city):
        city=newcity
        order=1
    strcity=str(PY[i][0])
    strorder=str(order)
    upper='0'*(6-len(strcity))+strcity
    lower='0'*(6-len(strorder))+strorder
    order=order+1
    print(upper+lower)

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

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

birth[0].append(0)
cnt=0
for i in range(M-1):
    if birth[i][1]==birth[i+1][1]:
        cnt+=1
    else:
        cnt=0
    birth[i+1].append(cnt)

birth.sort(key=lambda x:x[0])
for i in range(M):
    ans=str(birth[i][1]).zfill(6)+str(birth[i][3]+1).zfill(6)
    print(ans)


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 = map(int, input().split())
data = [0] * m
res = [0] * m
for i in range(m):
    d = list(map(int, input().split()))
    d.append(i)
    data[i] = tuple(d)
data.sort()
city_num = data[0][0]
birth_num = 1
print(data)
for item in data:
    # print(item, city_num)
    if item[0] != city_num:
        city_num = item[0]
        birth_num = 1
    res[item[2]] = '{:06d}{:06d}'.format(item[0], birth_num)
    birth_num += 1
for item in res:
    print(item)


n, m = map(int, input().split())
data = [0] * m
res = [0] * m
for i in range(m):
    d = list(map(int, input().split()))
    d.append(i)
    data[i] = tuple(d)
data.sort()
city_num = data[0][0]
birth_num = 1
# print(data)
for item in data:
    # print(item, city_num)
    if item[0] != city_num:
        city_num = item[0]
        birth_num = 1
    res[item[2]] = '{:06d}{:06d}'.format(item[0], birth_num)
    birth_num += 1
for item in res:
    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())
t=[[] for _ in range(n)]
for i in range(m):
    p,y=map(int,input().split())
    t[p-1].append((y,i))
ans=[""]*m
for i,j in enumerate(t,1):
    j.sort()
    for k,(j,l) in enumerate(j,1):
        print(l)
        ans[l]=str(i).zfill(6)+str(k).zfill(6)
print("\n".join(ans))

n,m=map(int,input().split())
t=[[] for _ in range(n)]
for i in range(m):
    p,y=map(int,input().split())
    t[p-1].append((y,i))
ans=[""]*m
for i,j in enumerate(t,1):
    j.sort()
    for k,(j,l) in enumerate(j,1):
        ans[l]=str(i).zfill(6)+str(k).zfill(6)
print("\n".join(ans))

Verdicts: Wrong Answer

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

Submission attempts (in order):
import sys
def input():
    return sys.stdin.readline()[:-1]
N,M=map(int,input().split())
l=[None]*M
for i in range(M):
    P,Y=map(int,input().split())
    l[i]=(P,Y,i)
l.sort()
a=[None]*M
s=0
t=1
for i in l:
    if i[0]==s:
        t+=1
    else:
        t=1
        s=i[0]
    a[i[2]]="{:06d}".format(i[0]) + "{:06d}".format(t)
print(a)

import sys
def input():
    return sys.stdin.readline()[:-1]
N,M=map(int,input().split())
l=[None]*M
for i in range(M):
    P,Y=map(int,input().split())
    l[i]=(P,Y,i)
l.sort()
a=[None]*M
s=0
t=1
for i in l:
    if i[0]==s:
        t+=1
    else:
        t=1
        s=i[0]
    a[i[2]]="{:06d}".format(i[0]) + "{:06d}".format(t)
print(*a,sep="\n")

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):
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']

# 1 2	x,y = map(int,input().split())	x=1,y=2




# 3
# hoge
# foo
# bar
# n=int(input())

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

# P, Y = [], []
# for _ in range(M):
#     P_i, Y_i = = map(int,input().split())
#     P.append(P_i)
#     Y.append(Y_i)

N, M = map(int, input().split())
py = {}
all_py = []
for _ in range(M):
  p, y = map(int, input().split())
  if not p in py:
    py[p] = []
  py[p].append(y)
  all_py.append([p, y])

sort_p = {}
for k, v in all_py:
  if not k in sort_p:
    sort_p[k] = sorted(py[k])
  print("{}{}".format(str(k).zfill(8), str((sort_p[k]).index(v)+1).zfill(8)))

# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']

# 1 2	x,y = map(int,input().split())	x=1,y=2




# 3
# hoge
# foo
# bar
# n=int(input())

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

# P, Y = [], []
# for _ in range(M):
#     P_i, Y_i = = map(int,input().split())
#     P.append(P_i)
#     Y.append(Y_i)

N, M = map(int, input().split())
py = {}
for _ in range(M):
  p, y = map(int, input().split())
  if not p in py:
    py[p] = []
  py[p].append(y)

for i in py:
  sort_p = sorted(py[i])
  for j in py[i]:
    print("{}{}".format(str(i).zfill(8), str(sort_p.index(j)+1).zfill(8)))

# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']

# 1 2	x,y = map(int,input().split())	x=1,y=2




# 3
# hoge
# foo
# bar
# n=int(input())

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

# P, Y = [], []
# for _ in range(M):
#     P_i, Y_i = map(int,input().split())
#     P.append(P_i)
#     Y.append(Y_i)
def inpl(): return list(map(int, input().split()))

N, M = inpl()
A = [""]*M
P = [[] for _ in range(N+1)]
for i in range(M):
  p, y = inpl()
  P[p].append((y, i))

# print(P)
for ind, p in enumerate(P):
  p = sorted(p, key=lambda x: x[0])
  for j, (y, i) in enumerate(p):
    A[i] = "{}{}".format(str(ind).zfill(6), str(j+1).zfill(6))

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


Verdicts: Wrong Answer

Wrong Answer

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

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

P = [0] * M
Y = [0] * M
dic = {}
ano_dic = {}
for m in range(M):
    line = list(map(int, input().split()))
    P[m] = line[0]
    Y[m] = line[1]
    
    dic[m] =[P[m], Y[m]]


ID = {}
count = 0
sorted_list = sorted(dic.items(), key=lambda x: (x[1][0], x[0]))


for i, item in enumerate(sorted_list):
    if item[1][0] == sorted_list[i - 1][1][0]:
        count += 1
        ID[item[0]] = str(item[1][0]).zfill(6) + str(count).zfill(6)
    else:
        count = 1
        ID[item[0]] = str(item[1][0]).zfill(6) + str(count).zfill(6)

for item in sorted(ID.items(), key=lambda x: x[0]):
    print(item[1])

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

P = [0] * M
Y = [0] * M
dic = {}
ano_dic = {}
for m in range(M):
    line = list(map(int, input().split()))
    P[m] = line[0]
    Y[m] = line[1]
    
    dic[m] =[P[m], Y[m]]


ID = {}
count = 0
sorted_list = sorted(dic.items(), key=lambda x: (x[1][0], x[1][1]))



for i, item in enumerate(sorted_list):
    if item[1][0] == sorted_list[i - 1][1][0]:
        count += 1
        ID[item[0]] = str(item[1][0]).zfill(6) + str(count).zfill(6)
    else:
        count = 1
        ID[item[0]] = str(item[1][0]).zfill(6) + str(count).zfill(6)

for item in sorted(ID.items(), key=lambda x: x[0]):
    print(item[1])

Verdicts: Wrong Answer

Accepted