qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n = int(input())
sp = {}
for i in range(n):
    s, p = input().split()
    if s in sp:
        sp[s].append([int(p), i+1])
    else:
        sp[s] = []
        sp[s].append([int(p), i+1])
        
for i in sp.keys():
    sp[i].sort(reverse=True)
sp = sorted(sp.items(), key=lambda x:x[0])

print(sp)
for i in sp:
    for j in i[1]:
        print(j[1])

Fixed code:
n = int(input())
sp = {}
for i in range(n):
    s, p = input().split()
    if s in sp:
        sp[s].append([int(p), i+1])
    else:
        sp[s] = []
        sp[s].append([int(p), i+1])
        
for i in sp.keys():
    sp[i].sort(reverse=True)
sp = sorted(sp.items(), key=lambda x:x[0])

for i in sp:
    for j in i[1]:
        print(j[1])
Buggy code:
n = int(input())

list = []

for i in range(n):
	city,score = input().split()
	list.append({'id': i + 1, 'city': city, 'score': score})

list = sorted(list, key=lambda x:x['score'], reverse=True)
list = sorted(list, key=lambda x:x['city'])

for dict in list:
	print(dict['id'])


Fixed code:
n = int(input())

list = []

for i in range(n):
	city,score = input().split()
	list.append({'id': i + 1, 'city': city, 'score': int(score)})

list = sorted(list, key=lambda x:x['score'], reverse=True)
list = sorted(list, key=lambda x:x['city'])

for dict in list:
	print(dict['id'])
Buggy code:
n = int(input())
data =[]
for i in range(n):
  sity, score = input().split()
  data.append([sity, int(score),i+1])
  
data.sort(key=lambda x:x[0])
data.sort(key=lambda x:x[1], reverse=True)
for j in range(n):
  print(data[j][2])
  

  

Fixed code:
n = int(input())
data =[]
for i in range(n):
  sity, score = input().split()
  data.append([sity, int(score),i+1])
  
data.sort(key=lambda x:(x[0], -x[1]))
for j in range(n):
  print(data[j][2])
Buggy code:
n=int(input())
a=[]
b=[]


for i in range(n):
    s,p=input().split()
    a.append(s)
    b.append(p)

x=list(zip(a,b))

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

for i in range(n):
    print(int(x.index(y[i]))+1)

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


for i in range(n):
    s,p=input().split()
    p=int(p)
    a.append(s)
    b.append(p)

x=list(zip(a,b))

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

for i in range(n):
    print(int(x.index(y[i]))+1)
Buggy code:
n = int(input())
spi = []
for i in range(n):
    s, p = map(input().split())
    spi.append((s,-int(p), i))
spi = sorted(spi)
for s, p, i in spi:
    print(i+1)

Fixed code:
n = int(input())
spi = []
for i in range(n):
    s, p = input().split()
    spi.append((s,-int(p), i))
spi = sorted(spi)
for s, p, i in spi:
    print(i+1)
Buggy code:
n = int(input())
List = []
for i in range(n):
    List.append([i]+list(input().split()))
List.sort(key=lambda x: x[2], reverse=True)
List.sort(key=lambda x: x[1])

for i in range(n):
    print(1+List[i][0])



Fixed code:
n = int(input())
List = []
for i in range(n):
    Tmp = [i]+list(input().split())
    Tmp[2] = int(Tmp[2])
    List.append(Tmp)
List.sort(key=lambda x: x[2], reverse=True)
List.sort(key=lambda x: x[1])

for i in range(n):
    print(1+List[i][0])
Buggy code:
# -*- coding: utf-8 -*-
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    L = [0] * N
    for i in range(N):
        s, p = i2s().split()
        L[i] = (s, inr(p), i)

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

main()


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

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    L = [0] * N
    for i in range(N):
        s, p = i2s().split()
        L[i] = (s, int(p), i + 1)

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

main()
Buggy code:
# -*- coding: utf-8 -*-
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    r = {}
    for i in range(N):
        s, p = i2s().split()
        p = int(p)
        if s in r.keys():
            r[s] += [(p, i)]
        else:
            r[s] = [(p, i)]

    rname = list(r.keys())
    rname.sort()
    for n in rname:
        out = [x[1] for x in sorted(r[n], reverse=True)]
        for m in out:
            print(m)

