qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n = int(input())
s = [input().split() for i in range(n)]

dic = {}
for i in range(n):
    s[i][1] = int(s[i][1])
    s[i].append(i+1)
    restaurant = s[i][0]
    if restaurant not in dic:
        dic[restaurant] = [[s[i][1], s[i][2]]]
    else:
        dic[restaurant].append([s[i][1], s[i][2]])
print(dic)
keys = sorted(dic.keys())
print(keys)
for i in keys:
    for j in range(len(dic[i])):
        value = sorted(dic[i], key=lambda x: x[0], reverse=True)
        print(value[j][1])

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

dic = {}
for i in range(n):
    s[i][1] = int(s[i][1])
    s[i].append(i+1)
    restaurant = s[i][0]
    if restaurant not in dic:
        dic[restaurant] = [[s[i][1], s[i][2]]]
    else:
        dic[restaurant].append([s[i][1], s[i][2]])
#print(dic)
keys = sorted(dic.keys())
#print(keys)
for i in keys:
    for j in range(len(dic[i])):
        value = sorted(dic[i], key=lambda x: x[0], reverse=True)
        print(value[j][1])
Buggy code:
n = int(input())

d = [input().split() + [i+1] for i in range(N)]
d = sorted(d, key=lambda x:x[1], reverse=True)
d = sorted(d, key=lambda x:x[0], reverse=False)
for s in d:
    print(s[-1])

Fixed code:
n = int(input())

d = [input().split() + [i+1] for i in range(n)]
d = sorted(d, key=lambda x:int(x[1]), reverse=True)
d = sorted(d, key=lambda x:x[0], reverse=False)
for s in d:
    print(s[-1])
Buggy code:
N = int(input())
SP = {}
for i in range(N):
    line = input().split()
    SP[i] = [line[0], int(line[1])]
    
ans = []
for i, index in enumerate(sorted(SP.items(), key= lambda x: (x[1][0], -x[1][1]))):
    ans.append([index, i])
print(ans)

for ls in ans:
    print(ls[0][0] + 1)

Fixed code:
N = int(input())
SP = {}
for i in range(N):
    line = input().split()
    SP[i] = [line[0], int(line[1])]
    
ans = []
for i, index in enumerate(sorted(SP.items(), key= lambda x: (x[1][0], -x[1][1]))):
    ans.append([index, i])

for ls in ans:
    print(ls[0][0] + 1)
Buggy code:
N=int(input())
SP=[]
for i in range(N):
    SP.append(input().split())
for j in range(N):
    SP[j].append(j+1)
SP.sort(key=lambda x:x[1],reverse=True)
SP.sort(key=lambda x:x[0])
for k in range(N):
    print(SP[k][2])

Fixed code:
N=int(input())
SP=[]
for i in range(N):
    SP.append(input().split())
for j in range(N):
    SP[j].append(j+1)
SP.sort(key=lambda x:int(x[1]),reverse=True)
SP.sort(key=lambda x:x[0])
for k in range(N):
    print(SP[k][2])
Buggy code:
n = int(input())
shop_list = []
for i in range(n):
  s, p = input().split()
  shop_list.append((i+1, s, int(p)))

shop_list = sorted(shop_list, key=lambda x:x[2], reverse=True)
shop_list = sorted(shop_list, key=lambda x:(x[1], -x[2]), reverse=True)
for e in shop_list:
  print(e[0])

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

shop_list = sorted(shop_list, key=lambda x:(x[1], -x[2]))
for e in shop_list:
  print(e[0])
Buggy code:
N = int(input())
city={}
city_name=[]
for n in range(N):
    S = input().split()
    city[n+1]=S
    city_name.append(S[0])

city_name=list(set(city_name))
city_name.sort()

for c_name in city_name:
    city_temp = {}
    for c_key in city.keys():
        if city[c_key][0] == c_name:
            city_temp[city[c_key][1]]=c_key
            
    p_temp = list(city_temp.keys())
    p_temp.sort(reverse=True)
    for v in p_temp:
        print(city_temp[v])

Fixed code:
N = int(input())
city={}
city_name=[]
for n in range(N):
    S = input().split()
    city[n+1]=S
    city_name.append(S[0])

city_name=list(set(city_name))
city_name.sort()

for c_name in city_name:
    city_temp = {}
    for c_key in city.keys():
        if city[c_key][0] == c_name:
            city_temp[int(city[c_key][1])]=c_key
            
    p_temp = list(city_temp.keys())
    p_temp.sort(reverse=True)
    for v in p_temp:
        print(city_temp[v])
