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())
ans = []
for i in range(1, N + 1):
    S, P = input().split()
    ans.append([S, -int(P), i])
ans.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
restaurants = []
for index in range(1,n+1):
    # 文字列と点数を読み込んで、点数だけint型に変換
    tmp = list(map(lambda x:int(x)+1 if x.isdecimal() else x, input().split()))
    # ソート前のもともとの順番の番号を付与
    tmp.append(index)
    restaurants.append(tmp)
# 文字列の昇順、点数の降順でソート
ans = sorted(restaurants, key=lambda x:(x[0],-x[1]))
for i in ans:
    print(i[2])

Submission status: Accepted

Solution code:
n = int(input())

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

for key in sorted(s):
    for i, score in sorted(s[key], key=lambda t:~t[1]):
        print(i)

Submission status: Accepted

Solution code:
N=int(input())
li=[]
for i in range(N):
  a,b=input().split()
  b=str(100-int(b)).zfill(3)
  li.append(a+b)
lis = sorted(li)

for i in range(len(li)):
  for j in range(len(li)):
    if lis[i] == li[j]:
      print(j+1)

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
#print(*data, sep='\n')
tmp = sorted(data, key=lambda x:int(x[1]), reverse=True)
ans = sorted(tmp, key=lambda x:x[0])
#print(ans)
for i in range(n) :print(data.index(ans[i])+1)

Submission status: Accepted

Solution code:
n = int(input())

a = []

for i in range(n):
  	# input as str
	s, p = input().split()
    # p -> integer
	p = int(p)
    # create list
	a.append((s, p, i+1))

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

# sort
a.sort(key=lambda x:x[0])

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

Submission status: Accepted

Solution code:
N = int(input())
L = list()
for i in range(N):
    s, p = input().split()
    p = int(p)
    L.append((s, p, i+1))

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

Submission status: Accepted

Solution code:
# B
# Guidebook

N = int(input())

sp_list = []

for i in range(N):
    
    sp = input().split(" ")
    sp.append(str(i+1))
    sp_list.append(sp)

#print(sp_list)

sp_list.sort(key = lambda x: -int(x[1]))
sp_list.sort(key = lambda x: x[0])

