qyliang/CodeNanoFix huggingface dataset:
Buggy code:
from operator import itemgetter

def main():
    N,M = list(map(int, input().split()))
    lst = []
    anslst = []
    for i in range(M):
        P,Y = list(map(int, input().split()))
        lst.append({'city_id':i, 'pref':P, 'year':Y})
    print(lst)
    for i in range(N):
        tmp = [ d for d in lst if d['pref'] == i+1]
        print(tmp)
        sor = sorted(tmp, key = itemgetter('year'))
        for j in range(len(sor)):
            city_id = sor[j]['city_id']
            pref = sor[j]['pref']
            year = sor[j]['year']
            id = '{0:06d}'.format(pref) + '{0:06d}'.format(j+1)
            anslst.append({'city_id':city_id, 'pref':pref, 'year':year, 'id':id})
    anslst = sorted(anslst, key = itemgetter('city_id'))
    print(anslst)
    for i in range(len(anslst)):
        print(anslst[i]['id'])

if __name__ == '__main__':
    main()


Fixed code:
from operator import itemgetter

def main():
    N,M = list(map(int, input().split()))
    lst = [[] for i in range(N)]
    anslst = []

    for i in range(M):
        P,Y = list(map(int, input().split()))
        lst[P-1].append({'city_id':i, 'pref':P, 'year':Y})

    for i in range(N):
        tmp = lst[i]
        tmp = sorted(tmp, key = itemgetter('year'))
        for j in range(len(tmp)):
            city_id = tmp[j]['city_id']
            pref = tmp[j]['pref']
            year = tmp[j]['year']
            id = '{0:06d}'.format(pref) + '{0:06d}'.format(j+1)
            anslst.append({'city_id':city_id, 'pref':pref, 'year':year, 'id':id})

    anslst = sorted(anslst, key = itemgetter('city_id'))
    for i in range(len(anslst)):
        print(anslst[i]['id'])

if __name__ == '__main__':
    main()
Buggy code:
N, M = map(int, input().split())
D = [[] for i in range(N)]

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

ans = [None]*M

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

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

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

ans = [None]*M

for i, d in enumerate(D):
    d.sort()
    for k, (y, j) in enumerate(d):
        ans[j] = "%06d%06d" % (i+1, k+1)
    
print(*ans, sep='\n')
Buggy code:
N, M = map(int, input().split())
l = [None] * M
for i in range(M):
	p, y = map(int, input().split())
	l[i] = [p, y, i]
l.sort()
ans = []
t = l[0][0]
x = 0
for i in l:
	if t == i[0]:
		x += 1
		ans.append([l[2], i[0], x])
	else:
		t = i[0]
		x = 1
		ans.append([l[2], i[0], x])
ans.sort()
for i in ans:
	p = str(i[1])
	x = str(i[2])
	print('0' * (6 - len(p)) + p + '0' * (6 - len(x)) + x)

Fixed code:
N, M = map(int, input().split())
l = [None] * M
for i in range(M):
	p, y = map(int, input().split())
	l[i] = [p, y, i]
l.sort()
ans = []
t = l[0][0]
x = 0
for i in l:
	if t == i[0]:
		x += 1
		ans.append([i[2], i[0], x])
	else:
		t = i[0]
		x = 1
		ans.append([i[2], i[0], x])
ans.sort()
for i in ans:
	p = str(i[1])
	x = str(i[2])
	print('0' * (6 - len(p)) + p + '0' * (6 - len(x)) + x)
Buggy code:
def identify(N: int, M: int, PY: list) -> list:
    _PY = [(i, p, y) for i, (p, y) in enumerate(PY)]
    _PY.sort(key=lambda x: x[2])
    _PY.sort(key=lambda x: x[1])

    now_p = 0
    now_o = 1
    ids = []
    for i, p, _ in _PY:
        if p != now_p:
            now_p = p
            now_o = 1
        ids.append((i, '{p:08}{o:08}'.format(p=p, o=now_o)))
        now_o += 1

    return [i for _, i in sorted(ids, key=lambda x: x[0])]


