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=[0]*N
for i in range(N):
    s,n=map(str,input().split())
    L[i]=[i+1,s,-int(n)]
L.sort(key=lambda x:(x[1],x[2]))
for i in L:
    print(i[0])

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline

def main():
    N = int(input())
    store = []
    for i in range(N):
        S, P = readline().split()
        P = int(P)
        store.append([i+1,S,P])
    store.sort(key=lambda x: x[2], reverse=True)
    store.sort(key=lambda x: x[1])
    
    for s in store:
        print(s[0])

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

items = sorted(items)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

dk=sorted(l.keys())
for i in dk:
  l[i].sort(reverse=True, key=lambda x:x[0])
  for j,k in l[i]:
    print(k)

Submission status: Accepted

Solution code:
lst = []
for i in range(int(input())):
    S,P = input().split()
    lst.append([S,int(P),i+1])
lst2 = sorted(lst, key=lambda x:x[1],reverse=True)
lst3 = sorted(lst2, key=lambda x:x[0],reverse=False)
for i in lst3:
    print(i[2])

Submission status: Accepted

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

keys = sorted(set(s[0] for s in sp))

for k in keys:
    for ss in sorted([s[1:] for s in sorted(sp) if s[0]==k], reverse=True):
        print(ss[1])

Submission status: Accepted

Solution code:
rests = {}
for i in range(int(input())):
    S,P = input().split()
    P = int(P)
    if S in rests:
        rests[S] += [[P,i]]
    else:
        rests[S] = [[P,i]]
        
r = sorted(rests.items()) #市の名前でソート
for city in r:
    city[1].sort()
    city[1].reverse()
    
    for score,i in city[1]:
        print(i+1)

Submission status: Accepted

Solution code:
n = int(input())
sp = []
for i in range(n):
  s,p = input().split()
  sp.append([s, 100 - int(p), i+1])
sp.sort()
ans = []
for s,p,i in sp:
  ans.append(i)
print("\n".join(map(str, ans)))

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

b = sp[0][0]
I = 0
ans = []
for s,p,i in sp:
  if b == s:
    ans.insert(I, i)
  else:
    ans.append(i)
    b = s
    I = len(ans)-1
print("\n".join(map(str, ans)))

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

Submission status: Accepted

Solution code:
N = int(input())
T = [None]*N
for i in range(N):
    tmp = input().split()
    T[i] = (tmp[0], -int(tmp[1]), i+1)

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

Submission status: Accepted

Solution code:
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
a = [None]*n
for i in range(n):
    a[i] = [None]*2
for i in range(n):
    a[i] = input().split()
# print(a)
for i in range(n):
    a[i][1] = int(a[i][1])
for i in range(n):
    a[i].append(i+1)
#print('a', a)
b = sorted(a, key=itemgetter(1), reverse=True)
#print('b', b)
c = sorted(b, key=itemgetter(0))
#print('c', c)
for i in range(n):
    print(c[i][2])

Submission status: Accepted

Solution code:
N = int(input())
S = [None]*N
P = [None]*N
I = [None]*N
for i in range(N):
    tmp = input().split()
    S[i] = tmp[0]
    P[i] = int(tmp[1])
    I[i] = i+1


def less(a, b):
    if a[0] == b[0]:
        if a[1] == b[1]:
            return a[2] < b[2]
        return a[1] > b[1]
    return a[0] < b[0]


for i in range(N):
    for j in range(i+1, N):
        if not less([S[i], P[i], I[i]], [S[j], P[j], I[j]]):
            S[i], S[j] = S[j], S[i]
            P[i], P[j] = P[j], P[i]
            I[i], I[j] = I[j], I[i]

for i in range(N):
    print(I[i])

Submission status: Accepted

Solution code:
N=int(input())
List=[input().split(" ") for _ in range(N)]
#識別用indexの添付
List2=[]
List_sub=[]
for i in range(N):
    List_sub=[i+1,List[i][0],int(List[i][1])]
    List2.append(List_sub)
#独立する地名をピックアップ
set_List=[]
for i in range(len(List)):
    set_List.append(List2[i][1])
#地名を名前の順に変える
set_List=list(set(set_List))
set_List.sort()
#名前順の地名ごとに数字の大きい順にピックアップ
Ans_List=[]
const_const_List=[]
const_List=[]
for i in range(len(set_List)):
    const_List=[]
    for j in range(N):
        if set_List[i]==List2[j][1]:
            const_const_List=[List2[j][2],List2[j][0]]
            const_List.append(const_const_List)
    const_List.sort(reverse=True)
    Ans_List.extend(const_List)
#最後に並んだ順にindexを出力

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
data = [input().split()+[i+1] for i in range(n)]
data.sort(key = lambda tup: (tup[0],-int(tup[1])))
for city , k,number in data:
  print(number)

Submission status: Accepted

