qyliang/CodeNanoFix huggingface dataset:
Buggy code:
# -*- coding: utf-8 -*-
from operator import itemgetter
n = int(input())
restList = []
for i in range(n):
    city, p = map(str, input().split())
    restList.append([i + 1, city, int(p)])
restList.sort(key=itemgetter(1))

city = restList[0][1]
same_list = []
for R in restList:
    if R[1] == city:
        same_list.append(R)
    else:
        if same_list:
            same_list.sort(key=itemgetter(2), reverse=True)
            for s in same_list:
                print(s[0])
            same_list = []
            same_list.append(R)
    city = R[1]
if same_list:
    for s in same_list:
        print(s[0])


Fixed code:
# -*- coding: utf-8 -*-
from operator import itemgetter
n = int(input())
restList = []
for i in range(n):
    city, p = map(str, input().split())
    restList.append([i + 1, city, int(p)])
restList.sort(key=itemgetter(1))

city = restList[0][1]
same_list = []
for R in restList:
    if R[1] == city:
        same_list.append(R)
    else:
        if same_list:
            same_list.sort(key=itemgetter(2), reverse=True)
            for s in same_list:
                print(s[0])
            same_list = []
            same_list.append(R)
    city = R[1]
if same_list:
    same_list.sort(key=itemgetter(2), reverse=True)
    for s in same_list:
        print(s[0])
Buggy code:
from operator import itemgetter
n=int(input())
l=[[] for i in range(n)]
for i in range(n):
  s,p=input().split()
  l[i].append(s)
  l[i].append(int(p))
  l[i].append(i+1)
l2=sorted(l)
l3=sorted(l2,key=itemgetter(1),reverse=True)
for i in range(n):
  print(l3[i][2])

Fixed code:
from operator import itemgetter
n=int(input())
l=[[] for i in range(n)]
for i in range(n):
  s,p=input().split()
  l[i].append(s)
  l[i].append(int(p))
  l[i].append(i+1)
l2=sorted(l,key=itemgetter(1),reverse=True)
l3=sorted(l2,key=itemgetter(0))
for i in range(n):
  print(l3[i][2])
Buggy code:
n=int(input())
rest=[0]*n
for i in range(n):
  a,b=map(str,input().split())
  b=int(b)
  rest[i]=[i,a,b]
rest.sort(key=lambda x:x[1])
rest.sort(key=lambda x:x[2])

for i in range(n):
  print(rest[i][0])

Fixed code:
n=int(input())
rest=[0]*n
for i in range(n):
  a,b=map(str,input().split())
  b=int(b)
  rest[i]=[i+1,a,b]


rest.sort(key=lambda x:x[2],reverse=True)
rest.sort(key=lambda x:x[1])



for i in range(n):
  print(rest[i][0])
Buggy code:
N = input()
lst = []
for i in range(N):
  s, p = map(int, input().split())
  lst.append([s, p])
  lst_2 = sort(key = lambda x : (x[0], -1 * int(x[1])))
  
for i in lst_2:
  print(i[2] + 1)

Fixed code:
N = int(input())
lst = []
for i in range(N):
  s, p = input().split()
  lst.append([s, p, i])
  lst_2 = sorted(lst, key = lambda x : (x[0], -1 * int(x[1])))
  
for i in lst_2:
  print(i[2] + 1)
Buggy code:
n = int(input());
for el in sorted(sorted([[i]+input().split() for i in range(n)], key=lambda x:x[2])[::-1], key=lambda x:x[1]): print(el[0]+1)

Fixed code:
n = int(input());
for el in sorted(sorted([[i]+input().split() for i in range(n)], key=lambda x:int(x[2]))[::-1], key=lambda x:x[1]): print(el[0]+1)
Buggy code:
a=int(input())
c=[input().split(" ")for i in range(0,a)]
for i in c:
    i[1]=int(i[1])
#print(c)
d=sorted(c,key=lambda x:(x[0],-x[1]))
#print(d)
for i in c:
    print(d.index(i)+1)

