Problem:


Score : 200 points

Problem Statement

You have decided to write a book introducing good restaurants.
There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.
No two restaurants have the same score.

You want to introduce the restaurants in the following order:

The restaurants are arranged in lexicographical order of the names of their cities.

If there are multiple restaurants in the same city, they are arranged in descending order of score.

Print the identification numbers of the restaurants in the order they are introduced in the book.

Constraints

1 ≤ N ≤ 100

S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.

0 ≤ P_i ≤ 100

P_i is an integer.

P_i ≠ P_j (1 ≤ i < j ≤ N)

Input

Input is given from Standard Input in the following format:

N
S_1 P_1
:
S_N P_N

Output

Print N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.

Sample Input 1

6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40

Sample Output 1

3
4
6
1
5
2

The lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.

Sample Input 2

10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100

Sample Output 2

10
9
8
7
6
5
4
3
2
1



Sample input:
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40


Sample output:
3
4
6
1
5
2

Submission status: Accepted

Solution code:
n = int(input())
ll = []
for i in range(n):
  *l, = input().split()
  l.append(i+1)
  ll.append(l)
ll.sort(reverse=True, key = lambda x:int(x[1]))
ll.sort(key=lambda x:x[0])
for i in range(n):
  print(ll[i][2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l=[0]*n
for i in range(n):
  s,p=input().split()
  p=int(p)
  l[i]=(s,-p,i+1)
l=sorted(l)
for i in range(n):
  print(l[i][2])

Submission status: Accepted

Solution code:
n=int(input())

sp=list(list(input().split()) for _ in range(n))
ans=sorted(enumerate(sp),key=lambda x:(x[1][0],-int(x[1][1])))
for d in ans:
  print(d[0]+1)

Submission status: Accepted

Solution code:
from operator import itemgetter
N=int(input())
a=[]
for i in range(N):
  p,q=input().split()
  s=int(q)
  P=[p,-s,i+1]
  a.append(P)
A=sorted(a)
      
for n in range(N):
  print(A[n][2])

Submission status: Accepted

Solution code:
N = int(input())

lst = []
for i in range(N):
    s, P = map(str, input().split(" "))
    lst.append((s, -int(P), i))

lst.sort(key=lambda x: (x[0], x[1]))
for s, p, i in lst:
    print(i + 1)

Submission status: Accepted

Solution code:
N=int(input())
X=[input().split() for i in range(N)]
SP=[[str(X[j][0]),-1*int(X[j][1]),j+1] for j in range(N)]
X=sorted(SP,key=lambda x:(x[0],x[1]))
for k in range(N):
	print(X[k][2])

Submission status: Accepted

Solution code:
#!/usr/bin/env python

def main():
    N = int(input())
    d = [[] for _ in range(N)]

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

    d.sort(key = lambda x: (x[1], -x[2]))

    for item in d:
        print(item[0])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
D = []
for i in range(n):
  s, p  = map(str,input().split())
  D.append([s, int(p)*-1, i+1])
D.sort()

for j in D:
  print(j[2])

Submission status: Accepted

Solution code:
def solve():
    n = int(input())
    sp = list(list(input().split()) for _ in range(n))
    ans = sorted(enumerate(sp), key=lambda x: (x[1][0], -int(x[1][1])))
    for d in ans:
        print(d[0] + 1)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
n = int(input())
rest = [[i+1] + input().split() for i in range(n)]
rest = sorted(rest, key=lambda r: r[1] + str(100-int(r[2])).zfill(3))
for i in range(n):
    print(rest[i][0])

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
book = defaultdict(lambda : defaultdict(int))
for i in range(n):
    s, p = input().split()
    p = int(p)
    book[s][p] = i

for _, v in sorted(book.items()):
    for _, vv in sorted(v.items(), reverse=True):
        print(vv+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

for a in ans:
  print(a[2])

Submission status: Accepted

Solution code:
n = int( input() )
sp = [[list(input().split()),i] for i in range(n)]

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

for t in res:
    print(t[1]+1)

Submission status: Accepted

Solution code:
n = int(input())
sp = list(list(map(str,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])

Submission status: Accepted

Solution code:
n=int(input())

q=[input().split() + [i] for i in range(n)]
for i in range(n):
    q[i][1]=int(q[i][1])
p=sorted(sorted( q ,key=lambda x:x[1],reverse=1),key=lambda x:x[0])
for s,t,r in p:
    print(r+1)

Submission status: Accepted

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

N = int(input())
str_list = [input() for x in range(N)]
str_sort = sorted(str_list, key=lambda x: int(x.split()[1]), reverse=True)
str_sort2 = sorted(str_sort, key=lambda x: x.split()[0])

for x in str_sort2:
    print(str_list.index(x)+1)

Submission status: Accepted

Solution code:
N = int(input())

lst = [list(map(str, input().split())) + [s + 1] for s in range(N)]

all = []
for l in lst:
    l[1] = int(l[1])
    all.append(l)

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

for l in lst:
    print(int(l[2]))

Submission status: Accepted

Solution code:
n = int(input())
rest_list = []
for i in range(n):
    each_input = input().split()
    rest_list.append((i, each_input[0], int(each_input[1])))
   
rest_list.sort(key=(lambda x: x[2]), reverse=True)
rest_list.sort(key=(lambda x: x[1]))
print(*[i[0]+1 for i in rest_list], sep='\n')

Submission status: Accepted

Solution code:
n = int(input())
r = [list(input().split())+[i+1] for i in range(n)]
r.sort(key = lambda x: int(x[1]), reverse = True)
r.sort(key = lambda x: x[0])
for i in r: print(i[2])

Submission status: Accepted

Solution code:
N = int(input())
lst = []

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

# 点数の降順でソート
lst = sorted(lst, key=lambda x: x[1], reverse=True)

# 市名順ソート
lst = sorted(lst, key=lambda x: x[0])

for _, _, num in lst:
    print(num)

Submission status: Accepted

Solution code:
#14 ABC128B
n=int(input())
sp=[[list(input().split()),i] for i in range(n)]
res=sorted(sp, key=lambda x:(x[0][0],-int(x[0][1])))
for t in res:
    print(t[1]+1)

Submission status: Accepted

Solution code:
N = int(input())
S = sorted((list((lambda y: (y[0], -int(y[1]), x))(input().split()))) for x in range(1, N+1))

for x in S:
  print(x[2])

Submission status: Accepted

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

Submission status: Accepted

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

SP.sort(key = lambda x: (x[0], -x[1]))
#print(SP)

for _city, _point, idx in SP:
    print(idx)

Submission status: Accepted

Solution code:

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

# 点数hash
th = {}

# city hash
ch = {}

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

    # 点数hash
    th[p] = [s, i+1]

    # city hash
    if s in ch:
        tmp = ch[s]
        tmp += [p]
        ch[s] = tmp
    else:
        ch[s] = [p]

#print(th)
#print(ch)

x = list(set(S))
x.sort()
for city in x:
    tmp = ch[city]
    tmp.sort(reverse=True)
    for i in tmp:
        print(th[i][1])

Submission status: Accepted

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

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

for _, _, num in lst:
    print(num)

Submission status: Accepted

Solution 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()
for j in range(n):
  print(sp[j][2])

Submission status: Accepted

Solution code:
n = int(input())
s = [input().split()+[x+1] for x in range(n)]

s.sort(key=lambda p: int(p[1]), reverse=True)
s.sort(key=lambda p: p[0])

[print(x[2]) for x in s]

Submission status: Accepted

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

for a_ in a:
    print(a_[2])

Submission status: Accepted

Solution code:
N = int(input())
ans = []
for idx in range(1, N + 1):  # N = 100, no need to use sys.stdin
    S, P = input().split()
    ans.append((S, int(P), idx))

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

Submission status: Accepted

Solution code:
#ABC128 B
from operator import itemgetter as ig
N = int(input())
S = [0 for i in range(N)]
P = [0 for i in range(N)]
for i in range(N):
    S[i], P[i] = (_ for _ in input().split())
SP = sorted([(i, S[i], int(P[i]))for i in range(N)], key = ig(2), reverse = True)
SP = sorted(SP, key = ig(1))
for i in range(N):
    print(SP[i][0] + 1)

Submission status: Accepted

Solution code:
n=int(input())

l=[[0]*2 for _ in range(n)]

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

l.sort()

for j in range(n):
        print(l[j][2])

Submission status: Accepted

Solution code:
N = int(input())

rest = []
city = []
for i in range(N):
    s,p = input().split()
    rest.append([s,int(p),i+1])
    if s not in city:
        city.append(s)

city = sorted(city)

for c in city:
    rs = [s for s in rest if s[0]==c]
    rs_sort = sorted(rs, key=lambda x:(x[1]),reverse=True)
    for r in rs_sort:
        print(r[2])

Submission status: Accepted

Solution code:
N = int(input())

SP = {i+1: input().split() for i in range(N)}

for v in SP.values():
    v[1] = int(v[1])

# 降順
SP = sorted(SP.items(), key=lambda x: x[1][1], reverse=True)

# 昇順
SP = sorted(SP, key=lambda x: x[1][0])

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

Submission status: Accepted

Solution code:
from operator import itemgetter

N = int(input())

SP = [input().split() for i in range(N)]

for k, v in enumerate(SP):
    v.insert(0, str(k + 1))
    v[2] = int(v[2])

# 降順
SP.sort(key=itemgetter(2), reverse=True)

# 昇順
SP.sort(key=itemgetter(1))

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    rs = []
    for i in range(n):
        s, p = input().split()
        p = int(p)
        rs.append([s, -p, i + 1])
    for r in sorted(rs):
        print(r[2])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
data = [{}]*N

for i in range(N):
  tempS, tempP = input().split()
  data[i] = {'ID': i+1, 'Name': tempS, 'Point': int(tempP)}

data_sort = sorted(
  data,
  key = lambda x: (x['Name'], -x['Point'])
)

for i in range(N):
  print(data_sort[i]['ID'])

Submission status: Accepted

Solution code:
n = int(input())
a = [input().split() +[i+1] for i in range(n)]
a = sorted(a ,key=lambda x:(x[0], -int(x[1])))
for i in range(len(a)):
    print(a[i][2])

Submission status: Accepted

Solution code:
N = int(input())
a = [input().split() +[i+1] for i in range(N)]
a = sorted(a ,key=lambda x:(x[0], -int(x[1])))
 
for i in range(N):
  print(a[i][2])

Submission status: Accepted

Solution code:
from operator import itemgetter
N=int(input())
listA=[[] for i in range(N)]
listANS=[]
for i in range(N):
  S,P=input().split()
  listA[i]+=[S,int(P),i+1]
listA.sort()
before=0
if N!=1:
  for i in range(1,N):
    if listA[i-1][0]!=listA[i][0]:
      listN=listA[before:i]
      listN.sort(key=itemgetter(1),reverse=True)
      listANS+=listN
      before=i
 
    if i==N-1:
      listN=listA[before:N]
      listN.sort(key=itemgetter(1),reverse=True)
      listANS+=listN
else:
  listANS=listA
for i in range(N):
  print(listANS[i][2])

Submission status: Accepted

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

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

Submission status: Accepted

Solution 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)

Submission status: Accepted

Solution code:
N = int(input())
lst = []
for i in range(N):
  s,p = map(str,input().split())
  
  P = -int(p)
  lst.append([s,P,i+1])
lst.sort()


for j in range(N):
  print(lst[j][2])

Submission status: Accepted

Solution code:
N = int(input())
SP = []
for i in range(N):
    S, P = 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 range(N):
    print(SP[i][2])

Submission status: Accepted

Solution code:
N = int(input())

dicts = {}
for i in range(N):
    key, value = input().split()
    value = int(value)
    if key not in dicts:
        dicts[key] = [[value, i+1]]
    else:
        dicts[key].append([value, i+1])

dicts = sorted(dicts.items())
for values in dicts:
    for item in sorted(values[1], reverse=True):
        print(item[1])

Submission status: Accepted

Solution 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()

Submission status: Accepted

Solution code:
n = int(input())

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

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

for a in arr:
    print(a[0])

Submission status: Accepted

Solution code:
N = int(input())
l = [list(input().split()) for _ in range(N)]

for i in range(N):
    l[i] += [i+1]
l.sort(key=lambda x:(x[0],-int(x[1])))

for j in range(N):
    print(l[j][2])

Submission status: Accepted

Solution 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]))