if __name__ == "__main__":
    N, M = map(int, input().split())
    PY = [tuple(int(s) for s in input().split()) for _ in range(M)]
    for ans in identify(N, M, PY):
        print(ans)


Fixed code:
def identify(N: int, M: int, PY: list) -> list:
    _PY = [(i, p, y) for i, (p, y) in enumerate(PY)]
    _PY.sort(key=lambda x: x[2])
    _PY.sort(key=lambda x: x[1])

    now_p = 0
    now_o = 1
    ids = []
    for i, p, _ in _PY:
        if p != now_p:
            now_p = p
            now_o = 1
        ids.append((i, '{p:06}{o:06}'.format(p=p, o=now_o)))
        now_o += 1

    return [i for _, i in sorted(ids, key=lambda x: x[0])]


if __name__ == "__main__":
    N, M = map(int, input().split())
    PY = [tuple(int(s) for s in input().split()) for _ in range(M)]
    for ans in identify(N, M, PY):
        print(ans)
Buggy code:
n,m=map(int,input().split())
city=[]
for i in range(m):
    a=i
    b,c=map(int,input().split())
    city.append([a,b,c])
city=sorted(city,key=lambda x:(x[1],x[2]))
print(city)
city[0].append(1)
for i in range(1,m):
    if city[i][1]!=city[i-1][1]:
        city[i].append(1)
    else:
        city[i].append(city[i-1][3]+1)
print(city)
for i in range(m):
    city[i].append(str(city[i][1]).zfill(6)+str(city[i][3]).zfill(6))
city=sorted(city,key=lambda x:(x[0]))
for i in range(m):
    print(city[i][4])

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

py = sorted(py, key=lambda x:x[1])
py = sorted(py, key=lambda x:x[0])
#print(py)

ans = [[0] * 2 for i in range(m)]
cnt = 0
val = py[0][2]
for i in range(m):
    if py[i][2] != val:
        cnt = 0
    cnt += 1

    ans[py[i][2]][0] = py[i][0]
    ans[py[i][2]][1] = cnt
#print(ans)
for i in range(m):
    print('0' * (6 - len(str(ans[i][0]))) + str(ans[i][0]) + '0' * (6 - len(str(ans[i][1]))) + str(ans[i][1]))


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

py = sorted(py, key=lambda x:x[1])
py = sorted(py, key=lambda x:x[0])
#print(py)

ans = [[0] * 2 for i in range(m)]
cnt = 0
val = py[0][0]
for i in range(m):
    #print(val)
    if py[i][0] != val:
        cnt = 0
        val = py[i][0]
    cnt += 1

    ans[py[i][2]][0] = py[i][0]
    ans[py[i][2]][1] = cnt
#print(ans)
for i in range(m):
    print('0' * (6 - len(str(ans[i][0]))) + str(ans[i][0]) + '0' * (6 - len(str(ans[i][1]))) + str(ans[i][1]))
Buggy code:
import itertools


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


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


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


if __name__ == "__main__":
    print(solve())
Buggy code:
n,m = map(int, input().split())
py = [[list(map(int, input().split()))] + [i] for i in range(m)]
py.sort(key=lambda x: [x[0], x[1]])
ans = []
P = [0] * (n + 1)
for p, y, i in py:
    P[p] += 1
    tmp = str(p).zfill(6) + str(P[p]).zfill(6)
    ans.append([i,tmp])
ans.sort()
for i,a in ans:
    print(a)

Fixed code:
n,m = map(int, input().split())
py = [list(map(int, input().split())) + [i] for i in range(m)]
py.sort(key=lambda x: [x[0], x[1]])
ans = []
P = [0] * (n + 1)
for p, y, i in py:
    P[p] += 1
    tmp = str(p).zfill(6) + str(P[p]).zfill(6)
    ans.append([i,tmp])
ans.sort()
for i,a in ans:
    print(a)
Buggy code:
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)

Fixed code:
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

ans1 = zip(index,ans)
ans1 = sorted(ans1)
index,ans = zip(*ans1)
for i in ans:
    print(i)
Buggy code:
from collections import defaultdict