Fixed code:
a=int(input())
c=[input().split(" ")for i in range(0,a)]
for i in c:
    i[1]=int(i[1])
#print(c)
d=sorted(c,key=lambda x:(x[0],-x[1]))
#print(d)
for j in d:
    print(c.index(j)+1)
Buggy code:
n = int(input())
L = []
i = 0
while i < n:
    s,p = map(str,input().split(' '))
    L.append((s,p,i))
    i += 1
print(L)
L.sort()
ans = ''
for l in L:
    ans += str(l[2]-1)+'\n'
print(ans[:-1])

Fixed code:
n = int(input())
L = []
i = 0
while i < n:
    s,p = map(str,input().split(' '))
    p = -1*int(p)
    L.append((s,p,i))
    i += 1
L.sort()
ans = ''
for l in L:
    ans += str(l[2]+1)+'\n'
print(ans[:-1])
Buggy code:
N = int(input())
list_all = list()
list_name = list()
list_number = list()

for n in range(N):
  par = input()
  pars = par.split(' ')
  list_all.append([n+1,pars[0],pars[1]])
  list_name.append(pars[0])
list_unique = sorted(list(set(list_name)))

for name in list_unique:
  l = list()
  for elem in list_all:
    if elem[1] == name:
      l.append([elem[2],elem[0]])
  l = sorted(l, reverse=True)
  for tmp in l:
    list_number.append(tmp[1])

for num in list_number:
  print(num)


Fixed code:
N = int(input())
list_all = list()
list_name = list()
list_number = list()

for n in range(N):
  par = input()
  pars = par.split(' ')
  list_all.append([n+1,pars[0],int(pars[1])])
  list_name.append(pars[0])
list_unique = sorted(list(set(list_name)))

for name in list_unique:
  l = list()
  for elem in list_all:
    if elem[1] == name:
      l.append([elem[2],elem[0]])
  l = sorted(l, reverse=True)
  for tmp in l:
    list_number.append(tmp[1])

for num in list_number:
  print(num)
Buggy code:
from functools import cmp_to_key
def cmp(x, y):
  if x[0] < y[0]:
    return -1
  elif x[0] > y[0]:
    return 1
  else:
    return int(y[1]) - int(x[1])
n = int(input())
d = [input().split() for _ in range(n)]
for i in range(n):
  d[i].append(i + 1)
d.sort(key = cmp_to_key(cmp))
for i in range(n):
print(d[i][2])


Fixed code:
from functools import cmp_to_key
def cmp(x, y):
  if x[0] < y[0]:
    return -1
  elif x[0] > y[0]:
    return 1
  else:
    return int(y[1]) - int(x[1])
n = int(input())
d = [input().split() for _ in range(n)]
for i in range(n):
  d[i].append(i + 1)
d.sort(key = cmp_to_key(cmp))
for i in range(n):
  print(d[i][2])
Buggy code:
n = int(input())
li_w = list()

for _ in range(n):
    li_w.append(input().split())

li_sorted = sorted(li_w, key=lambda x: (x[0], 100 - int(x[1])))
for a in li_w:
    print(li_sorted.index(a))


Fixed code:
n = int(input())
li_w = list()

for _ in range(n):
    li_w.append(input().split())

li_sorted = sorted(li_w, key=lambda x: (x[0], 100 - int(x[1])))
for a in li_sorted:
    print(li_w.index(a) + 1)
Buggy code:
n = int(input())
n_list = [0]*n
for i in range(n):
    n_list[i] = input().split()
    n_list[i].append(i+1)
for i in range(n):
    n_list[i][1] = int(n_list[i][1])
n_list.sort()
n_list.append("dum")
print(n_list)
L = 0
for i in range(n):
    if n_list[i][0] != n_list[i+1][0]:
        for j in range(i,L-1,-1):
            print(n_list[j][2])
        L = i+1

Fixed code:
n = int(input())
n_list = [0]*n
for i in range(n):
    n_list[i] = input().split()
    n_list[i].append(i+1)
for i in range(n):
    n_list[i][1] = int(n_list[i][1])