Submission status: Accepted

Solution code:
Row=int(input())
List=[]

for i in range(Row):
    a,n=input().split()
    List.append((a,int(n)*(-1),i+1)) #タプルで渡す
    #i番目に+1を忘れずに

List.sort() #デフォルトでは要素を順に比較してくれる

for l in List:
    print(l[2])

Submission status: Accepted

Solution 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)

Submission status: Accepted

Solution code:
n=int(input())
L=[]


for i in range(n):
    s,p=map(str,input().split())
    L.append((s,int(p)*-1,i+1))

L.sort()

for l in L:
    print(l[2])

Submission status: Accepted

Solution code:
n = int(input())
d = {}
c = 1
for i in range(n):
    i = input().split(" ")
    city = i[0]
    point = int(i[1])
    if city not in d:
        d[city] = [(point,c)]
    else:
        d[city].append([point,c])
    c += 1

sorted_d = sorted(d.items(), key=lambda x:x[0])
for i in sorted_d:
    s_score = sorted(i[1],key=lambda x:x[0],reverse=True)
    for j in s_score:
        print(j[1])

Submission status: Accepted

Solution code:
N=int(input())
res = []
for i in range(N):
    s, p = input().split()
    p = -int(p)
    res.append((s,p,i+1))
res.sort()
for s, p, i in res:
    print(i)

