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


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


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

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


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


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


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

for py in PYlist:
    print(ans_dict[py])
Buggy code:
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)


Fixed code:
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)
Buggy code:
n, m = map(int, input().split())
a = []
for i in range(m):
	a.append([int(n) for n in input().split()])
	a[i].append(i)
print(a)
b = []
counter = 0
counter1 = 1
for i in range(m):
	c = ""
	if a[i][0] < 100000:
		getlen = len(str(a[i][0]))
		c = "0" * (6 - getlen) + str(a[i][0])
	else:
		c = str(a[i][0])
	if i == 0:
		c += "000001"
		counter = a[0][0]
	elif a[i][0] == counter:
		getlen = len(str(counter1 + 1))
		c += "0" * (6 - getlen) + str(counter1 + 1)
		counter1 += 1
	else:
		counter1 = 1
		c += "000001"
		counter = a[i][0]
	a[i].append(c)

for i in range(m):
	a[i][2], a[i][0] = a[i][0], a[i][2]
a = sorted(a)
for i in range(m):
	print(a[i][3])

Fixed code:
n, m = map(int, input().split())
a = []
for i in range(m):
	a.append([int(n) for n in input().split()])
	a[i].append(i)
a = sorted(a)
b = []
counter = 0
counter1 = 1
for i in range(m):
	c = ""
	if a[i][0] < 100000:
		getlen = len(str(a[i][0]))
		c = "0" * (6 - getlen) + str(a[i][0])
	else:
		c = str(a[i][0])
	if i == 0:
		c += "000001"
		counter = a[0][0]
	elif a[i][0] == counter:
		getlen = len(str(counter1 + 1))
		c += "0" * (6 - getlen) + str(counter1 + 1)
		counter1 += 1
	else:
		counter1 = 1
		c += "000001"
		counter = a[i][0]
	a[i].append(c)

for i in range(m):
	a[i][2], a[i][0] = a[i][0], a[i][2]
a = sorted(a)
for i in range(m):
	print(a[i][3])
Buggy code:
import numpy as np
# your code goes here
def main():
	buf = input().split()
	n = int(buf[0])
	m = int(buf[1])
	
	py = np.zeros((m, 4), dtype="int")#num, p, year, num in p
	for i in range(m):
		py[i][0] = i+1#################
		buf = input().split()
		py[i][1] = int(buf[0])
		py[i][2] = int(buf[1])
		
	py = np.array(sorted(py, key=lambda x:(x[1],x[2])))
	bufp = 0
	for i in range(m):
		if(py[i][1] != bufp):
			bufp = py[i][1]
			py[i][3] = 1#1-origin
		else:
			py[i][3] = py[i-1][3]+1
	#py = np.sort(py, axis=0)
	py = py[np.argsort(py[:, 0])]
	
	print(py)
	for i in range(m):
		ans = "{0:06d}".format(py[i][1])+"{0:06d}".format(py[i][3])
		print(ans)
	
main()

Fixed code:
import numpy as np
# your code goes here
def main():
	buf = input().split()
	n = int(buf[0])
	m = int(buf[1])
	
	py = np.zeros((m, 4), dtype="int")#num, p, year, num in p
	for i in range(m):
		py[i][0] = i+1#################
		buf = input().split()
		py[i][1] = int(buf[0])
		py[i][2] = int(buf[1])
		
	py = np.array(sorted(py, key=lambda x:(x[1],x[2])))
	bufp = 0
	for i in range(m):
		if(py[i][1] != bufp):
			bufp = py[i][1]
			py[i][3] = 1#1-origin
		else:
			py[i][3] = py[i-1][3]+1
	#py = np.sort(py, axis=0)
	py = py[np.argsort(py[:, 0])]
	
#	print(py)
	for i in range(m):
		ans = "{0:06d}".format(py[i][1])+"{0:06d}".format(py[i][3])
		print(ans)
	
main()
Buggy code:
import collections
import bisect
n,m = map(int,input().split())
p = [list(map(int,input().splilt())) for i in range(m)]
a = collections.defaultdict(list)
for x,y in sorted(p):
  a[x]+=[y]
for x,y in p:
  z = bisect.bisect(a[x],y)
  print("%06d%06d"%(x,z))