Buggy code:
def main():
    n = int(input())
    a = [list(input().split()) for i in range(n)]
    s = sorted(a, key=lambda x:(x[0],-int(x[1])))
    for i in a:
        print(s.index(i)+1)

if __name__ == '__main__':
    main()


Fixed code:
def main():
    n = int(input())
    if n == 1:
        print(1)
        return 
    a = [list(input().split()) for i in range(n)]
    s = sorted(a, key=lambda x:(x[0],-int(x[1])))
    for i in s:
        print(a.index(i)+1)

if __name__ == '__main__':
    main()
Buggy code:
n=int(input())
a=[]
for i in range(n):
    s,p=input().split()
    a+=[(s,-int(p),i+1)]
a.sort()
for i in a:
    print(a[2])

Fixed code:
n=int(input())
a=[]
for i in range(n):
    s,p=input().split()
    a+=[(s,-int(p),i+1)]
a.sort()
for i in range(n):
    print(a[i][2])
Buggy code:
n = int(input())
arr = [0]*n

for i in range(n):
	city, score = input().split()
    arr[i] = [city, int(score), i+1]
arr.sort(key = lambda x: (x[0], -x[1]))
for ele in arr:
  print(arr[2])

Fixed code:
n = int(input())

arr= [0]*n

for i in range(n):
	city, score = input().split()
	arr[i] = [city, int(score), i+1]

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

for ele in arr:
	print(ele[2])
Buggy code:
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N = I()
    #city = []
    city = set()
    sp = []
    for i in range(N):
        i += 1
        s, p = input().split()
        p = int(p)
        sp.append([s, p, i])
        city.add(s)
    city = list(city)
    city.sort()
    ans = [[] for i in range(len(city))]
    sp.sort(reverse=True, key=lambda x: x[1])
    for s, p, i in sp:
        for j, c in enumerate(city):
            if s == c:
                ans[j].append(i)

    print(city)

    for a in ans:
        print(*a, sep="\n")


if __name__ == '__main__':
    main()


Fixed code:
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N = I()
    #city = []
    city = set()
    sp = []
    for i in range(N):
        i += 1
        s, p = input().split()
        p = int(p)
        sp.append([s, p, i])
        city.add(s)
    city = list(city)
    city.sort()
    ans = [[] for i in range(len(city))]
    sp.sort(reverse=True, key=lambda x: x[1])
    for s, p, i in sp:
        for j, c in enumerate(city):
            if s == c:
                ans[j].append(i)

    for a in ans:
        print(*a, sep="\n")


if __name__ == '__main__':
    main()
Buggy code:
n = int(input())
li = []
for i in range(n):
    li.append(list(input().split()))
    li[i].append(i + 1)
li.sort(key=lambda x: x[1], reverse = True)
li.sort(key=lambda x: x[0])
for i in range(n):
    print(li[i][2])

Fixed code:
n = int(input())
li = []
for i in range(n):
    li.append(list(input().split()))
    li[i].append(i + 1)
    li[i][1] = int(li[i][1])
li.sort(key=lambda x: x[1], reverse = True)
li.sort(key=lambda x: x[0])
for i in li:
    print(i[2])
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[2])

