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:
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]", P: "List[int]"):
    cityDict = {}
    cityNameSet = set()
    for i in range(N):
        city = S[i]
        point = P[i]
        cityNameSet.add(city)
        if city not in cityDict:
            cityDict[city] = []
        cityDict[city].append((point,i))
    for city in sorted(list(cityNameSet)):
        arr = cityDict[city]
        arr.sort(reverse=True)
        for a in arr:
            print(a[1]+1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [str()] * (N)  # type: "List[str]"
    P = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        S[i] = next(tokens)
        P[i] = int(next(tokens))
    solve(N, S, P)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = {tuple(map(str, input().split())):i for i in range(1,n+1)}
sort_d = sorted(d.items(), key=lambda x:(x[0][0],-int(x[0][1]))) #点数に－で降順でマイナス順になる
r = []
for i in sort_d:
  print(i[1])

Submission status: Accepted

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

N = int(input().strip())

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

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

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

Submission status: Accepted

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

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

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

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 a,b,c in SP:
  print(c)

Submission status: Accepted

Solution code:
n = int(input())

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

for i in b:
  tmp = a[i]
  for j in sorted(tmp, reverse = True):
    print(j[1])

Submission status: Accepted

Solution code:
N = int(input())
restaurant = [tuple(input().split()) + (idx + 1,) for idx in range(N)]

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

Submission status: Accepted

Solution code:
n=int(input())
guide=[]
for i in range(n):
    city,point=input().split()
    point=int(point)
    guide.append([city,-point,i+1])


guide.sort()

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

Submission status: Accepted

Solution code:

n = int(input())

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

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

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

Submission status: Accepted

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

l=sorted(l, key = lambda x: (x[1]))
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())
SP=[list(input().split()) for _ in range(N)]

base=[]

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

sp=sorted(SP)

#print(sp)

for i in range(1,N):
    if sp[i][0]==sp[i-1][0]:
        base.append(sp[i-1][1:])
    else:
        base.append(sp[i-1][1:])
        base=sorted(base,reverse=True)
        for j in base:
            print(j[1])
        base=[]
    #print(base)
if sp[N-1][0]==sp[N-2][0]:
        base.append(sp[N-1][1:])
        base=sorted(base,reverse=True)
        for j in base:
            print(j[1])
        base=[]
else:
    print(sp[N-1][2])



#print(sp)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
SP=[list(input().split()) +[i] for i in range(n)]
SP.sort(key=lambda x: (x[0],-int(x[1])))
for i ,j ,k in SP:
      print(k+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 a:(a[0],-a[1]))
for i in sp:print(i[2])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())

r_dic = {}

for i in range(N):
    si,ppi = input().split()
    pi = int(ppi)
    if si in r_dic.keys():
        r_dic[si].append((i+1,pi))
    else:
        r_dic[si] = [(i+1,pi)]
    
skey = sorted(r_dic.keys())
for key in skey:
    line = r_dic[key]
    if len(r_dic[key]) == 1:
        print(line[0][0])
    else:
        sline = sorted(line, key = lambda x:x[1], reverse=True)
        for s in sline:
            print(s[0])

Submission status: Accepted

Solution code:
n = int(input())
jisyo = dict()
for i in range(n):
    city , point = input().split()
    if city in jisyo.keys():
        jisyo[city].append((int(point),i))
    else:
        jisyo[city] = [(int(point),i)]

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

for c in jisyo_sort:
    point_sort = sorted(c[1] , key = lambda x : x[0] , reverse = True)
    for i in point_sort:
        print(i[1]+1)

Submission status: Accepted

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

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

from collections import defaultdict

def main():
  n = int(input())
  sp = defaultdict(list)
  sp2number = {}
  for i in range(n):
    s, p = input().strip().split()
    p = int(p)
    sp[s].append(p)
    sp2number[(s, p)] = i + 1
  for key in sorted(sp.keys()):
    for score in sorted(sp[key], reverse=True):
      print(sp2number[(key, score)])

if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
S=[list(map(str,input().split())) for i in range(N)]

A=sorted(S,key=lambda x:int(x[1]), reverse=True)
B=sorted(A,key=lambda x:x[0])
#print(B)
for i in range(N):
    ans=S.index(B[i])+1
    print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())

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

    r.sort(key=lambda val: (val[0], val[1]))

    for v in r:
        print(v[2])


main()

Submission status: Accepted

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

spi = []
for i in range(n):
    spi.append([sp[i][0], -1*int(sp[i][1]), i])

spi.sort()

for _spi in spi:
    print(_spi[2]+1)