n_list.sort()
n_list.append("dum")
#print(n_list)
L = 0
for i in range(n):
    if n_list[i][0] != n_list[i+1][0]:
        for j in range(i,L-1,-1):
            print(n_list[j][2])
        L = i+1
Buggy code:
n=int(input())

list2=[]

for i in range(n):
    list=[j for j in input().split()]
    list[1]=int(list[1])
    list2.append(list)

#print(list2)

list3=sorted(list2, key=lambda x:(x[0],-x[1]))

#print(list3)

for i in list2:
    print(list3.index(i)+1)


Fixed code:
n=int(input())

list2=[]

for i in range(n):
    list=[j for j in input().split()]
    list[1]=int(list[1])
    list2.append(list)

#print(list2)

list3=sorted(list2, key=lambda x:(x[0],-x[1]))

#print(list3)

for i in list3:
    print(list2.index(i)+1)
Buggy code:
N = int(input())
s = [(lambda x, v: (x, -int(v)))(*input().split()) for i in range(N)]
s2 = s.copy()

s.sort()

print(s)
for i in s:
    print(s2.index(i)+1)


Fixed code:
N = int(input())
s = [(lambda x, v: (x, -int(v)))(*input().split()) for i in range(N)]
s2 = s.copy()

s.sort()
for i in s:
    print(s2.index(i)+1)
Buggy code:
n = int(input())

restrunt=[]

for i in range(n):
    a, b = input().split()
    restrunt.append( {"s":a, "t":int(b), "nom":i+1} )

restrunt.sort(key=lambda res:res["p"], reverse=True)
restrunt.sort(key=lambda res: res["s"])
for res in restrunt:
    print(res["nom"])


Fixed code:
n = int(input())

restrunt=[]

for i in range(n):
    a, b = input().split()
    restrunt.append( {"s":a, "p":int(b), "nom":i+1} )

restrunt.sort(key=lambda res:res["p"], reverse=True)
restrunt.sort(key=lambda res: res["s"])

for res in restrunt:
    print(res["nom"])
Buggy code:
N = int(input())
SP = []
for i in range(N):
    S, P = map(str, input().split())
    SP.append([S, int(P), i+1])

SP.sort(key = lambda x:x[1], reverse=True)
SP.sort(key = lambda x:x[0])

for e in SP:
    print(e[2])
    
print(SP)

Fixed code:
N = int(input())
SP = []
for i in range(N):
    S, P = map(str, input().split())
    SP.append([S, int(P), i+1])

SP.sort(key = lambda x:x[1], reverse=True)
SP.sort(key = lambda x:x[0])

for e in SP:
    print(e[2])
Buggy code:
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
rest = []
for i in range(N):
    c, s = input().split()
    s = -int(s)
    rest.append([c, s, i])

rest = sorted(rest, key=lambda x: [x[0], x[1]])
for r in rest:
    print(r[2])


Fixed code:
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
rest = []
for i in range(N):
    c, s = input().split()
    s = -int(s)
    rest.append([c, s, i])

rest = sorted(rest, key=lambda x: [x[0], x[1]])
for r in rest:
    print(r[2]+1)
Buggy code:
n = int(input())
sp = []
for i in range(n):
    spi = list(input().split())
    spi.append(i+1)
    sp.append(spi)

nsp = sorted(sp, key=lambda x: x[1], reverse=True)
nsp = sorted(nsp, key=lambda x: x[0])

for i in range(n):
    print(nsp[i][2])


Fixed code:
n = int(input())
sp = []
for i in range(n):
    spi = list(input().split())
    spi[1] = int(spi[1])
    spi.append(i+1)
    sp.append(spi)

nsp = sorted(sp, key=lambda x: x[1], reverse=True)
nsp = sorted(nsp, key=lambda x: x[0])

for i in range(n):
    print(nsp[i][2])
Buggy code:
N = int(input())
rest_dict = {}
city_list = []
for i in range(N):
    city, score = input().split()
    if city not in city_list:
        city_list.append(city)
        rest_dict[city] = [[score, i]]
    else:
        rest_dict[city].append([score, i])

