qyliang/CodeNanoFix huggingface dataset:
Buggy code:
def fix(s):
  ss = str(s)
  while len(ss) < 6:
    ss = "0" + ss
  return ss

N, M = map(int, input().split())
PY = [(0,0,0)] * M
Num = [(0,0,0)] * M

for i in range (M):
    P, Y = map(int, input().split())
    PY[i] = (P, Y, i)
PY.sort()
print(PY)
for i in range (M):
  if PY[i-1][0] == PY[i][0]:
    Num[i] = (PY[i][2], PY[i][0], Num[i-1][2]+1)
  else:
    Num[i] = (PY[i][2], PY[i][0], 1)

Num.sort()
for i in range(M):
  print(fix(Num[i][1]) + fix(Num[i][2]))

Fixed code:
def fix(s):
  ss = str(s)
  while len(ss) < 6:
    ss = "0" + ss
  return ss

N, M = map(int, input().split())
PY = [(0,0,0)] * M
Num = [(0,0,0)] * M

for i in range (M):
    P, Y = map(int, input().split())
    PY[i] = (P, Y, i)
PY.sort()

for i in range (M):
  if PY[i-1][0] == PY[i][0]:
    Num[i] = (PY[i][2], PY[i][0], Num[i-1][2]+1)
  else:
    Num[i] = (PY[i][2], PY[i][0], 1)

Num.sort()
for i in range(M):
  print(fix(Num[i][1]) + fix(Num[i][2]))
Buggy code:
N, M = map(int, input().split())
kv = {}
lst = []
for _ in range(M):
    x, y = map(int, input().split())
    lst.append("{0} {1}".format(x, y))
    if x in kv:
        kv[x][y] = 1
    else:
        kv[x] = {y:1}

for k1 in sorted(kv.keys()):
    keys = sorted(kv[k1].keys())
    for idx, k2 in enumerate(keys, 1):
        kv[k1][k2] = idx

print(kv)
for s in lst:
    x, y = map(int, s.split())
    print("{0:06d}{1:06d}".format(x,kv[x][y]))

Fixed code:
N, M = map(int, input().split())
kv = {}
lst = []
for _ in range(M):
    x, y = map(int, input().split())
    lst.append("{0} {1}".format(x, y))
    if x in kv:
        kv[x][y] = 1
    else:
        kv[x] = {y:1}

for k1 in sorted(kv.keys()):
    keys = sorted(kv[k1].keys())
    for idx, k2 in enumerate(keys, 1):
        kv[k1][k2] = idx

for s in lst:
    x, y = map(int, s.split())
    print("{0:06d}{1:06d}".format(x,kv[x][y]))
Buggy code:
from operator import itemgetter

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

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

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

Fixed code:
from operator import itemgetter

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

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

for i in sorted(ans, key=itemgetter(2)):
    print(str(i[0]).zfill(6) + str(i[1]).zfill(6))
Buggy code:
n, m = list(map(int, input().split()))
li = []
yli = []
for _ in range(m):
    p, y = list(map(int, input().split()))
    li.append((y, p))
    yli.append(y)

import numpy as np
idx = np.argsort(yli)
srt = sorted(li)
ans = []
from collections import Counter
pcnt = Counter()
for p, y in srt:
    pcnt[p] += 1    
    ans.append('{:06}{:06}'.format(p, pcnt[p]))

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


Fixed code:
n, m = list(map(int, input().split()))
li = []
yli = []
for _ in range(m):
    p, y = list(map(int, input().split()))
    li.append((y, p))
    yli.append(y)

import numpy as np
idx = np.argsort(yli).argsort()
srt = sorted(li)
ans = []
from collections import Counter
pcnt = Counter()
for y, p in srt:
    pcnt[p] += 1
    ans.append('{:06}{:06}'.format(p, pcnt[p]))

for i in idx:
    print(ans[i])
Buggy code:
N, M = map(int, input().split(' '))

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

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

p = cities[0][0]
cnt = 1
for i in range(M):

    if (cities[i][0] == p):
        cities[i].append(str(p).zfill(6) + str(cnt).zfill(6))
        cnt += 1
    else:
        p = cities[i][0]
        cnt = 1
        cities[i].append(str(p).zfill(6) + str(cnt).zfill(6))
        cnt += 1

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