Fixed code:
import collections
import bisect
n,m=map(int,input().split())
p=[[int(j) for j in input().split()] for i in range(m)]
a=collections.defaultdict(list)
for x,y in sorted(p):
    a[x]+=[y]
for x,y in p:
    z=bisect.bisect(a[x],y)
    print("%06d%06d"%(x,z))
Buggy code:
n,m = map(int, input().split())
py = []
for i in rante(m):
  a,b = map(int, input.split())
  py.append([a,b,i])
py.sort()
p = 1
y = 1
for i in range(m):
  if py[i][0] == p:
    py[i][1] = y
    y += 1
  else:
    py[i][1] = 1
    y = 1
    p = py[i][0]
py.sort(key=lambda x:x[2])
for p,y,i in py:
  print("{06}{06}".format(p,y))



Fixed code:
n,m = map(int, input().split())
py = []
for i in range(m):
  a,b = map(int, input().split())
  py.append([a,b,i])
py.sort()
p = py[0][0]
y = 1
for i in range(m):
  if py[i][0] == p:
    py[i][1] = y
    y += 1
  else:
    py[i][1] = 1
    y = 2
    p = py[i][0]
py = sorted(py, key=lambda x:x[2])
for p,y,i in py:
  print("{:0=6}{:0=6}".format(p,y))
Buggy code:
def ABC113C():
    
    N, M = map(int, input().split())
    PY = [list(map(int, input().split())) for i in range(M)]
    P = [[] for i in range(10 ** 5)]

    from operator import itemgetter
    PY.sort(key = itemgetter(1))
    for k in range(len(PY)):
        i = PY[k][0]
        j = PY[k][1]
        P[i - 1].append([j, k])
    anslist = []
    for i in range(len(P)):
        for j in range(len(P[i])):
            anslist.append([i + 1, j + 1, P[i][j][1] + 1])
    anslist.sort(key = itemgetter(2))
    for i, j, k in anslist:
        i = str(i)
        j = str(j)
        while len(i) != 6:
            i = "0" + i
        while len(j) != 6:
            j = "0" + j
        print(i + j)
ABC113C()

Fixed code:

def ABC113C():

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

    from operator import itemgetter
    #PY.sort(key = itemgetter(1))
    for k in range(len(PY)):
        i = PY[k][0]
        j = PY[k][1]
        P[i - 1].append([j, k])

    for i in range(len(P)):
        P[i].sort()

    anslist = []
    for i in range(len(P)):
        for j in range(len(P[i])):
            anslist.append([i + 1, j + 1, P[i][j][1] + 1])
    anslist.sort(key = itemgetter(2))
    for i, j, k in anslist:
        i = str(i)
        j = str(j)
        while len(i) != 6:
            i = "0" + i
        while len(j) != 6:
            j = "0" + j
        print(i + j)
ABC113C()
Buggy code:
N, M = map(int, input().split())
pLst = [list(map(int, input().split())) for i in range(M)]

for i in range(len(pLst)):
    pLst[i].append(i)
nLst = [''] * N

for i in range(N):
    nLst[i] = str(i + 1).zfill(6)
tLst = sorted(pLst, key=lambda x: (x[0], x[1]))
ansLst = [''] * M
tmp = nLst[tLst[i][0] - 1]
index = 1

Fixed code:
N, M = map(int, input().split())
pLst = [list(map(int, input().split())) for i in range(M)]

for i in range(len(pLst)):
    pLst[i].append(i)
nLst = [''] * N

for i in range(N):
    nLst[i] = str(i + 1).zfill(6)
tLst = sorted(pLst, key=lambda x: (x[0], x[1]))
ansLst = [''] * M
tmp = nLst[tLst[0][0] - 1]
index = 1
for i in range(M):
    if tmp == nLst[tLst[i][0] - 1]:
        ansLst[tLst[i][2]] = nLst[tLst[i][0] - 1] + str(index).zfill(6)
        index += 1
    else:
        index = 1
        tmp = nLst[tLst[i][0] - 1]
        ansLst[tLst[i][2]] = nLst[tLst[i][0] - 1] + str(index).zfill(6)
        index += 1

for i in ansLst:
    print(i)
Buggy code:
n, m = map(int, input().split())
tmp = [list(map(int, input().split())) for i in range(m)]
city = [[] for i in range(n+1)]
answers = [''] * m

