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

Submission attempts (in order):
n,m = list(map(int,input().split()))
a = [[] for i in range(n+1)]
b = []
for i in range(m):
    p,s = list(map(int,input().split()))
    a[p].append(s)
    b.append([p,s])
print(a)
for i in range(n+1):
    a[i].sort()
print(a)
for i in range(m):
    ken = b[i][0]
    si = a[ken].index(b[i][1]) +1
    ken = str(ken).zfill(6)
    si = str(si).zfill(6)
    print("".join([ken,si]))

n,m = list(map(int,input().split()))
a = [[None] for i in range(n+1)]
b = [None]*m
for i in range(m):
    p,s = list(map(int,input().split()))
    a[p].append(s)
    b[i] = [p,s]
print(a)
for i in a:
    a[i].sort()
print(a)
for i in b:
    ken = b[i][0]
    si = a[ken].index(b[i][1]) +1
    ken = str(ken).zfill(6)
    si = str(si).zfill(6)
    print("".join([ken,si]))

from bisect import bisect_left


n,m = list(map(int,input().split()))
a = [[0] for i in range(n)]
b = [None]*m
for i in range(m):
    p,s = list(map(int,input().split()))
    p-=1
    a[p].append(s)
    b[i] = [p,s]
for i in range(len(a)):
    a[i].sort()
for i in range(len(b)):
    ken = b[i][0]
    si = bisect_left(a[ken], b[i][1])
    ken = str(ken+1).zfill(6)
    si = str(si).zfill(6)
    print("".join([ken,si]))

Verdicts: Wrong Answer

Runtime Error

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

Submission attempts (in order):
import heapq
import sys
#input = sys.stdin.readline().strip
N, M = map(int, input().split())
clist = []
HQ = [[] for _ in range(N)]
for i in range(M):
    p, y = map(int, input().split())
    clist.append((p, y))
    heapq.heappush(HQ[p - 1], y)
print(HQ)

cmap = {}
for p, q in enumerate(HQ):
    cnt = 0
    for i in range(len(q)):
        y = heapq.heappop(q)
        cmap[str(p) + '_' + str(y)] = i + 1

for p, y in clist:
    idx = cmap[str(p - 1) + '_' + str(y)]
    print('{0:06d}'.format(p) + '{0:06d}'.format(idx))


import heapq
import sys
#input = sys.stdin.readline().strip
N, M = map(int, input().split())
clist = []
HQ = [[] for _ in range(N)]
for i in range(M):
    p, y = map(int, input().split())
    clist.append((p, y))
    heapq.heappush(HQ[p - 1], y)

cmap = {}
for p, q in enumerate(HQ):
    cnt = 0
    for i in range(len(q)):
        y = heapq.heappop(q)
        cmap[str(p) + '_' + str(y)] = i + 1

for p, y in clist:
    idx = cmap[str(p - 1) + '_' + str(y)]
    print('{0:06d}'.format(p) + '{0:06d}'.format(idx))


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
class City:
  def __init__(self, index, pref, time):
    self.index = index
    self.pref = pref
    self.time = time
    self.sort_res = None
  def get_id(self):
    str1 = "0"*(6-len(str(self.pref)))+str(self.pref)
    str2 = "0"*(6-len(str(self.sort_res)))+str(self.sort_res)
    return str1 + str2
if __name__ == '__main__':
  nm = list(sys.stdin,readline().split(" "))
  N = int(nm[0])
  M = int(nm[1])
  prefs = [[]] * N
  cities = []
  for i in range(M):
    info = list(sys.stdin,readline().split(" "))
    newcity = City(i,int(info[0]),int(info[1]))
    prefs[int(info[0])].append(newcity)
  for i in range(N):
    prefs[i].sort(key = lambda x: x.time)
  	for j in range(len(prefs[i])):
      prefs[i][j].sort_res = j+1
  for i in prefs:
    for j in i:
      cities.append(i)
  cities.sort(key = lambda x:x.index)
  for i in cities:
    print(i.get_id())
  
      
   
  

import sys


class City:
    def __init__(self, ind, pref, time):
        self.ind = ind
        self.pref = pref
        self.time = time
        self.sort_res = None

    def get_id(self):
        str1 = "0" * (6 - len(str(self.pref))) + str(self.pref)
        str2 = "0" * (6 - len(str(self.sort_res))) + str(self.sort_res)
        return str1 + str2
    def __str__(self):
    	return str(self.ind)