Submission status: Accepted

Solution code:
N = int(input())
SP = {}
ALL = {}
for i in range(N):
    [Stmp, Ptmp] = list(input().split())
    if Stmp not in SP:
        SP[Stmp] = [int(Ptmp)]
    else:
        SP[Stmp].append(int(Ptmp))
    ALL[Stmp+str(Ptmp)] = i+1

A = list(SP.keys())
A.sort()
M = len(A)
for i in range(M):
    L = SP[A[i]]
    L.sort(reverse=True)
    for j in range(len(L)):
        print(ALL[A[i]+str(L[j])])

Submission status: Accepted

Solution code:
from collections import defaultdict
from itertools import chain
n = int(input())
a = [input().split() + [i+1] for i in range(n)]
d = defaultdict(list)
for k,v,i in a:
    d[k].append((int(v), i))


sk = sorted(d.keys())
sd = [sorted(d[ski], reverse=True) for ski in sk]
[print(i) for v,i in chain.from_iterable(sd)]

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
guide = dict()
for i in range(N):
  s, p = input().split()
  city, point = str(s), int(p)
  # 辞書 key:都市 -> val:(点数, 通し番号)
  if city in guide.keys():
    guide[city].append((point, i))
  else:
    guide[city] = [(point, i)]
#print(guide)

# 都市名で昇順
guide_asc = sorted(guide.items(), key=lambda x: x[0])
#print(guide_asc)

for city_guide in guide_asc:
  # 市内のレストラン点数で降順
  city_guide_desc = sorted(city_guide[1], key=lambda x: x[0], reverse=True)
  #print(city_guide[0], city_guide_desc)
  # 通し番号を出力
  for rest in city_guide_desc:
    print(rest[1] + 1)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
lst = list()
for idx in range(int(input())):
  k,v = input().split()
  lst.append((k,int(v), idx+1))
lst.sort(key=lambda t: (t[0],-t[1]), reverse=False)
for t in lst:
  print(t[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_sort = sorted(sp, key=lambda x: (x[0], -1 * x[1]))

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
list = []
for i in range(N) :
    s, p = input().split()
    list.append((s,p,i+1))

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

for i in sorted(lst):
    print(i[2])

Submission status: Accepted

Solution code:
n = int(input())

id = 0
res = []
for i in range(n):
    id += 1
    s, p = map(str, input().split())
    res.append([s, -1 * int(p), id])

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())

name = []
score = []
for i in range(n):
    a, b = input().split()
    b = int(b)
    name.append(a)
    score.append(b)
rank = []

N = sorted(list(set(name)))
A = []
B = []
t = 1
for i in N:
    A = []
    B = []
    for j in range(n):
        if name[j] == i:
            A.append(j)
            B.append(score[j])

    C = zip(B, A)
    C = list(reversed(sorted(C)))
    D, E = zip(*C)

    for i in E:
        print(i+1)

Submission status: Accepted

Solution code:
n = int(input())
sp = [[0]*3 for i in range(n)]

for i in range(n):
  s, m = input().split()
  sp[i][0] = s
  sp[i][1] = -int(m)
  sp[i][2] = i

sp.sort()
for s, n, i in sp:
  print(i+1)

Submission status: Accepted

Solution code:
from operator import itemgetter 
n=int(input())
data=[]
name=[]
for i in range(n):
    s_i,p_i=input().split()
    data.append([s_i,100-int(p_i),i+1])
data.sort()
for i in range(n):
    print(data[i][2])

Submission status: Accepted

Solution code:
n = int(input())
X = [["0", "0", 0]]
for i in range(n):
    s, p = map(str, input().split())
    X.append([s, p, i + 1])
X = sorted(X, key = lambda x : x[0])
X.append(["0", "0", 0])
Y = []
for i in range(1, n + 1):
    if X[i][0] != X[i + 1][0] and X[i - 1][0] != X[i][0]:
        print(X[i][2])
    elif X[i][0] == X[i + 1][0]:
        Y.append([X[i][1], X[i][2]])
    elif X[i][0] != X[i + 1][0] and X[i - 1][0] == X[i][0]:
        Y.append([X[i][1], X[i][2]])
        Y = sorted(Y, key = lambda x : int(x[0]))
        Y.reverse()
        for j in range(len(Y)):
            print(Y[j][1])
        Y = []

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

for s, n, i in SP:
    print(i+1)

Submission status: Accepted

Solution code:


def readints():
    return list(map(int, input().split()))


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

Submission status: Accepted

Solution code:
N = int(input())
table = []
for i in range(N):
    tmp = list(input().split())
    tmp[1] = int(tmp[1]) * (-1)
    tmp_table = [tmp, i+1]
    table.append(tmp_table)
table.sort()
for i in range(N):
    print(table[i][1])

Submission status: Accepted

Solution code:
N = int(input())
f = lambda x: (x[0], int(x[1]))
SP = tuple(f(input().split()) for _ in range(N))
print(*sorted(range(1, N+1), key=lambda i: (SP[i-1][0], -SP[i-1][1])), sep='\n')

Submission status: Accepted

Solution code:
table=[]
n=int(input())
for i in range(n):
    tmp=list(input().split())
    tmp[1]=int(tmp[1])*(-1)
    tmp_table=[tmp,i+1]
    table.append(tmp_table)
table.sort(key=lambda x:x[0])
for i in range(n):
    print(table[i][1])

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 city,price,idx in l:
    print(idx)

Submission status: Accepted

Solution code:
n = int(input())

restrunt=[]

for i in range(n):
    a, b = input().split()
    restrunt.append( {"s":a, "p":int(b), "nom":i+1} )

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

for res in restrunt:
    print(res["nom"])

Submission status: Accepted

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

x=sorted(rest)


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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    sp[i][1] = int(sp[i][1])
    sp[i] = sp[i]+[i+1]
    
sp_s0 = sorted(sp, key=lambda x:(x[0], -x[1]), reverse=False)

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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

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

num = []

for i in range(n):
    for j in range(n):
        if b[i][0] == c[j][0]:
            if c[j][2] not in num:
                print(c[j][2]+1)
                num.append(c[j][2])

Submission status: Accepted

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

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


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

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

Submission status: Accepted

Solution code:
n = int(input())
lst = []
for i in range(n):
    s,p = input().split()
    lst.append([s,-int(p),i+1])
lst.sort()
for i in range(n):
    print(lst[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 name, p, inx in l:
 print(inx)

Submission status: Accepted

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

b_n=l[0][0]
t_list=[]

for name, p, inx in l:
 if name!=b_n:
  t_list.sort(reverse=True)
  for i,j in t_list:
   print(j+1)
  t_list=[]
  b_n=name

 t_list.append([int(p),inx])

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()
l.append(['',0,0])

b_name=l[0][0]
t_list=[]

for name, point, inx in l:
 if name==b_name:
  t_list.append([int(point),inx])
 else:
  t_list.sort(reverse=True)
  for i,j in t_list:
   print(j+1)
  t_list=[]
  t_list.append([int(point),inx])
  b_name=name

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[0],-x[1]))
for _, _, i in l:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())