n, m = map(int, input().split())
PY = [tuple(map(int, input().split())) for _ in range(m)]
ypi = sorted((y, p) for i, (p, y) in enumerate(PY))
d = defaultdict(lambda: 0)

ans = [None]*m

for y, p in ypi:
    d[p] += 1
    ans[i] = str(p).zfill(6) + str(d[p]).zfill(6)

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

Fixed code:
from collections import defaultdict

n, m = map(int, input().split())
PY = [tuple(map(int, input().split())) for _ in range(m)]
ypi = sorted((y, p, i) for i, (p, y) in enumerate(PY))
d = defaultdict(lambda: 0)

ans = [None]*m

for y, p, i in ypi:
    d[p] += 1
    ans[i] = str(p).zfill(6) + str(d[p]).zfill(6)

print(*ans, sep='\n')
Buggy code:
import sys
input = sys.stdin.readline

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

p.sort()
cnt = 1
pre = -1

for city in p:
    if city[0] == pre:
        cnt = cnt + 1
    else:
        pre = city[0]

    city.append("{:0>6}{:0>6}".format(city[0], cnt))

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

for city in p:
    print(city[3])

Fixed code:
import sys
input = sys.stdin.readline

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

p.sort()
cnt = 0
pre = -1

for city in p:
    if city[0] == pre:
        cnt = cnt + 1
    else:
        pre = city[0]
        cnt = 1

    city.append("{:0>6}{:0>6}".format(city[0], cnt))

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

for city in p:
    print(city[3])
Buggy code:
n, m = [int(i) for i in input().split(" ")]
ps = []
pc = [0 for i in range(0, n + 1)]

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

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

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

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

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

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

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

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

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

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

for i in range(0, m):
    print(ps[i][3])
Buggy code:
def con(var):
    var=str(var)
    while(len(var)<6):
        var="0"+var
    return var



def run():
    N,M=input().split()
    N=int(N)
    M=int(M)
    P=[-1]*M
    Y=[-1]*M
    arr=[]
    for i in range(M):
        P[i],Y[i]=input().split()
        P[i]=int(P[i])-1
        Y[i]=int(Y[i])
        arr.append([P[i],Y[i],i])
    arr=sorted(arr,key=lambda x:x[1])
    print(arr)
    ans=[0]*M
    cnt=[0]*N
    for i in range(M):
        cnt[arr[i][0]]=cnt[arr[i][0]]+1
        ans[arr[i][2]]=con(arr[i][0]+1)+con(cnt[arr[i][0]])
    for i in range(M):
        print(ans[i])
run()

Fixed code:
def con(var):
    var=str(var)
    while(len(var)<6):
        var="0"+var
    return var



def run():
    N,M=input().split()
    N=int(N)
    M=int(M)
    P=[-1]*M
    Y=[-1]*M
    arr=[]
    for i in range(M):
        P[i],Y[i]=input().split()
        P[i]=int(P[i])-1
        Y[i]=int(Y[i])
        arr.append([P[i],Y[i],i])
    arr=sorted(arr,key=lambda x:x[1])
    ans=[0]*M
    cnt=[0]*N
    for i in range(M):
        cnt[arr[i][0]]=cnt[arr[i][0]]+1
        ans[arr[i][2]]=con(arr[i][0]+1)+con(cnt[arr[i][0]])
    for i in range(M):
        print(ans[i])
run()
Buggy code:
# -*- coding: utf-8 -*-

import sys
import itertools
import math

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

ps=dict()
for c,(p,y) in enumerate(C):
    if not p in ps:
        ps[p]=[]
    ps[p].append((y,c))

qs=[]
for p,cs in ps.items():
    cs.sort()
    qs += [(c,p,i) for i,(y,c) in enumerate(cs)]

qs.sort()

for c,p,i in qs:
    print("{0:0=6}{1:0=6}".format(p,i))




Fixed code:
# -*- coding: utf-8 -*-

import sys
import itertools
import math

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

ps=dict()
for c,(p,y) in enumerate(C):
    if not p in ps:
        ps[p]=[]
    ps[p].append((y,c))

qs=[]
for p,cs in ps.items():
    cs.sort()
    qs += [(c,p,i) for i,(y,c) in enumerate(cs)]