for i in range(M):
    print(cities[i][3])


Fixed code:
N, M = map(int, input().split(' '))

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

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

p = cities[0][0]
cnt = 1
for i in range(M):

    if (cities[i][0] == p):
        cities[i].append(str(p).zfill(6) + str(cnt).zfill(6))
        cnt += 1
    else:
        p = cities[i][0]
        cnt = 1
        cities[i].append(str(p).zfill(6) + str(cnt).zfill(6))
        cnt += 1

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

for i in range(M):
    print(cities[i][3])
Buggy code:
N,M=map(int,input().split())
PY=[[0,0]]
ans=[]
for _ in range(M):
    PY.append(list(map(int,input().split())))
PY.sort(key=lambda x:(x[0],x[1]))

for i in range(M):
    number=""
    if PY[i+1][0]!=PY[i][0]:
        x=1
    else:
        x+=1
    number+=str(PY[i+1][0]).zfill(6)
    number+=str(x).zfill(6)
    ans.append(number)

for i in ans:
    print(i)

Fixed code:
N,M=map(int,input().split())
PY=[[0,0]]
ans=[]
for m in range(M):
    L=list(map(int,input().split()))
    L.append(m+1)
    PY.append(L)
PY.sort(key=lambda x:(x[0],x[1]))

for i in range(M):
    number=""
    if PY[i+1][0]!=PY[i][0]:
        x=1
    else:
        x+=1
    number+=str(PY[i+1][0]).zfill(6)
    number+=str(x).zfill(6)
    ans.append([number,PY[i+1][2]])

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

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

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


if debug:
    N = 2
    m = 10
else:
    (N, M) = list(map(int, input().split()))

if debug:
    p_y_list = [
        [1, 30]
        ,[1, 20]
        ,[1, 10]
        ,[1, 3]
        ,[2, 63]
        ,[2, 33]
        ,[2, 23]
        ,[3, 21]
        ,[3, 7]
    ]

city_id_list = []
for z in range(M):
# for (P, Y) in p_y_list:
    
    if not debug:
        (P, Y) = list(map(int, input().split()))

    city_id_list.append([Y, P])
    
city_id_list = sorted( city_id_list, key= lambda x: x[0])

state_cnt = {}
tmp_list = []
for (Y, P) in city_id_list:
    
    if P not in state_cnt.keys():
        state_cnt[P] = 1
    elif P in state_cnt.keys():
        state_cnt[P] += 1
        
    tmp_id = str(P).zfill(6) + str(state_cnt[P]).zfill(6)
    
    tmp_list.append([state_cnt[P], tmp_id])
    
for cid in sorted(tmp_list, key=lambda x: (x[0], x[1])):
    print(cid[1])

Fixed code:
debug = 0
"""
N: state num
M: city num
"""


if debug:
    N = 2
    m = 10
else:
    (N, M) = list(map(int, input().split()))

if debug:
    p_y_list = [
        [1, 30]
        ,[1, 20]
        ,[1, 10]
        ,[1, 3]
        ,[2, 63]
        ,[2, 33]
        ,[2, 23]
        ,[3, 21]
        ,[3, 7]
    ]

city_id_list = []
for num, z in enumerate(range(M)):
# for num, (P, Y) in enumerate(p_y_list):
    
    if not debug:
        (P, Y) = list(map(int, input().split()))

    city_id_list.append([Y, P, num])
    
city_id_list = sorted( city_id_list, key= lambda x: x[0])

state_cnt = {}
tmp_list = []
for (Y, P, num) in city_id_list:
    
    if P not in state_cnt.keys():
        state_cnt[P] = 1
    elif P in state_cnt.keys():
        state_cnt[P] += 1
        
    tmp_id = str(P).zfill(6) + str(state_cnt[P]).zfill(6)
    
    tmp_list.append([num, tmp_id])
    
for cid in sorted(tmp_list, key=lambda x: x[0]):
    print(cid[1])
Buggy code:
#!/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()

Fixed code:
#!/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()
Buggy code:
N, M = [int(i) for i in input().split()]

PY = []
PYd = {i:[] for i in range(1, N+1)}

for i in range(M):
    x, y = [int(i) for i in input().split()]
    PYd[x].append(y)
    PY.append((x,y))
    