Submission status: Accepted

Solution code:
# ABC 128, B - guidebook
from operator import itemgetter

n = int(input())

X = []
for i in range(n):
    tmp = input().split(' ')
    X.append((i+1, tmp[0], -int(tmp[1])))
X.sort(key=itemgetter(1, 2))

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

Submission status: Accepted

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

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

ans = [x[0] for x in l]
for i in range(len(ans)):
    print(ans[i])

Submission status: Accepted

Solution code:
n = int(input())
sl=[]

for i in range(n):
    s,p=input().split()
    sl.append((s,-int(p),i+1))

sl.sort()

for j in range(n):
    print(sl[j][2])

Submission status: Accepted

Solution code:
N = int(input())
l = [list(input().split()) for _ in range(N)]
for i in range(N):
  l[i] += [i+1]
l.sort(key=lambda x:(x[0],-int(x[1])))

for j in range(N):
  print(l[j][2])

Submission status: Accepted

Solution code:
N = int(input())
A = []

for i in range(N):
  S, p = map(str, input().split())
  P = 100 - int(p)
  A.append((S, P, i+1))
  
A.sort()
for i in range(N):
  print(A[i][2])

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    data = []
    for i in range(N):
        s, p = input().split()

        data.append((s, 100 - int(p), i+1))

    for s, p, i in sorted(data):
        print(i)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# stdin