for i, (pref, year) in enumerate(tmp):
    city[pref].append([year, i])
print(city)

for i in range(n+1):
    for j, (year, index) in enumerate(sorted(city[i])):
        ans = str(i).zfill(6) + str(j+1).zfill(6)
        answers[index] = ans

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

Fixed code:
n, m = map(int, input().split())
tmp = [list(map(int, input().split())) for i in range(m)]
city = [[] for i in range(n+1)]
answers = [''] * m

for i, (pref, year) in enumerate(tmp):
    city[pref].append([year, i])

for i in range(n+1):
    for j, (year, index) in enumerate(sorted(city[i])):
        ans = str(i).zfill(6) + str(j+1).zfill(6)
        answers[index] = ans

print(*answers, sep='\n')
Buggy code:
N,M = map(int,input().split())
L = []
for i in range(M):
  L.append(list(map(int,input().split())))
for j in range(M):
  L[j].append(j)
L.sort()
l = L[0][0]
cnt = 0
for k in range(M):
  if l == L[k][0]:
    L[k].append(cnt)
    cnt += 1
  else:
    l = L[k][0]
    cnt = 0
    L[k].append(cnt)
L = sorted(L, key = lambda x:x[2])
print(L)
for i in range(M):
  print('0'*(6-len(str(L[i][0])))+str(L[i][0])+'0'*(6-len(str(L[i][3]+1)))+str(L[i][3]+1))

Fixed code:
N,M = map(int,input().split())
L = []
for i in range(M):
  L.append(list(map(int,input().split())))
for j in range(M):
  L[j].append(j)
L.sort()
l = L[0][0]
cnt = 0
for k in range(M):
  if l == L[k][0]:
    cnt += 1
    L[k].append(cnt)
  else:
    l = L[k][0]
    cnt = 1
    L[k].append(cnt)
L = sorted(L, key = lambda x:x[2])
for i in range(M):
  print('0'*(6-len(str(L[i][0])))+str(L[i][0])+'0'*(6-len(str(L[i][3])))+str(L[i][3]))
Buggy code:
n, m = map(int, input().split())
P = [0]*(m+1)
Y = [0]*(m+1)
for i in range(1, m+1):
    P[i], Y[i] = map(int, input().split())
PP = [[] for i in range(n+1)]
#print(PP)
for i in range(1, m+1):
    p = P[i]
    y = Y[i]
    PP[p].append((i, y))

for i in range(1, n+1):
    if len(PP[i]) == 0:
        continue
    for j in range(1, len(PP[i])+1):
         print('%06d%06d' % (i, j))
    #if len(PP[i]) > 1:
    #    PP[i].sort(key=lambda x: x[1])
    #for i, pp in enumerate(PP[i]):
    #    num = '%06d%06d' % (i, )

Fixed code:
n, m = map(int, input().split())
P = [0]*(m+1)
Y = [0]*(m+1)
for i in range(1, m+1):
    P[i], Y[i] = map(int, input().split())
PP = [[] for i in range(n+1)]
#print(PP)
for i in range(1, m+1):
    p = P[i]
    y = Y[i]
    PP[p].append((i, y))

C = []
for i in range(1, n+1):
    if len(PP[i]) == 0:
        continue
    if len(PP[i]) > 1:
        PP[i].sort(key=lambda x: x[1])
    for j, pp in enumerate(PP[i]):
        num = '%06d%06d' % (P[pp[0]], j+1)
        C.append((pp[0], num))
#print(C)
C.sort(key=lambda x: x[0])
for i, num in C:
    print(num)
Buggy code:
n, m = list(map(int, input().split()))
cities = []

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

sorted_cities = sorted(cities, key=lambda x: (x[0], x[1]))
print(sorted_cities)
cnt = 1
ans = []
for i in range(m-1):
    p_id = str(sorted_cities[i][0]).rjust(6, '0')
    c_id = str(cnt).rjust(6, '0')
    ans.append([sorted_cities[i][2], p_id+c_id])
    if sorted_cities[i][0] != sorted_cities[i+1][0]:
        cnt = 1
    else:
        cnt += 1

p_id = str(sorted_cities[m-1][0]).rjust(6, '0')
c_id = str(cnt).rjust(6, '0')
ans.append([sorted_cities[m-1][2], p_id+c_id])
ans.sort()