for i in PYd.keys():
    PYd[i].sort()
    
for p,y in PY:
    str_p = str(p).zfill(6)
    index = str(bisect.bisect(PYd[p], y)).zfill(6)
    print(str_p+index)

Fixed code:
import bisect

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

PY = []
PYd = {i:[] for i in range(1, N+1)}

for i in range(M):
    x, y = [int(i) for i in input().split()]
    PYd[x].append(y)
    PY.append((x,y))
    
for i in PYd.keys():
    PYd[i].sort()
    
for p,y in PY:
    str_p = str(p).zfill(6)
    index = str(bisect.bisect(PYd[p], y)).zfill(6)
    print(str_p+index)
Buggy code:
n,m=map(int,input().split())
x=[[] for _ in range(n+1)]
ans=[-1]*m
for i in range(m):
    p,y=map(int,input().split())
    x[p].append([y,i])

for p in range(1,n+1):
    tmp=sorted(x[p])
    print(p,tmp)
    for j in range(len(tmp)):
        ans[tmp[j][1]]=str(p).zfill(6)+str(j+1).zfill(6)

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

Fixed code:
n,m=map(int,input().split())
x=[[] for _ in range(n+1)]
ans=[-1]*m
for i in range(m):
    p,y=map(int,input().split())
    x[p].append([y,i])

for p in range(1,n+1):
    x[p].sort()
    for j in range(len(x[p])):
        ans[x[p][j][1]]=str(p).zfill(6)+str(j+1).zfill(6)

for i in range(m):
    print(ans[i])
Buggy code:
import bisect
from collections import defaultdict
n,m = map(int,input().split())
p = [list(map(int, input().split())) for _ in range(m)]

a = defaultdict(list)
for x,y in sorted(p):
    a[x].append(y)
for x,y in p:
    z=bisect.bisect(a[x],y)
    print("{0:06d}{0:06d}".format(x,z))

Fixed code:
import bisect
from collections import defaultdict
n,m = map(int,input().split())
p = [list(map(int, input().split())) for _ in range(m)]
 
a = defaultdict(list)
for x,y in sorted(p):
    a[x].append(y)
for x,y in p:
    
    z=bisect.bisect(a[x],y)
    print("{0:06d}{1:06d}".format(x,z))
Buggy code:
N, M = map(int, input().split())
pref_dict = {}

for i in range(M):
    P, Y = map(int, input().split())
    pref_dict[i] = [P, Y]

sorted_dict = sorted(pref_dict.items(), key= lambda x: (x[1][0], x[1],[1]))
print(sorted_dict)

ans_dict = {}
buf = ""
count = 1

for tup in sorted_dict:

    row = tup[0]
    pref_name = f"00000{tup[1][0]}"[-6:]

    if pref_name == buf:
        count += 1
    else:
        count = 1

    pref_id = f"00000{count}"[-6:]
    ans_dict[row] = [pref_name, pref_id]
    buf = pref_name

for key, value in sorted(ans_dict.items(), key=lambda x: x[0]):
    print(*value, sep="")

Fixed code:
N, M = map(int, input().split())
pref_dict = {}

for i in range(M):
    P, Y = map(int, input().split())
    pref_dict[i] = [P, Y]

sorted_dict = sorted(pref_dict.items(), key= lambda x: (x[1][0], x[1],[1]))
ans_dict = {}
buf = ""
count = 1

for tup in sorted_dict:

    row = tup[0]
    pref_name = "00000{}".format(tup[1][0])
    pref_name = pref_name[-6:]

    if pref_name == buf:
        count += 1
    else:
        count = 1

    pref_id = "00000{}".format(count)
    pref_id = pref_id[-6:]
    ans_dict[row] = [pref_name, pref_id]
    buf = pref_name

for key, value in sorted(ans_dict.items(), key=lambda x: x[0]):
    print(*value, sep="")
Buggy code:
N, M = map(int, input().split())

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

print(city)

out = [0]*M
cnt = 1
for i in range(len(city)):
	out[city[i][2]] = '{0:06d}{1:06d}'.format(city[i][0], cnt)
	try:
		if city[i+1][0] == city[i][0]: cnt += 1
		else: cnt = 1
	except(IndexError):
		cnt += 1

