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())
l=[]
for i in range(n):l.append([])
for i in range(m):
    p,y=map(int,input().split())
    l[p-1].append((i,y))
rl=[]
for i in range(n):
    ll=l[i]
    ll.sort(key=lambda x:x[1])
    hd="000000"+str(i+1)[-6:]
    rr=[(ll[j][0],hd+("000000"+str(j+1))[-6:]) for j in range(len(ll))]
    rl+=rr
rl.sort()
for e in rl:
    print(e[1])


n,m=map(int,input().split())
l=[]
for i in range(n):l.append([])
for i in range(m):
    print(i)
    p,y=map(int,input().split())
    l[p-1].append((i,y))
rl=[]
for i in range(n):
    ll=l[i]
    ll.sort(key=lambda x:x[1])
    hd="000000"+str(i+1)[-6:]
    rr=[(ll[j][0],hd+("000000"+str(j+1))[-6:]) for j in range(len(ll))]
    rl+=rr
rl.sort()
for e in rl:
    print(e[1])


n,m=map(int,input().split())
l=[]
for i in range(n):l.append([])
for i in range(m):
    p,y=map(int,input().split())
    l[p-1].append((i,y))
rl=[]
for i in range(n):
    ll=l[i]
    ll.sort(key=lambda x:x[1])
    hd=("000000"+str(i+1))[-6:]
    rr=[(ll[j][0],hd+("000000"+str(j+1))[-6:]) for j in range(len(ll))]
    rl+=rr
rl.sort()
for e in rl:
    print(e[1])


Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
N, M = [int(x) for x in input().split()]

PREF = 0
YEAR = 1
PY = [tuple(int(x) for x in input().split()) for _ in range(M)]

PY.sort()

ord = 1 
for i in range(M):
    if i > 0 and PY[i][PREF] == PY[i - 1][PREF]:
        ord += 1
    else:
        ord = 1
    print('{:0>6}{:0>6}'.format(str(PY[i][PREF]),  str(ord)))


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

CITYID = 2
PREF = 0
YEAR = 1
city = [[int(x) for x in input().split()] + [i] for i in range(M)]

city.sort()

id = [""] * M
for i in range(M):
    print(city[i])

ord = 1 
for i in range(M):
    if i > 0 and city[i][PREF] == city[i - 1][PREF]:
        ord += 1
    else:
        ord = 1
    id[city[i][CITYID]] = '{:0>6}{:0>6}'.format(str(city[i][PREF]),  str(ord))

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


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

CITYID = 2
PREF = 0
YEAR = 1
city = [[int(x) for x in input().split()] + [i] for i in range(M)]

city.sort()
id = [""] * M
ord = 1 

for i in range(M):
    if i > 0 and city[i][PREF] == city[i - 1][PREF]:
        ord += 1
    else:
        ord = 1
    id[city[i][CITYID]] = '{:0>6}{:0>6}'.format(str(city[i][PREF]),  str(ord))