for id in ans:
    print(id[1])



Fixed code:
n, m = list(map(int, input().split()))
cities = []

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

sorted_cities = sorted(cities, key=lambda x: (x[0], x[1]))
cnt = 1
ans = []
for i in range(m-1):
    p_id = str(sorted_cities[i][0]).rjust(6, '0')
    c_id = str(cnt).rjust(6, '0')
    ans.append([sorted_cities[i][2], p_id+c_id])
    if sorted_cities[i][0] != sorted_cities[i+1][0]:
        cnt = 1
    else:
        cnt += 1

p_id = str(sorted_cities[m-1][0]).rjust(6, '0')
c_id = str(cnt).rjust(6, '0')
ans.append([sorted_cities[m-1][2], p_id+c_id])
ans.sort()

for id in ans:
    print(id[1])
Buggy code:
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)]))

Fixed code:
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)]))
Buggy code:
N,M = map(int,input().split())
L = []
for i in range(M):
    l = list(map(int,input().split()))+[i]
    L.append(l)
cnt = 0
tmp = []
M = sorted(L,key = lambda x: (x[0],x[1]))
for x in M:
    if tmp == x[0]:
        x.append(cnt+1)
        cnt += 1
    else:
        tmp = x[0]
        cnt = 0
        x.append(cnt)
M = sorted(L,key = lambda x:x[2])
print(M)
for x in M:
    st = str(x[0]).zfill(5)
    st += str(x[3]+1).zfill(5)
    print(st)


Fixed code:
N,M = map(int,input().split())
L = []
for i in range(M):
    l = list(map(int,input().split()))+[i]
    L.append(l)
cnt = 0
tmp = []
M = sorted(L,key = lambda x: (x[0],x[1]))
for x in M:
    if tmp == x[0]:
        x.append(cnt+1)
        cnt += 1
    else:
        tmp = x[0]
        cnt = 0
        x.append(cnt)
M = sorted(L,key = lambda x:x[2])
#print(M)
for x in M:
    st = str(x[0]).zfill(6)
    st += str(x[3]+1).zfill(6)
    print(st)
Buggy code:
n,m=map(int,input().split())
t=[[] for _ in range(n)]
for i in range(m):
    p,y=map(int,input().split())
    t[p-1].append((y,i))
ans=[""]*m
for i,j in enumerate(t,1):
    j.sort()
    for k,(j,l) in enumerate(j,1):
        print(l)
        ans[l]=str(i).zfill(6)+str(k).zfill(6)
print("\n".join(ans))

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


Fixed code:
n, m = map(int, input().split())
data = [0] * m
res = [0] * m
for i in range(m):
    d = list(map(int, input().split()))
    d.append(i)
    data[i] = tuple(d)
data.sort()
city_num = data[0][0]
birth_num = 1
# print(data)
for item in data:
    # print(item, city_num)
    if item[0] != city_num:
        city_num = item[0]
        birth_num = 1
    res[item[2]] = '{:06d}{:06d}'.format(item[0], birth_num)
    birth_num += 1
for item in res:
    print(item)
Buggy code:
N,M = map(int,input().split())
PYlist = []
for i in range(M):
    PYlist_ele = list(map(int,input().split()))
    PYlist_ele.append(i+1)
    PYlist.append(PYlist_ele)
PYlist.sort()
check = 0
count = 0
P_id = []
for i in range(M):
    if check == PYlist[i][0]:
        count +=1
    else:
        count = 1
    idup = '{:06}'.format(PYlist[i][0])
    iddown = '{:06}'.format(check)
    P_id.append([str(idup)+str(iddown),PYlist[i][2]])
P_id.sort(key=lambda x: x[1])
for ans in P_id:
    print(ans[0])

Fixed code:
N,M = map(int,input().split())
PYlist = []
for i in range(M):
    PYlist_ele = list(map(int,input().split()))
    PYlist_ele.append(i+1)
    PYlist.append(PYlist_ele)
PYlist.sort()
check = 0
count = 0
P_id = []
for i in range(M):
    if check == PYlist[i][0]:
        count +=1
    else:
        count = 1
        check = PYlist[i][0]
    idup = '{:06}'.format(PYlist[i][0])
    iddown = '{:06}'.format(count)
    P_id.append([str(idup)+str(iddown),PYlist[i][2]])
