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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

p.sort()
p.reverse()
tbl2 = []
for i in range(n):
    for j in range(n):
        if(tbl[j][0] == p[i]):
            tbl2.append(tbl[j])
s = list(set(s))
s.sort()
for i in range(len(s)):
    for j in range(len(tbl2)):
        if (tbl2[j][1] == s[i]):
            print(tbl2[j][2])

Submission status: Accepted

Solution code:
from operator import itemgetter 
n = int(input())
point = []
ans = []
for i in range(n):
    a,b = input().split()
    s = [a,int(b),i+1]
    point.append(s)

s_point = sorted(point,key=itemgetter(1),reverse=True)
s_point = sorted(s_point,key=itemgetter(0))
[print(s_point[j][2]) for j in range(n)]

Submission status: Accepted

Solution code:
n=int(input())
s=[]
for i in range(n):
    tmp=input().split()
    tmp[1]=100-int(tmp[1])
    s.append(tmp+[str(i+1)])
s=sorted(s)

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

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

# 地名に関して辞書順に / (-点数)に関して昇順に（点数に関して降順に）並べる
l = sorted(l, key=lambda x:(x[0], x[1]))
for i in range(N):
  print(l[i][2])

Submission status: Accepted

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

# まず点数で降順に並べる
l = sorted(l, key=lambda x:(x[1]), reverse=True)
# 次に地名で辞書順に並べる
l = sorted(l, key=lambda x:(x[0]))
for i in range(N):
  print(l[i][2])

Submission status: Accepted

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

my_list = []

for i in range(N):
    sp = input().split()
    sp[1] = int(sp[1])
    sp.insert(0, i+1)
    
    my_list.append(sp)
    
my_list.sort(key = lambda x: x[2], reverse=True)
my_list.sort(key = lambda x: x[1])

for i in my_list:
    print(i[0])

Submission status: Accepted

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

R2 = [{'i':i+1, 's':R[i][0], 'p':int(R[i][1])} for i in range(N)] 

S = []
for r in R:
  if r[0] not in S:
    S.append(r[0])
S.sort()

for s in S:
  rs = [r for r in R2 if r['s'] == s]
  sorted_rs = sorted(rs, key=lambda x:x['p'], reverse=True)
  for r in sorted_rs:
    print(r['i'])

Submission status: Accepted

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

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

Submission status: Accepted

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

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

for i in new_guidebook:
    print(guidebook.index(i)+1)

Submission status: Accepted

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

d = {}
for i, v in enumerate(s_p):
    s = v[0]
    p = v[1]
    if s not in d.keys():
        d[s] = [(i, p)]
    else:
        d[s] = sorted(d[s] + [(i,p)], key=lambda x: int(x[1]), reverse=True)

for key in sorted(d.keys()):
    for i,j in d[key]:
        print(i+1)

Submission status: Accepted

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

Submission status: Accepted

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

import operator
ans.sort(key=operator.itemgetter(0,1))

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

Submission status: Accepted

Solution code:
N = int(input())
S = []
P = []
for i in range(N):
    s,p = input().split()
    S.append(s)
    P.append(int(p))
Sset = sorted(list(set(S)))

dict1 = {}
for i in range(N):
    dict1[P[i]] = S[i]

for k in Sset:
    U = [i for i, j in dict1.items() if j == k]
    V = sorted(U,reverse=True)
    for l in V:
        print(P.index(l) + 1)

Submission status: Accepted

Solution code:
N = int(input())

l = []

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

for x in l:
    print(x[0])

Submission status: Accepted

Solution code:
N = int(input())
city = []
score = dict()
arr = []
for i in range(N):
  c, s = input().split()
  arr.append([c, int(s)])
  city.append(c)
  if c in score:
    score[c].append(int(s))
  else:
    score[c] = [int(s)]
city.sort()
ans = []
for i, var in enumerate(city):
  t = score[var].index(max(score[var]))
  u = score[var].pop(t)
  ans.append(arr.index([var,u]) + 1)
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    dic = collections.defaultdict(list)
    for i in range(n):
        s, p = LS()
        p = int(p)

        dic[s].append((p,i+1))
    
    key = list(dic.keys())
    key.sort()
    for k in key:
        lst = dic[k]
        lst.sort(reverse=True)
        lst = list(zip(*lst))[1]
        for s in lst:
            print(s)

    
    