for i in range(len(lst)):
    print(lst[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(len(lst)):
    print(lst[i][2])
Buggy code:
#!/usr/bin/env python3

N = int(input())
SP = []
for i in range(N):
    SP.append({"id" :i, "data": input().split()})

tmp = sorted(SP, key=lambda x:x["data"][1], reverse=True)

for k in sorted(tmp, key=lambda x:x["data"][0]):
    print(k["id"]+1)


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

N = int(input())
SP = []
for i in range(N):
    SP.append({"id" :i, "data": input().split()})

tmp = sorted(SP, key=lambda x:int(x["data"][1]), reverse=True)

for k in sorted(tmp, key=lambda x:x["data"][0]):
    print(k["id"]+1)
Buggy code:
from operator import itemgetter, attrgetter

a = int(input())
b = []
for i in range(a):
    c = input().split()
    b.append((c[0], int(c[1]), i+1))
s = sorted(b, key=itemgetter(0))
sorted(s, key=itemgetter(1), reverse=True)
for i in s:
    print(i[-1])



Fixed code:
from operator import itemgetter, attrgetter

a = int(input())
b = []
for i in range(a):
    c = input().split()
    b.append((c[0], int(c[1]), i+1))
s = sorted(b, key=itemgetter(1), reverse=True)
#print(s)
f = sorted(s, key=itemgetter(0), reverse=False)
#print(f)

for i in f:
    print(i[-1])
Buggy code:
from collections import defaultdict


def main():
    N = int(input())
    restaurant = defaultdict(list)
    for i in range(N):
        tmp = input().split()
        restaurant[tmp[0]].append((tmp[1], i+1))

    name_list = sorted(list(restaurant.keys()))

    for n in name_list:
        tmp = sorted(restaurant[n], key=lambda x: x[0], reverse=True)
        for t in tmp:
            print(t[1])


if __name__ == "__main__":
    main()


Fixed code:
from collections import defaultdict


def main():
    N = int(input())
    restaurant = defaultdict(list)
    for i in range(N):
        tmp = input().split()
        restaurant[tmp[0]].append((int(tmp[1]), i+1))

    name_list = sorted(list(restaurant.keys()))

    for n in name_list:
        tmp = sorted(restaurant[n], key=lambda x: x[0], reverse=True)
        for t in tmp:
            print(t[1])


if __name__ == "__main__":
    main()
Buggy code:
N = int(input())
SP = []
for i in range(N):
  c, p = input().split()
  SP.append([i+1, c, p])
SP = sorted(SP, key=lambda x:x[2], reverse=True)
SP = sorted(SP, key=lambda x:x[1])
for s in SP:
  print(s[0])

Fixed code:
N = int(input())
SP = []
for i in range(N):
  c, p = input().split()
  SP.append([i+1, c, int(p)])
SP = sorted(SP, key=lambda x:x[2], reverse=True)
SP = sorted(SP, key=lambda x:x[1])
for s in SP:
  print(s[0])
Buggy code:
N = int(input())
L=[]
for _ in range(N):
    tmp = input().split()
    L.append((tmp[0],int(tmp[1])))

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

for i in L:
    print(i[1])

Fixed code:
N = int(input())
L=[]
for i in range(N):
    tmp = input().split()
    L.append((tmp[0],int(tmp[1]),i+1))
    
L.sort(reverse=True, key=lambda x:x[1])
L.sort(key=lambda x:x[0])

for i in L:
    print(i[2])
Buggy code:
N = int(input())
S = [[i for i in input().split()] for i in range(N)]

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

s = sorted(S)

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


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

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

s = sorted(S)

for i in range(N):
    print(S.index(s[i]) + 1)
Buggy code:
def solve():
  n = int(input())
  query = []
  for i in range(n):
    s,p = input().split()
    query.append((s+str(1010-int(p)),i+1))
  query.sort()
  for i in range(n):
    print(query[i][1])
solve()

Fixed code:
def solve():
  n = int(input())
  query = []
  for i in range(n):
    tmp = input()
    s,p = tmp.split()
    p = str(90000000-int(p))
    s = s+p
    query.append((s,i+1))
  query.sort()
            
    
  for i in range(n):
    print(query[i][1])
solve()
Buggy code:
n = int(input())
a = []
for i in range(n):
    s, p = list(map(int, input().split()))
    a.append((s, -int(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)
Buggy code:
N = int(input())
lst = []
for i in range(N):
  data = input().split(" ")
  lst.append([data[0], int(data[1]), i+1])

s = sorted(lst, key = lambda x: (x[1], x[2]))

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

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

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

Fixed code:
N=int(input())
l=[]
for i in range(N):
  l.append(list(input().split()))
  l[i][1]=int(l[i][1])
l1=sorted(l,key=lambda x:x[1],reverse=True)
l2=sorted(l1,key=lambda x:x[0])
for i in range(N):
  print(l.index(l2[i])+1)
Buggy code:
N = int(input())
L = []

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

LS = sorted(L)

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

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

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

LS = sorted(L)

for i in range(N):
  print(LS[i][2])
Buggy code:
n = int(input())
l = []
for i in  range():
    s, p = input().split()
    l.append([s, int(p), i])
l_sorted = sorted(l, key = lambda x: (x[0], -x[1]))
for out in l_sorted:
    print(out[2]+1)

Fixed code:
n = int(input())
l = []
for i in range(n):
    s, p = input().split()
    l.append([s, int(p), i+1])
l_sorted = sorted(l, key = lambda x: (x[0], -x[1]))
for j in range(n):
    print(l_sorted[j][2])
Buggy code:
from operator import itemgetter

city_point_list = []
N = int(input())
for i in range(N):
    c, p = input().split()
    city_point_list.append(c, int(p))

cp_num_dict = {}
for i in range(city_point_list):
    cp_num_dict[city_point_list[i]] = i + 1

point_sort_rev = sorted(city_point_list, key=itemgetter(1), reverse=True)
city_sort = sorted(point_sort_rev, key=itemgetter(0))

for cp in city_sort:
    print (cp_num_dict[cp])

Fixed code:
from operator import itemgetter

N = int(input())
city_point_list = []
for i in range(N):
    c, p = input().split()
    pair = (c, int(p))
    city_point_list.append(pair)

cp_num_dict = {}
for i in range(len(city_point_list)):
    cp_num_dict[city_point_list[i]] = i + 1

point_sort_rev = sorted(city_point_list, key=itemgetter(1), reverse=True)
city_sort = sorted(point_sort_rev, key=itemgetter(0))

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

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

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

for i in range(N):
    print(l[i][2])
Buggy code:
n = int(input())
g = [input().split() + [i+1] for i in range(n)]

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

for spi in g:
    print(spi[2])

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

for spi in g:
    spi[1] = int(spi[1])

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

for spi in g:
    print(spi[2])
Buggy code:
n=int(input())
res = []
for i in range(n):
    s,p=map(str, input().split())
    res += [(s,int(p))]
res1=res
res.sort(key=lambda x:(x[0],-x[1]))
for i in range(n):
    print(res1.index(res[i])+1)



Fixed code:
n=int(input())
res = []
for i in range(n):
    s,p=map(str, input().split())
    res += [(s,int(p))]
res1=res
res = sorted(res, key=lambda x:(x[0],-x[1]))
for i in range(n):
    print(res1.index(res[i])+1)
Buggy code:
n = int(input())
sp = [input().split() + [i+1] for i in range(n)]
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 = [input().split() + [i+1] for i in range(n)]
sp.sort(key=(lambda x: int(x[1])), reverse=True)
sp.sort(key=(lambda x: x[0]))
for i in range(n):
    print(sp[i][2])
Buggy code:
# ABC 128: B – Guidebook
from operator import itemgetter

n = int(input(0))

s = []
p = []

for _ in range(n):
    tmp = [s for s in input().split()]
    s.append(tmp[0])
    p.append(int(tmp[1]))

restaurants = []
for i in range(n):
    restaurants.append([i + 1, s[i], p[i]])

restaurants.sort(key=itemgetter(2), reverse=True)
restaurants.sort(key=itemgetter(1))

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

Fixed code:
# ABC 128: B – Guidebook
from operator import itemgetter

n = int(input())

s = []
p = []

for _ in range(n):
    tmp = [s for s in input().split()]
    s.append(tmp[0])
    p.append(int(tmp[1]))

restaurants = []
for i in range(n):
    restaurants.append([i + 1, s[i], p[i]])

restaurants.sort(key=itemgetter(2), reverse=True)
restaurants.sort(key=itemgetter(1))

for i in range(n):
    print(restaurants[i][0])
Buggy code:
from collections import defaultdict
n = int(input())
restaurants = defaultdict(list)
for i in range(n):
    s, p = input().split()
    p = int(p)
    restaurants[s].append([p, i])

ans = [''] * n
cnt = 0
for k, v in sorted(restaurants.items(), key=lambda x: x[0]):
    for p, i in sorted(v, key=lambda x: -x[0]):
        cnt += 1
        ans[i] = cnt

for a in ans:
    print(a)

Fixed code:
from collections import defaultdict
n = int(input())
restaurants = defaultdict(list)
for i in range(n):
    s, p = input().split()
    p = int(p)
    restaurants[s].append([p, i])

cnt = 0
for k, v in sorted(restaurants.items(), key=lambda x: x[0]):
    for p, i in sorted(v, key=lambda x: -x[0]):
        print(i + 1)
Buggy code:
N = int(input())
city = dict()
restaurants = []
for _ in range(N):
    s, p = input().split()
    restaurants.append([s, int(p)])
    if s in city.keys():
        city[s].append(int(p))
    else:
        city[s] = [int(p)]

city = sorted(city.items(), key=lambda x:x[0])

for c in city:
    points = c[1]
    points.reverse()
    for p in points:
        for i in range(N):
            s = c[0]
            r = restaurants[i]
            if r[0] == s and r[1] == p:
                print(i + 1)

Fixed code:
N = int(input())
city = dict()
restaurants = []
for _ in range(N):
    s, p = input().split()
    restaurants.append([s, int(p)])
    if s in city.keys():
        city[s].append(int(p))
    else:
        city[s] = [int(p)]

city = sorted(city.items(), key=lambda x:x[0])

for c in city:
    points = c[1]
    points.sort(reverse=True)
    for p in points:
        for i in range(N):
            s = c[0]
            r = restaurants[i]
            if r[0] == s and r[1] == p:
                print(i + 1)
Buggy code:
N = int(input())
A = []
for i in range(N):
	tem_data = input().split()
	A.append([tem_data[0] , int(tem_data[1]) , i])
A = sorted(A , key = lambda x: (x[0] , -x[1]))
for name , score  , number in A:
	print(name , score , number)

Fixed code:
N = int(input())
A = []
for i in range(N):
	tem_data = input().split()
	A.append([tem_data[0] , int(tem_data[1]) , i+1])
A = sorted(A , key = lambda x: (x[0] , -x[1]))
for name , score  , number in A:
	print(number)
Buggy code:
n = int(input())
t = []
for i in range(n):
    tmp = input().split()
    t.append(tuple(tmp))
tmp = sorted(t, key=lambda x: x[1],reverse = True)
res = sorted(tmp, key=lambda x: x[0])
for sp in res:
    print(t.index(sp)+1)
    

Fixed code:
n = int(input())
t = []
for i in range(n):
    tmp = input().split()
    t.append(tuple(tmp))
tmp = sorted(t, key=lambda x: int(x[1]),reverse = True)
res = sorted(tmp, key=lambda x: x[0])
for sp in res:
    print(t.index(sp)+1)
Buggy code:
def main():
    n = int(input())
    ll = list()
    for i in range(n):
        tmp = list(map(str, input().split()))
        tmp[1] = int(tmp[1])
        tmp.append(i+1)
        ll.append(tmp)
    print(ll)
    
    ll_s = sorted(ll, key=lambda x:(x[0],-x[1]))
    print(ll_s)
    for i in ll_s:
        print(i[2][0])
        
if __name__ == '__main__':
    main()

Fixed code:
def main():
    n = int(input())
    ll = list()
    for i in range(n):
        tmp = list(map(str, input().split()))
        tmp[1] = int(tmp[1])
        tmp.append(i+1)
        ll.append(tmp)
    ll_s = sorted(ll, key=lambda x:(x[0],-x[1]))
    for i in ll_s:
        print(i[2])

if __name__ == '__main__':
    main()
Buggy code:
N = int(input())
L = []

for l in range(0,N):
	L.append(input().split())
	L[l][1] = (int(L[l][1])-10 ** 10,l+1)

L = sorted(L)
for i in range(N):
	print(L[i][1][1])



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

for l in range(0,N):
	L.append(input().split())
	L[l][1] = (abs(int(L[l][1])-10**10),l+1)

L = sorted(L)

for i in range(N):
	print(L[i][1][1])
Buggy code:
list_SP = []
N = int(input())

for i in range(N):
  S, P = input().split()
  list_SP.append([S, 100 - int(P), i+1])
  
  
sorted_listSP = sorted(list_SP)
print(sorted_listSP[2])

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

for i in range(N):
  S, P = input().split()
  list_SP.append([S, 100 - int(P), i+1])
  
  
sorted_listSP = sorted(list_SP)
for data in sorted_listSP:
  print(data[2])
Buggy code:
N = int(input())
list = []
for i in range(N):
  line = input().split()
  line = [i] + line
  list.append(line)
list.sort( key=lambda x: (x[1], -int(x[2])) )
for i in range(N):
  print(list[i][0])


Fixed code:
N = int(input())
list = []
for i in range(N):
  line = input().split()
  line = [i + 1] + line
  list.append(line)
list.sort( key=lambda x: (x[1], -int(x[2])) )
for i in range(N - 1):
  print(list[i][0])
print(list[N-1][0], end="")
Buggy code:
N = int(input())
S = []
P = []
I = []
Z = []

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

for i, j, k in zip(S,P,I):
    Z.append([i,j,k])

Z_sorted = sorted(Z)

for i in range(N-1):
    if Z_sorted[i][0] == Z_sorted[i+1][0]:
        a = Z_sorted[i]
        b = Z_sorted[i+1]
        Z_sorted[i] = b
        Z_sorted[i+1] = a

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

Fixed code:
# 190526_2

N = int(input())
S = []
P = []
I = []
Z = []

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

for i, j, k in zip(S,P,I):
    Z.append([i,j,k])

Z_sorted = sorted(Z)

for j in range(N-1):
    for i in range(N-1):
        if Z_sorted[i][0] == Z_sorted[i+1][0]:
            if Z_sorted[i][1] < Z_sorted[i+1][1]:
                a = Z_sorted[i]
                b = Z_sorted[i+1]
                Z_sorted[i] = b
                Z_sorted[i+1] = a

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