main()


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

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    r = {}
    for i in range(N):
        s, p = i2s().split()
        p = int(p)
        if s in r.keys():
            r[s] += [(p, i)]
        else:
            r[s] = [(p, i)]

    rname = list(r.keys())
    rname.sort()
    # print(rname)
    for n in rname:
        out = [x[1] for x in sorted(r[n], reverse=True)]
        for m in out:
            print(m + 1)

main()
Buggy code:
N = int(input())
A = []
for i in range(N):
    S, P = input().split()
    A.append([S, P, i + 1])
A.sort(key=lambda x:x[1], reverse=True)
A.sort(key=lambda x:x[0])
for a in A:
    print(a[2])


Fixed code:
N = int(input())
A = []
for i in range(N):
    S, P = input().split()
    A.append([S, int(P), i + 1])
A.sort(key=lambda x:(x[0], -x[1]))
for a in A:
    print(a[2])
Buggy code:
def main():
    N = int(input())
    S = []
    for i in range(N):
        line = [a for a in input().split()]
        S.append([i+1] + line)
    tmp = sorted(S, key=lambda x:x[2], reverse=True)
    ans = sorted(tmp, key=lambda x:x[1])
    for i in range(len(ans)):
        print(ans[i][0])

main()


Fixed code:
def main():
    N = int(input())
    S = []
    for i in range(N):
        line = [a for a in input().split()]
        line[1] = int(line[1])
        S.append([i+1] + line)
    tmp = sorted(S, key=lambda x:x[2], reverse=True)
    ans = sorted(tmp, key=lambda x:x[1])
    for i in range(len(ans)):
        print(ans[i][0])

main()
Buggy code:
n = int(input())
l = []
for i in range(n):
    s, p = input().split()
    l.append((s,int(p),i))