if __name__ == '__main__':
    nm = list(sys.stdin.readline().split(" "))
    N = int(nm[0])
    M = int(nm[1])
    prefs = [[] for x in range(N)]
    cities = []
    for i in range(M):
        info = sys.stdin.readline().rstrip().split(" ")
        newcity = City(i, int(info[0]), int(info[1]))
        prefs[int(info[0])-1].append(newcity)
    for i in range(N):
        prefs[i].sort(key=lambda x: x.time)
        for j in range(len(prefs[i])):
            prefs[i][j].sort_res = j + 1
    for i in prefs:
        for j in i:
            cities.append(j)
    cities.sort(key=lambda y: y.ind)
    for i in cities:
        print(i.get_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())
PY=[list(map(int, input().split()))+[i] for i in range(M)]
PY=list(sorted(PY))
ls=[]
current=0
ct=1
for i in range(M):
    s1=str(PY[i][0])
    s2=''
    for j in range(6-len(s1)):
        s2+='0'
    s3=s2+s1

    if current==PY[i][0]:
        ct+=1
    else:
        ct=1
        current=PY[i][0]

    s4=str(ct)
    s5=''
    for j in range(6-len(s1)):
        s5+='0'
    s6=s5+s4
    s7=s3+s6

    ls.append([s7,PY[i][2]])


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


N,M=map(int, input().split())
PY=[list(map(int, input().split()))+[i] for i in range(M)]
PY=list(sorted(PY))
ls=[]
current=0
ct=1
for i in range(M):
    s1=str(PY[i][0])
    s2=''
    for j in range(6-len(s1)):
        s2+='0'
    s3=s2+s1

    if current==PY[i][0]:
        ct+=1
    else:
        ct=1
        current=PY[i][0]

    s4=str(ct)
    s5=''
    for j in range(6-len(s4)):
        s5+='0'
    s6=s5+s4
    s7=s3+s6

    ls.append([s7,PY[i][2]])

ls=sorted(ls, key=lambda x :x[1])
for i in ls:
    print(i[0])


Verdicts: Wrong Answer

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

Submission attempts (in order):
n,m = map(int,input().split())
p,y = [],[]
for i in range(m):
    v1,v2 = map(int,input().split())
    p.append(v1)
    y.append(v2)
    
py = zip(p,y,range(m))
py = sorted(py)
p,y,index = zip(*py)
 
ans = []
start = p[0]
count = 1
for i in range(m):
    if start == p[i]:
        ans.append(str(p[i]).zfill(6) + str(count).zfill(6))
        count += 1
    else:
        count = 1
        start = p[i]
        ans.append(str(p[i]).zfill(6) + str(count).zfill(6))
        count += 1
 
ans = zip(index,ans)
ans = sorted(ans1)
index,ans = zip(*ans)
for i in ans:
    print(i)

n,m = map(int,input().split())
p,y = [],[]
for i in range(m):
    v1,v2 = map(int,input().split())
    p.append(v1)
    y.append(v2)
    
py = zip(p,y,range(m))
py = sorted(py)
p,y,index = zip(*py)
 
ans = []
start = p[0]
count = 1
for i in range(m):
    if start == p[i]:
        ans.append(str(p[i]).zfill(6) + str(count).zfill(6))
        count += 1
    else:
        count = 1
        start = p[i]
        ans.append(str(p[i]).zfill(6) + str(count).zfill(6))
        count += 1
 
ans = zip(index,ans)
ans = sorted(ans)
index,ans = zip(*ans)
for i in ans:
    print(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())
py = []
for _ in range(M):
    py.append(list(map(int, input().split())))
d = {}
now = 0
num = 0
for p, y in sorted(py):
    if now != p:
        now = p
        num = 1
    d[(p, y)] = num
    num += 1
for p, y in py:
    print('{0:6}{0:6}'.format(p, d[(p, y)]))

N, M = map(int, input().split())
py = []
for _ in range(M):
    py.append(list(map(int, input().split())))