INPUT_SENTENCES = 1
N = int([input() for i in range(INPUT_SENTENCES)][0])
INPUT_SENTENCES = N
ss = [input() for i in range(INPUT_SENTENCES)]
SP = list(map(lambda x: [x[0], int(x[1])], [[i for i in s.split(" ")] for s in ss]))
spm = {city: map(lambda v: v[1], sorted(list(filter(lambda x: x[0] == city, SP)))) for city in map(lambda v: v[0], SP)}
[[print(SP.index([k,v])+1) for v in sorted(spm[k], reverse=True)] for k in sorted(spm.keys())]

Submission status: Accepted

Solution code:
N = int(input())
lis = [0]*N
S = [0]*N
P = [0]*N
for k in range(N):
  S[k],P[k] = input().split()
  P[k] = int(P[k])
  lis[k] = [S[k],P[k],k+1]
from operator import itemgetter
lis = sorted(lis, key=itemgetter(1),reverse = True)
lis = sorted(lis, key=itemgetter(0))
for i in range(N):
  print(lis[i][2])

Submission status: Accepted

Solution code:

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

data.sort()
for i in range(N):
  print(data[i][2])

Submission status: Accepted

Solution code:
n = int(input())
lis = []
for i in range(1,n+1):
    s,p = input().split()
    lis.append((s,int(p),i))