main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

guide=[]

for i in range(N):
    name,score=map(str,input().split())
    guide.append([i,name,int(score)])

guide_sorted=sorted(guide,reverse=True,key=lambda x:x[2])
guide_sorted=sorted(guide_sorted,key=lambda x:x[1])

for i in range(N):
    print(guide_sorted[i][0]+1)

Submission status: Accepted

Solution code:
N = int(input())
Rest = dict()
Parg = [0]*(101)
for i in range(N):
    S, P = map(str,input().split())
    P = int(P)
    if S not in Rest:
        Rest[S] = [P]
    else:
        Rest[S] += [P]
    Parg[P] = i+1 
Restsort = sorted(Rest)
for cit in Restsort:
    box = Rest[cit]
    box.sort(reverse = True)
    for j in box:
        print(Parg[j])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
score = [0] * n
for i in range(n):
    s = input().split()
    score[i] = (s[0].strip(), int(s[1]), i + 1)

for s in sorted(score, key=lambda l: (l[0], -l[1])):
    print(s[2])

Submission status: Accepted

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

l = sorted(sp, key=lambda x: (x[1], -x[2]))
for a, b, c in l:
    print(a)

Submission status: Accepted

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

Submission status: Accepted

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

for info in book:
  print(info[1])

Submission status: Accepted

Solution code:
n=int(input())
A = [list(map(str,input().split())) for i in range(n)]
A_s = sorted(A, key=lambda x: int(x[1]), reverse=True)
A_ss = sorted(A_s, key=lambda x: x[0], reverse=False)
for i in range(n):
    print(A.index( A_ss[i])+1)

Submission status: Accepted

Solution code:
def solver():
    N = int(input())
    ans = []
    for i in range(1, N+1):
        s, p = [n for n in input().split()]
        ans.append({'id': i, 'city': s , 'point': int(p)})
    ans_s = sorted(ans, key=lambda x: (x['city'], -x['point']))
    for j in ans_s:
        print(j['id'])

if __name__=='__main__':
    solver()

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

s = []

for i in range(n):
	s.append((input()+' '+str(i)).split())

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

for i in s:
	print(int(i[2])+1)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
n=int(input())

s_list=[]

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

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

Submission status: Accepted

Solution code:
from operator import itemgetter
n=int(input())
SP=[list(map(str,input().split())) for i in range(n)]
for sp in SP:
  sp[1] = -1*int(sp[1])
SPsort = sorted(SP,key=itemgetter(0,1))
for i in range(n):
  print(SP.index(SPsort[i])+1)

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, key = lambda x: x[1], reverse=True)
lst = sorted(lst, key = lambda x: x[0])
for j in range(N):
  print(lst[j][2], end=" ")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
data = []
cities = []

for i in range(1,N+1):
    c,p = input().split()
    data.append([c,-(int(p)),i])
    if c in cities:
        None
    else:
        cities.append(c)

cities.sort()

ans = []
for c in cities:
    b = [s for s in data if c in s]
    b.sort(key=lambda x: x[1])
    for i in range(len(b)):
        ans.append(b[i])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [input().split() for i in range(n)]
for i in range(n):
    a[i][1] = int(a[i][1])
    a[i].append(i + 1)
a.sort()
for i in range(100):
    for j in range(1,n):
        if a[j][0] == a[j-1][0] and a[j][1] > a[j-1][1]:
            a[j-1],a[j] = a[j],a[j-1]
for i in range(n):
    print(a[i][2])

Submission status: Accepted

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

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

for i in range(N):
  print(X[i][1])

Submission status: Accepted

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

for i in range(n) :
    sp[i][1] = int(sp[i][1])
    sp[i].append(i+1)

sp.sort()

for i in range(100):
    for j in range(1,n) :
        if sp[j][0] == sp[j-1][0] :
            if sp[j][1] > sp[j-1][1] :
                sp[j-1],sp[j] = sp[j],sp[j-1]

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