Solution code:
def main():
    from collections import defaultdict

    book = defaultdict(list)
    N = int(input())
    for ind in range(1, N + 1):
        s, p = input().split()
        book[s].append((int(p), ind))

    for s in sorted(book.keys()):
        book[s].sort(key=lambda x: x[0], reverse=True)
        for _, ind in book[s]:
            print(ind)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
rest = list()
preres = list()
for i in range(N):
    preres = list(map(str,input().split()))
    preres.append(i+1)
    preres[1] = int(preres[1])
    rest.append(preres)
    #  rest.append(preres.append(str(i+1)))
    # rest[i][1] = int(rest[i][1])
    # print(preres)
sort_rest =  sorted(rest, key=lambda x:(x[0], -x[1]))
for i in range(N):
    print(sort_rest[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])
  
l=sorted(SP,key = lambda SP : (SP[0],-SP[1]))
 
for i in l:
  print(i[2])

Submission status: Accepted

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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()
    sp = [readstrs() for _ in range(N)]
    S = list(map(lambda x: x[0], sp))
    t = {x: [] for x in S}
    for v in sp:
        t[v[0]].append(v[1])

    for k in t.keys():
        t[k] = sorted(list(map(int, t[k])), reverse=True)

    for k, v in sorted(t.items()):
        for vv in v:
            print(sp.index([k, str(vv)]) + 1)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
D={}

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

name=sorted(D)
#print(name,D)
for n in name:
    d=sorted(D[n], reverse=True)
    for t in d:
        p,n=t
        print(n)

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for i in range(n):
    a,b = input().split()
    if a in d:
        d[a].append([int(b),i+1])
    else:
        d.setdefault(a,[[int(b),i+1]])
for k in sorted(d.keys()):
    d[k].sort(reverse=True)
    for i in d[k]:
        print(i[1])

Submission status: Accepted

Solution code:
import sys

# import math
# import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
# INF = sys.maxsize
# MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


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

    tmp = sorted(d, key=lambda x: x[1], reverse=True)
    tmp1 = sorted(tmp, key=lambda x: x[0])

    for t in tmp1:
        print(t[2])


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

a = []
for s,p in sp:
  a.append([s, 100-int(p)])
A = sorted(a)
for i in range(n):
  print(a.index(A[i])+1)

Submission status: Accepted

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



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

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

Submission status: Accepted

Solution code:
N = int(input())
a = {}
b = set()

for i in range(N):
    S, P = input().split()

    if not S in a:
        a[S] = []

    a[S].append((int(P), i+1))
    b.add(S)
b = list(b)
b.sort()

for v in a.values(): v.sort(reverse=True)

for s in b:
    for _, i in a[s]:
        print(i)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    SP = []
    for i in range(n):
        s, p = map(str, input().split())
        SP.append([i + 1, s, int(p)])
    SP = sorted(SP, key=lambda x: x[2], reverse=True)
    SP = sorted(SP, key=lambda x: x[1])

    for idx, _,_ in SP:
        print(idx)


if __name__ == '__main__':
    resolve()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    group = {}
    city = []
    for i in range(n):
        s, p = input().split()
        if s not in city:
            city.append(s)
        if s in group:
            group[s].append([int(p), i + 1])
        else:
            group[s] = [[int(p), i + 1]]
    city.sort()
    for c in city:
        group[c].sort(key=lambda x: x[0], reverse=True)
        for _, n in group[c]:
            print(n)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())
s = [list(map(str, input().split())) for _ in range(n)]
t = sorted(s, key=lambda s:(s[0], -int(s[1])))
for i in range(n):
    for j in range(n):
        if t[i] == s[j]:
            print(j+1)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    l=[]
    n=int(input())
    for i in range(n):
        s,p=input().split()
        l1=[s,-int(p),i+1]
        l.append(l1)
    from operator import itemgetter
    l2=sorted(l,key=itemgetter(0,1))
    for s,p,i in l2:
        print(i)
resolve()

Submission status: Accepted

Solution code:

class restaurant:
    def __init__(self, name, point, num):
        self.name = name
        self.point = point
        self.num = num
    def __repr__(self):
        return "%d" % (self.num)



def main():
    N  = int(input())
    restaurants = []
    for i in range(N):
        S = input().split()   
        restaurants.append(restaurant(str(S[0]),int(S[1]),i+1))

    restaurants = sorted(restaurants, key=lambda x: x.point , reverse=True)
    restaurants = sorted(restaurants, key=lambda x: x.name)

    
    for i in range(N):
        print(restaurants[i])



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    l=[]
    n=int(input())
    for i in range(n):
        s,p=input().split()
        ll=[s,int(p),i+1]
        l.append(ll)
    lll = sorted(l, key=lambda x:x[1], reverse=True)
    llll=sorted(lll,key=lambda x:x[0])
    for s,p,i in llll:
        print(i)
