qyliang/CodeNanoFix huggingface dataset:
Buggy code:

a = sorted([input().split() + [str(i+1)] for i in range(n)])

a.append(['end', '0', '0'])

tmp = []
ans = []

for i in range(n):
    tmp.append(a[i])
    if a[i][0] != a[i+1][0]:
        ans.append(sorted(tmp, key=lambda x: int(x[1]), reverse=True))
        tmp = []

[print(c[2]) for c in ans[0]]


Fixed code:
n = int(input())


def f(n):
    n[1] = int(n[1])
    return n


a = sorted([input().split() + [str(i+1)] for i in range(n)])

a.append(['end', '0', '0'])

tmp = []
ans = []

for i in range(n):
    tmp.append(a[i])
    if a[i][0] != a[i+1][0]:
        ans.append(sorted(tmp, key=lambda x: int(x[1]), reverse=True))
        tmp = []

for c in ans:
    for d in c:
        print(d[2])
Buggy code:
# -*- coding: utf-8 -*-
import copy

N = int(input())
list = [input().split() for i in range(N)]
list2 = copy.deepcopy(list)
list2.sort(key=lambda x:(x[0],-int(x[1])))
print(list2)

for i in range(N):
    a = list[i]
    b = list2.index(a)
    print(b + 1)

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

N = int(input())
list = [input().split() for i in range(N)]
list2 = copy.deepcopy(list)
list2.sort(key=lambda x:(x[0],-int(x[1])))

for i in range(N):
    a = list2[i]
    b = list.index(a)
    print(int(b + 1))
Buggy code:
from operator import itemgetter
N = int(input())
rest = []

for i in range(N) :
  raw = list(input().split())
  raw[1] = int(raw[1]) 
  raw.append(int(i + 1))
  rest.append(raw)

rest.sort(key=itemgetter(0, 1))

for k in range(N) :
  print(rest[k][2])

Fixed code:
from operator import itemgetter
N = int(input())
rest = []

for i in range(N) :
  raw = list(input().split())
  raw[1] = int(raw[1]) 
  raw.append(int(i + 1))
  rest.append(raw)

rest.sort(key=itemgetter(1), reverse = True )
rest.sort(key=itemgetter(0))

for k in range(N) :
  print(rest[k][2])
Buggy code:
n = int(input())
SP = []
for i in range(n):
  sp = input().split()
  sp.append(i+1)
  SP.append(sp)
sortedSP = sorted(SP, key = lambda x:x[0])
for i in range(n-1):
  for j in range(n-1-i):
    if sortedSP[j][0] == sortedSP[j+1][0] and int(sortedSP[j][1]) < int(sortedSP[j+1][1]):
      sortedSP[j], sortedSP[j+1] = sortedSP[j+1], sortedSP[j]
print(sortedSP)
for i in range(n):
  print(sortedSP[i][2])

Fixed code:
n = int(input())
SP = []
for i in range(n):
  sp = input().split()
  sp.append(i+1)
  SP.append(sp)
sortedSP = sorted(SP, key = lambda x:x[0])
for i in range(n-1):
  for j in range(n-1-i):
    if sortedSP[j][0] == sortedSP[j+1][0] and int(sortedSP[j][1]) < int(sortedSP[j+1][1]):
      sortedSP[j], sortedSP[j+1] = sortedSP[j+1], sortedSP[j]
for i in range(n):
  print(sortedSP[i][2])
Buggy code:
N = int(input())
lst = []
for i in range(N):
  s,p = input().split()
  p=int(p)
  lst.append((s,-p,i+1))
for e in lst:
  print(e[2])

Fixed code:
N = int(input())
lst = []
for i in range(N):
  s,p = input().split()
  p=int(p)
  lst.append((s,-p,i+1))
lst.sort()
for e in lst:
  print(e[2])
Buggy code:
N = int(input())
rest_list = []
for i in range(N):
    a,b=input().split()
    temp=[i+1,a,(-1)*int(b)]
    rest_list.append(temp)
print(rest_list)
rest_list.sort(key=lambda x: (x[1], x[2]))
for i in rest_list:
    print(i[0])


