qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import sys
import collections
import itertools
import math
import re
from collections import Counter
from collections import deque
import bisect


MOD = 10 ** 9 + 7

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


KenList = [[] for _ in range(N)]


PYlist = [None] * M
for i in range(M):
    P, Y = [int(x) for x in input().split()]
    P = P - 1
    PYlist[i] = (P, Y)
    KenList[P].append((i, Y))


# for i in range(N):
    # KenList[i] = sorted(KenList[i], key=lambda x: x[1])

for i in range(M):
    ken = PYlist[i][0]
    idx = 0
    kl = KenList[ken]
    for j in range(len(kl)):
        if kl[j][0] == i:
            idx = j
            break
    print("{0:06d}{1:06d}".format(ken+1, idx+1))


sys.exit(0)


Fixed code:
import sys
import collections
import itertools
import math
import re
from collections import Counter
from collections import deque
import bisect


MOD = 10 ** 9 + 7

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

KenList = [[] for _ in range(N)]

PYlist = [None] * M
for i in range(M):
    P, Y = [int(x) for x in input().split()]
    P = P - 1
    PYlist[i] = (P, Y)
    KenList[P].append((i, Y))


for i in range(N):
    KenList[i] = sorted(KenList[i], key=lambda x: x[1])

cityOrder = [None] * N
for i in range(N):
    kl = KenList[i]
    dic = {}
    for j in range(len(kl)):
        city = kl[j][0]
        dic[city] = j
    cityOrder[i] = dic


for i in range(M):
    ken = PYlist[i][0]
    kl = KenList[ken]
    idx = cityOrder[ken][i]
    # for j in range(len(kl)):
    #     if kl[j][0] == i:
    #         idx = j
    #         break

    print("{0:06d}{1:06d}".format(ken+1, idx+1))


sys.exit(0)
Buggy code:
import numpy as np
N, M = [int(a) for a in input().split()]
P = []
Y = []

for _ in range(M):
    p, y =  [int(a) for a in input().split()]
    P.append(p)
    Y.append(y)

index = {}
id = ["" for _ in range(len(P))]

for i in np.argsort(Y):
    index[P[i]] = index.get(P[i], 0)
    id[i] = "{0:06d}".format(P[i])+"{0:06d}".format(index[P[i]])
    index[P[i]] += 1

for i in id:
    print(i)

Fixed code:
import numpy as np
N, M = [int(a) for a in input().split()]
P = []
Y = []

for _ in range(M):
    p, y =  [int(a) for a in input().split()]
    P.append(p)
    Y.append(y)

index = {}
id = ["" for _ in range(len(P))]

for i in np.argsort(Y):
    index[P[i]] = index.get(P[i], 1)
    id[i] = "{0:06d}".format(P[i])+"{0:06d}".format(index[P[i]])
    index[P[i]] += 1

for i in id:
    print(i)
Buggy code:
#ABC113_C

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

PYi.sort()

prep=PYi[0][0]
cc=1#city code
PYi[0][1]=cc
for j in range(1,M):
    p=PYi[j][0]
    if prep==p:
        cc+=1
    else:
        cc=1
    PYi[j][1]=cc
    prep=p
        
PYi.sort(key=lambda x:x[2])

def padding(A):
    A=str(A)
    while len(A)<6:
        A=str(0)+A
    return A

for i in range(M):
    print(padding(PYi[i][0]),padding(PYi[i][1]))

Fixed code:
#ABC113_C

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

PYi.sort()

prep=PYi[0][0]
cc=1#city code
PYi[0][1]=cc
for j in range(1,M):
    p=PYi[j][0]
    if prep==p:
        cc+=1
    else:
        cc=1
    PYi[j][1]=cc
    prep=p
        
PYi.sort(key=lambda x:x[2])

def padding(A):
    A=str(A)
    while len(A)<6:
        A=str(0)+A
    return A

for i in range(M):
    ansi=padding(PYi[i][0])+padding(PYi[i][1])
    print(ansi)