resolve()

Submission status: Accepted

Solution code:
N = int(input())
l=list()#empty list
 
for i in range(1,N+1):
    tempS,tempP = input().split()
    l.append([tempS,-int(tempP),i])
 
sortedList = sorted(l,key=lambda item:(item[0],item[1]))
 
for i in range(1,N+1):
    print(sortedList[i-1][2])

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

Submission status: Accepted

Solution code:
N = int(input())
l=list()#empty list

for i in range(1,N+1):
    tempS,tempP = input().split()
    l.append([tempS,-int(tempP),i])

sortedList = sorted(l,key=lambda item:(item[0],item[1]))

for i in range(1,N+1):
    print(sortedList[i-1][2])

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,n+1):
  name,score =input().split()
  a.append([name,-int(score),i])
  
a.sort()
for n,s,idx in a:
  print(idx)

Submission status: Accepted

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

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

rest.sort()
for re in rest:
    print(re[2])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
s = [input().split() for i in range(n)]
print(*[i + 1 for i, _ in sorted(enumerate(s), key = lambda x: (x[1][0], -int(x[1][1])))], sep="\n")

Submission status: Accepted

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

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

SP.sort()

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

Submission status: Accepted

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

ans_list = list(i for i in range(1, n + 1))
for i in range(n):
  index = i
  for j in range(i, n):
    if s[index] > s[j] or (s[index] == s[j] and p[index] < p[j]):
      index = j
  s[i], s[index] = s[index], s[i]
  p[i], p[index] = p[index], p[i]
  ans_list[i], ans_list[index] = ans_list[index], ans_list[i]

for i in ans_list:
  print(i)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())
a = [list(input().split()) for nesya in range(n)]
s = 1

for hoge in a:
  hoge[1] = int(hoge[1])*(-1)
  hoge.append(s)
  s += 1
a.sort()
for raw in a:
  print(raw[2])

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

Submission status: Accepted

Solution code:
n = int(input())
S, P = [], []
Sdic = {}
line = [list(input().split()) for _ in range(n)]
for i in range(n):
    S.append(line[i][0])
    P.append(int(line[i][1]))
    if line[i][0] not in Sdic:
        Sdic[line[i][0]] = 1
Sdic2 = sorted(Sdic.items())
Sa = []
for i in range(len(Sdic2)):
    Sa.append(Sdic2[i][0])
for s in Sa:
    data = []
    for j in range(n):
        if S[j] == s:
            data.append(j)
    Pd = [[k, P[k]] for k in data]
    Pd = sorted(Pd, reverse=True, key=lambda x: x[1])
    for j in range(len(Pd)):
        print(Pd[j][0] + 1)

Submission status: Accepted

Solution code:
N=int(input())

Restaurants =[]

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

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

for j in Restaurants:
    print(j[0])

Submission status: Accepted

Solution code:
n = int(input())
# A = [0] * n
# B = [0] * n
# for i in range(n):
#     A[i], B[i] = input().split()
# A = list(map(str, A))
# B = list(map(int, B))
sp = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    sptemp = [s, -p, i]
    sp.append(sptemp)
spsorted = sorted(sp)

for temp in spsorted:
    print(temp[2] + 1)

# As = sorted(A)
# Bs = sorted(B)[::-1]
# print(As)
# print(Bs)
# print()

# L = [i for i in range(n)]
# AL = [i for i in range(n)]
# BL = [i for i in range(n)]

# for i in range(n):
#     AL[i] = L[A.index(As[i])] + 1
#     # A.remove(str([A.index(As[i])]))
# print(AL)
# # print(Bs)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
from operator import itemgetter

def main():
    N = int(readline())
    SP = []
    for i in range(N):
        s, p = readline().rstrip().split()
        SP.append((s, int(p), i+1))
    SP.sort(key=itemgetter(1), reverse=True)
    SP.sort(key=itemgetter(0))
    for i in range(N):
        print(SP[i][2])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
from operator import itemgetter

def main():
    N = int(readline())
    SP = [readline().rstrip().split() for _ in range(N)]
    SP = [(s, -int(p), i+1) for i, (s, p) in enumerate(SP)]
    SP = sorted(SP, key=itemgetter(0, 1))
    for i in range(N):
        print(SP[i][2])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from heapq import heappush, heappop


n = int(input())
ans = []
for i in range(1, n + 1):
    s, p = input().split()
    p = int(p)
    heappush(ans, (s, -p, i))
while ans:
    print(heappop(ans)[2])

Submission status: Accepted

Solution code:
N = int(input())

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
n_list = [0]*n
for i in range(n):
    n_list[i] = input().split()
    n_list[i].append(i+1)
for i in range(n):
    n_list[i][1] = int(n_list[i][1])