Fixed code:
N = int(input())
rest_list = []
for i in range(N):
    a,b=input().split()
    temp=[i+1,a,(-1)*int(b)]
    rest_list.append(temp)
rest_list.sort(key=lambda x: (x[1], x[2]))
for i in rest_list:
    print(i[0])
Buggy code:
from operator import itemgetter

N= int(input())
lst = []
for i in range(N):
    s, p = input().split()
    lst.append([s, int(p), i])
lst = sorted(lst, key=itemgetter(1), reverse=True)
lst = sorted(lst, key=itemgetter(0))
lst = [l + [i] for i, l in enumerate(lst)]
lst = sorted(lst, key=itemgetter(2))
for l in lst:
    print(l[3]+1)

Fixed code:
from operator import itemgetter

N= int(input())
lst = []
for i in range(N):
    s, p = input().split()
    lst.append([s, int(p), i])
lst = sorted(lst, key=itemgetter(1), reverse=True)
lst = sorted(lst, key=itemgetter(0))
for l in lst:
    print(l[2]+1)
Buggy code:
n=int(input())
R=[list(input().split()) + [i+1] for i in range(n)]
R.sort(key=lambda x: (x[0],-int(x[1])))
print(R)
for r in R:
    print(r[2])

Fixed code:
n=int(input())
R=[list(input().split()) + [i+1] for i in range(n)]
R.sort(key=lambda x: (x[0],-int(x[1])))
for r in R:
    print(r[2])
Buggy code:
n=int(input())
sp=[]
for i in range(n):
  s,p=input().split()
  p=int(p)
  sp.append([s,p,i+1])

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

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

sp.sort(key=lambda sp:(sp[0],-sp[1]))
for i in sp:
  print(i[2])
Buggy code:
N = int(input())
ls = []
for i in range(N):
  s,p = input().spiit()
  p = int(p)
  ls.append([s,-p,i+1])
ls.sort()
for i in range(len(ls)):
  print(ls[2])

Fixed code:
N = int(input())
ls = []
for i in range(N):
  s,p = input().split()
  p = int(p)
  ls.append([s,-p,i+1])
ls.sort()
for i in range(len(ls)):
  print(ls[i][2])
Buggy code:
n = int(input())
a = []
for i in range(n):
  s, p = map(int, input().split())
  a.append([s,-p,i])
a.sort()
for i in a:
  print(i[-1])

Fixed code:
n = int(input())
a = []
for i in range(n):
  s, p = input().split()
  a.append([s,-int(p),i])
a.sort()
for i in a:
  print(i[-1]+1)
Buggy code:
import sys
input = sys.stdin.readline
import numpy as np
def print_ans(N, ar):
    """Test Case
    >>> print_ans(6,[["khabarovsk",-20, 1], ["moscow",-10, 2], ["kazan",-50, 3], ["kazan",-35, 4], ["moscow",-60, 5], ["khabarovsk",-40, 6]])
    3
    4
    6
    1
    5
    2
    >>> print_ans(10, [["yakutsk", -10, 1 ], ["yakutsk", -20, 2 ], ["yakutsk", -30, 3 ], ["yakutsk", -40, 4 ], ["yakutsk", -50, 5 ], ["yakutsk", -60, 6 ], ["yakutsk", -70, 7 ], ["yakutsk", -80, 8 ], ["yakutsk", -90, 9 ], ["yakutsk", -100,10]])
    10
    9
    8
    7
    6
    5
    4
    3
    2
    1
    """
    ans = sorted(ar)
    for a in ans:
        print(a[2])

if __name__ == '__main__':
    N = int(input().rstrip())
    ar = []
    for i in range(N):
        s, p = input().rstrip().split()
        n = int(n)
        ar.append((s, -n, i + 1))
    print_ans(N, ar)