for o in out:
	print(o)
	

Fixed code:
N, M = map(int, input().split())

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

out = [0]*M
cnt = 1
for i in range(len(city)):
	out[city[i][2]] = '{0:06d}{1:06d}'.format(city[i][0], cnt)
	try:
		if city[i+1][0] == city[i][0]: cnt += 1
		else: cnt = 1
	except(IndexError):
		cnt += 1

for o in out:
	print(o)
Buggy code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n, m = map(int, input().split())
p = defaultdict(lambda :defaultdict(int))
e = [[int(i) for i in input().split()] for i in range(m)] 
p_index = [0] * (100001)
for i in e:
    pp, yy = i[0], i[1]
    p_index[pp] += 1
    p[pp][yy] = p_index[pp]

for i in e:
    print("{:0=6}".format(i[0]) + "{:0=6}".format(p[i[0]][i[1]]))

Fixed code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n, m = map(int, input().split())
p = defaultdict(lambda :defaultdict(list))
e = [[int(i) for i in input().split()] for i in range(m)] 
p_index = defaultdict(int)
for i in e:
    pp, yy = i[0], i[1]
    p[pp][yy] = 0

for i in p:
    count = 0
    l = sorted(p[i])
    for j in l:
        count += 1
        p[i][j] += count

for i in e:
    print("{:0=6}".format(i[0]) + "{:0=6}".format(p[i[0]][i[1]]))
Buggy code:
n,m = map(int,input().split())
ls = []
for i in range(m):
    p,y = map(int,input().split())
    ls.append([p,y])
ls.sort(key= lambda x:x[1])
ls.sort(key= lambda x:x[0])
pre = ls[0][0]
cnt = 1
for p,y in ls:
    if p==pre:
        print(str(p).zfill(6) + str(cnt).zfill(6))
        cnt+=1
    else:
        pre = p
        print(str(p).zfill(6) + str(1).zfill(6))
        cnt=2


Fixed code:
n,m = map(int,input().split())
ls = []
for i in range(m):
    p,y = map(int,input().split())
    ls.append([p,y,i])
ls.sort(key= lambda x:x[1])
ls.sort(key= lambda x:x[0])
pre = ls[0][0]
cnt = 1
ans = []
for p,y,i in ls:
    if p==pre:
        ans.append(   (str(p).zfill(6) + str(cnt).zfill(6) ,i))
        cnt+=1
    else:
        pre = p
        ans.append((str(p).zfill(6) + str(1).zfill(6),i))
        cnt=2
ans.sort(key=lambda x:x[1])
for a,i in ans:
    print(a)
Buggy code:
N, M = map(int, input().split())
data = [[] for i in range(M)]
ans = [""] * M
num = [0] * M
for i in range(M):
    ken, year = map(int, input().split())
    data[i] = [ken, year, i]
    
data.sort(key=lambda x:x[1])

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

for i in ans:
    print(i)

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

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

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

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

check.sort()

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

ans.sort()

for aa, bb in ans:
    print(bb)

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

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

check.sort()

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

ans.sort()

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

ps = sorted(ps)
ps

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

ans = sorted(ans)

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

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

ps = sorted(ps)
ps

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

ans = sorted(ans)

for i in ans:
    aw = i[1]
    aww = str(aw).zfill(12)
    print(aww)
Buggy code:
n,m = map(int,input().split())
s = []
for i in range(m):
    a =list(map(int,input().split()))
    a.append(i)
    s.append(a)
s.sort()
print(s)
ans = [0 for i in range(m)]
num = 0
ans_ = ""
for i in range(m):
    if num != s[i][0]:
        num = s[i][0]
        count = 1
    ans_ = str(s[i][0])
    ans__ = str(count)
    for j in range(5):
        if len(ans_) < 6:
            ans_ = "0"+ans_
        if len(ans__) < 6:
            ans__ = "0" + ans__
    ans[s[i][2]] = ans_+ans__
    count += 1
for i in range(m):
    print(ans[i])

Fixed code:
n,m = map(int,input().split())
s = []
for i in range(m):
    a =list(map(int,input().split()))
    a.append(i)
    s.append(a)