for i in sp_list:
#    print(sp_list)
    print(int(i[2]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
P = int(input())
res= []
for i in range(P):
  a, b = input().split()
  res.append((a,int(b)))
res2 = sorted(res, key = lambda x:x[1], reverse = True)
res3 = sorted(res2, key = lambda x:x[0])
for j in range(P):
  print(str(res.index(res3[j])+1))

Submission status: Accepted

Solution code:
N = int(input())
R = []
for i in range(N):
  s_i, p_i = input().split()
  R.append([s_i, -int(p_i), i+1])
R = sorted(R, key=lambda x: x[1])
R = sorted(R, key=lambda x: x[0])
for r_i in R:
  print(r_i[-1])

Submission status: Accepted

Solution code:
N = int(input())

a = list()

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

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

a.sort(key = lambda x: x[0])

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

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
    s, p = input().split()
# pを数値に
    p = int(p)
# i,s,pの並びでlistを入れる
    a.append([i+1, s, p])

# 点数の高い順に並べる
a.sort(key=lambda x:x[2], reverse=True)
# レストラン名の辞書順に並べる
a.sort(key=lambda x:x[1])
# それぞれの市について、辞書順に点数の高い順に並べる
for i in range(n):
    print(a[i][0])

Submission status: Accepted

Solution code:
num_restaurants = int(input())
restaurants = [input().split() for _ in range(num_restaurants)]
city_restaurant = dict()
cities = set()
for idx, i in enumerate(restaurants):
    if i[0] in cities:
        city_restaurant[i[0]].append((int(i[1]), idx + 1))
    else:
        city_restaurant[i[0]] = [(int(i[1]), idx + 1)]
        cities.add(i[0])
cities = sorted(list(cities))
for i in cities:
    for j in reversed(sorted(city_restaurant[i], key=lambda x: x[0])):
        print(j[1])

Submission status: Accepted

Solution code:
n=int(input())
r={i:list(input().split()) for i in range(n)}
r_state=[r[i][0] for i in range(n)]
r_score=[int(r[i][1]) for i in range(n)]
r_state.sort()
r_score.sort(reverse=True)
l=[]

for i in range(n):
  for j in range(n):
    for k in range(n):
      if k in r.keys():
        if r[k]==[r_state[i],str(r_score[j])]:
          l.append(k+1)
          r.pop(k)
for item in l:
  print(item)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
lili = []
for i in range(n):
  a, b = input().split()
  lili.append([a, -1*int(b), i])
  
lili.sort()
for j in range(n):
  print(lili[j][2] + 1)

Submission status: Accepted

Solution code:
N = int(input())
assign = []
for index in range(1,N+1):
    S, P = map(str, input().split())
    P = int(P)
    assign.append([S, P, index])

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

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

Submission status: Accepted

Solution code:
N = int(input())

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

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


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

Submission status: Accepted

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

if __name__ == '__main__':
    n = int(input())
    ary = []
    city = []
    ans = []
    for i in range(n):
        x, y = input().split()
        city.append(x)
        ary.append([x, int(y), i+1])
    
    cities = sorted(set(city), key=city.index)
    cities.sort()
    for c in cities:
        tmp = [x for x in ary if x[0] == c]
        tmp.sort(reverse=True)
        for t in tmp:
            ans.append(t)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
li=[0]*n
for i in range(n):
    a=input().split()
    li[i]=[a[0], -int(a[1]), i+1]

li.sort(key=lambda x:(x[0],int(x[1])))

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

Submission status: Accepted

Solution code:
N = int(input())
E = []
for i in range(N):
    s, t = map(str, input().split())
    E.append((s, int(t), i+1))
#At first, sorted by the score
E.sort(key = lambda x: x[1], reverse = True)
#sorted by the alphabet
E.sort(key = lambda x: x[0])

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

Submission status: Accepted

Solution code:
n = int(input())

data = dict()

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

for key in sorted(data.keys()):
    for _, num in sorted(data[key], key=lambda x: -x[0]):
        print(num)

Submission status: Accepted

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

for i in range(N):
    x, y = map(str, input().split())
    a.append([x, int(y), i + 1])

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

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

Submission status: Accepted

Solution code:
n = input()
li = [input() for i in range(int(n))]

disp = {}

for i in range(int(n)):
    city, point = li[i].split()
    if not (city in disp.keys()):
        disp[city] = {}
    disp[city][point] = i + 1

for elm in sorted(disp.keys()):
    for item in sorted(map(int, disp[elm].keys()), reverse=True):
        print(disp[elm][str(item)])

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    city, point = input().split()
    point = int(point)
    s = (city, point, i+1)
    S.append(s)

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

S.sort(key=lambda x: x[0])

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

Submission status: Accepted

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

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

for i in sorted(d.keys()):  
	for j in sorted(d[i].keys(), reverse=True):
		print(d[i][j])

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in sorted(sorted(l, key=lambda x: int(x[1]), reverse=True), key=lambda x: x[0]):
    print(l.index(i) + 1)

Submission status: Accepted

Solution code:
from sys import stdin, stdout
_write = stdout.write
_readline = stdin.readline

n = int(_readline())
d = dict()

for i, line in enumerate(stdin, 1):
  s, p = line.strip().split()
  k = s.ljust(10, ' ') + str(100 - int(p)).zfill(3)
  d[k] = i

for k in sorted(d.keys())[:n]:
  _write(str(d[k]) + '\n')

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.sort()
for s, p, i in SP:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())

restaurant_data = [[i+1]+(list(input().split())) for i in range(N)]
restaurant_data = list(map(lambda x:[x[0],x[1],int(x[2])],restaurant_data))
restaurant_data = sorted(restaurant_data, key=lambda x: -1*x[2])
restaurant_data = sorted(restaurant_data,key=lambda x:x[1])
# print(restaurant_data)
for ans in list(map(lambda x:x[0],restaurant_data)):
  print(ans)

Submission status: Accepted

Solution code:
N = int(input())

t = []
for i in range(N):
  a = input().split()
  b = (i+1,a[0],int(a[1])*-1)
  t.append(b)
    
t.sort(key = lambda x:(x[:][1],x[:][2]))

for j in range(len(t)):
  print(t[j][0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
lst = []
klst = []
for i in range(N):
    k, v = input().split()
    lst.append((i+1, k, int(v)))
    klst.append(k)
klst = list(set(klst))
klst.sort()
# print(lst)
# print(klst)

ans = [[] for i in range(len(klst))]
#ans2 = [[0], [1], [2]]
#print(ans)
counter = 0
for name in klst:
    #for i in range(len(lst)):
    for res in lst:
        a, b, c = res
        if b == name:
            ans[counter].append((c, a))
    ans[counter].sort()
    #print(ans)
    counter += 1
#print(ans)

for answer in ans:
    for (a, b) in reversed(answer):
        print(b)

Submission status: Accepted

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


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


for i in range(N):
    SP[i][1] = int(SP[i][1])
SP.sort(reverse=True)
SP.sort(key=lambda x: x[0])


for a, b, c in SP:      
	print(c + 1)

Submission status: Accepted

Solution code:
N = int(input())
mylist =[]
#リストの作成
for i in range(N):
  mylist.append(input().split()+[i])
#得点を整数に
for i in range(N):
    mylist[i][1]=int(mylist[i][1])
#ソート
mylist=sorted(sorted( mylist ,key=lambda x:x[1],reverse=1),key=lambda x:x[0])
    
for s,t,r in mylist:
    print(r+1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = []
N = int(input())

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

#同じ市に複数レスト欄があったときのために、先にスコアでソート
#reverseを指定して、スコアが高い方からにする
s.sort(key = lambda x:x[1],reverse = True)
#次に市でソート(文字コードで並び替えれば辞書順になる)することで、スコアが高い順で市を辞書順でソートできる
s.sort(key = lambda x:x[0])
for i in range(N):
	print(s[i][2])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
ri = lambda: int(input())
rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

N=ri()
SP = []
for i in range(1,N+1):
    s,p = rl()
    SP.append([s,p,i])

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

Submission status: Accepted

Solution code:
N = int(raw_input())
SP = [raw_input().split() + [i + 1] for i in range(N)]
for i in range(N):
    SP[i][1] = -int(SP[i][1])
SP.sort()
for i in range(N):
    print SP[i][2]

Submission status: Accepted

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

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

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

for l in L:
    print(l[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 a in l:
  print(a[-1])

Submission status: Accepted

Solution code:
[print(x[2])for x in sorted([(s[0],-int(s[1]),i+1)for i,s in enumerate([input().split()for _ in range(int(input()))])])]

Submission status: Accepted

Solution code:
n = int(input())

sp = [input().split() for _ in range(n)]
sp = [(_sp[0], -int(_sp[1]), i+1) for i, _sp in enumerate(sp)]

sp.sort()
for _, _, i in sp:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
sp = [0] * n
for i in range(n):
  a = input().split()
  sp[i] = [a[0], -int(a[1]), (i+1)]
sp.sort()
for i in range(n):
  print(sp[i][2])

Submission status: Accepted

Solution code:
# coding: utf-8

N = int(input())
guidebook = dict()

for i in range(N):
    d = input().split()
    ci = d[0]
    pi = int(d[1])
    restaurants = guidebook.get(ci, dict())
    restaurants[pi] = i+1
    guidebook[ci] = restaurants

# print(guidebook)
city_names = sorted(guidebook.keys())
for cn in city_names:
    restaturants = guidebook[cn]
    # print(restaturants.keys())
    r_keys = list(restaturants.keys())
    r_keys.sort(reverse=True)
    for r_key in r_keys:
        print(restaturants[r_key])

Submission status: Accepted

Solution code:
a = int(input())
l = []
for i in range(a):
    ta,tb = map(str,input().split())
    l.append([ta,-int(tb),i+1])
l.sort()
for i, j , k in l:
    print(k)

Submission status: Accepted

Solution code:

a = int(input())
l = []
for i in range(a):
    ta,tb = map(str,input().split())
    l.append([ta,-int(tb),i+1])
l.sort()
for i, j , k in l:
    print(k)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
N=int(input())
restranlist=[]
for i in range(N):
    l=input().split()
    restranlist.append([str(l[0]),-int(l[1]),i])
    #print(restranlist)
    restranlist_s=sorted(restranlist)
    #print(restranlist_s)
for i in range(N):
    print(restranlist_s[i][2]+1)

Submission status: Accepted

Solution code:
n = int(input())
dct=[]
for i in range(n):
  d = input().split()
  name = d[0]
  score = int(d[1])
  dct.append([name,-score,i+1])

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

Submission status: Accepted

Solution code:
N = int(input())
SP = []
a = 1
for i in range(N):
    SP.append(input().split())
    SP[i][1] = int(SP[i][1])
for i in SP:
    i.append(a)
    a += 1
SP.sort(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())
SP = []
a = 1
for i in range(N):
    SP.append(input().split())
for i in SP:
    i.append(a)
    a += 1
for i in range(N):
    SP[i][1] = int(SP[i][1])
SP.sort(reverse=True)
SP.sort(key=lambda x: x[0])
for i in range(N):
    print(SP[i][2])

Submission status: Accepted

Solution code:
from operator import itemgetter as get
Res=[]
for i in range(int(input())):
    a,b=input().split()
    Res.append((a,int(b),i))
Res.sort(key=get(1))
Res.reverse()
Res.sort(key=get(0))
for i in Res:
    print(i[2]+1)

Submission status: Accepted

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

P.sort()

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

Submission status: Accepted

Solution code:
n=int(input())

list2=[]

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

#print(list2)

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

#print(list3)

for i in list3:
    print(list2.index(i)+1)

Submission status: Accepted

Solution code:
N=int(input())
L=[]
n=1
while n<=N:
    L.append(list(input().split()))
    L[n-1][1]=int(L[n-1][1])*(-1)
    L[n-1].append(n)
    n+=1
L_sorted=sorted(L, key=lambda _:(_[0],_[1]))
n=1
while n<=N:
    L_sorted[n-1].append(n)
    n+=1
n=1
while n<=N:
    print(L_sorted[n-1][2])
    n+=1

Submission status: Accepted

Solution code:
N=int(input())
Index=[]
S=[]
P=[]
for i in range(N):
  Index.append(i+1)
  s,p=input().split()
  S.append(s)
  P.append(int(p))
#print(S)
#print(P)

for i in range(N):
  deleteIndex=0
  outputIndex=Index[0]
  minS=S[0]
  maxP=P[0]
  for j in range(1,N-i):
    if (S[j] < minS) or ((S[j] == minS) and (P[j] > maxP)):
      deleteIndex=j
      outputIndex=Index[j]
      minS=S[j]
      maxP=P[j]
  print(outputIndex)
  del Index[deleteIndex]
  del S[deleteIndex]
  del P[deleteIndex]

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
def inserter(sp, splist) :
    if  splist == [] :
        return [sp]
    elif sp[0] < splist[0][0] :
        return [sp] + splist
    elif sp[0] == splist[0][0] :
        if int(sp[1]) > int(splist[0][1]) :
            return [sp] + splist
        else :
            return [splist[0]] + inserter(sp, splist[1:])
    else :
        return [splist[0]] + inserter(sp, splist[1:])
lst = []
for i in range(n) :
    s, p = input().split()
    lst = inserter([s, p, i+1], lst)
for j in lst :
    print(j[2])

Submission status: Accepted

Solution code:
from operator import itemgetter
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[0], -x[1]))
for s, p, i in l:
    print(i)

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(n):
    s, p = input().split()
    p = 100 - int(p)
    restaurant = "{} {:03} {}".format(s, p, i+1)
    restaurants.append(restaurant)
sorted_restaurants = sorted(restaurants)

for i in range(n):
    id = sorted_restaurants[i].split()[-1]
    print(id)

Submission status: Accepted

Solution code:
N = int(input())
SP = []
for n in range(N):
    l = input().split()
    l.append(n+1)
    SP.append(l)

tmp = sorted(SP, key=lambda sp: int(sp[1]), reverse=True)
tmp2 = sorted(tmp, key=lambda sp: sp[0])

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
def guide():
    n = int(raw_input())
    d = {}
    j = []
    for _ in range(n):
        a, b = raw_input().split(' ')
        j.append(int(b))
        d[int(b)] = a

    c = {}
    f = []
    for a in d:
        e = d[a]
        f.append(e)
        if c.has_key(e):
            c[e].append(a)
        else:
            c[e] = []
            c[e].append(a)

    f = list(set(f))
    f.sort()
    h = []
    for g in f:
        c[g].sort(reverse=True)
        h += c[g]

    for k in h:
        print(j.index(k)+1)

guide()

Submission status: Accepted

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

elems.sort()
for elem in elems:
    print(elem[2])

Submission status: Accepted

Solution code:

w = int(input())
list1 = []

for i in range(w):
  s,p = input().split()
  p = 100 - int(p)
  list1.append("%s %03d %03d" % (s,p,i+1))

sorted_list = sorted(list1)
for i in range(w):
  id = int(sorted_list[i][-3:])
  print(id)

Submission status: Accepted

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

for i in range(n):
    s, p = input().split()
    p = 100 - int(p)
    restaurants.append("%s %03d %03d" % (s, p, i + 1))
sorted_restaurants = sorted(restaurants)

for i in range(n):
    id = int(sorted_restaurants[i][-3:])
    print(id)

Submission status: Accepted

Solution code:
a = int(input())
l = [list(input().split()) for i in range(a)]
b = sorted(l, key=lambda x:(x[0], -int(x[1])))
for i in b:
  for k, j in enumerate(l, 1):
    if j == i:
      print(k)

Submission status: Accepted

Solution code:
from operator import itemgetter
N = int(input())
guide = []
for i in range(N):
  lst = input().split(' ')
  guide.append([i+1,lst[0],int(lst[1])])
guide = sorted(guide, key=itemgetter(2),reverse=True)
guide = sorted(guide, key=itemgetter(1))
for i in range(N):
  print(guide[i][0])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys

def main():
    num = int(sys.stdin.readline())
    
    input = [None] * num

    for i in range(num):
        read = sys.stdin.readline().split()
        input[i] = [i+1, read[0], int(read[1])]

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

    for restaurant in input:
        print(restaurant[0])

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def make_guide():
    num = int(input())
    lst = [(i + 1, input().split()) for i in range(num)]
    # TODO fix
    # 同じものが存在したら、っていう条件のもとでないとダメ
    # あと数字は降順
    lst = sorted(lst, key=lambda t: int(t[1][1]), reverse=True)
    lst = sorted(lst, key=lambda t: t[1][0])
    return lst


def test_display():
    lst = make_guide()
    for i, guides in lst:
        print(str(i) + " " + guides[0] + " " + guides[1])


def display():
    lst = make_guide()
    for i, guides in lst:
        print(i)


if __name__ == "__main__":
    display()

Submission status: Accepted

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

Submission status: Accepted

Solution 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 s,p,j in SP:
    print(j)

Submission status: Accepted

Solution code:
restaurants = []
for i in range(int(input())):
    data = input().split()
    restaurants.append([data[0], int(data[1]), i+1])

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

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    lst = []
    for i in range(1, N+1):
        inp = input().split()
        inp[1] = int(inp[1]) * -1
        inp.append(i)
        lst.append(inp)
    newLst = sorted(lst)
    for j in range(N):
        print(newLst[j][2])
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy
n=input()
mylist=[]
for i in range(n):
   mylist.append(raw_input().split())
mylistn=[]
for i in range(n):
    mylistn.append([i+1, mylist[i][0],int(mylist[i][1])])
mylistnn=sorted(mylistn,key=lambda x:(x[1],-x[2]))
for i in range(n):
    print(mylistnn[i][0])

Submission status: Accepted

Solution code:
from operator import itemgetter
N = int(input())
sp = []
for i in range(0,N):
    s,p = input().split()
    p = int(p)
    sp.append((s,p,i+1))

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

for s,p,i in sp:
    print(i, end=" ")

Submission status: Accepted

Solution code:
N = int(input())

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

for ResNum in range(0, N + 1):
    if ResNum <= N - 1:
        Restaurants[ResNum][1] = int(Restaurants[ResNum][1])

    if ResNum > 0:
        Restaurants[ResNum - 1].append(ResNum)

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

#print(Restaurants)

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3.4

# abc128_b

def main():
    # Input
    n, = [int(s) for s in input().split()]
    reports = [input().split()+[i+1] for i in range(n)]
    # Get ans
    for repo in reports:
        repo[1] = int(repo[1])
    reports.sort(key=lambda r: (r[0], -r[1]))
    # Output
    for repo in reports:
        print(repo[2])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
a = []
b = []
for _ in range(N):
    s = input().split()
    a.append(s[0])
    b.append(int(s[1]))
ind = list(range(1, N+1))
so = list(zip(a, b, ind))
so.sort(key=lambda x: x[1], reverse=True)
so.sort(key=lambda x: x[0], )
for s in so:
    print(s[2])

Submission status: Accepted

Solution code:
N = int(input())

SP = []
for i in range(N):
    tmp = list(map(str, input().split()))
    tmp[1] = int(tmp[1])
    tmp.append(i+1)
    SP.append(tmp)

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

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

Submission status: Accepted

Solution code:
N=int(input())

SP=[]
for i in range(N):
    SP.append(input().split())
    SP[i][1] = int(SP[i][1])
    SP[i].append(i)
    #print(SP)

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

for j in range(N):
    print(SP[j][2]+1)

Submission status: Accepted

Solution code:
n=int(input())
l=[list(input().split()) for i in range(n)]
for i in range(n):
  l[i][1]=-int(l[i][1])
L=sorted(l)
for i in range(n):
  print(l.index(L[i])+1)

Submission status: Accepted

Solution code:
N = int(input())
Arr = []
tmp = []
for i in range(N):
    tmp = list(map(str, input().split()))
    tmp.append(i+1)
    tmp[1] = int(tmp[1])
    Arr.append(tmp)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
inputs = []
for i in range(N):
  s = input().split()
  inputs.append([i, s[0], int(s[1])])

inputs.sort(key=lambda x: x[2], reverse=True)
inputs.sort(key=lambda x: x[1])
for x in inputs:
  print(x[0] + 1)

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.sort(key=lambda x:-x[1])
SP.sort(key=lambda x:x[0])
for i in range(N):
    print(SP[i][2])