P_id.sort(key=lambda x: x[1])
for ans in P_id:
    print(ans[0])
Buggy code:
N, M = map(int, input().split())
l = []
for i in range(M):
  	l.append(list(map(int, input().split())))

def FillZero(num,f=6):
    s = ""
    s += (f - len(str(num))) * "0"
    s += str(num)
    return(s)

for i in range(M):
    l[i].append(i)

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

key0 = l[0][0]
key1 = 0
for i in range(M):
    if key0 == l[i][0]:
      	key1 += 1
        l[i][1] = key1
    else:
        key1 = 1
        l[i][1] = key1
        key0 += 1

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

for i in range(M):
    print(FillZero(l[i][0]) + FillZero(l[i][1]))

Fixed code:
N, M = map(int, input().split())
l = []
for i in range(M):
  	l.append(list(map(int, input().split())))

def FillZero(num,f=6):
    s = ""
    s += (f - len(str(num))) * "0"
    s += str(num)
    return(s)

for i in range(M):
    l[i].append(i)

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

key0 = l[0][0]
key1 = 0
for i in range(M):
    if key0 == l[i][0]:
        key1 += 1
        l[i][1] = key1
    else:
        key1 = 1
        l[i][1] = key1
        key0 = l[i][0]

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

for i in range(M):
    print(FillZero(l[i][0]) + FillZero(l[i][1]))
Buggy code:
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
p = [[i]+LIST() for i in range(m)]
q = [0]*(n+1)

p.sort(key=itemgetter(2))
for x in p:
    q[x[1]] += 1
    x.append(q[x[1]])

p.sort(key=itemgetter(0))
for x in p:
    print(str(x[1]).zfill(6), str(x[3]).zfill(6))

Fixed code:
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
p = [[i]+LIST() for i in range(m)]
q = [0]*(n+1)

p.sort(key=itemgetter(2))
for x in p:
    q[x[1]] += 1
    x.append(q[x[1]])

p.sort(key=itemgetter(0))
for x in p:
    print(str(x[1]).zfill(6)+str(x[3]).zfill(6))
Buggy code:
n,m=map(int,input().split())

ans=[[] for i in range(m)]
p_list=[[] for i in range(n)]

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

 ans[i]=str(p).zfill(6)
 p_list[p].append([i,y])

for pp in p_list:
 pp=sorted(pp,key=lambda x:x[1])
 num=0
 for ppp in pp:
  num+=1
  ans[ppp[0]]+=str(num).zfill(6)
 num=0

for i in ans:
 print(i)

Fixed code:
n,m=map(int,input().split())

ans=[[] for i in range(m)]
p_list=[[] for i in range(n+1)]

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

 ans[i]=str(p).zfill(6)

 p_list[p].append([i,y])

for pp in p_list:
 pp=sorted(pp,key=lambda x:x[1])
 num=0
 for ppp in pp:
  num+=1
  ans[ppp[0]]+=str(num).zfill(6)
 num=0

for i in ans:
 print(i)
Buggy code:
n, m = map(int, input().split())
py = []
s = '000000'
for i in range(m):
    p, y = map(int, input().split())
    py.append([p, y, i])
py.sort(key=lambda py:(py[0],py[1]))

py[0].append(1)
for i in range(m-1):
    a = 1
    if py[i][0] == py[i+1][0]:
        py[i+1].append(py[i][3]+1)
    else:
        py[i+1].append(1)
        
py.sort(key=lambda py:(py[2]))

for j in range(len(py)):
    print((s+str(py[j][0]))[-5:]+(s+str(py[j][3]))[-5:])

Fixed code:
n, m = map(int, input().split())
py = []
s = '000000'
for i in range(m):
    p, y = map(int, input().split())
    py.append([p, y, i])
py.sort(key=lambda py:(py[0],py[1]))

py[0].append(1)
for i in range(m-1):
    a = 1
    if py[i][0] == py[i+1][0]:
        py[i+1].append(py[i][3]+1)
    else:
        py[i+1].append(1)
        
py.sort(key=lambda py:(py[2]))

for j in range(len(py)):
    print((s+str(py[j][0]))[-6:]+(s+str(py[j][3]))[-6:])