coty_list = sorted(city_list)
for city in city_list:
    rest_list = rest_dict[city]
    rest_list = sorted(rest_list, reverse=True)
    for rest in rest_list:
        print(rest[1]+1)

Fixed code:
N = int(input())
rest_dict = {}
city_list = []
for i in range(N):
    city, score = input().split()
    if city not in city_list:
        city_list.append(city)
        rest_dict[city] = [[int(score), i]]
    else:
        rest_dict[city].append([int(score), i])

city_list = sorted(city_list)
for city in city_list:
    rest_list = rest_dict[city]
    rest_list = sorted(rest_list, reverse=True)
    for rest in rest_list:
        print(rest[1]+1)
Buggy code:
N = int(input())
L1 = []
for i in range(N):
    L1.append(list(input().split()))

L2 = L1

ans=[]
for i in L1:
    seq = 1
    for j in L2:
        if i[0] > j[0]:
            seq += 1
        elif i[0] == j[0]:
            if i[1] < j[1]:
                seq += 1
    ans.append(seq)

print(ans)

for i in range(N):
    print(ans.index(i+1)+1)
    


Fixed code:
N = int(input())
L1 = []
for i in range(N):
    L1.append(list(input().split()))

L2 = L1

ans=[]
for i in L1:
    seq = 1
    for j in L2:
        if i[0] > j[0]:
            seq += 1
        elif i[0] == j[0]:
            if int(i[1]) < int(j[1]):
                seq += 1
    ans.append(seq)
    
for i in range(N):
    print(ans.index(i+1)+1)
Buggy code:
N = int(input())
Lis = []
for i in range(N):
	S, P = input().split()
	Lis.append([i+1, S, int(P)])
print (Lis)
Lis = sorted(Lis, key = lambda x: (x[1], -x[2]))
print (Lis)
for i in range(N):
	print(Lis[i][0])

Fixed code:
N = int(input())
Lis = []
for i in range(N):
	S, P = input().split()
	Lis.append([i+1, S, int(P)])
Lis = sorted(Lis, key = lambda x: (x[1], -x[2]))
for i in range(N):
	print(Lis[i][0])
Buggy code:
from operator import itemgetter
i = int(input())

data = []

def chg(x,y):
	print("hoge")
	if x[0] == y[0]:
		return x[1] > y[1]
	else:
		return x[0] > y[0]

for i in range(i):
	ip = input().split(' ')
	dt = [ip[0],int(ip[1])]
	data.append(dt)


ls = sorted(data,key=itemgetter(1),reverse=True)
ls = sorted(ls,key=itemgetter(0))

print(ls)

for i in ls:
	cnt = 0
	for j in data:
		if i == j:
			break
		cnt += 1
	
	print(cnt + 1)
	
	



Fixed code:
from operator import itemgetter
i = int(input())

data = []

def chg(x,y):
	print("hoge")
	if x[0] == y[0]:
		return x[1] > y[1]
	else:
		return x[0] > y[0]

for i in range(i):
	ip = input().split(' ')
	dt = [ip[0],int(ip[1])]
	data.append(dt)


ls = sorted(data,key=itemgetter(1),reverse=True)
ls = sorted(ls,key=itemgetter(0))

for i in ls:
	cnt = 0
	for j in data:
		if i == j:
			break
		cnt += 1
	
	print(cnt + 1)
Buggy code:
N=int(input())
SP=[]
for i in range(N):
  S,P=input()
  SP.append([S,int(P),i+1])
  
l=sorted(SP,key = lamda SP : (SP[0],-SP[1]))

for i in l:
  print(SP[2])

Fixed code:
N=int(input())
SP=[]
for i in range(N):
  S,P=input().split()
  SP.append([S,int(P),i+1])
  
l=sorted(SP,key = lambda SP : (SP[0],-SP[1]))

for i in l:
  print(i[2])
Buggy code:
n = int(input())
sp = [input().split() for _ in range(n)]