d = {}
now = 0
num = 0
for p, y in sorted(py):
    if now != p:
        now = p
        num = 1
    d[(p, y)] = num
    num += 1
for p, y in py:
    print('{0:06}{0:06}'.format(p, d[(p, y)]))

N, M = map(int, input().split())
py = []
for _ in range(M):
    py.append(list(map(int, input().split())))
d = {}
now = 0
num = 0
for p, y in sorted(py):
    if now != p:
        now = p
        num = 1
    d[(p, y)] = num
    num += 1
for p, y in py:
    print('{:06d}{:06d}'.format(p, d[(p, y)]))

Verdicts: Wrong Answer

Wrong Answer

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

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

n, m = map(int, input().split())
city = [[0] for _ in range(n)]
buffer = []

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

for i in range(n):
    city[i].sort()

for i in range(m):
    p, y = buffer[i]
    print(str(p).zfill(6) + str(city[p - 1].index(y)).zfill(6))


import sys
input = sys.stdin.readline

n, m = map(int, input().split())
l = []
num = 1
ans = [""] * m

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

l.sort()
print(l)

pn = l[0][0]

for p, y, i in l:
    if p == pn:
        ans[i] = str(p).zfill(6) + str(num).zfill(6)
        num += 1
    else:
        num = 1
        ans[i] = str(p).zfill(6) + str(num).zfill(6)
        num += 1

for a in ans:
    print(a)


import sys
input = sys.stdin.readline

n, m = map(int, input().split())
l = []
num = [0] * n
ans = [""] * m

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

l.sort()


for p, y, i in l:
    num[p - 1] += 1
    ans[i] = str(p).zfill(6) + str(num[p - 1]).zfill(6)

for a in ans:
    print(a)


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):
def main():
  
  
  
  

  N, M = map(int, input().split())
  # PY = []
  # for _ in range(M):
  #   a = list(map(int, input().split()))
  #   PY.append(a)
  PY = [list(map(int, input().split())) for _ in range(M)]
  PY_sorted = sorted(PY, key=lambda x: x[1])

  city_count = {}
  order = {}
  for i, (p, y) in enumerate(PY_sorted):
    if not p in city_count:
      city_count[p] = 0
    city_count[p] += 1
    order[p, i] = city_count[p]
    
  for i, (p, y) in enumerate(PY):
    print('{:06}{:06}'.format(p, order[p, i]))

main()

def main():
  
  
  
  

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

  city_count = {}
  order = {}
  for i, (p, y) in enumerate(PY_sorted):
    if not p in city_count:
      city_count[p] = 0
    city_count[p] += 1
    order[p, i] = city_count[p]
    
  for i, (p, y) in enumerate(PY):
    print('{:06}{:06}'.format(p, order[p, i]))

main()

def main():
  
  
  
  

  N, M = map(int, input().split())
  iPY = []
  for i in enumerate(range(M)):
    p, y = map(int, input().split())
    iPY.append([i, p, y])
  # PY = [list(map(int, input().split())) for _ in range(M)]
  iPY_sorted = sorted(iPY, key=lambda x: x[2])

  city_count = {}
  order = {}
  for i, p, y in iPY_sorted:
    if not p in city_count:
      city_count[p] = 0
    city_count[p] += 1
    order[p, i] = city_count[p]
    
  for i, p, y in enumerate(iPY):
    print('{:06}{:06}'.format(p, order[p, i]))

main()

N, M = map(int, input().split())
iPY = []
 
for i in range(M):
    p, y = map(int, input().split())
    iPY.append([i, p, y])
 
city_count = {}
order = {}
 
for i, p, y in sorted(iPY, key=lambda x: x[2]):
    if not p in city_count:
        city_count[p] = 0
    city_count[p] += 1
    order[p, i] = city_count[p]
    
for i, p, y in iPY:
    print('{:06}{:06}'.format(p, order[p, i]))

Verdicts: Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):

n,m = map(int, input().split())
pyl = [ [] for _ in range(n+1) ]

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

ans = ['']*m
for p, yil in enumerate(pyl):
    top = str(p).zfill(6)
    yil.sort()
    for order,(y,i) in enumerate(yil):
        print(order,i)
        bottom = order+1
        bottom = str(bottom).zfill(6)
        ans[i] = top+bottom

for a in ans:
    print(a)