s.sort()
ans = [0 for i in range(m)]
num = 0
ans_ = ""
for i in range(m):
    if num != s[i][0]:
        num = s[i][0]
        count = 1
    ans_ = str(s[i][0])
    ans__ = str(count)
    for j in range(5):
        if len(ans_) < 6:
            ans_ = "0"+ans_
        if len(ans__) < 6:
            ans__ = "0" + ans__
    ans[s[i][2]] = ans_+ans__
    count += 1
for i in range(m):
    print(ans[i])
Buggy code:
import sys
input = sys.stdin.readline

a,b = map(int,input().split())

d = []
for i in range(b):
    k,kk = map(int,input().split())
    d.append([k, kk,0])

da = sorted(d)

kkk = da[0][0]
ll = 0
for i in da:
    kkkk = i[0]
    if kkk == kkkk:
        ll += 1
        i[2] += ll
    else:
        kkk = kkkk
        ll = 1
        i[2] += ll
for i in d:
    p = (da.index(i)-1)
    n = str(i[0])
    m = str(d[p][2])

    n = "0"*(6-len(n)) + n
    m = "0"*(6-len(m)) + m

    print(n+m)

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

a,b = map(int,input().split())
aa = []
d = []
for i in range(b):
    k,kk = map(int,input().split())
    d.append([k, kk,i+1])

da = sorted(d)

kkk = da[0][0]
ll = 0
for i in range(b):
    kkkk = da[i][0]
    if kkk == kkkk:
        ll += 1
    else:
        kkk = kkkk
        ll = 1
    aa.append([da[i][2],da[i][0],ll])
aa.sort()

for i in aa:
    m = str(i[1])
    n = str(i[2])
    m = "0"*(6-len(m))+m
    n = "0"*(6-len(n))+n
    print(m+n)
Buggy code:
from sys import stdin
import bisect

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = [[]for _ in range(n)]
lin2 = []
for i in range(m):
    lin[li[j][0]-1].append(li[i][1])

for j in range(n):
    liv = sorted(lin[j])
    lin2.append(liv)

for k in range(m):
    tosi = str(li[k][0]).zfill(6)
    ban =  str(bisect.bisect(lin2[li[k][0]-1],li[k][1])).zfill(6)
    print(tosi+ban)

Fixed code:
from sys import stdin
import bisect

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = [[]for i in range(n)]
lin2 = []
li3 = []
for j in range(m):
    lin[li[j][0]-1].append(li[j][1])
    lin2.append(li[j][0]-1)

for j in range(n):
    liv = sorted(lin[j])
    li3.append(liv)

for k in range(m):
    tosi = str(li[k][0]).zfill(6)
    ban =  str(bisect.bisect(li3[li[k][0]-1],li[k][1])).zfill(6)
    print(tosi+ban)
Buggy code:
from bisect import bisect_left
n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(n)]
t = [[] for _ in range(n)]
for p, y in data:
  t[p - 1].append(y)
for i in range(n):
  t[i].sort()
for p, y in data:
  nth = bisect_left(t[p - 1], y) + 1
  print("%06d%06d" % (p, nth))


Fixed code:
from bisect import bisect_left
n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(m)]
t = [[] for _ in range(n)]
for p, y in data:
  t[p - 1].append(y)
for i in range(n):
  t[i].sort()
for p, y in data:
  nth = bisect_left(t[p - 1], y) + 1
  print("%06d%06d" % (p, nth))
Buggy code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
L = []
for i in range(M):
    P, Y = map(int, input().split())
    L.append([P, Y])

L = sorted(L)

reset = 0
count = 0
for i in range(M):
    if L[i][0] != reset:
        reset = L[i][0]
        count = 1
    else:
        count += 1
    
    ans = str(reset).zfill(6) + str(count).zfill(6)
    print(ans)

Fixed code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
L = []
for i in range(M):
    P, Y = map(int, input().split())
    L.append([P, Y, i])

L = sorted(L)

reset = 0
count = 0
ans = []
for i in range(M):
    if L[i][0] != reset:
        reset = L[i][0]
        count = 1
    else:
        count += 1
    
    ans.append([L[i][2], str(reset).zfill(6) + str(count).zfill(6)])

ans = sorted(ans)

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

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

years.sort()

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

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

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

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

years.sort()

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

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