for i in range(n):
    sp[i][1] = int(sp[i][1])
    sp[i] = sp[i]+[i+1]
    
sp_s0 = sorted(sp, key=lambda x:(x[0], -x[1]), reverse=False)
print(sp_s0)

for i in range(n):
    print(sp_s0[i][2])

Fixed code:
n = int(input())
sp = [input().split() for _ in range(n)]

for i in range(n):
    sp[i][1] = int(sp[i][1])
    sp[i] = sp[i]+[i+1]
    
sp_s0 = sorted(sp, key=lambda x:(x[0], -x[1]), reverse=False)

for i in range(n):
    print(sp_s0[i][2])
Buggy code:
n=int(input())
sp=[]
for i in range(n):
    s,p=input().split()
    sp.append(s,-int(p),i+1)
sp.sort()
for i in sp:
    print(i[2])


Fixed code:
n=int(input())
sp=[]
for i in range(n):
    s,p=input().split()
    sp.append((s,-int(p),i+1))
sp.sort()
for i in sp:
    print(i[2])
Buggy code:
from operator import itemgetter
N = int(input())
SP_1 = [list(input().split()) for i in range(N)]
for i in range(N) :
    SP_1[i][1] = int(SP_1[i][1])
buf = 0
SP_2 = SP_1
SP_1 = sorted(SP_1,key = itemgetter(0))
# print(SP_1)
for i in range(1,N) :
    if SP_1[i][0] != SP_1[i-1][0] :
        print(SP_1[buf:i])
        SP_1[buf:i] = sorted(SP_1[buf:i],key = itemgetter(1),reverse = True)
        buf = i
SP_1[buf:N] = sorted(SP_1[buf:N],key=itemgetter(1),reverse = True)
# print(SP_1) 
for i in range(N) :
    for j in range(N) :
        if SP_1[i] == SP_2[j] :
            print(j+1)
            break

Fixed code:
from operator import itemgetter
N = int(input())
SP_1 = [list(input().split()) for i in range(N)]
for i in range(N) :
    SP_1[i][1] = int(SP_1[i][1])
buf = 0
SP_2 = SP_1
SP_1 = sorted(SP_1,key = itemgetter(0))
# print(SP_1)
for i in range(1,N) :
    if SP_1[i][0] != SP_1[i-1][0] :
        #print(SP_1[buf:i])
        SP_1[buf:i] = sorted(SP_1[buf:i],key = itemgetter(1),reverse = True)
        buf = i
SP_1[buf:N] = sorted(SP_1[buf:N],key=itemgetter(1),reverse = True)
# print(SP_1) 
for i in range(N) :
    for j in range(N) :
        if SP_1[i] == SP_2[j] :
            print(j+1)
            break
Buggy code:
n = int(input())
a = []
for i in range(n):
    s, p  = input().split()
    p = int(p)
    a.append([s,p,i])
a.sort(key = lambda x:x[0],reverse = True)
a.sort(key = lambda x:x[1],reverse=True)
for i in a:
    print(i[2]+1)

Fixed code:
n=int(input())
a=[]
for i in range(n):
    x,y=input().split()
    a.append((i+1,x,int(y)))
a.sort(key=lambda x:x[2],reverse=True)
a.sort(key=lambda x:x[1])
for i in range(n):
    print(a[i][0])
Buggy code:
from sys import stdin

n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
#print(*data, sep='\n')
tmp = sorted(data, key=lambda x:x[1], reverse=True)
ans = sorted(tmp, key=lambda x:x[0])
for i in range(n) :print(data.index(ans[i])+1)

Fixed code:
from sys import stdin

n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
#print(*data, sep='\n')
tmp = sorted(data, key=lambda x:int(x[1]), reverse=True)
ans = sorted(tmp, key=lambda x:x[0])
#print(ans)
for i in range(n) :print(data.index(ans[i])+1)
Buggy code:
from sys import stdin

N = int(input())
# print(N)

bcs = [list(x.split()) for x in stdin.readlines()]

for i in range(N):
	bcs[i].append(int(i+1))
	# print(bcs[i])