li = []

for i in range(n):
    s,p = map(str, input().split())
    p = int(p)
    li.append((s,p,i))

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

for i in range(n):
    print(li[i][2] + 1)

Submission status: Accepted

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

Submission status: Accepted

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

flag=1
finished=0
while flag:
    flag=0
    for i in range(N-1-finished):
        if lst[i][0]==lst[i+1][0] and lst[i][1]<lst[i+1][1]:
            lst[i],lst[i+1]=lst[i+1],lst[i]
            flag=1
    finished+=1

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc128/tasks/abc128_b

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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


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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    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[1], x[2] * -1))

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


main()

Submission status: Accepted

Solution code:
n = int(input())
hako = []
for i in range(n):
    a,b = input().split()
    hako.append([a,int(b)*-1])
kari = hako.copy()
hako.sort()
for i in range(n):
    print(kari.index(hako[i])+1)

Submission status: Accepted

Solution code:
from operator import itemgetter
N=int(input())
hako=[]
for i in range(N):
    A,B=input().split()
    hako.append([A,int(B)*-1])
kari=hako.copy()
#print(kari)
hako.sort()
#print(hako)
for i in range(N):
    print(kari.index(hako[i])+1)

Submission status: Accepted

Solution code:
from operator import itemgetter
N=int(input())
hako=[]
for i in range(N):
    A,B=input().split()
    hako.append([A,int(B)*-1])
kari=hako.copy()
#print(kari)
hako.sort()
hako=sorted(hako,key=itemgetter(0,1))
#print(hako)
for i in range(N):
    print(kari.index(hako[i])+1)

Submission status: Accepted

Solution code:
n = int(input())
li = []
for i in range(n):
    s,p = input().split()
    li.append([s,-int(p)])
b = sorted(li)
for i in range(n):
    for j in range(n):
        if b[i][0] == li[j][0] and b[i][1] == li[j][1]:
            print(j+1)

Submission status: Accepted