Buggy code:
def main():
    n, m = map(int, input().split())
    query = []
    result =  [[] for i in range(n)]
    for i in range(m):
        qList = list(map(int, input().split()))
        query.append(qList)
        result[qList[0]-1].append(qList[1])
 
    for i in result:
        i.sort()
 
    for city in query:
        rank = bisect.bisect_left(result[city[0]-1], city[1])
        ans = "%06d%06d"%(city[0],rank+1)
        print(ans)
 
if __name__ == "__main__":
    main()

Fixed code:
def main():
    import bisect
    n, m = map(int, input().split())
    query = []
    result =  [[] for i in range(n)]
    for i in range(m):
        qList = list(map(int, input().split()))
        query.append(qList)
        result[qList[0]-1].append(qList[1])
 
    for i in result:
        i.sort()
 
    for city in query:
        rank = bisect.bisect_left(result[city[0]-1], city[1])
        ans = "%06d%06d"%(city[0],rank+1)
        print(ans)
 
if __name__ == "__main__":
    main()
Buggy code:
def main():
    import sys
    import bisect
    input = sys.stdin.readline

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

    result = [sorted(i) for i in result]
 
    for city in query:
        rank = bisect.bisect_left(result[city[0]-1], city[1])
        ans = "%06d%06d"%(city[0],rank)
        print(ans)

main()

Fixed code:
def main():
    import sys
    import bisect
    input = sys.stdin.readline

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

    result = [sorted(i) for i in result]
 
    for city in query:
        rank = bisect.bisect_left(result[city[0]-1], city[1])
        ans = "%06d%06d"%(city[0],rank+1)
        print(ans)

main()
Buggy code:
#!/usr/bin/env python3

import numpy as np

# line1 = "2 3"
# line2 = ['1 32', '2  63', '1 12']

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

PY = np.array(PY)
cn = np.array([np.arange(np.shape(PY)[0])])
cc = np.array([np.zeros(np.shape(PY)[0], dtype=int)])

city_list = np.hstack([cn.T, PY, cc.T])
cl_ysort = city_list[np.argsort(city_list[:, 2])]
city_count = np.zeros(N+1, dtype=int)
for i, cinfo in enumerate(cl_ysort):
    pref = cinfo[1]
    city_count[pref] += 1
    cl_ysort[i, 3] = city_count[pref]

cl_idsort = cl_ysort[np.argsort(cl_ysort[:, 0])]

[print('{:06d}{:06d}'.format(cl[1], cl[3])) for cl in cl_idsort]


Fixed code:
#!/usr/bin/env python3

import numpy as np

# line1 = "2 3"
# line2 = ['1 32', '2  63', '1 12']

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

PY = np.array(PY)
cn = np.array([np.arange(np.shape(PY)[0])])
cc = np.array([np.zeros(np.shape(PY)[0], dtype=int)])

city_list = np.hstack([cn.T, PY, cc.T])
cl_ysort = city_list[np.argsort(city_list[:, 2])]
city_count = np.zeros(N+1, dtype=int)
for i, cinfo in enumerate(cl_ysort):
    pref = cinfo[1]
    city_count[pref] += 1
    cl_ysort[i, 3] = city_count[pref]

cl_idsort = cl_ysort[np.argsort(cl_ysort[:, 0])]

[print('{:06d}{:06d}'.format(cl[1], cl[3])) for cl in cl_idsort]
Buggy code:
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    py = []
    ls = [1] * (n + 1)
    for i in range(m):
        p, y = list(map(int, input().rstrip('\n').split()))
        py.append([p, y, 0, i])
    py.sort()
    for i in range(m):
        py[i][2] = ls[py[i][0]]
        ls[py[i][0]] += 1
    py.sort(key=lambda x: x[3])
    for i in range(len(py)):
        a = ["0"] * 6
        a.append(list(str(py[i][0])))
        a = a[-6:]
        b = ["0"] * 6
        b.append(list(str(py[i][2])))
        b = b[-6:]
        print("".join(a + b))


if __name__ == '__main__':
    slove()


Fixed code:
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    py = []
    ls = [1] * (n + 1)
    for i in range(m):
        p, y = list(map(int, input().rstrip('\n').split()))
        py.append([p, y, 0, i])
    py.sort()
    for i in range(m):
        py[i][2] = ls[py[i][0]]
        ls[py[i][0]] += 1
    py.sort(key=lambda x: x[3])
    for i in range(len(py)):
        a = ["0"] * 6
        a = a + list(str(py[i][0]))
        a = a[-6:]
        b = ["0"] * 6
        b = b + list(str(py[i][2]))
        b = b[-6:]
        print("".join(a + b))