bcs.sort(key=lambda x:x[1], reverse=True)
bcs.sort(key=lambda x: x[0])

for i in range(N):
	print(bcs[i][2])

Fixed code:
from sys import stdin

N = int(input())
# print(N)

bcs = [list(x.split()) for x in stdin.readlines()]

for i in range(N):
	bcs[i][1] = int(bcs[i][1])
	bcs[i].append(int(i+1))
	# print(bcs[i])

bcs.sort(key=lambda x:x[1], reverse=True)
bcs.sort(key=lambda x: x[0])

# print(bcs)
for i in range(N):
	print(bcs[i][2])
Buggy code:
from collections import defaultdict

N = int(input())

D = defaultdict(list)
for i in range(N):
    s,p = input().split()
    D[s].append((i+1,p))
    
for k in sorted(D.keys()):
    for v in sorted(D[k],key=lambda x:x[1],reverse=True):
        print(v[0])

Fixed code:
from collections import defaultdict

N = int(input())

D = defaultdict(list)
for i in range(N):
    s,p = input().split()
    D[s].append((i+1,int(p)))
    
for k in sorted(D.keys()):
    for v in sorted(D[k],key=lambda x:x[1],reverse=True):
        print(v[0])
Buggy code:
n = int(input())
s = [0]*n
p = [0]*n
l = [[] for i in range(n)]

for i in range(n):
    s[i],p[i] = input().split()
    l[i] = [s[i],p[i],i+1]

l.sort(key=lambda x:x[1],reverse = True)
print(l)
l.sort(key=lambda x:x[0])
print(l)
for i in l:
    print(i[2])

Fixed code:
n = int(input())
s = [0]*n
p = [0]*n
l = [[] for i in range(n)]

for i in range(n):
    s[i],p[i] = input().split()
    l[i] = [s[i],int(p[i]),i+1]

l.sort(key=lambda x:x[1],reverse = True)
l.sort(key=lambda x:x[0])

for i in l:
    print(i[2])
Buggy code:
if __name__ == '__main__':
    N = int(input())
    S = []
    P = []
    num = []
    for i in range(N):
        s = input().rstrip().split(' ')
        S.append(s[0])
        P.append(int(s[1]))
        num.append(i+1)

    Z = list(zip(S,P,num))
    print(Z)

    Z.sort(key=lambda k:k[1],reverse=True)
    Z.sort(key=lambda k:k[0])

    for elem in Z:
        print(elem[2])

Fixed code:
if __name__ == '__main__':
    N = int(input())
    S = []
    P = []
    num = []
    for i in range(N):
        s = input().rstrip().split(' ')
        S.append(s[0])
        P.append(int(s[1]))
        num.append(i+1)

    Z = list(zip(S,P,num))

    Z.sort(key=lambda k:k[1],reverse=True)
    Z.sort(key=lambda k:k[0])

    for elem in Z:
        print(elem[2])
Buggy code:

a = int(input())
l = []
for i in range(a):
    ta,tb = map(int,input().split())
    l.append([ta,tb,i+1])
l.sort()
for i, j , k in l:
    print(k)



Fixed code:

a = int(input())
l = []
for i in range(a):
    ta,tb = map(str,input().split())
    l.append([ta,-int(tb),i+1])
l.sort()
for i, j , k in l:
    print(k)
Buggy code:
N = int(input())
S = []
P = []
for i in range(N):
    tmp_S, tmp_P = input().split()
    S.append(tmp_S)
    P.append(int(tmp_P)*(-1))

index = [i for i in range(1,N+1)]

ZIP = zip(P, index, S)

ZIP = sorted(ZIP)

P, index, S = zip(*ZIP)

for i in range(N):
    print(index[i])
    print(S[i])

ZIP = zip(S, index)

ZIP = sorted(ZIP)

S, index = zip(*ZIP)

for i in range(N):
    print(index[i])

Fixed code:
N = int(input())
S = []
P = []
for i in range(N):
    tmp_S, tmp_P = input().split()
    S.append(tmp_S)
    P.append(int(tmp_P)*(-1))