from operator import itemgetter
lis = sorted(lis,key=itemgetter(1),reverse=True)
lis = sorted(lis,key=itemgetter(0))
for i in range(n):
    print(lis[i][2])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
data = []
for n in range(N):
    S,P = input().split()
    data.append((S,-int(P),n+1))

data.sort()

for n in range(N):
    print(data[n][2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
X = []
for i in range(N):
    s, p = input().split()
    p = int(p)
    X.append((s, p, i))
X.sort(key=lambda p: (p[0], -p[1]))
for x in X:
    print(x[2] + 1)

Submission status: Accepted

Solution code:
from operator import itemgetter

N = int(input())
SP = [[0,"none",0]]*N
for i in range(N):
	s, p = input().split()
	SP[i] = [i+1, s, int(p)]

SP.sort(key=itemgetter(2), reverse=True)
SP.sort(key=itemgetter(1))
[ print(i[0]) for i in SP ]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC128 B

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

n = int(input())
sp = [list(input().split()) for _ in range(n)]
for i in range(n):
    sp[i].append(i+1)
sp.sort(key = lambda x:(x[0],-int(x[1])))
for i in range(n):
    print(sp[i][2])

Submission status: Accepted

Solution code:
n = int(input())
r_list = []

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

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

for line in r_list:
    print(line[2])

Submission status: Accepted

Solution code:
n = int(input())
a = []
#名前はアルファベット順(昇順)，評価は降順にするために評価は-をつけて格納している
for i in range(n):
    s, p = input().split()
    a.append((s, -int(p), i + 1))
a.sort()
for b in a:
    print(b[2])

Submission status: Accepted

Solution code:
n = int(input())

l = [[0, 0, 0] for j in range(n)]

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

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

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

Submission status: Accepted

Solution code:
N = int(input())
li = []
for i in range(N):
    n,p = input().split()
    li.append([n,int(p),i+1])
li.sort(key =lambda x:x[1], reverse = True)
li.sort(key = lambda x:x[0])
for x in li:
    print(x[2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
cities = []
cities_index_points = {}

for i in range(N):
    s,p = input().split()
    p = int(p)
    cities.append(s)
    try:
        x = cities_index_points[s]
        x.append((i,p))
    except:
        cities_index_points[s] = [(i,p)]

cities = sorted(set(cities))

for c in cities:
    iplist = cities_index_points[c]
    iplist.sort(key=lambda x: x[1], reverse=True)
    for ip in iplist:
        print(ip[0]+1)

Submission status: Accepted

Solution 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])

Submission status: Accepted

Solution 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])

Submission status: Accepted

Solution code:
import operator
n=int(input())
rest=[]

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

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

Submission status: Accepted

Solution code:
import sys
from collections import deque, defaultdict
import copy
import bisect
#input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


N = int(input())
res = []
for i in range(N):
    S, P = list(input().split())
    bisect.insort(res, (S, -int(P), i + 1))
for i in range(len(res)):
    print(res[i][2])

Submission status: Accepted

Solution code:
def Guidebook():
    n = int(input())
    rest = []
    for i in range(n):
        s, p = map(str, input().split())
        rest.append([i+1, s, int(p)])

    rest.sort(key=lambda x:x[2], reverse=True)
    rest.sort(key=lambda x:x[1])
    for i in range(n):
        print(rest[i][0])
if __name__ == "__main__":
    Guidebook()

Submission status: Accepted

Solution code:
N = int(input())

rs = []
for i in range(N):
  c, s = input().split()
  s = int(s)
  rs.append([c, -s, i+1])
  
rs.sort()
for i in range(N):
  print(rs[i][2])

Submission status: Accepted

Solution code:
n=int(input())
l=[]
for i in range(n):
    s=input()
    k=s.split()
    x=int(k[1])

    c=[k[0],x]
    l.append(c)
# print(l)
m=[]
for i in range(n):
    m.append(l[i][0])


# print(l)
m.sort()
# print(m)

boolean=[False for i in range(n)]