qs.sort()

for c,p,i in qs:
    print("{0:0=6}{1:0=6}".format(p,i+1))
Buggy code:
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))

Fixed code:
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))
Buggy code:
from collections import defaultdict

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

d = defaultdict(list)

for x, y in py:
    d[x].append(int(y))

ans = {}

for k, v in d.items():
    print(k, v)
    for i, x in enumerate(sorted(v), start=1):
        ans[(k, str(x))] = k.zfill(6) + str(i).zfill(6)

for x in py:
    print(ans[x])


Fixed code:
from collections import defaultdict

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

d = defaultdict(list)

for x, y in py:
    d[x].append(int(y))

ans = {}

for k, v in d.items():
    for i, x in enumerate(sorted(v), start=1):
        ans[(k, str(x))] = k.zfill(6) + str(i).zfill(6)

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

Fixed code:
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))
Buggy code:
n,m=map(int,input().split())
somelists=[]
for i in range(m):
    a,b=map(int,input().split())
    somelists.append([i,a,b])

somelists.sort(key=lambda x:(x[1],x[2]))
numbers=0
prefs=1
for x in somelists:
    if x[1]==prefs:
        numbers+=1
        x.append(numbers)
    if x[1]!=prefs:
        numbers=1
        x.append(numbers)

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

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

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

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

prefs=1
numbers=0

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

somelists.sort(key=lambda x:x[0])
for _ in range(m):
    print(str(somelists[_][1]).zfill(6)+str(somelists[_][3]).zfill(6))
Buggy code:
def resolve():
    (N, M) = list(map(int,input().split(" ")))
    cities = [list(map(int, input().split(" "))) + [i] for i in range(M)]
    sorted_cities = sorted(cities, key=lambda x: (x[0], x[1]))

    pref = 0
    cnt = 0
    for city in sorted_cities:
        if pref != city[0]:
            pref = city[0]
            cnt = 0
        cnt = cnt + 1
        city.append("{:06d}{:06d}".format(pref, cnt))
    
    #sorted_cities = sorted(cities, key=lambda x: x[2])
    for city in sorted_cities:
        print(city[3])

if '__main__' == __name__:
    resolve()

Fixed code:
def resolve():
    (N, M) = list(map(int,input().split(" ")))
    cities = [list(map(int, input().split(" "))) + [i] for i in range(M)]
    sorted_cities = sorted(cities, key=lambda x: (x[0], x[1]))

    pref = 0
    cnt = 0
    for city in sorted_cities:
        if pref != city[0]:
            pref = city[0]
            cnt = 0
        cnt = cnt + 1
        city.append("{:06d}{:06d}".format(pref, cnt))
    
    sorted_cities = sorted(cities, key=lambda x: x[2])
    for city in sorted_cities:
        print(city[3])
        

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

if __name__=='__main__':
    main()

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

if __name__=='__main__':
    main()
Buggy code:
N,M=map(int,input().split())
PY=[list(map(int,input().split())) for i in range(M)]
x=collections.defaultdict(list)
for city,year in PY:
    x[city]+=[year]
for city,year in PY:
    num=bisect.bisect(x[city],year)
    print("%06d%06d"%(city,num))

Fixed code:
import collections,bisect
N,M=map(int,input().split())
PY=[list(map(int,input().split())) for i in range(M)]
x=collections.defaultdict(list)
for city,year in sorted(PY):
    x[city]+=[year]
for city,year in PY:
    num=bisect.bisect(x[city],year)
    print("%06d%06d"%(city,num))
Buggy code:
N,M = (int(x) for x in input().split())

p_y_list = []
y_count = [1]*(M+1)

for i in range(M):
    p,y = (int(x) for x in input().split())
    p_y_list[i] = [p,y,i]
p_y_list.sort(key = lambda x:x[1])

for i in p_y_list:
    i[1] = y_count[i[0]]
    y_count[i[0]] += 1

p_y_list.sort(key = lambda x:x[2])
for i in p_y_id_list:
    print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0"))

Fixed code:
N,M = (int(x) for x in input().split())

p_y_list = [0]*M
y_count = [1]*(N+1)

