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

Submission status: Accepted

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

n = int(raw_input())

lst = []

for i in xrange(n):
 name,p=map(str,raw_input().split())
 lst.append([i+1,name,int(p)])
lst.sort(key=lambda x:(x[1],-x[2]))
for i in xrange(n):
  print lst[i][0]

Submission status: Accepted

Solution code:
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces546B
from collections import Counter
gi = lambda : list(map(int,input().strip().split()))
n, = gi()
l = [input().split() for _ in range(n)]
l = [(l[k][0], -int(l[k][1]), str(k+1)) for k in range(n) ]
l.sort()
print("\n".join([e[2] for e in l]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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])
list_point = sorted(q, key=lambda x:x[1], reverse=1)
list_city = sorted(list_point, key=lambda x:x[0], reverse=0)
for s,t,r in list_city:
    print(r+1)

Submission status: Accepted

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

sp = sorted(sp, key = lambda x: (x[0], -x[1]))
for i in sp:
    print(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:
N = int(input())
SN = []
for i in range(N):
  s, n =input().split()
  SN.append([s, int(n), i])

SN.sort()
#print(SN)

start = 0
while (start < N-1):
  for i in range(start, N):
    search = SN[start][0]
    while(SN[i][0] == search):
      end = i
      if(i<N-1):
        i = i+1
      else:
        end = i
        break
        
  SNpart = SN[start:min(end+1, N)]
  #print(SNpart)
  SNpart.sort(key=lambda x:-x[1])
  SN[start:min(end+1, N)] = SNpart

  #print(SN[start:end+1])
  start = end+1

for i in range(N):
  print(SN[i][2]+1)

Submission status: Accepted

Solution code:
print('\n'.join([l[2] for l in sorted(sorted([[l[1][0], int(l[1][1]), str(l[0] + 1)] for l in enumerate(input().split() for _ in range(int(input())))], key=lambda l: l[1], reverse=True), key=lambda l: l[0])]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
cps = {}
for i in range(1,N+1):
    city,point = input().split()
    point = int(point)
    if city in cps:
        cps[city].append((point,i))
    else:
        cps[city] = [(point,i)]
for k in sorted(cps.keys()):
    for v,idx in sorted(cps[k], reverse=True):
        print(idx)

Submission status: Accepted

Solution code:
N = int(input())

R = [input().split()+[i] for i in range(1, N+1)]

R = [[r[0], int(r[1]), r[2]] for r in R]

city = ''
stars = []
for r in sorted(R):
  if city != r[0]:
    for star in reversed(stars):
      print(star)
    city = r[0]
    stars = [r[2]]
  else:
    stars.append(r[2])
for star in reversed(stars):
  print(star)

Submission status: Accepted

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

Submission status: Accepted

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

for i, _, _ in sarr:
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
dic = defaultdict(list)
for n in range(1, N + 1):
    s, p  = input().split()
    p = int(p)
    dic[s].append((p, n))
for s in sorted(dic.keys()):
    lis = sorted(dic[s])[::-1]
    for _, p in lis:
        print(p)

Submission status: Accepted

Solution code:
from operator import itemgetter, attrgetter
N = int(input())
A = []
for i in range(N):
    tmp = input().split()
    A.append([tmp[0],-int(tmp[1]),i])
A.sort()
A.sort(key=itemgetter(0,1))
for i in range(N):
    print(A[i][2]+1)

Submission status: Accepted

Solution code:
def main():
	'''
	メイン関数
	'''
	# a
	N = int(input())
	
	SPList_reverse = []

	for n in range(0,N):
		SP = input().split()
		sp_tuple_reverse = SP[0], (100-int(SP[1]))
		SPList_reverse.append(sp_tuple_reverse)


	sortedSPList = sorted(SPList_reverse)


	for ssp in sortedSPList :
		ori = ssp[0], int(ssp[1])
		print(SPList_reverse.index(ori)+1)



if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
def main():
	'''
	メイン関数
	'''
	# a
	N = int(input())
	
	SPList = []
	SPList_reverse = []

	for n in range(0,N):
		SP = input().split()
		sp_tuple = SP[0], int(SP[1])
		sp_tuple_reverse = SP[0], (100-int(SP[1]))
		SPList.append(sp_tuple)
		SPList_reverse.append(sp_tuple_reverse)


	sortedSPList = sorted(SPList_reverse)


	for ssp in sortedSPList :
		ori = ssp[0], int(ssp[1])
		print(SPList_reverse.index(ori)+1)



if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
arr=[(0,0,0)]*N
for i in range(N):
	S,P = input().split()
	arr[i] = (S,-int(P),i+1)
arr.sort()
for _,_,i in arr:
	print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy
n=int(input())
data=[0]*n
for i in range(n):
    data[i]=input().split()

ans=numpy.empty((n,2))
for i in range(n):
    ans[i][1]=i
    ans[i][0]=int(data[i][0].upper().ljust(10,'0'),36)+100-int(data[i][1])
Ans=sorted(ans,key=lambda x:x[0])
for i in range(n):
    print(int(Ans[i][1])+1)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

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 i in range(N):
	print(A[i][2])

Submission status: Accepted

Solution code:
from sys import stdin
from collections import defaultdict

N = int(input())
lines = stdin.readlines()

dic = defaultdict(dict)

for i, line in enumerate(lines):
    line = line.strip().split()
    if i==0:
        tuple1 = ([i+1, line[0], int(line[1])],)
    else:
        tuple1 = tuple1 + ([i+1, line[0], int(line[1])],)


#print(tuple1)

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N = int(input().rstrip())

S = []
P = []
for _ in range(N):
    s, p = input().rstrip().split()
    S.append(s)
    P.append(int(p))

Index = sorted(range(N), key=lambda i: P[i], reverse=True)
Last_Index = sorted(Index, key=lambda i: S[i])

for i in Last_Index:
    print(i + 1)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n = int(input())
X = [list(input().split()) for _ in range(n)]


xx = [0]*n
for i in range(n):
    X[i][1] = int(X[i][1])
    xx[i] = int(X[i][1])


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

for i in range(n):
    print(xx.index(L[i][1]) + 1)

Submission status: Accepted

Solution code:
import numpy as np

s = np.array([input().split() for _ in range(int(input()))])
s = [i[0]+"{0:03d}".format(100-int(i[1])) for i in s]
s = np.argsort(s,axis=0)

for i in s:
    print(i+1)

Submission status: Accepted

Solution code:
# coding: utf-8
import os
import time
import re
import math


N = int(input())
SP=[]
for a in range(N):
    temp=input().split()
    SP.append([temp[0],int(temp[1]),(a+1)])
#SP=list(map(lambda x: x[0], SP))
SP=sorted(SP, key=lambda x: (x[0],-x[1]))
for a in range(N):
    print(SP[a][2])

Submission status: Accepted

Solution code:
n = int(input())
s = [[int(i) if str.isnumeric(i) else i for i in input().split()] for i in range(n)]

k = 1
for row in s:
    row.append(k)
    k += 1

s.sort(reverse=True)
s.sort(key=lambda x: x[0])

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
a = []
for i in range(N):
  S, P = input().split()
  a.append((S, 100-int(P), i+1))
a.sort()
for i in a:
  print(i[2])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8
N = int(input())
cnt = 1

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

for i in range(0,N):
    datalist[i].append(cnt)
    cnt += 1

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

for i in range(0,N):
    print(datalist2[i][2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
N=int(input().strip())
points=defaultdict(list)
for i in range(N):
    S,P=input().strip().split()
    P=int(P)
    points[S].append((i+1,P))
for s in sorted(points.keys()):
    shps=points[s]
    for sh in sorted(shps,key=lambda x:-x[1]):
        print(sh[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
res = []
for i in range(N):
    name, point = input().split()
    point = int(point)
    res.append((name, point, len(res) + 1))
res = sorted(res, key=lambda x: (x[0], -x[1]))
for name, point, idx in res:
    print(idx)

Submission status: Accepted

Solution code:
n=int(input())

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

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

Submission status: Accepted

Solution code:
from operator import itemgetter

n = int(input())
a = []

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

b = sorted(a,key=itemgetter(1),reverse=True)
xs = sorted(b,key=itemgetter(0))
for x in xs:
    print(x[2])

Submission status: Accepted

Solution code:
N = int(input())
li = []
cities = []
for i in range(N) :
    inp = input().split()
    l = [inp[0], int(inp[1]), int(i+1)]
    li.append(l)
    if (l[0] not in cities) :
        cities.append(l[0])

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

ans = []
for c in cities :
    # hoge = list(filter(lambda x : x[0] == c, li)).sort(key=lambda x : x[1], reverse=True)
    ans += sorted(list(filter(lambda x : x[0] == c, li)),key=lambda x: x[1], reverse=True)
    # ans.extend()

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

Submission status: Accepted

Solution code:
N = int(input())
PS = [[int(i) if str.isnumeric(i) else i for i in input().split()] for i in range(N)]
a = 1
for i in PS:
    i.append(a)
    a += 1
PS = sorted(PS, reverse=True)
for i in sorted(PS, key=lambda x: x[0]):
    print(i[2])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def guidebook(N: int, scores: list)->list:
    rev = {v: i for i, v in enumerate(scores)}
    scores.sort(key=lambda x: -x[1])
    scores.sort(key=lambda x: x[0])

    return [rev[v]+1 for v in scores]


if __name__ == "__main__":
    N = int(input())
    scores = []
    for _ in range(N):
        s, p = input().split()
        scores.append((s, int(p)))

    for ans in guidebook(N, scores):
        print(ans)

Submission status: Accepted

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

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 i in range(N):
  print(a[i][2])

Submission status: Accepted

Solution code:
# sys.stdin.readline()
import sys
input = sys.stdin.readline

n = int(input())
S = [list(input().split()) for i in range(n)]
for i in range(n):
    S[i].append(i)
    S[i][1]= int(S[i][1])
S = sorted(S,key=lambda x:x[1],reverse=1)
S = sorted(S,key=lambda x:x[0])
for i in range(n):
    print(S[i][2]+1)

Submission status: Accepted

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

# Pythonのソートが安定であることを利用する
# まず、得点で降順でソートして、市名で昇順ソートする

N = int(input())
ls = [None]*N
for i in range(N):
    s, p = input().split()
    ls[i] = (i+1, s, int(p))
ls.sort(key=(lambda x: -x[2]))  # pで降順ソート
ls.sort(key=(lambda x: x[1]))   # sで昇順ソート (安定ソートなので、同じsについてpが降順となる)

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

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

Submission status: Accepted

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

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

for i in range(0, N):
  print(l[i][2])

Submission status: Accepted

Solution code:
#abc128b

n=int(raw_input())
l=[]
for i in xrange(n):
 c,p=map(str,raw_input().split())
 l.append([i+1,c,int(p)])
ll=sorted(l,key=lambda x:(x[1],-x[2]))
for i in xrange(n):
 print ll[i][0]

Submission status: Accepted

Solution code:
N = int(input())

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

sorted_A = sorted(A)

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

Submission status: Accepted

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

Submission status: Accepted

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

for _ in a:
	_[1] = int(_[1])

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

for index in range(len(a)):
	print(a.index(sorted_a[index])+1)

#last = [0,0]

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 = sorted(L, key=lambda x: x[1], reverse=True)
L = sorted(L, key=lambda x: x[0], reverse=False)

ans = [L[i][2] for i in range(N)]

print(*ans, sep="\n")

Submission status: Accepted

Solution code:
N = int(input())
rest = [tuple(input().split()) for _ in range(N)]
def f1(l):
    s, p = l
    return s
def f2(l):
    s, p = l
    return int(p)
rest2 = sorted(rest, key = f2, reverse = True)
rest2.sort(key = f1)
dict = {}
for i in range(N):
    dict[rest[i]] = i+1
for j in rest2:
    print(dict[j])

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


from sys import stdin
from operator import itemgetter

N = int(stdin.readline().rstrip())

rest_list = []

for i in range(N):
    S, P = [x for x in stdin.readline().rstrip().split()]
    P = int(P)
    rest_list.append([i+1,S,P])


sorted_rest_1 = sorted(rest_list, key=itemgetter(2),reverse=True)
sorted_rest_2 = sorted(sorted_rest_1, key=itemgetter(1))

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

Submission status: Accepted

Solution code:
N = int(input())
shop_list = [0 for _ in range(N)]
for i in range(N):
    s,p = map(str, input().split())
    p = int(p)
    shop_list[i] = {"no":i+1,"city":s,"points":p}
shop_list.sort(key = lambda x:(x["city"],-x["points"]))
for i in range(N):
    print(shop_list[i]["no"])

Submission status: Accepted

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

Submission status: Accepted

Solution 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 = set()
    sp = []
    for i in range(N):
        i += 1
        s, p = input().split()
        p = -int(p)
        sp.append([s, p, i])
    sp.sort()
    for s, p, i in sp:
        print(i)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
L=[]
for i in range(N):

    city,p=input().split()
    L.append([i+1,str(city),int(p)])

L=sorted(L, key=lambda x:(x[1],-x[2]))

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

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))
l.sort()
for i in range(N):
    print(l[i][2] + 1)

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)])
ls.sort(key=lambda x:(x[1], -x[2]))
for j in range(len(ls)):
    print(ls[j][0])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=[]
b=[i+1 for i in range(n)]
for i in range(n):
  m,l=(j for j in input().split())
  a.append([m,int(l)])
for i in range(n):
  for j in range(n-1):
    if a[j+1][0]<a[j][0] or (a[j+1][0]==a[j][0] and a[j][1]<a[j+1][1]):
                 c=a[j]
                 a[j]=a[j+1]
                 a[j+1]=c
                 d=b[j]
                 b[j]=b[j+1]
                 b[j+1]=d
for i in range(n):
  print(b[i])

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)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
sp = [None] * n
for i in range(n):
    s, p = input().split()
    sp[i] = [s, -int(p), i + 1]
for x in sorted(sp):
    print(x[2])

Submission status: Accepted

Solution code:
a = int(input())

List = []
for i in range(a):
	b, c = input().split()
	c = int(c)
	List.append([b, -c, i])
List.sort()

for i in range(a):
  print(List[i][2]+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
l1, l2 = [], []
l3 = []
d = defaultdict(dict)

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

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

for i in s_sorted :
    s = sorted(i[1].values(), reverse = True)
    l3.append(s)


for i in range(len(s_sorted)) :
    for k, v in sorted(s_sorted[i][1].items(), key=lambda x: -x[1]) :
        print(k + 1)

Submission status: Accepted

Solution code:
from operator import itemgetter

# a, b = map(int, input().split())
a = int(input())
array2 = {}
array99 = []
for i in range(a):
    array = input().split()
    array99.append((array[0], int(array[1]) * -1, i))

# print(array99)

b = sorted(array99, key=itemgetter(0, 1))

# print(b)

for i in range(a):
    print(b[i][2] + 1)

Submission status: Accepted

Solution code:
N = int(input())
name_dict = {}
for i in range(N):
  n, c = input().split()
  c = int(c)
  if n not in name_dict:
    name_dict[n] = [[c, i+1]]
  else:
    name_dict[n].extend([[c, i+1]])

name_dict = sorted(name_dict.items())
for i, value in name_dict:
  value = sorted(value, reverse=True)
  for j in value:
    print(j[1])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
info=[input().split() for i in range(N)] #mojiretu
#print(info)
from operator import itemgetter
dic1={}
for i in range(len(info)):
    dic1[i+1]=info[i]
#print(dic1)
info1=sorted(info,key=lambda x:int(x[1]),reverse=True)
info2=sorted(info1,key=itemgetter(0))
#print(info2)
for i in info2:
    for key,value in dic1.items():
        if value==i:
            print(key)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
def myop1(e):
    return e[1]

def myop2(e):
    return e[0]

t=int(input())
l=[]
d={}
for _ in range(t):
    s,n=input().split(' ')
    n=int(n)
    l.append((s,n))
k=[i for i in l]
l.sort(reverse=True,key=myop1)
l.sort(key=myop2)
for i in range(len(l)):
    d[k[i]]=i
for i in l:
    print(str(d[i]+1))

Submission status: Accepted

Solution code:
class Rest:

    def __init__(self, idx, city, point):
        self.idx = idx
        self.city = city
        self.point = point

    def __repr__(self):
        return repr((self.idx, self.city, self.point))

    def __lt__(self, other):
        if self.city == other.city:
            return self.point > other.point
        else:
            return self.city < other.city


N = int(input())
Rests = []

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

Rests.sort()

for i in Rests:
    print(i.idx)

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 v in a:
    print(v[2])

Submission status: Accepted

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

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

sps.sort()

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

Submission status: Accepted

Solution code:
#整数をint型に変換する
def is_int(x):
    try:
        x = int(x)
    except ValueError as e:
        pass
    finally:
        return x

n = int(input())
list = [list(map(is_int,input().split())) for i in range(n)]

#レストランの番号を追加
for i in range(n):
    list[i].append(i+1)

#辞書順,点数で降順にソート
list.sort(key=lambda x:(x[0],-x[1]))

#レストランの番号を出力
for i in range(n):
    print(list[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 = sorted(L)
for x in L:
  print(x[2])

Submission status: Accepted

Solution code:
# ABC128B
N = int(input())

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

SP.sort()
for i in range(N):
    print(SP[i][2]+1)

Submission status: Accepted

Solution code:
n = int(input())
sp_array = [[x for x in input().split()]+[index] for index, y in enumerate(range(n))]
tmp = []
for row in sp_array:
    t = [row[0], int(row[1]), int(row[2])]
    tmp.append(t)
res = sorted(tmp, key=lambda x:(x[0],-x[1]))
for row in res:
    print(row[2]+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 = sorted(sp)

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

Submission status: Accepted

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

list.sort()

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

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):
    a, b = input().split()
    S.append([a, -int(b), i + 1])

#ソートの時に０番目を基準にソートし，次に１番目を基準にソートする
S.sort()

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

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n = int(input())
reviews = []
for i in range(n):
    s,p = input().split(" ")
    p = int(p)
    reviews.append((i,s,p))

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

for r in reviews:
    print(r[0]+1)

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
SP=[]
SPs=[]
for i in range(n):
    SP=[i]
    for j in input().split():
        SP.append(j)
    SPs.append(SP)
SPs=np.array(SPs)

SPs2=SPs[SPs[:,2].astype(int).argsort(kind="mergesort")[::-1],:]
SPs3=SPs2[SPs2[:,1].argsort(kind="mergesort"),:][:,0]

for i in range(n):
    print(int(SPs3[i])+1)