for i in range(M):
    print(id[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())
X = [(0,0)]*M
Y = [1]*(N+1)
for i in range(M):
    p,y = map( int, input().split())
    X[i] = (y,p)
X.sort()
for i in range(M):
    y, p = X[i]
    ans = '%06d'%p + '%06d'%Y[p]
    print(ans)
    Y[p] += 1

N, M = map( int, input().split())
X = [(0,0,0)]*M
Y = [1]*(N+1)
for i in range(M):
    p,y = map( int, input().split())
    X[i] = (y,p,i)
X.sort()
ANS = ['']*M
for i in range(M):
    y, p, j = X[i]
    ans = '%06d'%p + '%06d'%Y[p]
    ANS[j] = ans
    Y[p] += 1
for i in range(M):
    print(ANS[i])

Verdicts: Wrong Answer

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

Submission attempts (in order):
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

def main():
  n, m = map(int, input().split())
  ipy = [(i+1, )+(tuple(map(int, input().split()))) for i in range(m)]
  kens = set([p for i,p,y in ipy])
  di = {ken:0 for ken in kens}

  ans = []
  for i,p,y in ipy:
    di[p] += 1
    number = ('%06d%06d' % (p, di[p]))
    ans += [(i, number)]
  ans.sort(key=lambda x:x[0])

  for _, number in ans:
    print(number)
  pass

if __name__=='__main__':
  main()

#!/usr/bin/env python3
# -*- coding:utf-8 -*-

def main():
  n, m = map(int, input().split())
  ipy = [(i+1, )+(tuple(map(int, input().split()))) for i in range(m)]
  ipy.sort(key=lambda x:x[2])
  kens = set([p for i,p,y in ipy])
  di = {ken:0 for ken in kens}

  ans = []
  print(ipy)
  for i,p,y in ipy:
    di[p] += 1
    number = ('%06d%06d' % (p, di[p]))
    ans += [(i, number)]
  ans.sort(key=lambda x:x[0])

  for _, number in ans:
    print(number)
  pass

if __name__=='__main__':
  main()

#!/usr/bin/env python3
# -*- coding:utf-8 -*-

def main():
  n, m = map(int, input().split())
  ipy = [(i+1, )+(tuple(map(int, input().split()))) for i in range(m)]
  ipy.sort(key=lambda x:x[2])
  kens = set([p for i,p,y in ipy])
  di = {ken:0 for ken in kens}

  ans = []
  for i,p,y in ipy:
    di[p] += 1
    number = ('%06d%06d' % (p, di[p]))
    ans += [(i, number)]
  ans.sort(key=lambda x:x[0])

  for _, number in ans:
    print(number)
  pass

if __name__=='__main__':
  main()

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
from operator import itemgetter

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

x = [0] * n
pn = [i for i in range(1, m+1)]
idn = [''] * m
yp = list(zip(y, p, pn, idn))
yp.sort()

for i in range(m):
    p_ = p[i] - 1
    x[p_] += 1
    idn[i] = format(p[i], '0>6') + format(x[p_], '0>6')

yp.sort(key=itemgetter(2))
for i in range(m):
    print(idn[i])

from operator import itemgetter

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

x = [0] * n
pn = [i for i in range(1, m+1)]
idn = [''] * m

yp = list(zip(y, p, pn))
yp.sort()

for i in range(m):
    p_ = yp[i][1] - 1
    x[p_] += 1
    idn[i] = format(yp[i][1], '0>6') + format(x[p_], '0>6')

y, p, pn = zip(*yp)
yp = list(zip(y, p, pn, idn))
yp.sort(key=itemgetter(2))
for i in range(m):
    print(yp[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):
from collections import defaultdict
from bisect import bisect
n,m=map(int,input().split())
l=[list(map(int,input().split()) for _ in range(m))]
a=defaultdict(list)
for x,y in sorted(l):
    a[x]+=[y]

for x,y in l:
    z=bisect(a[x],y)
    print('%06d%06d'%(x,z))

from collections import defaultdict
from bisect import bisect
n,m=map(int,input().split())
l=[tuple(map(int,input().split())) for _ in range(m)]
a=defaultdict(list)
for x,y in sorted(l):
    a[x]+=[y]

for x,y in l:
    z=bisect(a[x],y)
    print('%06d%06d'%(x,z))

Verdicts: Runtime Error

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

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

for i in range(m):
    l[i].append(i)
l = sorted(l,key=lambda x: (x[0],x[1]))

l[0].append(1)
for i in range(1,m):
    if l[i][0]!=l[i-1][0]:
        l[i].append(1)
    else:
        l[i].append(l[i-1][3]+1)

for i in range(m):
    l[i].append(str(l[i][0]).zfill(6) + l[i][3].zfill(6))

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

for i in range(m):
    print(l[i][4])

n,m=map(int, input().split())
l=[input().split() for i in range(m)]
m,m_sort={},{}
lab={}
for j in range(len(l)):
    if l[j][0] not in m.keys():
        m[l[j][0]],m_sort[l[j][0]]=[],[]
    m[l[j][0]].append(l[j][1])
    m_sort[l[j][0]].append(l[j][1])
    m_sort[l[j][0]].sort()
for k in m.keys():
    p='0'*(6-len(k))+k
    for h in range(len(m[k])):
        q='0'*(6-len(str(h+1)))+str(h+1)
        key=l.index([k,m[k][h]])
        lab[key]=p+q
for k,v in sorted(lab.items()):
    print(v)

n,m=map(int, input().split())
l = [[int(i) for i in input().split()] for i in range(m)]

for i in range(m):
    l[i].append(i)
l = sorted(l,key=lambda x: (x[0],x[1]))

l[0].append(1)
for i in range(1,m):
    if l[i][0]!=l[i-1][0]:
        l[i].append(1)
    else:
        l[i].append(l[i-1][3]+1)

for i in range(m):
    l[i].append(str(l[i][0]).zfill(6) + str(l[i][3]).zfill(6))

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

for i in range(m):
    print(l[i][4])


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):
# coding: utf-8
# Your code here!

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

for i in range(M):
    pp,yy = map(int,input().split())
    py.append((pp,yy,i))

py.sort()

cnt = 1
pp_prev = 0
code = ['' for _ in range(M)]

for pp,yy,i in py:
    if pp == pp_prev:
       cnt += 1 
    else:
        cnt = 1
    code[i] = "%06d%06d"%(pp,cnt)
    
print(*code,sep='\n')

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

for i in range(M):
    pp,yy = map(int,input().split())
    yi[pp-1].append((yy,i))

code = ['' for _ in range(M)]

for pp,d in enumerate(yi):
    d.sort()
    for x, (yy,i) in enumerate(d):
        code[i] = "%06d%06d"%(pp+1,x+1)
    
print(*code,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):
import numpy as np
n,m=map(int,input().split())
d=[[] for i in range(n)]
l=[]
for i in range(m):
    a,b=map(int,input().split())
    d[a-1].append(b)
    l.append(a)
x=[[] for i in range(n)]
for i in range(n):
    d[i]=list(np.argsort(d[i]))
    tmp=[0]*len(d[i])
    for j in range(len(d[i]):
        tmp[d[i][j]]=j+1
    x[i]=tmp
for i in range(m):
    b=x[l[i]-1].pop(0)
    b+=1
    p=len(list(str(l[i])))
    q=len(list(str(b)))
    ans=''
    for j in range(6-p):
        ans+='0'
    ans+=str(l[i])
    for j in range(6-q):
        ans+='0'
    ans+=str(b)
    print(ans)


import numpy as np
n,m=map(int,input().split())
d=[[]*m for i in range(n)]
l=[]
for i in range(m):
    a,b=map(int,input().split())
    d[a-1].append(b)
    l.append(a)

for i in range(n):
    d[i]=np.argsort(d[i])
    
for i in range(m):
    b=d[l[i]-1].pop(0)
    b+=1
    p=len(list(str(l[i])))
    q=len(list(str(b)))
    ans=''
    for j in range(6-p):
        ans+='0'
    ans+=str(l[i])
    for j in range(6-q):
        ans+='0'
    ans+=str(b)
    print(ans)

n,m=map(int,input().split())
l=[]
for i in range(m):
    a,b=map(int,input().split())
    l.append([a,b])
x=sorted(l)
dic={}
x.append([0,0])
f=1
for i in range(m):
    if x[i][0]==x[i+1][0]:
        dic[str(x[i][0])+'000000'+str(x[i][1])]=f
        f+=1
    else:
        dic[str(x[i][0])+'000000'+str(x[i][1])]=f
        f=1
for i in range(m):
    b=dic[str(l[i][0])+'000000'+str(l[i][1])]
    p=len(list(str(l[i])))
    q=len(list(str(b)))
    ans=''
    for j in range(6-p):
        ans+='0'
    ans+=str(l[i])
    for j in range(6-q):
        ans+='0'
    ans+=str(b)
    print(ans)


n,m=map(int,input().split())
l=[]
for i in range(m):
    a,b=map(int,input().split())
    l.append([a,b])
x=sorted(l)
dic={}
x.append([0,0])
f=1
for i in range(m):
    if x[i][0]==x[i+1][0]:
        dic[str(x[i][0])+'000000'+str(x[i][1])]=f
        f+=1
    else:
        dic[str(x[i][0])+'000000'+str(x[i][1])]=f
        f=1
for i in range(m):
    b=dic[str(l[i][0])+'000000'+str(l[i][1])]
    p=len(list(str(l[i][0])))
    q=len(list(str(b)))
    ans=''
    for j in range(6-p):
        ans+='0'
    ans+=str(l[i][0])
    for j in range(6-q):
        ans+='0'
    ans+=str(b)
    print(ans)


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

def main():
    ps = [[] for _ in range(N)]
    print(ps)

    for m in range(M):
        p, y = [int(n) for n in input().split()]
        pref = ps[p - 1]
        pref.append([m, y])

    result = []

    for i, pref in enumerate(ps):
        pref.sort(key=lambda p: p[1])
        for j, p in enumerate(pref):
            result.append([p[0], '{:06}{:06}'.format(i + 1, j + 1)])

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

    for p in result:
        print(p[1])

    # ans = '\n'.join(map(lambda p: p[1], result))
    # print(ans)

if __name__ == '__main__':
    main()

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

def main():
    ps = [[] for _ in range(N)]
    print(ps)

    for m in range(M):
        p, y = [int(n) for n in input().split()]
        pref = ps[p - 1]
        pref.append([m, y])

    result = []

    for i, pref in enumerate(ps):
        pref.sort(key=lambda p: p[1])
        for j, p in enumerate(pref):
            result.append([p[0], '{:06}{:06}'.format(i + 1, j + 1)])

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

    ans = '\n'.join(map(lambda p: p[1], result))
    print(ans)

if __name__ == '__main__':
    main()

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

def main():
    ps = [[] for _ in range(N)]

    for m in range(M):
        p, y = [int(n) for n in input().split()]
        pref = ps[p - 1]
        pref.append([m, y])

    result = []

    for i, pref in enumerate(ps):
        pref.sort(key=lambda p: p[1])
        for j, p in enumerate(pref):
            result.append([p[0], '{:06}{:06}'.format(i + 1, j + 1)])

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

    ans = '\n'.join(map(lambda p: p[1], result))
    print(ans)

if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
n,m= map(int, input().split())
x=[[] for j in range(n)]
for i in range(m):
    p,ye= map(int, input().split())
    x[p-1].append([ye,i])
for i in range(n):
    x[i].sort()
y=[0]*m
cnt=1
for i in range(n):
    for a in range(len(x[i])):
        j=str(i+1)
        k=str(cnt)
        y[x[i][a][1]]="0"*(6-len(j))+j+"0"*(6-len(k))+k
        cnt+=1
    cnt=1
print(x)
for i in range(m):
    print(y[i])

def compress(arr):
    *XS, = set(arr)
    XS.sort()
    return {e: i+1 for i, e in enumerate(XS)} 
n,m=map(int,input().split())
s=[[] for i in range(n+1)]
p=[0]*m
y=[0]*m
for i in range(m):
    p[i],y[i]=map(int,input().split())
    s[p[i]].append(y[i])
for i in range(1,n+1):
    s[i]=compress(s[i])
for i in range(m):
    print("0"*(6-len(str(p[i]))),p[i],"0"*(6-len(str(s[p[i]][y[i]]))),s[p[i]][y[i]],sep="")

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):
def pypri(p,y):print(str(p).zfill(6)+str(y).zfill(6))
n,m=map(int,input().split())
a=[[]for _ in range(n)]
b=[]
for i in range(m):
  p,y=map(int,input.split())
  b.append(p-1)
  a[p-1].append([y,len(a[p-1])+1])
for i in range(n):
  a[i].sort()
  for j in range(len(a[i])):
    a[i][j]=[a[i][j][1],j]
    a.sort()
for i in b:
  pypri(i+1,a[i][0][1]+1)
  del a[i][0]

n,m=map(int,input().split())
e=[[]for _ in range(n)]
py=[]
for _ in range(m):
  p,y=map(int,input().split())
  py.append((p,y))
  e[p-1].append(y)
for i in range(n):e[i].sort()
xy=lambda x,y:y*1000000+x
d={}
for i in range(n):
  for j in range(len(e[i])):
    d[xy(i+1,e[i][j])]=str(i+1).zfill(6)+str(j+1).zfill(6)
for p,y in py:
  print(d[xy(p,y)])


Verdicts: Runtime Error

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

Submission attempts (in order):
n,m = map(int,input().split())
pyl = [list(map(int,input().split())) for nesya in range(m)]
predic = dict()
pyl = sorted(pyl,key = lambda x:x[1])
for py in pyl:
  p = py[0]
  if p in predic:
    predic[p] += 1
  else:
    predic[p] = 1
  print((str(p).zfill(6))+(str(predic[p]).zfill(6)))

n,m = map(int,input().split())
pyl = [list(map(int,input().split())) for nesya in range(m)]
predic = dict()
ydic = dict()
spyl = sorted(pyl,key = lambda x:x[1])
for py in spyl:
  p = py[0]
  y = py[1]
  if p in predic:
    predic[p] += 1
  else:
    predic[p] = 1
  ydic[y] = (str(p).zfill(6))+(str(predic[p]).zfill(6))
for hoge in pyl:
  print(ydic[hoge[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())
py = [list(map(int, input().split())) for _ in range(m)]

ans = [0]*m
prefecs = [1]*(n+1)
for i, (p, y) in enumerate(py):
    top = p
    under = prefecs[p]
    ans[i] = str(top).zfill(6)+str(under).zfill(6)
    prefecs[p] += 1

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


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

ans = [0]*m
prefecs = [1]*(n+1)
for i, (p, y, j) in enumerate(py):
    top = p
    under = prefecs[p]
    ans[i] = (str(top).zfill(6)+str(under).zfill(6), j)
    prefecs[p] += 1

ans = sorted(ans, key = lambda x: x[1])
for i in range(m):
    print(ans[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())
py = [list(map(int, input().split())) for _ in range(m)]
py.sort()

ans = []
b = py[0][0]
cnt = 0
for p,y in py:
  if b == p: cnt += 1
  else:
    b = p
    cnt = 1
  a = [str(p), str(cnt)]
  if len(str(p)) < 6: a[0] = "0"*(6-len(str(p))) + str(p)
  if len(str(cnt)) < 6: a[1] = "0"*(6-len(str(cnt))) + str(cnt)
  ans.append(a[0] + a[1])
for v in ans: print(v)

n,m = map(int, input().split())
pyi = [list(map(int, input().split())) + [i] for i in range(m)]
pyi.sort()

pnow = pyi[0][0]
cnt = 1

ans = [-1 for _ in range(m)]

for p,y,i in pyi:
  if pnow != p:
    cnt = 1
    pnow = p
  ans[i] = str(p).zfill(6) + str(cnt).zfill(6)
  cnt += 1
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):
n,m = map(int,input().split())
city = [[] for _ in range(n+1)]
ret = ["" for _ in range(m)]
def createSix(s):
    while len(s) != 6:
        s = "0" + s
    return s
for i in range(m):
    a,b = map(int, input().split())
    city[a].append((b, i))
for i in range(m):
    city[i].sort()
print(city)
for i in range(n+1):
    for j in range(len(city[i])):
        ret[city[i][j][1]] = createSix(str(i)) + createSix(str(j+1))
for i in ret:
    print(i)
    

    


n,m = map(int,input().split())
city = [[] for _ in range(n+1)]
ret = ["" for _ in range(m)]
def createSix(s):
    while len(s) != 6:
        s = "0" + s
    return s
for i in range(m):
    a,b = map(int, input().split())
    city[a].append((b, i))
for i in range(n+1):
    city[i].sort()
for i in range(n+1):
    for j in range(len(city[i])):
        ret[city[i][j][1]] = createSix(str(i)) + createSix(str(j+1))
for i in ret:
    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())
L = []
for i in range(m):
    li = list(map(int,input().split()))
    L.append(li)

li = []
for i,j in enumerate(L):
    li.append(j+[i])
li.sort()

i = 1
ans = []
while i <= n:
    l = []
    for j in range(m):
        if li[j][0] == i:
            l.append(li[j])
    l.sort(key = lambda x:x[1])
    for k,v in enumerate(l):
        l[k][1] = k+1
    ans += l
    i +=1
ans.sort(key = lambda x:x[2])

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


n,m = map(int,input().split())
L = []
for i in range(m):
    li = list(map(int,input().split()))
    L.append(li)

li = []
for i,j in enumerate(L):
    li.append(j+[i])
li.sort(key = lambda x:(x[0],x[1]))

li.append([0,0,0])

k,r = li[0][0],1
for i in range(m):
    if li[i][0] == k:
        if li[i+1][1] == li[i][1]:
            li[i][1] = r
            li[i+1][1] = r
        else:
            li[i][1] = r
            r +=1
    else:
        k = li[i][0]
        r = 1
        li[i][1] = r
        r +=1

li.pop()

li.sort(key = lambda x:x[2])

for i in range(m):
    print("{:06d}".format(li[i][0])+"{:06d}".format(li[i][1]))

Verdicts: Wrong Answer

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

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

def zero(num):
    return str(num).zfill(6)


if m == 1:
    print(zero(py[0])+zero(1))
else:
    year_py = sorted(py, key=lambda x: x[1])
    dic = {x: 0 for x in range(1,m+1)}

    
    
    #    year_py[i].append(dic[year_py[i][0]])
    

    
    

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

def zero(num):
    return str(num).zfill(6)


if m == 1:
    print(zero(py[0])+zero(1))
else:
    year_py = sorted(py, key=lambda x: x[1])
    dic = {x: 0 for x in range(1,m+1)}

    for i in range(m):
        dic[year_py[i][0]] += 1
        year_py[i].append(dic[year_py[i][0]])
    yb_py = sorted(year_py, key=lambda x: x[2])

    
    

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

def zero(num):
    return str(num).zfill(6)


if m == 1:
    print(zero(py[0][0])+zero(1))
else:
    year_py = sorted(py, key=lambda x: x[1])
    dic = {str(x): 0 for x in range(1,n+1)}

    for i in range(m):
        dic[str(year_py[i][0])] += 1
        year_py[i].append(dic[str(year_py[i][0])])
    yb_py = sorted(year_py, key=lambda x: x[2])

    for i in range(m):
        print(zero(yb_py[i][0]) + zero(yb_py[i][3]))

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 bisect

n, m = [int(_) for _ in input().split(' ')]

p, y = [], []
for _ in range(m):
    temp = [int(_) for _ in input().split(' ')]
    p.append(temp[0])
    y.append(temp[1])
ys = dict()
for i in range(m):
    if not(p[i] in ys):
        ys[p[i]] = []
    ys[p[i]].append(y[i])

for j in ys.keys():
    ys[j].sort()

print(ys)

for i in range(m):
    print('{0}{1}'.format(str(p[i]).zfill(6), str(bisect.bisect(ys[p[i]], y[i])).zfill(6)))


import bisect

n, m = [int(_) for _ in input().split(' ')]

p, y = [], []
for _ in range(m):
    temp = [int(_) for _ in input().split(' ')]
    p.append(temp[0])
    y.append(temp[1])
ys = dict()
for i in range(m):
    if not(p[i] in ys):
        ys[p[i]] = []
    ys[p[i]].append(y[i])

for j in ys.keys():
    ys[j].sort()

for i in range(m):
    print('{0}{1}'.format(str(p[i]).zfill(6), str(bisect.bisect(ys[p[i]], y[i])).zfill(6)))


Verdicts: Wrong Answer

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

Submission attempts (in order):
import sys

def fill(s): while len(s) < 6: s = '0' + s; return s
def create_id(p, o): return fill(str(p)) + fill(str(o))

n, m, *py = map(int, sys.stdin.read().split())
pyi = sorted(zip(zip(*[iter(py)] * 2), range(m)))

def main():
    res = [None] * m
    prev = j = None
    for (p, y), i in pyi:
        j = j + 1 if p == prev else 1
        res[i] = create_id(p, j)
        prev = p
    print(*res, sep='\n')
    
if __name__ ==  '__main__':
    main()

import sys

def fill(s): return '0' * (6 - len(s)) + s
def create_id(p, o): return fill(str(p)) + fill(str(o))

n, m, *py = map(int, sys.stdin.read().split())
pyi = sorted(zip(*[iter(py)] * 2 + [range(m)]))

def main():
    res = [None] * m
    prev = j = None
    for p, y, i in pyi:
        j = j + 1 if p == prev else 1
        res[i] = create_id(p, j)
        prev = p
    print(*res, sep='\n')
    
if __name__ ==  '__main__':
    main()

Verdicts: Runtime Error

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

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

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

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

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


ans = [0] * M

count = 0
tmp = 0 
for p, y, i in lst:
    if tmp == p:
        count += 1
    else:
        count = 1
        tmp = p
    tmp_ans = str(p).zfill(6) + str(count).zfill(6)
    ans[i] = tmp_ans

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





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

lst = []
for i in range(M):
    a = list(map(int, input().split()))
    lst += [a]

#print (lst)
lst.sort()
#print (lst)

ken = -1
x = 0
for j in range(M):
    if ken != lst[j][0]: 
        x = 1 #
        ken = lst[j][0]
        P = '{:0>6}'.format(ken)
    else: 
        x += 1
    X = '{:0>6}'.format(x)
    ans = P + X
    print (ans)

import sys
input = sys.stdin.readline

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

lst = [list(map(int, input().split())) + [i] for i in range(M)]
# print (lst)

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


ans = [0] * M

count = 0
tmp = 0 
for p, y, i in lst:
    if tmp == p:
        count += 1
    else:
        count = 1
        tmp = p
    tmp_ans = str(p).zfill(6) + str(count).zfill(6)
    ans[i] = tmp_ans

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





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)]
PY.sort(key=lambda x:x[1])
flag=[1]*N
ans=[]
for P,Y in PY:
  ans.append(str(P).zfill(6)+str(flag[P-1]).zfill(6))
  flag[P-1]+=1
  