if __name__ == '__main__':
    slove()
Buggy code:
n, m = map(int, input().split())
pys = [list(map(int, input().split())) for _ in range(m)]
map_ = {}
for i, (p, y) in enumerate(pys):
    map_.setdefault(p, [])
    map_[p].append(i)
for val in map_.values():
    val.sort()

ans = [None] * m
for key, val in map_.items():
    for num, i in enumerate(val):
        ans[i] = '{:06d}'.format(key) + '{:06d}'.format(num + 1)
for a in ans:
    print(a)


Fixed code:
n, m = map(int, input().split())
pys = [list(map(int, input().split())) for _ in range(m)]
map_ = {}
for i, (p, y) in enumerate(pys):
    map_.setdefault(p, [])
    map_[p].append(i)

for val in map_.values():
    val.sort(key=lambda i: pys[i][1])

ans = [None] * m
for key, val in map_.items():
    for num, i in enumerate(val):
        ans[i] = '{:06d}'.format(key) + '{:06d}'.format(num + 1)
for a in ans:
    print(a)
Buggy code:
n,m = map(int,input().split())
P = [list(map(int,input().split()))+[0] for i in range(m)]
X = sorted(P,key = lambda x:x[1])
city = {}
for p,y,z in X:
    if p in city:
        city[p] += 1
    else:
        city[p] = 1
    z = city[p]
for p,y,z in P:
    print(str(p).zfill(6)+str(z).zfill(6))


Fixed code:
n,m = map(int,input().split())
PY = [list(map(int,input().split()))+[0] for i in range(m)]
X = sorted(PY,key = lambda x:x[1])
city = {}
for x in X:
    p = x[0]
    y = x[1]
    if p in city:
        city[p] += 1
    else:
        city[p] = 1
    x[2] = city[p]
for p,y,z in PY:
    print(str(p).zfill(6)+str(z).zfill(6))
Buggy code:
#!/usr/bin/env python3

class City:
    def __init__(self, i1, p, y, o=None):
        self.i1 = i1
        self.p = p
        self.y = y
        self.o = o

    def __repr__(self):
        return f"City({self.i1}, {self.p}, {self.y}, {self.o})"

    def get_id(self):
        return f"{self.p:06}{self.o:06}"

def put_ids(n, cities):
    years = {i: [] for i in range(1, n + 1)}
    for c in cities:
        years[c.p].append(c.y)

    year_to_order = {i: {} for i in range(1, n + 1)}
    for i in range(1, n + 1):
        ys = sorted(years[i])
        for j0, y in enumerate(ys):
            year_to_order[i][y] = j0 + 1

    for c in cities:
        c.o = year_to_order[c.p][c.y]

def main():
    n, m = map(int, input().split())
    cities = []
    for i0 in range(m):
        p, y = map(int, input().split())
        city = City(i0, p, y)
        cities.append(city)
    put_ids(n, cities)
    # for c in cities:
    #     print(c.get_id())

main()


Fixed code:
#!/usr/bin/env python3

class City:
    def __init__(self, i1, p, y, o=None):
        self.i1 = i1
        self.p = p
        self.y = y
        self.o = o

    # def __repr__(self):
    #     return f"City({self.i1}, {self.p}, {self.y}, {self.o})"

    def get_id(self):
        return "%06d%06d" % (self.p, self.o)

def put_ids(n, cities):
    years = {i: [] for i in range(1, n + 1)}
    for c in cities:
        years[c.p].append(c.y)

    year_to_order = {i: {} for i in range(1, n + 1)}
    for i in range(1, n + 1):
        ys = sorted(years[i])
        for j0, y in enumerate(ys):
            year_to_order[i][y] = j0 + 1

    for c in cities:
        c.o = year_to_order[c.p][c.y]

def main():
    n, m = map(int, input().split())
    cities = []
    for i0 in range(m):
        p, y = map(int, input().split())
        city = City(i0, p, y)
        cities.append(city)
    put_ids(n, cities)
    for c in cities:
        print(c.get_id())