for i in range(n):
    tmp=0
    for j in range(n):
        if(m[i]==l[j][0]):
            if(boolean[j]==False):
                if(tmp<l[j][1]):
                    tmp=l[j][1]
    for x in range(n):
        if(l[x][1]==tmp):
            boolean[x]=True
            print(x+1)

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
import copy

res_list = []
n = int(input())
for i in range(n):
    name, score = input().split()
    score = int(score)

    res_list.append([name,score,i+1])

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

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

Submission status: Accepted

Solution code:
import copy

n = int(input())
l = [input().split() for i in range(n)]
index = copy.deepcopy(l)

for i in range(n):
    l[i][1] = int(l[i][1])
    index[i][1] = int(index[i][1])

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

for i in range(n):
    for j in range(n):
        if l[i] == index[j]:
            print(j+1)
            break

Submission status: Accepted

Solution code:
N = int(input())
SP = []
for i in range(1,N+1):
    S,P = map(str,input().split())
    SP.append([S,int(P),i])
SP = sorted(SP, key=lambda x:x[1], reverse=True)
SP = sorted(SP, key=lambda x:x[0])
[print(SP[i][2]) for i in range(N)]

Submission status: Accepted

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

Submission status: Accepted

Solution 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)

Submission status: Accepted

Solution code:
N = int(input())
l = []
for i in range(N):
    a,b = input().split()
    l.append((a,-int(b),i+1))
l.sort()
for a,b,k in l:
    print(k)

Submission status: Accepted

Solution code:
a = [int(input()) for i in range(1)]
n = a[0] 
input = [list(map(str, input().split())) for i in range(n)]
#print(input)
for i in range(n):
  input[i].append(i+1)
#print(input)

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

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

Submission status: Accepted

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

for i in range(n):
    a[i].append(i+1)

b = sorted(a, key = lambda x:int(x[1]), reverse = True)
c = sorted(b, key = lambda x:x[0])

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

Submission status: Accepted

Solution code:
num = int(input())
scoreList = [input().split() for i in range(num)]
test = [[scoreList[i][0],int(scoreList[i][1])] for i in range(num)]
[test[i].append(i+1) for i in range(num)]
citySorted = sorted(test, key=lambda x:(x[0],-x[1]), reverse = False)
print(*[citySorted[i][2] for i in range(num)],sep='\n')

Submission status: Accepted

Solution code:
n = int(input())
rests = []
for i in range(n):
    rest_name, point = input().split() 
    rests.append([rest_name, int(point)])

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

for i in range(len(sorted_rests)):
    for j in range(len(rests)):
        if sorted_rests[i] == rests[j]:
            print(j + 1)
            break

Submission status: Accepted

Solution code:
n = int(input())
dic = {}

for i in range(n):
  s,p = input().split()
  num = 100 - int(p)
  num_zero = str(num).zfill(3)
  s2 = s + num_zero
  dic[s2] = i + 1
  
array = sorted(dic.keys())

for s in array:
  print(dic[s])

Submission status: Accepted

Solution code:
n = int(input())
l = [input().split()+[i+1] for i in range(n)]
for i in range(n):
    l[i][1] = int(l[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])

Submission status: Accepted

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

l.sort()
for i in l:
    print(i[2])

Submission status: Accepted

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

l.sort()
for i in l:
    print(i[2])

Submission status: Accepted

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

l.sort()
for i in l:
    print(i[2])

Submission status: Accepted

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

l.sort()
for i in l:
    print(i[2])

Submission status: Accepted

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

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

for c, x in d:
    x.sort(reverse=True)
    for i in x:
        print(i[1])

Submission status: Accepted

Solution code:
a = int(input())
b = []
for i in range(a):
    c, d = input().split()
    b.append([c, int(d), i + 1])
b = sorted(b, key=lambda x: x[1], reverse=True)
b = sorted(b, key=lambda x: x[0])
for i in range(a):
    print(int(b[i][2]))

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
restaurants = {}
for i in range(N):
    S = input().split()
    restaurants.update([((S[0], int(S[1]) * -1), i + 1)])

sorted_restaurants = sorted(restaurants.items())

for k, v in sorted_restaurants:
    print(v)