ans.sort
for a in ans:
  print(a)

N,M=map(int,input().split())
PY=[list(map(int,input().split())) for _ in range(M)]
idx=sorted(range(M),key=lambda x:PY[x][1])
PY.sort(key=lambda x:x[1])
flag=[1]*N
keep=[]
for P,Y in PY:
  keep.append(str(P).zfill(6)+str(flag[P-1]).zfill(6))
  flag[P-1]+=1
  
ans=[0]*M
for i,k in zip(idx,keep):
  ans[i]=k
  
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())
dict1={}
dict2={}
for i in range(m):
    x,y=map(int,input().split())
    try:
        dict1[x].append([y,i+1])
    except:
        KeyError
        dict1[x]=[[y,i+1]]
ansarr=["0"]*m
for i in dict1.keys():
    dict1[i].sort()
    s1=(6-len(str(i)))*'0'+str(i)
    for j in range(len(dict1[i])):
        s2=(6-len(str(j+1)))*'0'+str(j+1)
        print(dict1[i][j][1])
        ansarr[dict1[i][j][1]-1]=s1+s2
for i in range(m):
    print(ansarr[i])

n,m=map(int,input().split())
dict1={}
dict2={}
for i in range(m):
    x,y=map(int,input().split())
    try:
        dict1[x].append([y,i+1])
    except:
        KeyError
        dict1[x]=[[y,i+1]]