Fixed code:
import sys
input = sys.stdin.readline
import numpy as np
def print_ans(N, ar):
    """Test Case
    >>> print_ans(6,[["khabarovsk",-20, 1], ["moscow",-10, 2], ["kazan",-50, 3], ["kazan",-35, 4], ["moscow",-60, 5], ["khabarovsk",-40, 6]])
    3
    4
    6
    1
    5
    2
    >>> print_ans(10, [["yakutsk", -10, 1 ], ["yakutsk", -20, 2 ], ["yakutsk", -30, 3 ], ["yakutsk", -40, 4 ], ["yakutsk", -50, 5 ], ["yakutsk", -60, 6 ], ["yakutsk", -70, 7 ], ["yakutsk", -80, 8 ], ["yakutsk", -90, 9 ], ["yakutsk", -100,10]])
    10
    9
    8
    7
    6
    5
    4
    3
    2
    1
    """
    ans = sorted(ar)
    for a in ans:
        print(a[2])

if __name__ == '__main__':
    N = int(input().rstrip())
    ar = []
    for i in range(N):
        s, p = input().rstrip().split()
        p = int(p)
        ar.append([s, -p, i + 1])
    print_ans(N, ar)
Buggy code:
def main():
    N = int(input())
    SP = []
    for _ in range(N):
        temp = input().split()
        SP.append((temp[0], int(temp[1])))

    sorted_SP = sorted(SP, key=lambda x: x[1], reverse=True)
    sorted_SP = sorted(sorted_SP, key=lambda x: x[0])

    indices = [SP.index(x)+1 for x in sorted_SP]
    # print(sorted_SP)
    print(indices)

if __name__ == '__main__':
    main()

Fixed code:
def main():
    N = int(input())
    SP = []
    for _ in range(N):
        temp = input().split()
        SP.append((temp[0], int(temp[1])))

    sorted_SP = sorted(SP, key=lambda x: x[1], reverse=True)
    sorted_SP = sorted(sorted_SP, key=lambda x: x[0])

    indices = [SP.index(x)+1 for x in sorted_SP]
    # print(sorted_SP)
    for i in indices:
        print(i)

if __name__ == '__main__':
    main()
Buggy code:
n = int(input())
lst = [list(input().split())+[i+1] for i in range(n)]

print(lst)

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

for i in range(0, len(lst)):
    print(i[2])

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

# print(lst)

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

for i in range(0, len(lst)):
    print(lst[i][2])
Buggy code:
n = int(input())
l = [0] * n
for i in range(n):
    l[i] = list(map(str, input().split()))
    l[i][1] = int(l[i][1])
l_sorted = sorted(l, key=lambda l: l[1], reverse=True)
l_sorted = sorted(l_sorted, key=lambda l: l[0])
print(l_sorted)
for i in range(len(l)):
    print(l.index(l_sorted[i]) + 1)

Fixed code:
n = int(input())
l = [0] * n
for i in range(n):
    l[i] = list(map(str, input().split()))
    l[i][1] = int(l[i][1])
l_sorted = sorted(l, key=lambda l: l[1], reverse=True)
l_sorted = sorted(l_sorted, key=lambda l: l[0])

for i in range(len(l)):
    print(l.index(l_sorted[i]) + 1)
Buggy code:
l = []
for i in range(N):
    s, p = input().split()
    l.append([s, int(p), i + 1])

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

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

l.sort(key = lambda x: (x[0], -x[1]))
for i in l:
    print(i[2])
Buggy code:
import sys
import math

N = int(input())

list = []

for i in range(n):
    S, P = input().split()
    list.append((S, int(P), i+1))

list = sorted(list, key=lambda x:x[1],reverse = True) 
list = sorted(list, key=lambda x:x[0]) 
for j in range(N):
	print(list[j][2])


Fixed code:
import sys
import math

N = int(input())

list = []

for i in range(N):
    S, P = input().split()
    list.append((S, int(P), i+1))