for i in range(M):
    p,y = (int(x) for x in input().split())
    p_y_list[i] = [p,y,i]
p_y_list.sort(key = lambda x:x[1])

for i in p_y_list:
    i[1] = y_count[i[0]]
    y_count[i[0]] += 1

p_y_list.sort(key = lambda x:x[2])
for i in p_y_list:
    print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0"))
Buggy code:
n = input().split()
l1 = []
for i in range(int(n[1])):
    l1.append(input().split())

for i in range(int(n[1])):
    for j in range(2):
        l1[i][j] = int(l1[i][j])

print(l1)
m = 0
for k in l1:
    k.append(m)
    m += 1

print(l1)
l3 = sorted(l1)
print(l3)

l3[0][1] = 1
for i in range(1,len(l3)):
    if l3[i][0]==l3[i-1][0]:
        l3[i][1]=l3[i-1][1]+1
    else:
        l3[i][1]=1

for i in range(len(l3)):
    l3[i][2],l3[i][0]=l3[i][0],l3[i][2]
for i in range(len(l3)):
    l3[i][1],l3[i][2]=l3[i][2],l3[i][1]
l3.sort()


for i in range(int(n[1])):
    for j in range(2):
        l3[i][j] = str(l3[i][j])

for i in range(len(l3)):
    print(str(l3[i][1]).zfill(6)+str(l3[i][2]).zfill(6))

Fixed code:
n = input().split()
l1 = []
for i in range(int(n[1])):
    l1.append(input().split())

for i in range(int(n[1])):
    for j in range(2):
        l1[i][j] = int(l1[i][j])


m = 0
for k in l1:
    k.append(m)
    m += 1


l3 = sorted(l1)


l3[0][1] = 1
for i in range(1,len(l3)):
    if l3[i][0]==l3[i-1][0]:
        l3[i][1]=l3[i-1][1]+1
    else:
        l3[i][1]=1

for i in range(len(l3)):
    l3[i][2],l3[i][0]=l3[i][0],l3[i][2]
for i in range(len(l3)):
    l3[i][1],l3[i][2]=l3[i][2],l3[i][1]
l3.sort()


for i in range(int(n[1])):
    for j in range(2):
        l3[i][j] = str(l3[i][j])

for i in range(len(l3)):
    print(str(l3[i][1]).zfill(6)+str(l3[i][2]).zfill(6))
Buggy code:
n,m=map(int,input().split())
py=[list(map(int,input().split()))]
l=[1]*n
for i in range(m):
    py[i].append(i+1)
py.sort()
for i in range(m):
    py[i].append( str(py[i][0]).zfill(6) + str(l[py[i][0]-1]).zfill(6))
    l[py[i][0]-1]+=1
py.sort(key=lambda x:x[2])
for i in range(m):
    print(py[i][-1])

Fixed code:
n,m=map(int,input().split())
py=[list(map(int,input().split())) for _ in range(m)]
l=[1]*n
for i in range(m):
    py[i].append(i+1)
py.sort()
for i in range(m):
    py[i].append( str(py[i][0]).zfill(6) + str(l[py[i][0]-1]).zfill(6))
    l[py[i][0]-1]+=1
py.sort(key=lambda x:x[2])
for i in range(m):
    print(py[i][-1])
Buggy code:
n,m=map(int,input().split())
A=[[] for i in range(n+1)]
I=[]
for i in range(m):
    p,y=map(int,input().split())
    A[p].append(y)
print(A)
for i in range(n+1):
    if A[i] != []:
        for j in range(len(A[i])):
            I.append([str(i).zfill(6) ,str(j+1).zfill(6)])
I.sort(key=lambda x: x[1])
for i in range(len(I)):print("".join(I[i]))

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

for i in range(n+1):A[i].sort(key=lambda x: x[1])

for i in range(n+1):
    if A[i] != []:
        for j in range(len(A[i])):
            I.append([A[i][j][0] ,str(i).zfill(6) ,str(j+1).zfill(6)])
I.sort(key=lambda x: x[0])
for i in range(len(I)):print(I[i][1],I[i][2],sep="")