ansarr=["0"]*m
for i in dict1.keys():
    dict1[i].sort()
    s1=(6-len(str(i)))*'0'+str(i)
    for j in range(len(dict1[i])):
        s2=(6-len(str(j+1)))*'0'+str(j+1)
        #print(dict1[i][j][1])
        ansarr[dict1[i][j][1]-1]=s1+s2
for i in range(m):
    print(ansarr[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):
import copy
n, m = map(int, input().split())
s = []
for i in range(m):
    s.append([int(i) for i in input().split()])
    #l2 = l[:]
t = s[:]
t.sort()
t.sort(key=lambda x: x[1])
co = 1
for i in range(m):
    if i != 0:
        if t[i][0] != t[i - 1][0]:
            co = 1
    if t[i][0] <10:
        moji1 = "00000" + str(t[i][0])
    elif t[i][0] <100:
        moji1 = "0000" + str(t[i][0])
    elif t[i][0] <1000:
        moji1 = "000" + str(t[i][0])
    elif t[i][0] <10000:
        moji1 = "00" + str(t[i][0])
    elif t[i][0] <100000:
        moji1 = "0" + str(t[i][0])
    else:
        moji1 = str(t[i][0])

    if co <10:
        moji2 = "00000" + str(co)
    elif co <100:
        moji2 = "0000" + str(co)
    elif co <1000:
        moji2 = "000" + str(co)
    elif co <10000:
        moji2 = "00" + str(co)
    elif co <100000:
        moji2 = "0" + str(co)
    else:
        moji2 = str(co)
    t[i].append(moji1 + moji2)

for i in range(m):
    print(s[i][2])

import copy
n, m = map(int, input().split())
s = []
for i in range(m):
    s.append([int(i) for i in input().split()])
    #l2 = l[:]
t = s[:]
t.sort()
t.sort(key=lambda x:(x[0], x[1]))
co = 1
for i in range(m):
    if i != 0:
        if t[i][0] != t[i - 1][0]:
            co = 1
    if t[i][0] <10:
        moji1 = "00000" + str(t[i][0])
    elif t[i][0] <100:
        moji1 = "0000" + str(t[i][0])
    elif t[i][0] <1000:
        moji1 = "000" + str(t[i][0])
    elif t[i][0] <10000:
        moji1 = "00" + str(t[i][0])
    elif t[i][0] <100000:
        moji1 = "0" + str(t[i][0])
    else:
        moji1 = str(t[i][0])

    if co <10:
        moji2 = "00000" + str(co)
    elif co <100:
        moji2 = "0000" + str(co)
    elif co <1000:
        moji2 = "000" + str(co)
    elif co <10000:
        moji2 = "00" + str(co)
    elif co <100000:
        moji2 = "0" + str(co)
    else:
        moji2 = str(co)
    t[i].append(moji1 + moji2)
    co += 1

for i in range(m):
    print(s[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):
from itertools import chain


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

P = [0] * N

I = list(range(M))

Q = [None] * M
Y = [None] * M

for m in range(M):
    Q[m], Y[m] = map(int, input().split())
    P[Q[m]-1] += 1

D = zip(I, Q, Y)
D = sorted(D, key=lambda x: [x[1], x[2]])
I, Q, Y = map(list, zip(*D))

print(P)

P = list(chain.from_iterable([list(range(1, p+1)) for p in P]))

print(P)

D = zip(I, Q, Y, P)
D = sorted(D, key=lambda x: x[0])
I, Q, Y, P = map(list, zip(*D))

print(P)

for i in range(M):
    print('%06d%06d' % (Q[i], P[i]))


from itertools import chain
import numpy as np
import pandas as pd


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

P = [0] * N

I = list(range(M))

Q = [None] * M
Y = [None] * M

for m in range(M):
    Q[m], Y[m] = map(int, input().split())
    P[Q[m]-1] += 1

D = zip(I, Q, Y)
D = sorted(D, key=lambda x: [x[1], x[2]])
I, Q, Y = map(list, zip(*D))

print(P)

P = list(chain.from_iterable([list(range(1, p+1)) for p in P]))

print(P)

D = zip(I, Q, Y, P)
D = sorted(D, key=lambda x: x[0])
I, Q, Y, P = map(list, zip(*D))

print(P)

for i in range(M):
    print('%06d%06d' % (Q[i], P[i]))


from itertools import chain


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

P = [0] * N

I = list(range(M))

Q = [None] * M
Y = [None] * M

for m in range(M):
    Q[m], Y[m] = map(int, input().split())
    P[Q[m]-1] += 1

D = zip(I, Q, Y)
D = sorted(D, key=lambda x: [x[1], x[2]])
I, Q, Y = map(list, zip(*D))

P = list(chain.from_iterable([list(range(1, p+1)) for p in P]))

D = zip(I, Q, Y, P)
D = sorted(D, key=lambda x: x[0])
I, Q, Y, P = map(list, zip(*D))

for i in range(M):
    print('%06d%06d' % (Q[i], P[i]))


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())
lis=[]
for i in range(m):
  p,q=map(int,input().split())
  lis.append([q,p])
lis.sort()
ken=[1]*n
for i in range(0,m):
  attack=lis[i]
  kenken=attack[1]
  ken_count=ken[kenken-1]
  moji=""
  moji+="0"*(6-len(str(kenken)))+str(kenken)+"0"*(6-len(str(ken_count)))+str(ken_count)
  ken[kenken-1]+=1
  print(moji)

n,m=map(int,input().split())
lis=[]
for i in range(0,m):
  p,q=map(int,input().split())
  lis.append([q,p,i])
lis.sort()
ken=[1]*n
res=[]
for i in range(0,m):
  attack=lis[i]
  kenken=attack[1]
  ken_count=ken[kenken-1]
  moji=""
  moji+="0"*(6-len(str(kenken)))+str(kenken)+"0"*(6-len(str(ken_count)))+str(ken_count)
  ken[kenken-1]+=1
  res.append([attack[2],moji])
  
res.sort()
for i in range(0,m):
  print(res[i][1])





Verdicts: Wrong Answer

Accepted