Buggy code:
from heapq import heappush
N,M = map(int, input().split())
A = {}
prefs = []
years = []
for i in range(M):
    p,y = input().split()
    prefs.append(p)
    years.append(y)
    if p not in A:
        A[p] = [y]
    else:
        heappush(A[p], y)
res = {}
for k,v in A.items():
    for i in range(len(v)):
        res[k+v[i]] = str(i+1)
for p,y in zip(prefs, years):
    print(p.zfill(6) + res[k+y].zfill(6))


Fixed code:
from heapq import heappush, heappop
N,M = map(int, input().split())
A = {}
prefs = []
years = []
for i in range(M):
    p,y = input().split()
    prefs.append(p)
    years.append(y)
    if p not in A:
        A[p] = [int(y)]
    else:
        heappush(A[p], int(y))
res = {}
for k,v in A.items():
    for i in range(len(v)):
        res[k+str(heappop(v))] = str(i+1)
for p,y in zip(prefs, years):
    print(p.zfill(6) + res[p+y].zfill(6))
Buggy code:
N, M = map(int, input().split())
L = []
for i in range(M):
  P, Y = map(int, input().split())
  L.append((P, Y, i))
ans = ['']*(N)

L.sort(key=lambda x:(x[0], x[1]))
before = L[0][0]
num = 1
for i in range(M):
  if L[i][0] == before:
    num += 1
    id = '{:06d}'.format(L[i][0]) + '{:06d}'.format(num)
    ans[L[i][2]] = id
  else:
    num = 1
    id = '{:06d}'.format(L[i][0]) + '{:06d}'.format(num)
    ans[L[i][2]] = id
    before = L[i][0]
for city in ans:
  print(city)
    
  
  

Fixed code:
N, M = map(int, input().split())
L = []
for i in range(M):
  P, Y = map(int, input().split())
  L.append((P, Y, i))
ans = ['']*(M)
L.sort(key=lambda x:(x[0], x[1]))
before = L[0][0]
num = 0
for i in range(M):
  if L[i][0] == before:
    num += 1
    id = '{:06d}'.format(L[i][0]) + '{:06d}'.format(num)
    ans[L[i][2]] = id
  else:
    num = 1
    id = '{:06d}'.format(L[i][0]) + '{:06d}'.format(num)
    ans[L[i][2]] = id
    before = L[i][0]
for city in ans:
  print(city)
Buggy code:
# -*- coding: utf-8 -*-
from operator import itemgetter

N, M = list(map(int, input().split()))
A = [[0] * 4 for i in range(M)]
for i in range(M):
    A[i][0], A[i][1] = list(map(int, input().split()))
    A[i][2] = i

sorted_A = sorted(A, key=itemgetter(1))
print(sorted_A)

P_num = [1]*N
for a in sorted_A:
    y = a[0]
    a[3] = P_num[y-1]
    P_num[y-1] += 1

print(sorted_A)
B = sorted(sorted_A, key=itemgetter(2))
for b in B:
    print("%06d%06d" % (b[0], b[3]))


Fixed code:
# -*- coding: utf-8 -*-
from operator import itemgetter

N, M = list(map(int, input().split()))
A = [[0] * 4 for i in range(M)]
for i in range(M):
    A[i][0], A[i][1] = list(map(int, input().split()))
    A[i][2] = i

sorted_A = sorted(A, key=itemgetter(1))

P_num = [1]*N
for a in sorted_A:
    y = a[0]
    a[3] = P_num[y-1]
    P_num[y-1] += 1

B = sorted(sorted_A, key=itemgetter(2))
for b in B:
    print("%06d%06d" % (b[0], b[3]))
Buggy code:
n,m=map(int,input().split())
a=[[] for _ in range(n)]
ans=[None]*n

for i in range(m):
  p,y=map(int,input().split())
  a.append((y,i))
  
for i,b in enumerate(a):
  b.sort()
  for j,(y,k) in b:
    ans[k]='%06d%06d' % (i+1,j+1)
    
print(*ans,sep='\n')

Fixed code:
n,m=map(int,input().split())
a=[[] for _ in range(n)]
ans=[None]*m

for i in range(m):
  p,y=map(int,input().split())
  a[p-1].append((y,i))
  
for i,b in enumerate(a):
  b.sort()
  for j,(y,k) in enumerate(b):
    ans[k]='%06d%06d' % (i+1,j+1)
    
print(*ans,sep='\n')