Solution code:
n=int(input())
s = [input().split() for i in range(n)]
c=0
for x in s:
    c+=1
    x.append(c)
    x[1]=str(100-int(x[1])).zfill(3)
s.sort(key=lambda x:(x[0],x[1]))
for x in s:
    print(x[2])

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

for i, _, _ in sorted(hoge, key=lambda x: (x[1], -x[2])):
    print(i)

Submission status: Accepted

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


new_rs = sorted(rs, key=lambda x: - int(x[1]))


def mp_count(s):
    mps = {}
    for mp, _ in s:  # 2個の変数を用意しないと、1個の変数にリストがいい感じにおさまってしまう
        if mp not in mps:
            mps[mp] = 0
    return sorted(mps)


for m in mp_count(rs):
    for r in new_rs:
        if m == r[0]:
            print(rs.index(r) + 1)

Submission status: Accepted

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

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

Restaurant.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from operator import itemgetter
N = int(input())
restrant = []
for i in range(N):
    mise = [j for j in input().split()]
    L = []
    for k in range(2):
        if k == 0:
            L.append(mise[k])
        else:
            L.append(int(mise[k]))
    restrant.append(L+[i+1])
restrant.sort(key = lambda x:(x[0],-x[1]))
for i in restrant:
    print(i[2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(1, n+1):
    n, p = input().split()
    if n not in dic.keys(): dic[n] = []
    dic[n].append([int(p), i])
keys = sorted(list(dic.keys()))
for key in keys:
    city = dic[key]
    city = sorted(city, key=lambda x: x[0], reverse=True)
    for city_i in city:
        print(city_i[1])

Submission status: Accepted

Solution code:
n = int(input())
restaurant = []
for i in range(n):
  s, p = input().split()
  d = str(100 - int(p))
  restaurant.append((s + '0' * (13 - len(s) - len(d)) + d, i+1))
restaurant.sort()
for rest in restaurant:
  print(rest[1])

Submission status: Accepted

Solution code:
n = int(input())
l = [0] * n
for i in range(n):
    l[i] = list(map(str, input().split()))
    l[i][1] = int(l[i][1])
l_sorted = sorted(l, key=lambda l: l[1], reverse=True)
l_sorted = sorted(l_sorted, key=lambda l: l[0])

for i in range(len(l)):
    print(l.index(l_sorted[i]) + 1)

Submission status: Accepted

Solution code:
n = int(input())
ans = {}
for i in range(1,n+1):
    s,t = input().split()
    ans[i] = [s,-1*int(t)]
ans = sorted(ans.items(),key = lambda x:x[1])
for i in range(n):
    print(ans[i][0])

Submission status: Accepted

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

for i in range(1,n+1):
  s,p=input().split()
  l.append([s,int(p),i])
  
l.sort(key=lambda x:x[1],reverse = True)
l.sort(key=lambda x:x[0])

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

n = int(sys.stdin.readline().rstrip())
sp = [sys.stdin.readline().split() for _ in range(n)]

def main():
    res = defaultdict(list)
    for i in range(n):
        s, p = sp[i]
        res[s].append((int(p), i+1))
    
    for s, l in sorted(res.items()):
        for p, i in sorted(l, reverse=True):
            yield i

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Submission status: Accepted

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n = int(input())
	ll=[]
	for i in range(n):
		b , c = input().split()
		c=int(c)
		ll.append((b,-c,i+1))
	ll.sort()
	for _, _, i in ll:
		print(i)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

Solution code:
from operator import itemgetter

# input
N = int(input())
S, P = ['0']*N, [0]*N
SP = []
for i in range(N):
    tmp_s, tmp_p = map(str, input().split())
    S[i], P[i] = tmp_s, tmp_p
    SP.append((tmp_s,int(tmp_p)))

# 点数で逆順ソート
SSP = sorted(SP, key=itemgetter(1), reverse=True)
# 名前で昇順ソート
SSP = sorted(SSP, key=itemgetter(0))

answer = [0]*N
for i in range(N):
    for j in range(N):
        if SSP[i] == SP[j]:
            answer[i] = j+1

for i in answer:
    print(i)

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])
for j in range(len(l)):
  print(l[j][2])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
d = dict()
cities = set()
for n in range(N):
    i = n + 1
    S, P = [s for s in input().split(' ')]
    cities.add(S)
    P = int(P)
    Ps = d.get(S, [])
    Ps.append((P, i))
    d[S] = Ps
for city in sorted(d.keys()):
    rs = d[city]
    for r, i in sorted(rs, reverse=True):
        print(i)

Submission status: Accepted

Solution code:
import os, sys, re, math

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

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