n_list.sort()
n_list.append("dum")
#print(n_list)
L = 0
for i in range(n):
    if n_list[i][0] != n_list[i+1][0]:
        for j in range(i,L-1,-1):
            print(n_list[j][2])
        L = i+1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

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

Submission status: Accepted

Solution code:
n=int(input())
keep=[]
re_ans=[]

for i in range(n):
    s=input().split()
    keep.append(s)

for J in range(n):
    j=keep[J]
    ans=1
    for k in (keep):
        if j[0]>k[0]:
            ans+=1
        elif j[0]==k[0] and int(j[1])<int(k[1]):
            ans+=1
    re_ans.append(ans)
for i in range(n):
    print(re_ans.index(i+1)+1)

Submission status: Accepted

Solution code:
n=int(input())
sp=[0]*n
for i in range(n):
	s,p=input().split()
	p=str(100-int(p))
	if len(p)==1:
		p="0"+p
	elif len(p)==3:
		p="999"+p
	sp[i]=[s+p,i+1]
sp.sort()
for i in range(n):
	print(sp[i][1])

Submission status: Accepted

Solution code:
n=int(input())
l=sorted([(s,-int(p),i+1) for i,(s,p) in enumerate([tuple(input().split()) for _ in range(n)])])
a,s,d=zip(*l)
print(*d,sep="\n")

Submission status: Accepted

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


for i in range(n):
    y = data[i]
    result = temp.index(y)
    print(result+1)

Submission status: Accepted

Solution code:
N = int(input())
W = [list(input().split()) for _ in range(N)]
S = sorted(W)
for i in range(N):
  for j in range(i+1, N):
    if S[i][0] == S[j][0] and int(S[i][1]) < int(S[j][1]):
      a = S[i]
      S[i] = S[j]
      S[j] = a
for k in range(N):
  print(W.index(S[k])+1)

Submission status: Accepted

Solution code:
n=int(input())
lis=[]
for i in range(0,n):
  p,q=map(str,input().split())
  lis.append([p,int(q),i+1])
for j in range(0,n):
  for k in range(0,n-1):
    if lis[n-k-1][0]<lis[n-k-2][0]:
      t=lis[n-k-2]
      lis[n-k-2]=lis[n-k-1]
      lis[n-k-1]=t
    elif lis[n-k-1][0]==lis[n-k-2][0]:
      if lis[n-k-1][1]>=lis[n-k-2][1]:
        t=lis[n-k-2]
        lis[n-k-2]=lis[n-k-1]
        lis[n-k-1]=t
      
for i in range(n):
  print(lis[i][2])

Submission status: Accepted

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

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

Submission status: Accepted

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

# 数字でソート
l = sorted(l, key=lambda x: (x[1]), reverse=True)
# 文字でソート
l = sorted(l, key=lambda x: (x[0]))
for k in l:
    print(k[-1])

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
MOD = 1000000007

N = int(input())

x = {}
c  = {}

res = []

i = 0
for j in range(1,N+1):
    s,p =input().split()
    p = int(p)
    if s not in x:
        x[s]   = i
        i+=1
        res.append([])

    res[x[s]].append(p)
    c[p] = j


for j in range(i):
    res[j].sort()

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

for  key,value in dict2: #key : city name , value: city number
#    print(key,value)
    #print(res[value])
    for j in res[value][::-1]:
        print(c[j])

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.sort(key=lambda x: x[1], reverse=True)
sp.sort(key=lambda x: x[0])

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

Submission status: Accepted

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

from copy import copy, deepcopy

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

cities=[]
for s in sp:
    cities.append(s[0])
cities=list(set(cities))
cities.sort()

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

for c in cities:
    for i in range(n):
        if sp[i][0]==c:
            print(sp_.index(sp[i])+1)

Submission status: Accepted

Solution code:
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
n = int(input())
res = {}
ans = []
for _ in range(n):
    s, p = input().split()
    ans.append(int(p))
    if s in res:
        res[s].append(int(p))
    else:
        res[s] = [int(p)]
stdRes = sorted(res.keys())
for x in stdRes:
    for m in sorted(res[x], reverse=True):
        print(ans.index(m) + 1)

Submission status: Accepted

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

for i in range(n):
    x, y = input().split()
    l[i][0] = x
    l[i][1] = int(y)*-1
    l[i][2] = i + 1

l.sort()

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

Submission status: Accepted

Solution code:

n=int(input())
d=[]
for i in range(n):
    s,p=input().split()
    p=int(p)
    d.append((s,-p,i+1)) # タプルをリストへappend
d=sorted(d) #sortedにより、アルファベット順、数値順（-をつけて大きい値が先に来るようにしている）に整形
for i in range(n):
    print(d[i][2]) # d[i]でタプルの順番を指定し、その中の3番目の要素（インデックス）を出力

Submission status: Accepted

Solution code:
n = int(input())

a = []

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

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