Submission status: Accepted

Solution code:
n=int(input())

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l=[input().split() for i in range(n)]
l2=[x for x in range(n)]
base=list(zip(l2,l))
ans=sorted(base, key=lambda x: int(x[1][1]),reverse=True)
ans=sorted(ans,key=lambda x: x[1][0])

for i in range(n):
    print(1+ans[i][0])

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
dic1={}
bokk=[]
list0=[]
for i in range(n):
  c,p=map(str,input().split())
  p=int(p)
  list0.append([c,p])
  if c not in dic1:
    dic1[c]=[]
  dic1[c].append(p)
dic1=dict(sorted(dic1.items()))
for i,k in dic1.items():
  k.sort(reverse=True)
  for j in k:
    bokk.append([i,j])
for i in bokk:
  print(list0.index(i)+1)

Submission status: Accepted

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

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

for ans in sort_SP:
    print(ans[0])

Submission status: Accepted

Solution code:
N=int(input())
d=[input().split() for i in range(N)]
name=[]
for i in range(N):
    d[i].append(i+1)
    d[i][1]=int(d[i][1])
    name.append(d[i][0])
Name=list(set(name))
Name.sort()
d.sort()
for i in range(len(Name)):
    li=[]
    for j in range(N):
        if Name[i]==d[j][0]:
            li.append([d[j][1],d[j][2]])
        else:
            continue
    li.sort()
    Li=li[::-1]
    for k in range(len(li)):
        print(Li[k][1])

Submission status: Accepted

Solution code:
import re
n = int(input())
R = []
for i in range(n):
    S, P = input().split()
    R.append((S, int(P),int(i+1)))

Point = []
for j in range(n):
    Point.append(R[j][0])
Point = list(sorted(set(Point)))
Point
SR = sorted(R, key=lambda x:(x[0], -int(x[1])))
for k in range(n):
    print(SR[k][2])
pass

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()

    city = []
    dic = {}
    for i in range(N):
        S,P=isp()
        P = int(P)
        if not S in city:
            city.append(S)
            dic[S] = [(P,i)]
        else:
            dic[S].append((P,i))
    
    city.sort()
    for S in city:
        Ps = dic[S]
        Ps.sort(reverse=True) 
        for p,i in Ps:
            print(i+1)
    


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def mapt(fn, *args):
    return list(map(fn, *args))


def Atom(segment):
    try:
        return int(segment)
    except ValueError:
        try:
            float(segment)
        except ValueError:
            return segment


def Input():
    return mapt(int, input().split(" "))


def main():
    n = int(input())
    data = [mapt(Atom, input().split(" ")) for _ in range(n)]
    for i in range(n):
        data[i].append(i)
    data = sorted(data, key=lambda x:x[1], reverse=True)
    data = sorted(data, key = lambda x:x[0])
    for row in data:
        print(row[2]+1)

main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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


    Z = zip(S, P, R)
    Z = sorted(Z)
    S, P, R = zip(*Z)

    for i in R:
        print(i)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(n):
    print(restaurants.index(sorted_list[i]) + 1)

Submission status: Accepted

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

ans = sorted(sp2, key= lambda x:int(x[2]), reverse=True)

ans2 = sorted(ans, key =lambda x:x[1])
for i in range(n):
  
  print(ans2[i][0] +1)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

c = sorted(c, key=lambda x: (x[1], x[2]))
for i in c:
  print(i[0])

Submission status: Accepted

Solution code:
N = int(input())
restaurants = []
for i in range(N):
    name, rating = input().split()
    restaurants.append([name, -int(rating), i])
restaurants.sort()
for i in restaurants:
    print(i[2] + 1)

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

l = []
n = inp()
for i in range(1, n+1):
    r = input().split()
    s = r[0]
    p = int(r[1])
    l.append([i, s, p])
ans = sorted(l, key=lambda x:(x[1], -x[2]))
for t in ans:
    print(t[0])

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])
a.sort()

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

Submission status: Accepted

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

for i in range(N):
    SP[i].append(i+1)
  