main()
Buggy code:
from operator import itemgetter
n,m=map(int,input().split())
a=[]
for i in range(m):
    pi,yi=map(int,input().split())
    a.append([i,pi,yi])
b=[]
c=[]
for i in range(n):
    b.append([])
    c.append([])
for i in range(m):
    x=a[i][0]
    y=a[i][2]
    b[a[i][1]-1].append([x,y])

for i in range(n):
    b[i].sort(key=itemgetter(1))
    l=len(b[i])
    for j in range(l):
        a[b[i][j][0]].append(j+1)
for i in range(m):
    x=a[i][1]
    y=a[i][3]
    print('{0:06d}{0:06d}'.format(x,y))



Fixed code:
from operator import itemgetter
n,m=map(int,input().split())
a=[]
for i in range(m):
    pi,yi=map(int,input().split())
    a.append([i,pi,yi])
b=[]
c=[]
for i in range(n):
    b.append([])
    c.append([])
for i in range(m):
    x=a[i][0]
    y=a[i][2]
    b[a[i][1]-1].append([x,y])

for i in range(n):
    b[i].sort(key=itemgetter(1))
    l=len(b[i])
    for j in range(l):
        a[b[i][j][0]].append(j+1)
for i in range(m):
    xi=a[i][1]
    yi=a[i][3]
    print('{0:06d}{1:06d}'.format(xi,yi))
Buggy code:
n, m = map(int, input().split())
l = [list(map(int, input().split(' '))) for _ in range(m)]
#print(l)
l = sorted(l)
#print(n,m)
#print(l)

x = l[0][0]
y = 1
#print(x)

for i in range(m):
    if l[i][0] == x:
        l[i][1] = y
        y += 1
    else:
        y = 1
        l[i][1] = y
        y += 1
        x = l[i][0]
#print(l)
l = sorted(l, key=lambda x:(x[1]))
#print(l)
l = list(reversed(l))
#print(l)
z = []
for j in range(m):
    z.append(str(l[j][0]).rjust(6,'0') + str(l[j][1]).rjust(6,'0'))
#z.sort()
for k in range(m):
    print(z[k])

Fixed code:
n, m = map(int, input().split())
l = [list(map(int, input().split(' '))) for _ in range(m)]
#print(l)
for v in range(m):
    l[v].append(v)

l = sorted(l)
#print(n,m)
#print(l)

x = l[0][0]
y = 1

for i in range(m):
    if l[i][0] == x:
        l[i][1] = y
        y += 1
    else:
        y = 1
        l[i][1] = y
        y += 1
        x = l[i][0]
#print(l)
l = sorted(l, key=lambda x:(x[2]))
#print(l)
z = []
for j in range(m):
    z.append(str(l[j][0]).rjust(6,'0') + str(l[j][1]).rjust(6,'0'))
#z.sort()
for k in range(m):
    print(z[k])
Buggy code:
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]))


Fixed code:
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]))
Buggy code:
import sys
n,m = map(int,input().split())
py = []
d = dict()

for i in range(m):
    (a,b) = map(int,input().split())
    py.append((a,b))
sort_py = sorted(py)

tmp_p = sort_py[0][0]
cnt = 1
for p,y in sort_py:
    if p == tmp_p:
        d[(p,y)] = cnt
    else:
        tmp_p = p
        cnt = 1
        d[(p,y)] = cnt
    cnt += 1
print(d)
for i in range(m):
    print('{0} {1}'.format(str(py[i][0]).zfill(6), str(d[py[i]]).zfill(6)))    


Fixed code:
import sys
n,m = map(int,input().split())
py = []
d = dict()

for i in range(m):
    (a,b) = map(int,input().split())
    py.append((a,b))
sort_py = sorted(py)

tmp_p = sort_py[0][0]
cnt = 1
for p,y in sort_py:
    if p == tmp_p:
        d[(p,y)] = cnt
    else:
        tmp_p = p
        cnt = 1
        d[(p,y)] = cnt
    cnt += 1

for i in range(m):
    print('{0}{1}'.format(str(py[i][0]).zfill(6), str(d[py[i]]).zfill(6)))
