qyliang/CodeNanoFix huggingface dataset:
Buggy code:
a, p = map(int,input().split())

print(a*3//2)

Fixed code:
a, p = map(int,input().split())

print((a*3+p)//2)
Buggy code:
a,p=map(int,input().split())

print((a*3+p)/2)

Fixed code:
a,p=map(int,input().split())
b=a*3
print((p+b)//2)
Buggy code:
a, b = [int(i) for input().split()]
c = (a * 3 + b) // 2
print(c)

Fixed code:
a, b = [int(i) for i in input().split()]
c =(a * 3 + b) // 2
print(c)
Buggy code:
a, b = map(int, input.split())

a *= 3

print((a+b)//2)

Fixed code:
a, b = map(int, input().split())
a *= 3
print((a+b)//2)
Buggy code:
a,p = map(int, input().split())
print((a*3+p)/2)


Fixed code:
a, p = map(int, input().split())

ans = (a * 3 + p ) // 2

print(ans)
Buggy code:
A,P = map(int,input().split())

if ( A * 3 + P ) % 2 == 0:
  print(( A * 3 + P ) / 2 )
else:
  print( int(( A * 3 + P - 1) / 2 ))

Fixed code:
A,P = map(int,input().split())

if ( A * 3 + P ) % 2 == 0:
  print(int( ( A * 3 + P ) / 2 ))
else:
  print( int(( A * 3 + P - 1) / 2 ))
Buggy code:
a, p = map(int, input().split())
print((a*3 + p) / 2)


Fixed code:
a, p = map(int,(input().split()))
c = 3*a + p
print(c//2)
Buggy code:
A,P=map(int,input().split())
print((A*3 + P) / 2)


Fixed code:
A, P = map(int, input().split())

print(int((A*3 + P) // 2))
Buggy code:
a,p = [int(_) for _ in input()]
print((a*3+p)//2)

Fixed code:
a,p = [int(_) for _ in input().split()]
print((a*3+p)//2)
Buggy code:
A,P=map(int(input().split())
print((3*A+P)//2)


Fixed code:
A, P = list(map(int, input().split()))
P += 3*A
print (P//2)
Buggy code:
import math


def main(x,y):
    P = 3*x+y
    num = math.ceil(P/2)
    print(num)


    
x, y = map(int,input().split())
main(x,y)


Fixed code:
import math


def main(x,y):
    P = 3*x+y
    num = math.floor(P/2)
    print(num)


    
x, y = map(int,input().split())
main(x,y)
Buggy code:
A,N = map(int,input().split())
A_N = A*3 + N

print(A_N/2)

Fixed code:
A,N = map(int,input().split())
A_N = A*3 + N

print(A_N//2)
Buggy code:
A,P=map(input().split())
answer = int((A*3+P)/2)
print(answer)

Fixed code:
A, P = map(int,input().split())

P = P + A * 3
print(P//2)
Buggy code:
a,p=map(int,input().split())
b=3*a+p
if b%2==0:
  print(b/2)
else:
  print((b-1)/2)

Fixed code:
a,p=map(int,input().split())
b=3*a+p
if b%2==0:
  print(b//2)
else:
  print((b-1)//2)
Buggy code:
a,p = map(int,input().split())
 print(int((a*3+p)//2))

Fixed code:
a,p = map(int, input().split())
ans = ( a * 3 + p )//2
print(ans)
Buggy code:
A,P=map(int,input().split())
ans,maru,kakera = 0,0,0
def is_even(num):
    return num % 2 == 0
if P==0:
    maru=3*A//2
else:
    if is_even(A) == True:
        maru = 3*A
        kakera = P//2
    else:
        maru = 3*A//2
        kakera = P//2+1
ans=maru+kakera
print(ans)

Fixed code:
A,P=map(int,input().split())
ans,maru,kakera = 0,0,0
def is_even(num):
    return num % 2 == 0
maru=(3*A)//2
if P==0:
    kakera=0
else:
    if is_even(A) == False and is_even(P) == False:
        kakera = P//2+1
    else:
        kakera = P//2
ans=maru+kakera
print(ans)
Buggy code:
A,P = map(int, input().split())
sum_apple = A*3+P
print(sum_apple/2)

Fixed code:
A,P = map(int, input().split())
sum_apple = A*3+P
print(sum_apple//2)
Buggy code:
A,P = map(int,input().split())
ans = (3*A+P)//3
print(int(ans))

Fixed code:
A,P = map(int,input().split())
ans = (3*A+P)//2
print(int(ans))
Buggy code:
a, p = map(int,input().split())

print((3*a+p)/2)

Fixed code:
a,p = map(int,input().split())

p+=a*3
print(p//2)
Buggy code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
a,p=map(int,input().split())

print((a*3+b)//2)

Fixed code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
a,b=map(int,input().split())

print((a*3+b)//2)
Buggy code:
import sys

for l in sys.stdin:
  a, p = l.rstrip('\n').split(' ')
pies = (3*a+p)//2
print(pies)

Fixed code:
import sys

for l in sys.stdin:
  a, p = l.rstrip('\n').split(' ')
pies = (int(a) * 3 + int(p)) //2
print(pies)
Buggy code:
a, p = map(int, input().split())
print(int(a * 3 + p / 2))

Fixed code:
a, p = map(int, input().split())
print(int((a * 3 + p) // 2))
Buggy code:
line = input().split(' ')
a = int(line[0])
p = int(line[1])
n = (a*2 + p)//2
print(n)


Fixed code:
line = input().split(' ')
a = int(line[0])
p = int(line[1])
n = (a*3 + p)//2
print(n)
Buggy code:
i = list(map(int,input().split()))
A=i[0]
P=i[1]
S=(A/3+P)/2
print(S)

Fixed code:
i = list(map(int,input().split()))
A=i[0]
P=i[1]
S=(A*3+P)//2
print(S)
Buggy code:
n, m = map(int, input().split())
print(int(((n*3)+m)//3))

Fixed code:
n, m = map(int, input().split())
print(int(((n*3)+m)//2))
Buggy code:
A,P=map(int,input().split())
ap=A*3+P
print(ap//P)

Fixed code:
A,P=map(int,input().split())
ap=A*3+P
print(ap//2)
Buggy code:
A,P = map(int,input().split())
p = A*3 + p
print(p//2)

Fixed code:
A,P = map(int,input().split())
p = A*3 + P
print(p//2)
Buggy code:
number=int(input())
book=[]
for i in range(0,number):
  book.append(input().split())
for i in range(0,len(book)):
    book[i][1]=int(book[i][1])
    book[i].append(i+1)
book1=sorted(book,key=lambda x: -x[1])
book2=sorted(book1,key=lambda x: x[0])
for i in range(0,len(book2)):
  print(book[i][2])

Fixed code:
number=int(input())
book=[]
for i in range(0,number):
  book.append(input().split())
for i in range(0,len(book)):
    book[i][1]=int(book[i][1])
    book[i].append(i+1)
book1=sorted(book,key=lambda x: -x[1])
book2=sorted(book1,key=lambda x: x[0])
for i in range(0,len(book2)):
  print(book2[i][2])
Buggy code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
s = {}
for i in range(n):
	S,P = map(str,input().split())
	s[i+1] = [S, -int(P)]

note = sorted(s.items(), key=lambda x: x[1][0])
note.append( (10, ["LOL", 10] ) )
print(note)
memo = note[0][1][0]
a = []
for i in note:
	if memo != i[1][0]:
		memo = i[1][0]
		a = sorted(a, key=lambda x: x[1][1])
		for j in range(len(a)):
			print(a[j][0])
		a = []
		a.append(i)
	else:
		a.append(i)

Fixed code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
s = {}
for i in range(n):
	S,P = map(str,input().split())
	s[i+1] = [S, -int(P)]

note = sorted(s.items(), key=lambda x: x[1][0])
note.append( (10, ["LOL", 10] ) )
memo = note[0][1][0]
a = []
for i in note:
	if memo != i[1][0]:
		memo = i[1][0]
		a = sorted(a, key=lambda x: x[1][1])
		for j in range(len(a)):
			print(a[j][0])
		a = []
		a.append(i)
	else:
		a.append(i)
Buggy code:

n = int(input())
sp = [0] * n
for i in range(n):
    sp[i] = list(map(str,input().split()))
    sp[i].append(i+1)

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




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

sp.sort(key = lambda x: x[1],reverse = True)
sp.sort(key = lambda x: x[0])
for i in range(n):
    print(sp[i][2])
Buggy code:
n=int(input())
data_origin=[input().split() for i in range(n)]
for i in range(n):
  data_origin[i][1] = int(data_origin[i][1])
data = sorted(data_origin, key=lambda x:x[1],reverse=True)
data = sorted(data, key=lambda x:x[0])
print(data)
for i in data:
  print(1+data_origin.index(i))

Fixed code:
n=int(input())
data_origin=[input().split() for i in range(n)]
for i in range(n):
  data_origin[i][1] = int(data_origin[i][1])
data = sorted(data_origin, key=lambda x:x[1],reverse=True)
data = sorted(data, key=lambda x:x[0])
for i in data:
  print(1+data_origin.index(i))
Buggy code:
import copy

N = int(input())

S = []
P = []
for i in range(N):
	s, p = input().split()
	S.insert(i, s)
	P.insert(i, p)
print(S)
print(P)

list = []
for i in range(N):
	temp = [S[i], int(P[i])]
	list.append(temp)

clone = copy.copy(list)

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

print(list)
print(clone)

for i in range(N):
	print(list.index(clone[i])+1)


Fixed code:
import copy

N = int(input())

S = []
P = []
for i in range(N):
	s, p = input().split()
	S.insert(i, s)
	P.insert(i, p)

list = []
for i in range(N):
	temp = [S[i], int(P[i])]
	list.append(temp)

clone = copy.copy(list)

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

for i in range(N):
	print(list.index(clone[i])+1)
Buggy code:
n = int(input())
l = []
for i in range(n):
    sp = input().split()
    l.append((sp[0], int(sp[1]), i+1))

a = sorted(l, key=lambda i: (i[0], -l[1]))

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

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

a = sorted(l, key=lambda i: i[1], reverse=True)
a = sorted(a, key=lambda i: i[0])

for i in range(n):
    print(a[i][2])
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[0], x[1]))

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

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:
N=int(input())
S={}

for i in range(N):
  p,q=input().split()
  S[i+1]=(p,int(q))
S=sorted(S,key=lambda x:(S[x][0],-S[x][1]))
print(S)

print(*S,sep="\n")

Fixed code:
N=int(input())
S={}

for i in range(N):
  p,q=input().split()
  S[i+1]=(p,int(q))
S=sorted(S,key=lambda x:(S[x][0],-S[x][1]))

print(*S,sep="\n")
Buggy code:
n=int(input())
List=[[input().split() , i+1] for i in range(n)]

List=sorted(List,key=lambda x : (x[0],-int(x[1])))

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

Fixed code:
n=int(input())
List=[[input().split() , i+1] for i in range(n)]

List=sorted(List,key=lambda x : (x[0][0],-int(x[0][1])))

for i in range(n):
    print(List[i][1])
Buggy code:
N = int(input())
SP = []
for _ in range(N):
  SP.append([i for i in input().split()])
for n in range(N):
  SP[n][1] = str(100 - SP[n]).rjust(3,'0')
SP2 = []
for n in range(N):
  SP2.append(SP[0]+SP[1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
[print(i) for i in ans]

Fixed code:
N = int(input())
SP = []
for _ in range(N):
    SP.append([i for i in input().split()])
for n in range(N):
    SP[n][1] = str(100 - int(SP[n][1])).rjust(3,'0')
SP2 = []
for n in range(N):
    SP2.append(SP[n][0]+SP[n][1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
for i in ans:
    print(i+1)
Buggy code:
from operator import itemgetter
n = int(input())
arr_ = [[str(i) for i in input().split()] for _ in range(n)]
for i in range(n):
    arr_[i].append(i+1)

arr_.sort(key=itemgetter(1), reverse=True)
arr_.sort(key=itemgetter(0))
for i in range(n):
    print(arr_[i][2])

Fixed code:
from operator import itemgetter
n = int(input())
arr_ = [[str(i) for i in input().split()] for _ in range(n)]
for i in range(n):
    arr_[i].append(i+1)
    arr_[i][1] = int(arr_[i][1])

arr_.sort(key=itemgetter(1), reverse=True)
arr_.sort(key=itemgetter(0))
for i in range(n):
    print(arr_[i][2])
Buggy code:
N = int(input())
l = [None] * N

def cmp1(l, r):
   
    if l[0] < r[0]:
        return -1
    elif l[0] == r[0]:
        if l[1] == r[0]:
            return 0
        elif l[1] < r[1]:
            return 1 
        else:
            return -1
    else:
        return 1
        
    
for i in range(N):
    city, rate = input().split()
    l[i] =  city, int(rate), i+1

import functools
l.sort(key=functools.cmp_to_key(cmp1))
print(l)


for _, _, i in l:
    print(i)

Fixed code:
import functools

N = int(input())
l = [None] * N

def cmp1(l, r):
   
    if l[0] < r[0]:
        return -1
    elif l[0] == r[0]:
        if l[1] == r[0]:
            return 0
        elif l[1] < r[1]:
            return 1 
        else:
            return -1
    else:
        return 1
        
    
for i in range(N):
    city, rate = input().split()
    l[i] =  city, int(rate), i+1


l.sort(key=functools.cmp_to_key(cmp1))

for _, _, idx in l:
    print(idx)
Buggy code:
import functools as f

def to_num(a, b):
    if a > b:
        return 1
    if b > a:
        return -1
    return 0

def cmp(a, b):
    if (a[0] == b[0]):
        return to_num(b[1], a[1])
    return to_num(a[0], b[0])

n = int(input())
A = []
for i in range(n):
    a, b = input().split()
    A.append([a, int(b), i + 1])
#print(A)
A.sort(key=f.cmp_to_key(cmp))
for i in range(n):
    A[i].append(i + 1)
#print(A)
A.sort(key=lambda x: x[2])
#print(A)
for i in range(n):
    print(A[i][3])


Fixed code:
import functools as f

def to_num(a, b):
    if a > b:
        return 1
    if b > a:
        return -1
    return 0

def cmp(a, b):
    if (a[0] == b[0]):
        return to_num(b[1], a[1])
    return to_num(a[0], b[0])

n = int(input())
A = []
for i in range(n):
    a, b = input().split()
    A.append([a, int(b), i + 1])
#print(A)
A.sort(key=f.cmp_to_key(cmp))
for i in range(n):
    print(A[i][2])
#for i in range(n):
Buggy code:
n = int(input())
book = []
for i in range(n):
    name, rate = input().split()
    book.append((i+1, name, int(rate)))
b = sorted(book, key=lambda s: s[2], reverse=True)
b2 = sorted(b, key=lambda s: s[1])

print(b2)

for i, _, _ in b2:
    print(i)
    

Fixed code:
n = int(input())
book = []
for i in range(n):
    name, rate = input().split()
    book.append((i+1, name, int(rate)))
b = sorted(book, key=lambda s: s[2], reverse=True)
b2 = sorted(b, key=lambda s: s[1])

for i, _, _ in b2:
    print(i)
Buggy code:
n = int(input())
sp = []
for i in range(n):
  s, p = map(int,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])

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:
n = int(input())
L = []
for i in range(n):
    s,p = input().split()
    L.append([i,s,p])
L = sorted(L, key=lambda x:x[2])
L.reverse()
L = sorted(L, key=lambda x:x[1])
for i in range(n):
    print(L[i][0]+1)

Fixed code:
n = int(input())
L = []
for i in range(n):
    s,p = input().split()
    L.append([i,s,int(p)])
L = sorted(L, key=lambda x:x[2])
L.reverse()
L = sorted(L, key=lambda x:x[1])
for i in range(n):
    print(L[i][0]+1)
Buggy code:
from operator import itemgetter
N=int(input())
hako=[]
for i in range(N):
    A,B=input().split()
    hako.append([A,int(B)*-1])
kari=hako.copy()
#print(kari)
hako.sort()
hako=sorted(hako,key=itemgetter(0,1))
#print(hako)
for i in range(N):
    print(hako.index(kari[i])+1)

Fixed code:
from operator import itemgetter
N=int(input())
hako=[]
for i in range(N):
    A,B=input().split()
    hako.append([A,int(B)*-1])
kari=hako.copy()
#print(kari)
hako.sort()
hako=sorted(hako,key=itemgetter(0,1))
#print(hako)
for i in range(N):
    print(kari.index(hako[i])+1)
Buggy code:
N = int(input())
S = []
P = []
Num = []
for i in range(N):
  s, p = input().split()
  S.append(s)
  P.append(int(p))
  Num.append(i+1)
print(Num)
for i in range(N):
  for m in range(i):
    if S[m] > S[i] or (S[m] == S[i] and P[i] > P[m]):
      S[m], S[i] = S[i], S[m]
      P[m], P[i] = P[i], P[m]
      Num[m], Num[i] = Num[i], Num[m]
  print(Num)
for i in range(N):
  print("{}".format(Num[i]))

Fixed code:
N = int(input())
S = []
P = []
Num = []
for i in range(N):
  s, p = input().split()
  S.append(s)
  P.append(int(p))
  Num.append(i+1)
for i in range(N):
  for m in range(i):
    if S[m] > S[i] or (S[m] == S[i] and P[i] > P[m]):
      S[m], S[i] = S[i], S[m]
      P[m], P[i] = P[i], P[m]
      Num[m], Num[i] = Num[i], Num[m]
for i in range(N):
  print("{}".format(Num[i]))
Buggy code:
n = int(input())

isp = []
for i in range(1, n+1):
    s, p = input().split()
    isp.append([i, s, int(p)])
    
isp = sorted(isp, key=lambda x: x[2])
isp = sorted(isp, key=lambda x: x[1], reverse=True)
for i in isp:
    print(i[0])

Fixed code:
n = int(input())

isp = []
for i in range(1, n+1):
    s, p = input().split()
    isp.append([i, s, int(p)])
    
isp = sorted(isp, key=lambda x: x[2], reverse=True)
isp = sorted(isp, key=lambda x: x[1])
for i in isp:
    print(i[0])
Buggy code:
n = int(input())
sp = []
for i in range(n):
    sp.append(input().split())
    sp[i].append(i)
    sp[i][1] = int(sp[i][1])
sp = sorted(sp, key = lambda x : x[1], reverse = True)
sp = sorted(sp, key = lambda x : x[0])
fo ri in range(n):
    print(sp[i][2]+1)

Fixed code:
n = int(input())
sp = []
for i in range(n):
    sp.append(input().split())
    sp[i].append(i)
    sp[i][1] = int(sp[i][1])
sp = sorted(sp, key = lambda x : x[1], reverse = True)
sp = sorted(sp, key = lambda x : x[0])
for i in range(n):
    print(sp[i][2]+1)
Buggy code:
n = int(input())
dic = []
for _ in range(n):
  name, point = input().split()
  dic.append((name, int(point)))

srt = sorted(range(n), reverse=True, key=lambda x: dic[x][1])
srt = sorted(range(n), key=lambda x: dic[x][0])

for i in srt:
  print(str(i+1))
             

Fixed code:
n = int(input())
dic = []
for i in range(n):
  name, point = input().split()
  dic.append((name, int(point), i+1))

srt = sorted(dic, reverse=True, key=lambda x: x[1])
srt = sorted(srt, key=lambda x: x[0])

for x in srt:
  print(x[2])
Buggy code:
for*_,i in sorted((t.split()[0],-int(t[-3:]),i)for i,t in enumerate(open(0)))[1:]:print(i)

Fixed code:
for*_,i in sorted((t.split()[0],-int(t.split()[-1]),i)for i,t in enumerate(open(0)))[1:]:print(i)
Buggy code:
for i in sorted(range(int(input())),key=lambda:[(s,-int(p))for s,p in[input().split()]]):print(i+1)

Fixed code:
for i in sorted(range(int(input())),key=lambda _:[(s,-int(p))for s,p in[input().split()]]):print(i+1)
Buggy code:
n=int(input())
s=[]
for i in range(n):
    s.append(input().split()+[str(i+1)])
print(s)
s=sorted(s)
print(s)
for i in range(n):
    print(s[i][-1])


Fixed code:
n=int(input())
s=[]
for i in range(n):
    tmp=input().split()
    tmp[1]=100-int(tmp[1])
    s.append(tmp+[str(i+1)])
s=sorted(s)

for i in range(n):
    print(s[i][-1])
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],reverse = True)

for i in sp:
  print(i[2])

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 i in sp:
  print(i[2])
Buggy code:
N = int(input())

mylist = []
for i in range(n):
	mylist.append(list(map(str,input().split())))
	mylist[i].append(i+1)

mylist = sorted(mylist,key=lambda mylist:(mylist[0],-int(mylist[1])))
for i in mylist:
	print(i[2])

Fixed code:
n = int(input())

mylist = []
for i in range(n):
	mylist.append(list(map(str,input().split())))
	mylist[i].append(i+1)

mylist = sorted(mylist,key=lambda mylist:(mylist[0],-int(mylist[1])))
for i in mylist:
	print(i[2])
Buggy code:
n = int(input()) 
t = [input().split() for i in range(n)] 
t2 = t

t.sort()

result = []

def bubble_sort(arr):
    change = True
    while change:
        change = False
        for i in range(len(arr) - 1):
            if arr[i][0] == arr[i+1][0] and int(arr[i][1]) < int(arr[i+1][1]):
                arr[i], arr[i + 1] = arr[i + 1], arr[i]
                change = True
    return arr
_list = bubble_sort(t)


for a in _list:
    for i, item in enumerate(t2):
        i+=1
        if a == item:
            result.append(i)

for r in result:
    print(r)

Fixed code:
n = int(input()) 
t = [input().split() for i in range(n)] 
o = t
t =sorted(t)

result = []

def bubble_sort(arr):
    change = True
    while change:
        change = False
        for i in range(len(arr) - 1):
            if arr[i][0] == arr[i+1][0] and int(arr[i][1]) < int(arr[i+1][1]):
                arr[i], arr[i + 1] = arr[i + 1], arr[i]
                change = True
    return arr
_list = bubble_sort(t)

for a in _list:
    for i, item in enumerate(o):
        i+=1
        if a == item:
            result.append(i)
for r in result:
    print(r)
Buggy code:
N = int(input())

SP = {}

for n in range(N):
    s, p = input().split()
    p = int(p)
    if s not in SP:
        SP[s] = [(p, n+1)]
    else:
        SP[s].append((p, n+1))

print(SP)

K = sorted(SP)
print(K)

for k in K:
    SP[k].sort(reverse=True)
    for t in SP[k]:
        print(t[1])


Fixed code:
N = int(input())

SP = {}

for n in range(N):
    s, p = input().split()
    p = int(p)
    if s not in SP:
        SP[s] = [(p, n+1)]
    else:
        SP[s].append((p, n+1))


K = sorted(SP)

for k in K:
    SP[k].sort(reverse=True)
    for t in SP[k]:
        print(t[1])
Buggy code:
N = int(input())
SP = []
for i in range(N):
  s,p = map(str,input().split())
  pint = int(p)
  pint = -pint
  p = str(pint)
  SP.append([s,p,str(i+1)])
SP.sort()
for i in range(N):
  print(int(SP[i][2]))

Fixed code:
N = int(input())
SP = []
for i in range(N):
  s,p = map(str,input().split())
  pint = int(p)
  pint = 100-pint
  SP.append([s,pint,i+1])
SP.sort()
for i in range(N):
  print(SP[i][2])
Buggy code:
N = int(input())
list = []
for i in range(N):
    input_list = input()
    S = input_list.split(" ")[0]
    P = int(input_list.split(" ")[1])
    list.append([i, S, P])

#from operator import itemgetter

list.sort(key=lambda x: x[2] ,reverse=True)
list.sort(key=lambda x: x[1])
for i in range(N):
    list[i].append(i)
list.sort()
for i in range(N):
    print(list[i][3]+1)


Fixed code:
N = int(input())
list = []
for i in range(N):
    input_list = input()
    S = input_list.split(" ")[0]
    P = int(input_list.split(" ")[1])
    list.append([i, S, P])

#from operator import itemgetter

list.sort(key=lambda x: x[2] ,reverse=True)
list.sort(key=lambda x: x[1])
for i in range(N):
    print(list[i][0]+1)
Buggy code:
from collections import defaultdict
n = int(input())
d = {}
di = defaultdict(list)
for i in range(n):
    s, p = input().split()
    d[(s, p)] = i+1
    di[s].append(p)
dii = list(di.items())
dii.sort(key=lambda x: x[0])
#print(dii, "\n", d)
for i in dii:
    si, pi = i[0], i[1]
    pi.sort(reverse=True)
    for j in pi:
        print(d[(si, j)])

Fixed code:
from collections import defaultdict
n = int(input())
d = {}
di = defaultdict(list)
for i in range(n):
    tmp = input().split()
    s, p = tmp[0], int(tmp[1])
    d[(s, p)] = i+1
    di[s].append(int(p))
dii = list(di.items())
dii.sort(key=lambda x: x[0])

for i in dii:
    si, pi = i[0], i[1]
    pi.sort(reverse=True)
    for j in pi:
        print(d[(si, j)])
Buggy code:
n = int(input())
sp = []
for i in range(n):
        sp.append(input().split())
for i in range(n):
        sp[i][1] = int(sp[i][1])
for i in range(n):
        sp[i].append(i+1)
sp.sort()
start = 0
sp2=[]
for i in range(n-1):
        if sp[i][0] != sp[i+1][0]:
                sp2 = sp2+sorted(sp[start:i+1],key = lambda x:x[1],reverse = True)
                start = i+1
sp2 = sp2+sorted(sp[start:],key = lambda x:x[1],reverse = True)
print(sp2)
for i in range(n):
        print(sp2[i][2])

Fixed code:
n = int(input())
sp = []
for i in range(n):
        sp.append(input().split())
for i in range(n):
        sp[i][1] = int(sp[i][1])
for i in range(n):
        sp[i].append(i+1)
sp.sort()
start = 0
sp2=[]
for i in range(n-1):
        if sp[i][0] != sp[i+1][0]:
                sp2 = sp2+sorted(sp[start:i+1],key = lambda x:x[1],reverse = True)
                start = i+1
sp2 = sp2+sorted(sp[start:],key = lambda x:x[1],reverse = True)
for i in range(n):
        print(sp2[i][2])
Buggy code:
n = int(input())
s = [input().split() for i in range(n)]
for i in range(n):
    s[i][1] = int(s[i][1])
    s[i].append(i+1)
sorted_list = sorted(s, key=lambda x:(x[0], -x[1]))
print(sorted_list)
for i in range(n):
    print(sorted_list[i][2])

Fixed code:
n = int(input())
s = [input().split() for i in range(n)]
for i in range(n):
    s[i][1] = int(s[i][1])
    s[i].append(i+1)
sorted_list = sorted(s, key=lambda x:(x[0], -x[1]))
for i in range(n):
    print(sorted_list[i][2])