ans = sorted(SP, key=lambda x:(x[0], -int(x[1])))

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for r in restaurants:
    print(r[0])

Submission status: Accepted

Solution code:
N = int(input())
book = []
for i in range(N):
    city, sco = input().split()
    sco = int(sco)
    book.append({'city':city, 'score':sco, 'number':i+1})

book.sort(key = lambda x: (x['city'],-x['score']))

for j in range(N):
    print(book[j]['number'])

Submission status: Accepted

Solution code:
N = int(input())
S = [list(input().split()) for _ in range(N)]
for i in S:
    i[1] = 100 - int(i[1])
for i in range(N):
    S[i] += i+1,
S.sort()
for i in S:
    print(i[2])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = []
for i in range(N):
  a = list(input().split())
  A.append([a[0], -int(a[1]), i+1])
A.sort()
for i in range(N):
  print(A[i][2])

Submission status: Accepted

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

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

    s_dict_keys = sorted(list(s_dict.keys()))

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    sp_lst = [0 for _ in range(N)]

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

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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


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

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

Submission status: Accepted

Solution code:
N=int(input())
num=[i for i in range(1,N+1)]
X=[]

for i in range(N):
    S,P=map(str,input().split())
    X.append([num[i],S,int(P)])

X = sorted(X,key=lambda d:d[2],reverse=True)
X = sorted(X,key=lambda d:d[1])

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

Submission status: Accepted

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

for j in range(n):
    print(a[j][1])

Submission status: Accepted

Solution code:
n = int(input())
sp = []
for i in range(n):
    s,p = map(str, input().split())
    sp.append((s,int(p)))
sp1 = tuple(sp)
sp = sorted(sp, key=lambda x:(x[0],-x[1]))
for h in sp:
    print(sp1.index(h)+1)

Submission status: Accepted

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

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()



def main():
	n=II()
	A=[]
	for i in range(1,n+1):
		a,b=input().split()
		a=a.rstrip().decode()
		b=int(b)
		A.append([a,b,i])

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

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






if __name__ == "__main__":
	main()

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

Submission status: Accepted

Solution code:
n = int(input())
sp = {i+1:input().split() for i in range(n)}

d = []
for i,s in sp.items():
    d.append((i,s[0],int(s[1])))
    
d = sorted(d,key=lambda x:x[2],reverse=True)
d = sorted(d,key=lambda x:x[1])
    
    
for i in d:
    print(i[0])

Submission status: Accepted

Solution code:
_, *sp = open(0).read().split()
for _, _, a in sorted([(s, -int(p), i + 1) for i, (s, p) in enumerate(zip(*[iter(sp)] * 2))]):
    print(a)

Submission status: Accepted

Solution code:
_, *sp = open(0).read().split()
for a in sorted([(s, -int(p), i + 1) for i, (s, p) in enumerate(zip(*[iter(sp)] * 2))]):
    print(a[2])

Submission status: Accepted

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

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

for i in sorted_name:
    print(i[2] + 1)

Submission status: Accepted

Solution code:
N, *SP = open(0).read().split()
sp = sorted((s, -int(p), i) for i, (s, p) in enumerate(zip(*[iter(SP)] * 2), 1))
[print(i) for _, _, i in sp]

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

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

Submission status: Accepted

Solution code:
N = int(input())
D = [list(map(str,input().split())) for _ in range(N)]
for i in range(N):
  D[i].append(i+1)
sorted_d = sorted(D, key = lambda x: (x[0], -int(x[1])))
for i in range(N):
  print(sorted_d[i][2])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(1,n+1):
    s,p = map(str,input().split())
    dic.setdefault(s,[])
    dic[s].append([int(p),i])
#print(dic)
sort_list = sorted(dic)
for key in sort_list:
    sort_item = sorted(dic[key],reverse=True)
    #print(sort_item)
    for i in range(len(sort_item)):
        print(sort_item[i][1])

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

Submission status: Accepted

Solution code:
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
d = [LS() + [str(i)] for i in range(1, n+1)]
d = sorted(d, key=lambda x: (x[0], int(x[1])*(-1)))
for elem in d:
    print(elem[2])