Buggy code:
N,M = map(int,input().split())
py_list = []
d = dict()
for i in range(M):
    p,y = map(int,input().split())
    py_list.append([p,y])
py_sorted =  sorted(py_list)
p_temp = py_sorted[0][0]
count = 1
for p,y in py_sorted:
    if p_temp != p:
        p_temp = p
        count = 1
    d[(p,y)] = count
    count += 1

for i in range(M):
    s = d[(py_list[i][0],py_list[i][-1])]
    s = str(s)
    print(str(py_list[i][0]).zfill(6),s.zfill(6))



Fixed code:
N,M = map(int,input().split())
py_list = []
d = dict()
for i in range(M):
    p,y = map(int,input().split())
    py_list.append([p,y])
py_sorted =  sorted(py_list)
p_temp = py_sorted[0][0]
count = 1
for p,y in py_sorted:
    if p_temp != p:
        p_temp = p
        count = 1
    d[(p,y)] = count
    count += 1

for i in range(M):
    s = d[(py_list[i][0],py_list[i][-1])]
    s = str(s)
    ss = str(py_list[i][0]).zfill(6) + s.zfill(6)
    print(ss.strip())
Buggy code:
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])

Fixed code:
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])
Buggy code:
N,M = map(int,input().split())
ls = []
for i in range(M):
    P,Y = map(int,input().split())
    ls.append([i,P,Y])
ls.sort(key=lambda x:x[1])
num = 1
city = ls[0][1]
for i in range(M):
    if ls[i][1] == city:
        ls[i][2] = num
        num += 1
    else:
        num = 1
        ls[i][2] = num
        city = ls[i][1]