n,m = map(int, input().split())
pyl = [ [] for _ in range(n+1) ]

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

ans = ['']*m
for p, yil in enumerate(pyl):
    top = str(p).zfill(6)
    yil.sort()
    for order,(y,i) in enumerate(yil):
        bottom = order+1
        bottom = str(bottom).zfill(6)
        ans[i] = top+bottom

for a in ans:
    print(a)

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())
prefecture = [[] for i in range(N+1)]
ans = []
for i in range(M):
    p,y = map(int,input().split())
    prefecture[p].append([y,i])
    prefecture[p].sort()
for i in range(1,N+1):
    tmp_p = str(i)
    while(len(tmp_p)!=6):
         tmp_p = '0'+tmp_p
    for j in range(1,len(prefecture[i])+1):
        tmp_x = str(j)
        while (len(tmp_x)!=6):
            tmp_x = '0'+tmp_x
        ans.append([prefecture[i][j-1][1],tmp_p+tmp_x])
ans.sort()
print(prefecture)
print(ans)
for i in range(len(ans)):
    print(ans[i][1])
        

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

for i in range(1,N+1):
    prefecture[i].sort()
    for j in range(1,len(prefecture[i])+1):
        ans.append([prefecture[i][j-1][1],i,j])
ans.sort()
for i in range(len(ans)):
    print('{:06}{:06}'.format(ans[i][1],ans[i][2]))
        

Verdicts: Wrong Answer

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

Submission attempts (in order):
n, m = map(int, input().split())

cities = sorted(([list(map(int, input().split())) + [i] for i in range(m)]))
print(cities)
pref = cities[0]
counter = 1
for city in cities:
    if pref != city[0]:
        counter = 1
    pref = city[0]
    rank = counter
    number = str(pref).zfill(6) + str(rank).zfill(6)
    city.append(number)
    counter += 1
for i in sorted(cities, key=lambda x: x[2]):
    print(i[3])


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

cities = sorted(([list(map(int, input().split())) + [i] for i in range(m)]))
pref = cities[0]
counter = 1
for city in cities:
    if pref != city[0]:
        counter = 1
    pref = city[0]
    rank = counter
    number = str(pref).zfill(6) + str(rank).zfill(6)
    city.append(number)
    counter += 1
for i in sorted(cities, key=lambda x: x[2]):
    print(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())
ps = []
for i in range(m):
    p, y = map(int, input().split())
    ps.append([p, y, i+1])

ps = sorted(ps)
ps

ans = []
count = 1
for i in range(m):
    if (i != 0 and (ps[i])[0] != (ps[i-1])[0]):
        count = 1
    else:
        pass
    ans.append([(ps[i])[2], 100000*((ps[i])[0]) + count])
    count += 1

ans = sorted(ans)

for i in ans:
    aw = i[1]
    aww = str(aw).zfill(12)
    print(aww)

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

ps = sorted(ps)
ps

ans = []
count = 1
for i in range(m):
    if (i != 0 and (ps[i])[0] != (ps[i-1])[0]):
        count = 1
    else:
        pass
    ans.append([(ps[i])[2], 100000*((ps[i])[0]) + count])
    count += 1

ans = sorted(ans)

for i in ans:
    aw = i[1]
    aww = str(aw).zfill(12)
    print(aww)

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

ps = sorted(ps)
ps

ans = []
count = 1
for i in range(m):
    if (i != 0 and (ps[i])[0] != (ps[i-1])[0]):
        count = 1
    else:
        pass
    ans.append([(ps[i])[2], 1000000*((ps[i])[0]) + count])
    count += 1

ans = sorted(ans)

for i in ans:
    aw = i[1]
    aww = str(aw).zfill(12)
    print(aww)

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

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

for py in PY:
    l[py[0]].append(py[1])

for py in PY:
    l[py[0]].sort()

for py in PY:
    print('{:0>7}'.format(py[0]) + '{:0>7}'.format(l[py[0]].index(py[1]) + 1))


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

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

for py in PY:
    l[py[0]].append(py[1])

for py in PY:
    l[py[0]].sort()

for py in PY:
    print('{:0>6}'.format(py[0]), '{:0>6}'.format(l[py[0]].index(py[1]) + 1))


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

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