list = sorted(list, key=lambda x:x[1],reverse = True) 
list = sorted(list, key=lambda x:x[0]) 
for j in range(N):
	print(list[j][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=sorted(sp,key=lambda x: (x[0],-x[1]))
print(sp)

for i in range(n):
    print(sp[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=sorted(sp,key=lambda x: (x[0],-x[1]))

for i in range(n):
    print(sp[i][2])
Buggy code:
a = []

for i in range(N):
	S,P = input().split()
	P = int(P)
	a.append([S,-P,i])

a.sort()
for aa in a:
	print(aa[2])

Fixed code:
N = int(input())
a = []

for i in range(N):
	S,P = input().split()
	P = int(P)
	a.append([S,-P,i])

a.sort()
for aa in a:
	print(aa[2]+1)
Buggy code:
N = int(input())
S = [input().split() for i in range(N)]
S_P = S[:]
for i in range(N):
    S_P[i][1] = -1*int(S_P[i][1])  
S_P.sort()
for i in range(N):
    S_P[i][1] = -1*int(S_P[i][1])
for i in range(N):
    print(S_P.index(S[i])+1)

Fixed code:
N = int(input())
S = [input().split() for i in range(N)]
S_P = S[:]
for i in range(N):
    S_P[i][1] = -1*int(S_P[i][1])  
S_P.sort()
for i in range(N):
    S_P[i][1] = -1*int(S_P[i][1])
for i in range(N):
    print(S.index(S_P[i])+1)
Buggy code:
#https://atcoder.jp/contests/abc127
# -*- coding: utf-8 -*-

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

s2=sorted(s,key=lambda x: (x[1]),reverse = True)
s2=sorted(s2,key=lambda x: (x[0]))
print(s2)
for i in s2:
    for j in range(n):
        if i==s[j]:
            print(j+1)

Fixed code:
#https://atcoder.jp/contests/abc127
# -*- coding: utf-8 -*-

n = int(input())
s = []
for i in range(n):
    x,y=input().split()
    y = int(y)
    s.append([x,y])

s2=sorted(s,key=lambda x: (x[1]),reverse = True)
s2=sorted(s2,key=lambda x: (x[0]))
for i in s2:
    for j in range(n):
        if i==s[j]:
            print(j+1)
Buggy code:
n = int(input())

s = [0]*n
p = [0]*n

list_2d = [[] for _ in range(n)]

for i in range(n):
    s, p = input().split()
    list_2d[i].append(s)
    list_2d[i].append(p)
list_2d_sorted = sorted(list_2d, key = lambda x: (x[0],x[1]))
for i in range(n):
    print(list_2d.index(list_2d_sorted[i])+1)

Fixed code:
n = int(input())

s = [0]*n
p = [0]*n

list_2d = [[] for _ in range(n)]

for i in range(n):
    s, p = input().split()
    list_2d[i].append(s)
    list_2d[i].append(p)
list_2d_sorted = sorted(list_2d, key = lambda x: (x[0],-int(x[1])))
for i in range(n):
    print(list_2d.index(list_2d_sorted[i])+1)
Buggy code:
N = int(input())
S_P = []
for i in range(N):
    S , P = input().split()
    S_P.append([ S , int(P) , i])
S_P.sort( key = lambda x : x[0] )
state = S_P[0][0]
S_P_sort = []
temp = []
for S , P , i in S_P:
    if S != state:
        temp.sort( key = lambda x : x[1])
        S_P_sort.extend(temp)
        S_P_sort.append([S , P, i])
        state = S
        temp = []
    else:
        temp.append([S , P, i])
for j in range(N):
    print(S_P_sort[j][2]+1)

Fixed code:
N = int(input())
S_P = []
for i in range(N):
    S , P = input().split()
    S_P.append([ S , int(P) , i])
S_P.sort( key = lambda x : x[0] )
state = S_P[0][0]
S_P_sort = []
temp = []
for S , P , i in S_P:
    if S != state:
        temp.sort( key = lambda x : x[1] , reverse = True)
        S_P_sort.extend(temp)
        state = S
        temp = []
        temp.append([S , P, i])
    else:
        temp.append([S , P, i])
temp.sort( key = lambda x : x[1] , reverse = True)
S_P_sort.extend(temp)
for j in range(N):
    print(S_P_sort[j][2]+1)
Buggy code:
N = int(input())
li = []
for i in range(N):
    si, pi = input().split()
    pi = int(pi)
    li +=[ [i, si, pi]]
li.sort(key=lambda x:x[2], reverse=True)
li.sort(key=lambda x:x[1], reverse=False)
for j in li:
    print(j[0])

Fixed code:
N = int(input())
li = []
for i in range(N):
    si, pi = input().split()
    pi = int(pi)
    li +=[ [i+1, si, pi]]
li.sort(key=lambda x:x[2], reverse=True)
li.sort(key=lambda x:x[1], reverse=False)
for j in li:
    print(j[0])
Buggy code:
N = int(input())
rs = []
for _ in range(N):
  s, p = map(int, input().split())
  rs.append((i+1, s, p))

rs.sort(key=lambda x:(x[1], -x[2]))
for r in rs:
  print(r[0])

Fixed code:
N = int(input())
rs = []
for i in range(N):
  s, p = input().split()
  rs.append((i+1, s, int(p)))

rs.sort(key=lambda x:(x[1], -x[2]))
for r in rs:
  print(r[0])
Buggy code:
n = int(input())
li = []
for i in range(n):
  li.append([str(i+1),input().split()])
li = sorted(li,key = lambda x:x[1][1],reverse=True)
li = sorted(li,key = lambda x:x[1][0])
for j in li:
  print(int(j[0]))

Fixed code:
n = int(input())
li = []
for i in range(n):
  li.append([str(i+1),input().split()])
li = sorted(li,key = lambda x:int(x[1][1]),reverse=True)
li = sorted(li,key = lambda x:x[1][0])
for j in li:
  print(int(j[0]))
Buggy code:
from collections import OrderedDict

N = int(input())

city = set()

rest = OrderedDict()

for i in range(N):
    sp = input().split()

    if sp[0] in city:
        rest[sp[0]].append([sp[1], i])
    else:
        city.add(sp[0])
        rest[sp[0]] = [[sp[1], i]]

index = sorted(rest)

for i in index:
    for r in sorted(rest[i], reverse=True):
        print(r[1]+1)


Fixed code:
from collections import OrderedDict

N = int(input())

city = set()

rest = OrderedDict()

for i in range(N):
    sp = input().split()

    if sp[0] in city:
        rest[sp[0]].append([int(sp[1]), i])
    else:
        city.add(sp[0])
        rest[sp[0]] =[[int(sp[1]), i]]

index = sorted(rest)

for i in index:
    for r in sorted(rest[i], reverse=True):
        print(r[1]+1)
Buggy code:
n=int(input())

lst=[]
for i in range(1, N+1):
    c,p=input().split()
    s=[i,c,int(p)]
    lst.append(s)

s=sorted(lst,key=lambda x: (x[1], -(x[2])))
for i in s:
    print(i[0])


Fixed code:
n=int(input())

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

s=sorted(lst,key=lambda x: (x[1], -(x[2])))
for i in s:
    print(i[0])
Buggy code:
n = int(input())

l = []
for i in range(n):
  x,y = map(str,input().split())
  l.append((x,y, i))


L = []

for i in range(n):
  L.append((l[i][0], int(l[i][1]), l[i][2]))

L.sort(key = lambda L:L[2])

L.sort(key = lambda L:L[1])

for i in range(n):
  A = n-i-1
  print(L[A][2] + 1)



Fixed code:
n = int(input())

l = []
for i in range(n):
  x,y = map(str,input().split())
  l.append((x,y, i))


L = []

for i in range(n):
  L.append((l[i][0], int(l[i][1]), l[i][2]))

L.sort(key = lambda L:(L[0],-L[1]))


for i in range(n):
  print(L[i][2] + 1)
Buggy code:
n = int(input())
# a, p = list(map(int, input().split()))
# a = list(map(int, input().split()))
# S = [list(map(int, input().split())) for i in range(n)]
S = [list(input().split()) for i in range(n)]

# for i, s in enumerate(S):
#     s.append(i+1)

S = sorted(S, key=lambda x: x[1], reverse=True)
S = sorted(S, key=lambda x: x[0], reverse=False)

for s, p, n in S:
    print(n)

Fixed code:
n = int(input())
# a, p = list(map(int, input().split()))
# a = list(map(int, input().split()))
# S = [list(map(int, input().split())) for i in range(n)]
S = [list(input().split()) for i in range(n)]

for i, s in enumerate(S):
    s.append(i+1)

S = sorted(S, key=lambda x: int(x[1]), reverse=True)
S = sorted(S, key=lambda x: x[0], reverse=False)

for s, p, n in S:
    print(n)
Buggy code:
#b.py
n = int(input())
lis = [list(input().split())+[x] for x in range(n)]
lis = sorted(lis,key=lambda x:x[0])
now = lis[0][0]
ans_lis = []
sublis = []
for x in lis:
    if x[0] == now:
        sublis.append(x)
    else:
        now = x[0]
        sublis = sorted(sublis,key=lambda x:int(x[1]),reverse=True)
        print(int(x[1]))
        ans_lis.append(sublis)
        sublis = []
        sublis.append(x)
sublis.sort(key=lambda x:int(x[1]),reverse=True)
ans_lis.append(sublis)
sublis = []
sublis.append(x)       
print(ans_lis)
ans_lis = [item for sublist in ans_lis for item in sublist]
for x in ans_lis:
    print(x[2]+1)



Fixed code:
#b.py
n = int(input())
lis = [list(input().split())+[x] for x in range(n)]
lis = sorted(lis,key=lambda x:x[0])
now = lis[0][0]
ans_lis = []
sublis = []
for x in lis:
    if x[0] == now:
        sublis.append(x)
    else:
        now = x[0]
        sublis = sorted(sublis,key=lambda x:int(x[1]),reverse=True)
        ans_lis.append(sublis)
        sublis = []
        sublis.append(x)
sublis.sort(key=lambda x:int(x[1]),reverse=True)
ans_lis.append(sublis)
sublis = []
sublis.append(x)       
ans_lis = [item for sublist in ans_lis for item in sublist]
for x in ans_lis:
    print(x[2]+1)
Buggy code:
N = int(input())
M = [0 for i in range(N*3)]
for i in range(N):
    M[i *3], M[i * 3 +1] = input().split()
    M[i * 3 + 2] = i + 1
arr = [[0 for column in range(3)] for row in range(N)]
for i in range(N):
    arr[i][0] = M[i *3]
    arr[i][1] = M[i * 3 +1]
    arr[i][2] = M[i * 3 +2]
arr = sorted(arr, key=lambda x:(x[0], x[1]), reverse = True)
arr = sorted(arr, key=lambda x:x[0])
for i in range(N):
    print(arr[i][2])

Fixed code:
N = int(input())
M = [0 for i in range(N*3)]
for i in range(N):
    M[i *3], M[i * 3 +1] = input().split()
    M[i * 3 + 2] = i + 1
arr = [[0 for column in range(3)] for row in range(N)]
for i in range(N):
    arr[i][0] = M[i *3]
    arr[i][1] = int(M[i * 3 +1])
    arr[i][2] = M[i * 3 +2]
arr = sorted(arr, key=lambda x:(x[0], x[1]), reverse = True)
arr = sorted(arr, key=lambda x:x[0])
for i in range(N):
    print(arr[i][2])
Buggy code:
n = int(input())
lst=[]
for i in range(1, n+1):
    s, p = input().split()
    p = int(p) * -1
    lst.append([s, p, i])
lst = sorted(lst)
print(lst)
for i in range(n):
    print(lst[i][2])

Fixed code:
n = int(input())
lst = []
for i in range(n):
	s, p = input().split()
	lst.append([s, -int(p), i+1])
lst = sorted(lst)
for i in range(n):
	print(lst[i][2])
Buggy code:
from operator import itemgetter  
i = int(input())
#print(i)
point =[]
for n in range(0,i):
  s, p = list(input().split(' '))
  point.append((s,int(p)))

point2 = sorted(point, key=itemgetter(1),reverse=True) 
point3 = sorted(point2, key=itemgetter(0)) 
print(point3)

for i in point:
  print(point3.index(i)+1)

Fixed code:
from operator import itemgetter  
i = int(input())
#print(i)
point =[]
for n in range(0,i):
  s, p = list(input().split(' '))
  point.append((s,int(p)))

#point2 = sorted(point, key=itemgetter(1),reverse=True) 
point2 = sorted(point, key=itemgetter(1),reverse=True) 
#point3 = sorted(point2, key=itemgetter(0)) 
point3 = sorted(point2, key=itemgetter(0)) 
#print(point3)

for i in point3:
  print(point.index(i)+1)
Buggy code:
a = []
n = int(input())

for i in range(1,n+1):
  name,score = map(int,input().split())
  a.append([name,-int(score),i])
  
a.sort()
for n,s,idx in a:
  print(idx)
 


Fixed code:
a = []
n = int(input())

for i in range(1,n+1):
  name,score =input().split()
  a.append([name,-int(score),i])
  
a.sort()
for n,s,idx in a:
  print(idx)
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 = sorted(sp, key=lambda x: x[1], reverse=True)
sp = sorted(sp, key=lambda x: x[0])
print(sp)
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 = sorted(sp, key=lambda x: x[1], reverse=True)
sp = sorted(sp, key=lambda x: x[0])
for i in sp:
    print(i[2])
Buggy code:
from operator import itemgetter, attrgetter

class data:
    def __init__(self, i, c, n):
        self.ind = i
        self.city = c
        self.num = -int(n)

N = int(input())
d = []
for i in range(N):
    s, p = input().split()
    d.append(data(i, s, p))

d.sort(key=attrgetter('city', 'num'))

for i in range(N):
    print(d[i].ind+1, d[i].city, d[i].num)

Fixed code:
from operator import itemgetter, attrgetter

class data:
    def __init__(self, i, c, n):
        self.ind = i
        self.city = c
        self.num = -int(n)

N = int(input())
d = []
for i in range(N):
    s, p = input().split()
    d.append(data(i, s, p))

d.sort(key=attrgetter('city', 'num'))

for i in range(N):
    print(d[i].ind+1)
Buggy code:
sp = []
for i in range(n):
    s, p = input().split()
    sp.append((s, int(p), i+1))

sp_sort = sorted(sp, key=lambda x: (x[0], -1 * x[1]))

for i in range(n):
    print(sp_sort[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 = sorted(sp, key=lambda x: (x[0], -1 * x[1]))

for i in range(n):
    print(sp_sort[i][2])
Buggy code:
N = int(input())
l = []
for i in range(N):
    a = input().split()
    l.append([a[0], a[1], i + 1])
l.sort()
for i in range(N):
    print(a[i][2])

Fixed code:
N = int(input())
l = []
for i in range(N):
    a = input().split()
    l.append([a[0], 100 - int(a[1]), i + 1])
l.sort()
for i in range(N):
    print(l[i][2])
Buggy code:
N = int(input())
rest = []
for i in range(N):
  S,P = input().split()
  inrest = [ i + 1 , str(S) , int(P)]
  rest.append(inrest)

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

for i in range(N):
  print(lest[i][0])

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

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

for i in range(N):
  print(rest[i][0])
Buggy code:
from operator import itemgetter
N = int(input())
SP = [[x for x in input().split()]+[i]for i in range(N)]
SP.sort(key=itemgetter(1),reverse=True)
SP.sort(key=itemgetter(0))
for i in SP:
    print(i[2]+1)


Fixed code:
from operator import itemgetter
N = int(input())
SP = []
for i in range(N):
    name,cost = [x for x in input().split()]
    SP.append([name,int(cost),i])
SP.sort(key=itemgetter(1),reverse=True)
SP.sort(key=itemgetter(0))
for i in SP:
    print(i[2]+1)
Buggy code:
 N = int(input())
 SP = [list(map(str, input().split())) for _ in range(N)]

 for i in range(N):
   SP[i].append(i+1)
   SP[i][1] = int(SP[i][1])*(-1)

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

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


Fixed code:
N = int(input())
SP = [list(map(str, input().split())) for _ in range(N)]

for i in range(N):
  SP[i].append(i+1)
  SP[i][1] = int(SP[i][1])*(-1)

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

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