l.sort(key = lambda x:(x[0],x[1]), reverse = True)
for _ in l:
    print(l[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[1],reverse=True)
l.sort(key = lambda x : x[0])
for i in range(n):
    print(l[i][2])
Buggy code:
import numpy as np
from nltk.classify.maxent import calculate_empirical_fcount
N = int(input())
SList = []
PList = []
dic = {}
Slist = []
aa = []
for _ in range(N):
    S, P = input().split()
    dic[S] = int(P)
    Slist.append(S)
    aa.append((int(P), S))
dic = sorted(dic.items())

sortedS = list(sorted(set(Slist)))

for i in range(len(sortedS)):
    tempV = []
    tempI = []
    for j in range(N):
        if aa[j][1] == sortedS[i]:
            tempV.append(aa[j][0])
            tempI.append(j)
    indexList = np.argsort(tempV)
    for k in reversed(indexList):
        print(tempI[k] + 1)


Fixed code:
import numpy as np
N = int(input())
SList = []
PList = []
dic = {}
Slist = []
aa = []
for _ in range(N):
    S, P = input().split()
    dic[S] = int(P)
    Slist.append(S)
    aa.append((int(P), S))
dic = sorted(dic.items())

sortedS = list(sorted(set(Slist)))

for i in range(len(sortedS)):
    tempV = []
    tempI = []
    for j in range(N):
        if aa[j][1] == sortedS[i]:
            tempV.append(aa[j][0])
            tempI.append(j)
    indexList = np.argsort(tempV)
    for k in reversed(indexList):
        print(tempI[k] + 1)
Buggy code:
n=int(input())
s =[]
l =[]
ans = []
count = 1
for i in range(n):
    s1,p = map(str,input().split())
    p1 = int(p)
    l.append(s1)
    s.append(list([s1,p1]))
l = sorted(list(set(l)))
for i in l:
    t =[]
    index_num = [n for n, v  in enumerate(s) if v[0] == i]
    for k in index_num:
        t.append(list([s[k][1],k]))
    t=sorted(t,reverse=True)
    for z in t:
        ans.append(list([z[1],count]))
        count+=1
ans = sorted(ans)
[print(ans[i][1]) for i in range(len(ans))]

Fixed code:
n=int(input())
s =[]
l =[]
ans = []
for i in range(n):
    s1,p = map(str,input().split())
    p1 = int(p)
    l.append(s1)
    s.append(list([s1,p1]))
l = sorted(list(set(l)))
for i in l:
    t =[]
    index_num = [n for n, v  in enumerate(s) if v[0] == i]
    for k in index_num:
        t.append(list([s[k][1],k]))
    t=sorted(t,reverse=True)
    for z in t:
        ans.append(z[1]+1)
[print(i) for i in ans]
Buggy code:
khabarovsk 20
n = int(input())
dict = {}
for i in range(n):
    s, p = input().split()
    if s not in dict:
        dict[s] = []
    dict[s].append((int(p), i + 1))

for s in sorted(dict.keys()):
    for (p, i) in reversed(sorted(dict[s])):
        print(i)

Fixed code:
n = int(input())
dict = {}
for i in range(n):
    s, p = input().split()
    if s not in dict:
        dict[s] = []
    dict[s].append((int(p), i + 1))

for s in sorted(dict.keys()):
    for (p, i) in reversed(sorted(dict[s])):
        print(i)
Buggy code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 26 20:55:50 2019

@author: Yamazaki Kenichi
"""

N = int(input())
sp = [list(map(str,input().split()))+[i] for i in range(N)]


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

for c in sp:
    print(int(c[2])+1)

Fixed code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 26 20:55:50 2019

@author: Yamazaki Kenichi
"""

N = int(input())
sp = [list(map(str,input().split()))+[i] for i in range(N)]

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

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

#sp1.sort(reverse = True, key=lambda x: x[1])

for c in sp1:
    print(int(c[2])+1)
Buggy code:
from operator import itemgetter
n=int(input())
s=[input().split() for i in range(n)]
t=sorted(s,key=lambda x:(x[0],-int(x[1])))
print(s)
print(t)
for i in s:
  print(t.index(i)+1)

Fixed code:
from operator import itemgetter
n=int(input())
s=[input().split() for i in range(n)]
t=sorted(s,key=lambda x:(x[0],-int(x[1])))
[print(s.index(i)+1) for i in t]
Buggy code:
n = int(input())
sp = []

for i in range(n):
    sp.append(input().split())
    sp[i].append(i + 1)

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


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

for i in range(n):
    sp.append(input().split())
    sp[i].append(i + 1)

sp.sort(key=lambda x:(x[0], -int(x[1])))
# print(sp)
for r in sp:
    print(r[2])
Buggy code:
n = int(input())
res = []
for i in range(n):
    a,b = input().split()
    res.append ((a,b))        
res_1 = sorted(res,key=lambda x: (x[0], -int(x[1])))
for i in range(len(res_1)):
    print(res.index(res_1[i]))

Fixed code:
n = int(input())
res = []
for i in range(n):
    a,b = input().split()
    res.append ((a,b))        
res_1 = sorted(res,key=lambda x: (x[0], -int(x[1])))
for i in range(len(res_1)):
    print(res.index(res_1[i])+1)
Buggy code:
n=int(input())
temp=[0]*n
for i in range(0,n):
  s,p=input().split()
  temp[i]=[i,s,int(p)]
temp=sorted(temp, key=lambda x: (x[1],-x[2]))
for i in range(0,n)
  print(temp[i])



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

lst = list()
for i in range(1, N+1):
    s, p = input().split()
    lst.append({"id":i, "s":s, "p":p})

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

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

Fixed code:
N = int(input())

lst = list()
for i in range(1, N+1):
    s, p = input().split()
    lst.append({"id":i, "s":s, "p":int(p)})

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

for i in range(0, len(lst)):
    print(lst[i]["id"])
Buggy code:
n = int(input())
restaurant = [[n+1]+input().split(' ') for n in range(n)]

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

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

restaurant.sort(reverse=True, key=lambda x: x[2])
restaurant.sort(key=lambda x: x[1])
for i,_,_ in restaurant:
    print(i)
Buggy code:
from operator import itemgetter
import copy

data = []


for n in range(int(input())):
	data.append(input().split(" "))


for n in range(len(data)):
	data[n][1] = int(data[n][1])

base = copy.deepcopy(data)

print(data)



data.sort(key=itemgetter(1),reverse=True)

print(data)

data.sort(key=itemgetter(0))

print(data)

for n in range(len(data)):
	print(base.index(data[n])+1)

Fixed code:
from operator import itemgetter
import copy

data = []


for n in range(int(input())):
	data.append(input().split(" "))


for n in range(len(data)):
	data[n][1] = int(data[n][1])

base = copy.deepcopy(data)

data.sort(key=itemgetter(1),reverse=True)

data.sort(key=itemgetter(0))

for n in range(len(data)):
	print(base.index(data[n])+1)
Buggy code:
N = int(input())
lst = [[] for _ in range(N)]

for i in range(N):
    S, P = input().split()
    lst[i].append(S)
    lst[i].append(P)
    lst[i].append(i+1)
    
lst_a = sorted(lst, key=lambda x:x[1], reverse=True)
lst_a = sorted(lst_a, key=lambda x:x[0])

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

Fixed code:
N = int(input())
lst = [[] for _ in range(N)]

for i in range(N):
    S, P = input().split()
    lst[i].append(S)
    lst[i].append(P)
    lst[i].append(i+1)
    
lst_a = sorted(lst, key=lambda x:(x[0], -int(x[1])))
for i in range(N):
    print(lst_a[i][2])
Buggy code:
N= int(input())
li = list()

for i in range(N):
  res,score = input().split()
  score = int(score)
  li.append([res,score,i+1])
  
li.sort()

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

Fixed code:
N= int(input())
li = list()

for i in range(N):
  res,score = input().split()
  score = int(score)
  li.append([res,-score,i+1])
  
li.sort()

for i in li:
  print(i[2])
Buggy code:
import numpy as np
from operator import itemgetter

N = int(input())

list = []
for i in range(N):
    a,b=input().split()
    list.append([a, int(b),i+1])
sort1 = sorted(list, key=itemgetter(0))
if N == 1:
  print(1)
else:
  ans = []
  kari = []
  end = 1
  k = 1
  for i in range(0,N-1):
    if end == 1:
      kari.append(sort1[i])
      else:
        k = 0
        if sort1[i][0] == sort1[i+1][0]:  
          kari.append(sort1[i+1])
          end = 0
          if i+1 > N-2:
            kari.sort(key=itemgetter(1),reverse=True)
            ans.extend(kari)

            else:
              kari.sort(key=itemgetter(1),reverse=True)
              ans.extend(kari)
              if i+1 > N-2:
                ans.append(sort1[i+1])
                kari = []
                end = 1
  print(sort1)
  print(ans)
  for i in range(0,len(ans)):
      print(ans[i][2])

Fixed code:
import numpy as np
from operator import itemgetter
 
N = int(input())
 
list = []
for i in range(N):
    a,b=input().split()
    list.append([a, int(b),i+1])
sort1 = sorted(list, key=itemgetter(0))
if N == 1:
  	print(1)
else:
    ans = []
    kari = []
    end = 1
    k = 1
    for i in range(0,N-1):
        if end == 1:
            kari.append(sort1[i])
        else:
            k = 0
        if sort1[i][0] == sort1[i+1][0]:  
            kari.append(sort1[i+1])
            end = 0
            if i+1 > N-2:
            	kari.sort(key=itemgetter(1),reverse=True)
            	ans.extend(kari)

        else:
            kari.sort(key=itemgetter(1),reverse=True)
            ans.extend(kari)
            if i+1 > N-2:
            	ans.append(sort1[i+1])
            kari = []
            end = 1
    
    for i in range(0,len(ans)):
        print(ans[i][2])
Buggy code:
n = input()
x = []
for i in range(n):
  s,p=input().split()
  x.append([s,int(p),i+1])
x.sort(key=lambda x:(x[0],-x[1]))
for i in x:
  print(i[2])

Fixed code:
n = int(input())
x = []
for i in range(n):
  s,p=input().split()
  x.append([s,int(p),i+1])
x.sort(key=lambda x:(x[0],-x[1]))
for i in x:
  print(i[2])
Buggy code:
n=int(input())
x=[]
for i in range(n):
    key,val=map(str,input().split())
    x.append([key,-int(val),i+1])
dic_sort=sorted(x, key=lambda x:(x[0],x[1]))
print(dic_sort)
for i in range(n):
    print(dic_sort[i][2])

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

a = [input().split() for i in range(n)]

li=[]
for i in range(n):
    li.append([a[i][0],100- int(a[i][1]), i+1])
    print(li)

li.sort()

for i in range(n):
  print("{}\n".format(li[i][2]))

Fixed code:
n = int(input())

a = [input().split() for i in range(n)]

li=[]
for i in range(n):
    li.append([a[i][0],100- int(a[i][1]), i+1])

li.sort()

for i in range(n):
  print("{}".format(li[i][2]))
Buggy code:
from operator import itemgetter
n=int(input())
x,y,s=list(),list(),list()
for i in range(1,n+1):
	S=input().split()
	S.append(i)
	s.append(S)
y=sorted(s,key=itemgetter(0))
for i in range(n):
	for j in range(1,n):
		if((y[j-1][0]==y[j][0])&(y[j-1][1]<y[j][1])):
			y[j-1],y[j]=y[j],y[j-1]
for i in range(n):
	print(y[i][2])

Fixed code:
from operator import itemgetter
n=int(input())
y,s=list(),list()
for i in range(1,n+1):
	S=input().split()
	S[1]=int(S[1])
	S.append(i)
	s.append(S)
y=sorted(s,key=itemgetter(0))
for i in range(n):
	for j in range(1,n):
		if((y[j-1][0]==y[j][0])&(y[j-1][1]<y[j][1])): y[j-1],y[j]=y[j],y[j-1]
for i in range(n):
	print(y[i][2])
Buggy code:
N = int(input())

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

arr.sort()
for s, p, i in arr:
    print(i)

for s, p, i in arr:
    print(s, p)

Fixed code:
N = int(input())

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

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

sp.sort()
for i in range(n):
    print(sp[i][2])

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

sp.sort()
for i in range(n):
    print(sp[i][2])
Buggy code:
from sys import stdin
from copy import deepcopy


n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
for i, list in enumerate(data):
    list[1] = int(list[1])
    list.append(i+1)

sortdata = sorted(data, key=lambda x: (x[0], -x[1]))
print(sortdata)

for i, list in enumerate(sortdata):
    print(list[2])


Fixed code:
from sys import stdin
from copy import deepcopy


n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
for i, list in enumerate(data):
    list[1] = int(list[1])
    list.append(i+1)

sortdata = sorted(data, key=lambda x: (x[0], -x[1]))

for i, list in enumerate(sortdata):
    print(list[2])
Buggy code:
N = int(input())

l = []

for i in range(N):
    s , p = map(str, input().split())
    p = 100-int(p)
    if p == 0:
        l.append(s+str(999))
    elif p < 10:
        l.append(s+str(0)+str(p))
    else:
        l.append(s+str(p))
l_new = sorted(l)
# print(l)
# print(l_new)
for i in l_new:
    print(l.index(i)+1)

Fixed code:
N = int(input())

l = []

for i in range(N):
    s , p = map(str, input().split())
    p = 100-int(p)
    if p == 100:
        l.append(s+str(999))
    elif p < 10:
        l.append(s+str(0)+str(p))
    else:
        l.append(s+str(p))
l_new = sorted(l)
# print(l)
# print(l_new)
for i in l_new:
    print(l.index(i)+1)
Buggy code:
# -*- coding: utf-8 -*-

N = int(input())

SP = [input().split() for i in range(N)]
SP = [[sp[0], sp[1], i] for i, sp in enumerate(SP)]
SP.sort(key=lambda x: x[1], reverse=True)
SP.sort(key=lambda x: x[0])
SP = [[sp[0], sp[1], sp[2], i+1] for i, sp in enumerate(SP)]
SP.sort(key=lambda x: x[2])

for sp in SP:
    print(sp[3])

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

N = int(input())

SP = [input().split() for i in range(N)]
SP = [[sp[0], int(sp[1]), i+1] for i, sp in enumerate(SP)]
SP.sort(key=lambda x: x[1], reverse=True)
SP.sort(key=lambda x: x[0])
for sp in SP:
    print(sp[2])
Buggy code:
N = int(input())
# SP = sorted([list(input().split()) for _ in range(N)])
SP = {}
for i in range(N):
    city,score = input().split()
    if city in SP:
        SP[city].append([score,i])
    else:
        SP[city] = []
        SP[city].append([score,i])
# print(SP)


for city in sorted(SP.keys()):
    score = sorted(SP[city], reverse=True)
    for s in score:
        print(s[1]+1)


Fixed code:
N = int(input())
# SP = sorted([list(input().split()) for _ in range(N)])
SP = {}
for i in range(N):
    city,score = input().split()
    if city in SP:
        SP[city].append([int(score),i])
    else:
        SP[city] = []
        SP[city].append([int(score),i])
# print(SP)


for city in sorted(SP.keys()):

    score = sorted(SP[city], reverse=True)
    for s in score:
        print(s[1]+1)
Buggy code:
n = int(input())

sp = [list(input().split()) for i in range(n)]
for index, sp_t in enumerate(sp):
        sp_t.append(index)
sp.sort(key=lambda x:x[1], reverse=True)
sp.sort(key=lambda x:x[0])


for sp_t in sp:
        print(sp_t[2]+1)

Fixed code:
n = int(input())

sp = [list(input().split()) for i in range(n)]
for index, sp_t in enumerate(sp):
        sp_t.append(index)
sp.sort(key=lambda x:int(x[1]), reverse=True)
# print(sp)
sp.sort(key=lambda x:x[0])
# print(sp)

for sp_t in sp:
        print(sp_t[2]+1)
Buggy code:
n=int(input())
a=[]
for i in range(n):
    b,c=input().split()
    c=int(c)
    a.append([b,c])
sa=sorted(a)
sa.append(["STOP"])
ssa=[]
ssaa=[]
while len(sa)>1:
    while True:
        ssa.append(sa[0])
        sa=sa[1:]
        if ssa[-1][0]!=sa[0][0] or sa[0]=="STOP":
            break
    ssa=ssa[::-1]
    for i in ssa:
        ssaa.append(i)
    ssa=[]
for i in a:
    print(ssaa.index(i)+1)

Fixed code:
n=int(input())
a=[]
for i in range(n):
    b,c=input().split()
    c=int(c)
    a.append([b,c])
sa=sorted(a)
sa.append(["STOP"])
ssa=[]
ssaa=[]
while len(sa)>1:
    while True:
        ssa.append(sa[0])
        sa=sa[1:]
        if ssa[-1][0]!=sa[0][0] or sa[0]=="STOP":
            break
    ssa=ssa[::-1]
    for i in ssa:
        ssaa.append(i)
    ssa=[]
for i in ssaa:
    print(a.index(i)+1)
Buggy code:
N = int(input())
L = []
D = {}
for _ in range(N):
  k, v = input().split()
  L.append((k, v))
  if k not in D.keys():
    D[k] = [v]
  else:
    D[k].append(v)
for v in D.values():
  v.sort(reverse=True)
D = sorted(D.items(), key=lambda x: x[0])
for d in D:
  for i in range(len(d[1])):
    print(L.index((d[0], d[1][i]))+1)


Fixed code:
N = int(input())
L = []
D = {}
for _ in range(N):
  k, v = input().split()
  v = int(v)
  L.append((k, v))
  if k not in D.keys():
    D[k] = [v]
  else:
    D[k].append(v)

for v in D.values():
  v.sort(reverse=True)
D = sorted(D.items(), key=lambda x: x[0])

for d in D:
  for i in range(len(d[1])):
    print(L.index((d[0], d[1][i]))+1)