index = [i for i in range(1,N+1)]

ZIP = zip(S, P, index)

ZIP = sorted(ZIP)

S, P, index = zip(*ZIP)

for i in range(N):
    print(index[i])
Buggy code:
N=int(input())
grid=[]
for i in range(N):
   S_P=list(input().split())
   S_P.append(i+1)
   grid.append(S_P)

for i in range(N):
   grid[i][1]=int(grid[i][1])

grid.sort(key=lambda x:x[1],reverse=True)
grid.sort(key=lambda x:x[0])

print(grid)
for i in range(N):
   print(grid[i][2])

Fixed code:
N=int(input())
grid=[]
for i in range(N):
   S_P=list(input().split())
   S_P.append(i+1)
   grid.append(S_P)

for i in range(N):
   grid[i][1]=int(grid[i][1])

grid.sort(key=lambda x:x[1],reverse=True)
grid.sort(key=lambda x:x[0])

for i in range(N):
   print(grid[i][2])
Buggy code:
number = int(input())
my_set = set()
for i in range(number):
    input_line = raw_input()
    splitted_line = input_line.split(" ")
    my_set.add((splitted_line[0], - int(splitted_line[1]), i+1))

my_sorted_1 = sorted(my_set)
 
for item in my_sorted_1:
    print(item[2])


Fixed code:
number = int(input())
my_set = set()
for i in range(number):
    input_line = input()
    splitted_line = input_line.split(" ")
    my_set.add((splitted_line[0], - int(splitted_line[1]), i+1))

my_sorted = sorted(my_set)

for item in my_sorted:
    print(item[2])
Buggy code:
N = int(input())
array = []
for i in range(N):
    array.append(list(map(str, input().split())))
array_new = sorted(array, key=lambda x: (x[0], x[1]))
for i in range(N):
    print(int(array.index(array_new[i])+1))




Fixed code:
N = int(input())
array = []
for i in range(N):
    array.append(list(map(str, input().split())))
array_new = sorted(array, key=lambda x: (x[0], -int(x[1])))
for i in range(N):
    print(int(array.index(array_new[i])+1))
Buggy code:
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

import math
import string
import fractions
import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop

# from itertools import accumulate
# from collections import deque
import random


def main():
    n = int(input())
    dict={}
    for i in range(n):
        name, score= input().split()
        if not(name in dict):
            dict[name]=[((score,i+1))]
        else:
            dict[name].append((score,i+1))
            dict[name].sort(reverse=True)
    eprint(dict)
    ll=list(dict.items())
    eprint(ll)
    ll.sort()
    eprint(ll)
    for x in ll:
        for y in x[1]:
            print(y[1])
        
if __name__ == '__main__':
    main()


Fixed code:
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

import math
import string
import fractions
import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop

# from itertools import accumulate
# from collections import deque
import random


def main():
    n = int(input())
    dict={}
    for i in range(n):
        name, score= input().split()
        if not(name in dict):
            dict[name]=[((int(score),i+1))]
        else:
            dict[name].append((int(score),i+1))
            dict[name].sort(reverse=True)
    eprint(dict)
    ll=list(dict.items())
    eprint(ll)
    ll.sort()
    eprint(ll)
    for x in ll:
        for y in x[1]:
            print(y[1])
        
if __name__ == '__main__':
    main()
Buggy code:
N=int(input())
d={}
k=[]
for x in range(N):
  S,P=input().split()
  if S not in k:
    k.append(S)
    d[S]=[]
  d[S].append([P,x+1])
k.sort()
for y in k:
  d[y].sort(reverse=True)
  for z in range(len(d[y])):
    print(d[y][z][1])

Fixed code:
N=int(input())
d={}
k=[]
for x in range(N):
  S,P=input().split()
  if S not in k:
    k.append(S)
    d[S]=[]
  d[S].append([int(P),x+1])
k.sort()
for y in k:
  d[y].sort(reverse=True)
  for z in range(len(d[y])):
    print(d[y][z][1])