for py in PY:
    l[py[0]].append(py[1])

for py in PY:
    l[py[0]].sort()

for py in PY:
    print('{:0>7}'.format(py[0]), '{:0>7}'.format(l[py[0]].index(py[1]) + 1))


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

n = 1
now = PY[0][0]
for py in PY:
    if now != py[0]:
        now = py[0]
        n = 1
    py[1] = n
    n += 1

PY.sort(key=lambda val: val[2])

for py in PY:
    print('{:0>6}'.format(py[0]) + '{:0>6}'.format(py[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):
n , m = map(int, input().split())

lis = []
for i in range(m):
    a = list(map(int, input().split()))
    a.append(i)
    lis.append(a)
print(lis)

t = 1
tmp = sorted(lis)[0][0]

nlis =[]

for i in sorted(lis):
    if tmp == i[0]:
        a = str(i[0])
        left = a.zfill(6)
        right = str(t).zfill(6)
        t += 1
    else:
        t = 1
        tmp = i[0]
        left = str(i[0]).zfill(6)
        right = str(t).zfill(6)
    
    nlis.append([i[2],left+right])

for j in sorted(nlis):
    print(j[1])


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

lis = []
for _ in range(m):
    lis.append(list(map(int, input().split())))

t = 1
tmp = sorted(lis)[0][0]

for i in sorted(lis):
    if tmp == i[0]:
        a = str(i[0])
        left = a.zfill(6)
        right = str(t).zfill(6)
        t += 1
    else:
        t = 1
        tmp = i[0]
        left = str(i[0]).zfill(6)
        right = str(t).zfill(6)
    
    print(left+right)

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

lis = []
for _ in range(m):
    lis.append(list(map(int, input().split())))

print(lis)
print(sorted(lis))

t = 1
tmp = sorted(lis)[0][0]

for i in sorted(lis):
    if tmp == i[0]:
        a = str(i[0])
        left = a.zfill(6)
        right = str(t).zfill(6)
        t += 1
    else:
        t = 1
        tmp = i[0]
        left = str(i[0]).zfill(6)
        right = str(t).zfill(6)
    
    print(left+right)

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

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

t = 1
tmp = sorted(lis)[0][0]

nlis =[]

for i in sorted(lis):
    if tmp == i[0]:
        left = str(i[0]).zfill(6)
        right = str(t).zfill(6)
        t += 1
    else:
        t = 1
        tmp = i[0]
        left = str(i[0]).zfill(6)
        right = str(t).zfill(6)
        t += 1
    
    nlis.append([i[2],left+right])

for j in sorted(nlis):
    print(j[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):
N,M = map(int,input().split())
years = []
for i in range(1,M+1):
    p,y = map(int,input().split())
    years.append((p,y,i))

prefectureOrdering = [1] * (10 ** 5 + 1)
inputOrdering = [False] * (10 ** 5 + 1)

years.sort()

print(years)
for i in years:
    s = ""
    s += "0" * (6 - len(str(i[0]))) + str(i[0]) + "0" * (6 - len(str(prefectureOrdering[i[0]]))) + str(prefectureOrdering[i[0]])
    prefectureOrdering[i[0]] += 1
    inputOrdering[i[2]] = s

for i in range(1,M+1):
    print(inputOrdering[i])

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

prefectureOrdering = [1] * (10 ** 5 + 1)
inputOrdering = [False] * (10 ** 5 + 1)

years.sort()

for i in years:
    s = ""
    s += "0" * (6 - len(str(i[0]))) + str(i[0]) + "0" * (6 - len(str(prefectureOrdering[i[0]]))) + str(prefectureOrdering[i[0]])
    prefectureOrdering[i[0]] += 1
    inputOrdering[i[2]] = s

for i in range(1,M+1):
    print(inputOrdering[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())
data = [[] for _ in range(n)]
for i in range(m):
    p, y = map(int, input().split())
    data[p - 1].append([y, i])

ans = [None] * m
for i in  range(n):
    data[i].sort()
    for j in range(len(data[i])):
        y, k = data[i][j]
        print(k)
        ans[k] = '0' * (6 - len(str(i + 1))) + str(i + 1) + '0' * (6 - len(str(j + 1))) + str(j + 1)

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


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

ans = [None] * m
for i in  range(n):
    data[i].sort()
    for j in range(len(data[i])):
        y, k = data[i][j]
        ans[k] = '0' * (6 - len(str(i + 1))) + str(i + 1) + '0' * (6 - len(str(j + 1))) + str(j + 1)

for i in range(len(ans)):
    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()]
city = []
pref = [0 for i in range(n)]
for i in range(m):
    p, y = [int(_) for _ in input().split()]
    pref[p-1] += 1
    city.append([p,y,i])

city.sort(key = lambda x: (x[0], x[1]))
cnt = 1
for i in range(m):
    city[i].append(cnt)
    if cnt == pref[city[i][0]-1]:
        cnt = 1
    else:
        cnt += 1
city.sort(key = lambda x: x[2])
for i in range(m):
    print(str(city[i][0]).zfill(6), str(city[i][3]).zfill(6))

n, m = [int(i) for i in input().split()]
city = []
pref = [0 for i in range(n)]
for i in range(m):
    p, y = [int(_) for _ in input().split()]
    pref[p-1] += 1
    city.append([p,y,i])

city.sort(key = lambda x: (x[0], x[1]))
cnt = 1
for i in range(m):
    city[i].append(cnt)
    if cnt == pref[city[i][0]-1]:
        cnt = 1
    else:
        cnt += 1
city.sort(key = lambda x: x[2])
for i in range(m):
    print(str(city[i][0]).zfill(6)+str(city[i][3]).zfill(6))

Verdicts: Wrong Answer

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

Submission attempts (in order):
n,m=map(int,input().split())
p=[]
for i in range(m):
    a,b=map(int,input().split())
    p.append([i,a,b,0])
ps=sorted(p,key=lambda i:(i[1],i[2]))
cnt=1
print(ps)
for i in range(m):
    if i!=0:
        if ps[i][1]==ps[i-1][1]:
            print("aaa")
            cnt+=1
            ps[i][3]=cnt
        else:
            ps[i][3]=1
            cnt=1
    else:
        ps[i][3]=1
ps=sorted(ps,key=lambda i:i[0])
print(ps)
for i in range(m):
    print("{0:06d}".format(ps[i][1]),end='')
    print("{0:06d}".format(ps[i][3]))


n,m=map(int,input().split())
p=[]
for i in range(m):
    a,b=map(int,input().split())
    p.append([i,a,b,0])
ps=sorted(p,key=lambda i:(i[1],i[2]))
cnt=1
for i in range(m):
    if i!=0:
        if ps[i][1]==ps[i-1][1]:
            cnt+=1
            ps[i][3]=cnt
        else:
            ps[i][3]=1
            cnt=1
    else:
        ps[i][3]=1
ps=sorted(ps,key=lambda i:i[0])
for i in range(m):
    print("{0:06d}".format(ps[i][1]),end='')
    print("{0:06d}".format(ps[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):
import bisect
n, m = map(int, input().split())


order = []
pre = [[0] for _ in range(n + 1)]

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


for i in range(n + 1):
    pre[p].sort()

順に，各県の何番目かをにぶたんで探す

from collections import defaultdict
n, m = map(int, input().split())
order = []
dd = defaultdict(int)

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


order.sort(key=lambda x: (x[2]))
ans = []
for ii, pp, yy in order:
    dd[pp] += 1
    ans.append('{:0>6}{:0>6}'.format(pp, dd[pp]))

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


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


order = []
pre = [[0] for _ in range(n + 1)]

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


for i in range(n + 1):
    pre[p].sort()

順に，各県の何番目かをにぶたんで探す
for pp, year in order:
    print('{:0>6}'.format(pp) +
          '{:0>6}'.format(bisect.bisect_left(pre[pp], year)))


from collections import defaultdict
n, m = map(int, input().split())
order = []
dd = defaultdict(int)

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


order.sort(key=lambda x: (x[2]))
# print(order)

ans = ['']*m
for ii, pp, yy in order:
    dd[pp] += 1
    ans[ii] = '{:0>6}{:0>6}'.format(pp, dd[pp])

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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
N, M = map(int, input().split())
data = [[] for i in range(M)]
ans = [""] * M
num = [0] * M
for i in range(M):
    ken, year = map(int, input().split())
    data[i] = [ken, year, i]
    
data.sort(key=lambda x:x[1])

for p, y, i in data:
    num[p-1] += 1
    ans[i] = str(p).zfill(6) + str(num[p-1]).zfill(6)

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

N, M = map(int, input().split())
data = [[] for i in range(M)]
ans = [""] * M
num = [0] * M
for i in range(M):
    ken, year = map(int, input().split())
    data[i] = [ken, year, i]
    
data.sort(key=lambda x:x[1])

for p, y, i in data:
    num[p-1] += 1
    ans[i] = (str(p).zfill(6) + str(num[p]).zfill(6))

for i in ans:
    print(i)

N, M = map(int, input().split())
data = [[] for i in range(M)]
ans = [""] * (M+1)
num = [0] * (M+1)
for i in range(M):
    ken, year = map(int, input().split())
    data[i] = [ken, year, i]
    
data.sort(key=lambda x:x[1])

for p, y, i in data:
    num[p-1] += 1
    ans[i] = str(p).zfill(6) + str(num[p-1]).zfill(6)

for i in ans:
    print(i)

N, M = map(int, input().split())
cnt = [0 for i in range(n + 1)] 
check = []
ans = []

for i in range(m):
    p, y = map(int, input().split())
    check.append((y, p, i))

check.sort()

for y, p, i in check:
    cnt[p] += 1
    ans.append((i,str(p).zfill(6)+str(cnt[p]).zfill(6)))

ans.sort()

for aa, bb in ans:
    print(bb)

N, M = map(int, input().split())
data = [[] for i in range(M)]
ans = [""] * M
num = [0] * N
for i in range(M):
    ken, year = map(int, input().split())
    data[i] = [ken, year, i]
    
data.sort(key=lambda x:x[1])

for p, y, i in data:
    num[p-1] += 1
    ans[i] = str(p).zfill(6) + str(num[p-1]).zfill(6)

for i in ans:
    print(i)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
import numpy as np
from itertools import accumulate

N, M = map(int, input().split())
P = []
p = [0] * (N+1)
for i in range(M):
    p1, y1 = map(str, input().split())
    p[int(p1)] += 1
    P.append(int(p1+y1.rjust(10,"0")))
    
ans = np.argsort(P)
ans = np.argsort(ans)
p = list(accumulate(p))

for i in range(M):
    a = P[i] // 10 ** 6 
    print(str(a).rjust(6,"0") + str(ans[i] - p[a-1] + 1).rjust(6,"0"))

import numpy as np
from itertools import accumulate

N, M = map(int, input().split())
P = []
p = [0] * (N+1)
for i in range(M):
    p1, y1 = map(str, input().split())
    p[int(p1)] += 1
    P.append(int(p1+y1.rjust(6,"0")))
    
ans = np.argsort(P)
ans = np.argsort(ans)
p = list(accumulate(p))

for i in range(M):
    a = P[i] // 10 ** 6 
    print(int(str(a).rjust(6,"0") + str(ans[i] - p[a-1] + 1).rjust(6,"0")))

import numpy as np
from itertools import groupby, accumulate

N, M = map(int, input().split())
P = []
Y = []
for i in range(M):
    p1, y1 = map(int, input().split())
    P.append(p1)
    Y.append(y1)
    
y = np.argsort(P)
yy = [P[i] for i in y]
nn = [0] + [len(list(j)) for i, j in groupby(yy)]
n = list(accumulate(nn))
city = [np.argsort(yy[n[i]:n[i+1]]) for i in range(len(n)-1)]

k = []
for i in range(1,len(n)):
    for j in range(nn[i]):
        k.append(str(i).rjust(6,"0") + str(city[i-1][j]+1).rjust(6,"0"))
    
ans = [0] * M    
for i in range(M):
    ans[y[i]] = k[i]
    
for i in range(M):
    print(ans[i])

import numpy as np
from itertools import accumulate

N, M = map(int, input().split())
P = []
p = [0] * (N+1)
for i in range(M):
    p1, y1 = map(str, input().split())
    p[int(p1)] += 1
    P.append(int(p1+y1.rjust(10,"0")))
    
ans = np.argsort(P)
ans = np.argsort(ans)
p = list(accumulate(p))

for i in range(M):
    a = P[i] // 10 ** 10 
    print(str(a).rjust(6,"0") + str(ans[i] - p[a-1] + 1).rjust(6,"0"))

Verdicts: Runtime Error

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())
base = []
base_1 = []
key = {}
ans_str = []
ans_n = []

for i in range(m):
  p,y = map(int,input().split())
  base.append([p,y])
  base_1.append([p,y])
  
base_1.sort(key = lambda x:x[1])

for i in range(m):
  p_str = str(base_1[i][0])
  len_p = len(list(p_str))
  temp = "p"+p_str
  
  if temp not in key:
    key[temp] = 1
    count = str(1)
  else :
    a = key[temp]
    key[temp] = a + 1
    count = str(key[temp])
    
  len_count = len(list(count))
  
  for j in range(6-len_p):
    p_str = "0" + p_str
    
  for j in range(6-len_count):
    count = "0" + count
    
  print(p_str + count)

n,m = map(int,input().split())
base_1 = []
key = {}
ans_str = []
ans_n = []

for i in range(m):
  p,y = map(int,input().split())
  base_1.append([p,y,i])
  
base_1.sort(key = lambda x:x[1])

for i in range(m):
  p_str = str(base_1[i][0])
  len_p = len(list(p_str))
  temp = "p"+p_str
  
  if temp not in key:
    key[temp] = 1
    count = str(1)
  else :
    a = key[temp]
    key[temp] = a + 1
    count = str(key[temp])
    
  len_count = len(list(count))
  
  for j in range(6-len_p):
    p_str = "0" + p_str
    
  for j in range(6-len_count):
    count = "0" + count
    
  base_1[i].append(p_str + count)
    
base_1.sort(key = lambda x:x[2])

for i in range(m):
  print(base_1[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())
l=[]
for i in range(m):
  p,y=map(int,input().split())
  l.append([y,i,p])
l=sorted(l)
l1=[0 for i in range(n+1)] 
l2=[[] for i in range(m)] #shi
for i in range(m):
  l1[l[i][2]]+=1
  l2[l[i][1]]=[l1[l[i][2]],l[i][2]]
for i in range(m):
  w=""
  w+="0"*(6-len(str(l[i][1])))+str(l2[i][1])+"0"*(6-len(str(l[i][0])))+str(l2[i][0])
  print(w)

n,m=map(int,input().split())
l=[]
for i in range(m):
  p,y=map(int,input().split())
  l.append([y,i,p])
l=sorted(l)
l1=[0 for i in range(n+1)] 
l2=[[] for i in range(m)] #shi
for i in range(m):
  l1[l[i][2]]+=1
  l2[l[i][1]]=[l1[l[i][2]],l[i][2]]
for i in range(m):
  w=""
  w+="0"*(6-len(str(l2[i][1])))+str(l2[i][1])+"0"*(6-len(str(l2[i][0])))+str(l2[i][0])
  print(w)

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):
t=input()
N=int(t.split()[0])
M=int(t.split()[1])

city=[0]*M
for i in range(M):
  te=[int(x) for x in input().split()]
  city[i]={'i':i+1,'p':int(te[0]),'y':int(te[1])}

city_sorted = sorted(city,key = lambda x: (x['p'], x['y']))

x=0
temp_p=city_sorted[0]['p']
for c in city_sorted:
  if temp_p == c['p']:
    x+=1
  else:
    print("hoge")
    temp_p=c['p']
    x=1
  c['id']="{0:06d}{1:06d}".format(c['p'],x)
  
for ci in city:
  print(ci['id'])
  

t=input()
N=int(t.split()[0])
M=int(t.split()[1])

city=[0]*M
for i in range(M):
  te=[int(x) for x in input().split()]
  city[i]={'i':i+1,'p':int(te[0]),'y':int(te[1])}

city_sorted = sorted(city,key = lambda x: (x['p'], x['y']))

x=0
temp_p=city_sorted[0]['p']
for c in city_sorted:
  if temp_p == c['p']:
    x+=1
  else:
    temp_p=c['p']
    x=1
  c['id']="{0:06d}{1:06d}".format(c['p'],x)
  
for ci in city:
  print(ci['id'])
  

Verdicts: Wrong Answer

Accepted