ls.sort(key=lambda x:x[0])
for i in range(M):
    print('{0:06d}'.format(ls[i][1])+'{0:06d}'.format(ls[i][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()
num = 1
city = ls[0][0]
for i in range(M):
    if ls[i][0] == city:
        ls[i][1] = num
        num += 1
    else:
        num = 1
        ls[i][1] = num
        city = ls[i][0]
        num += 1
ls.sort(key=lambda x:x[2])
for i in range(M):
    print('{0:06d}'.format(ls[i][0])+'{0:06d}'.format(ls[i][1]))
Buggy code:
N, M = map(int, input().split())
pref = [[] for _ in range(N)]
P,Y = [0]*M,[0]*M
for i in range(M):
    P[i],Y[i] = map(int, input().split())
    pref[P[i]-1].append(Y[i])

for i in range(N):
    pref[i].sort()

from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort

def solve(P,Y,pref):
    ans = []
    for p, y in zip(P,Y):
        ind = bisect_left(Y,y)+1
        num = '0'*(6-len(str(p)))+str(p)+'0'*(6-len(str(ind)))+str(ind)
        ans.append(num)
    return ans
print(*solve(P,Y,pref),sep='\n')

Fixed code:
N, M = map(int, input().split())
pref = [[] for _ in range(N)]
P,Y = [0]*M,[0]*M
for i in range(M):
    P[i],Y[i] = map(int, input().split())
    pref[P[i]-1].append(Y[i])

for i in range(N):
    pref[i].sort()

from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort

def solve(P,Y,pref):
    ans = []
    for p, y in zip(P,Y):
        ind = bisect_left(pref[p-1],y)+1
        num = '0'*(6-len(str(p)))+str(p)+'0'*(6-len(str(ind)))+str(ind)
        ans.append(num)
    return ans
print(*solve(P,Y,pref),sep='\n')
Buggy code:
import numpy as np
from bisect import bisect_right
from time import time
start = time()
n, m = map(int, input().split())
p = []
y = []
d = {i + 1: [] for i in range(n)}
# n, m = 10**5, 10**5
# p = [10**5]*m
# y = [i + 1 for i in range(m)]
for i in range(m):
    p_, y_ = map(int, input().split())
    # p_, y_ = p[i], y[i]
    p.append(p_)
    y.append(y_)
    d[p_].append(y_)
for i in d.keys():
    d[i] = sorted(d[i])
for i in range(m):
    # print('{:06d}{:06d}'.format(p[i], d[p[i]].index(y[i]) + 1))
    print('{:06d}{:06d}'.format(p[i], bisect_right(d[p[i]], y[i])))

print(time() - start)


Fixed code:
import numpy as np
from bisect import bisect_right
# from time import time
# start = time()
n, m = map(int, input().split())
p = []
y = []
d = {i + 1: [] for i in range(n)}
# n, m = 10**5, 10**5
# p = [10**5]*m
# y = [i + 1 for i in range(m)]
for i in range(m):
    p_, y_ = map(int, input().split())
    # p_, y_ = p[i], y[i]
    p.append(p_)
    y.append(y_)
    d[p_].append(y_)
for i in d.keys():
    d[i] = sorted(d[i])
for i in range(m):
    # print('{:06d}{:06d}'.format(p[i], d[p[i]].index(y[i]) + 1))
    print('{:06d}{:06d}'.format(p[i], bisect_right(d[p[i]], y[i])))
#
# print(time() - start)
Buggy code:
n,m=map(int,input().split())
ken=[0 for i in range(n)]
for i in range(m):
    p,y=map(int,input().split())
    ken[p-1]+=1
ken0=[]
for i in range(n):
    for j in range(ken[i]):
        mae=str(i+1)
        ato=str(j+1)
        while len(mae)<6:
            mae='0'+mae
        while len(ato)<6:
            ato='0'+ato
        ken0.append(mae+ato)
for i in ken0:
    print(i)

Fixed code:
n,m=map(int,input().split())
ken=[[] for i in range(n)]
for i in range(m):
    p,y=map(int,input().split())
    ken[p-1].append([i,y])
for i in range(n):
    ken[i].sort(key=lambda x:x[1])
ken0=[]
for i in range(n):
    for j in range(len(ken[i])):
        mae=str(i+1)
        ato=str(j+1)
        while len(mae)<6:
            mae='0'+mae
        while len(ato)<6:
            ato='0'+ato
        ken0.append([ken[i][j][0],mae+ato])
ken0.sort(key=lambda x:x[0])
for i in ken0:
    print(i[1])
Buggy code:
n, m = list(map(int, input().split()))
city_list = []

for i in range(m):
    pm, ym = list(map(int, input().split()))
    city_list.append([i,pm,ym])

city_count = {}
city = {}

for i,p,y in sorted(city_list, key=lambda x: x[1]):
    if not p in city_count:
        city_count[p] = 1
    else:
        city_count[p] += 1
    city[i,p] = city_count[p]

for i,p,y in city_list:
    print("{:0=6}{:0=6}".format(p, city[i,p]))

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

for i in range(m):
    pm, ym = list(map(int, input().split()))
    city_list.append([i,pm,ym])

city_count = {}
city = {}

for i,p,y in sorted(city_list, key=lambda x: x[2]):
    if not p in city_count:
        city_count[p] = 1
    else:
        city_count[p] += 1
    city[i,p] = city_count[p]

for i,p,y in city_list:
    print("{:0=6}{:0=6}".format(p, city[i,p]))
Buggy code:
from operator import itemgetter

N,M=map(int,input().split())
PY=[]
ans=[0 for i in range(M)]
cc=[0 for i in range(N)]
for i in range(M):
    PYi=list(map(int,input().split()))
    PY.append([i,PYi[0],PYi[1]])
     
PY=sorted(PY, key=itemgetter(2))

for i in range(M):
    cc[PY[i][1]-1]+=1
    ans[PY[i][0]]=cc[PY[i][1]-1]

for i in range(M):
    a=format(PY[i][1],'06d')
    b=format(ans[i],'06d')
    print(a+b)

Fixed code:
from operator import itemgetter

N,M=map(int,input().split())
PY=[]
ans=[0 for i in range(M)]
cc=[0 for i in range(N)]
for i in range(M):
    PYi=list(map(int,input().split()))
    PY.append([i,PYi[0],PYi[1]])
     
PY=sorted(PY, key=itemgetter(2))

for i in range(M):
    cc[PY[i][1]-1]+=1
    ans[PY[i][0]]=format(PY[i][1],'06d')+format(cc[PY[i][1]-1],'06d')

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