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())
sp_list=[]
for i in range(n):
	s,p=map(str,input().split())
	sp_list.append({'key': i+1,'city':s,'point':int(p)})
sp_list=sorted(sp_list,key = lambda x: (x['city'], -x['point']))
for i in sp_list:
	print(i['key'])

Submission status: Accepted

Solution code:
N = int(input())


shop_dict = {}
for i in range(1,N+1):
    input_li = input().split()
    s = input_li[0]
    p = int(input_li[1])
    if s not in shop_dict.keys():
        shop_dict[s] = {}
    shop_dict[s][p] = i

all_city = list(shop_dict.keys())
all_city.sort()

for city in all_city:
    pt_list = list(shop_dict[city].keys())
    pt_list.sort(reverse=True)
    for pt in pt_list:
        print(shop_dict[city][pt])

Submission status: Accepted

Solution code:
N = int(input())
s = []
SP = {}
for i in range(N):
    S, P = input().split()
    P = int(P)
    if S not in SP:
        SP[S] = [[P, i+1]]
    else:
        SP[S].append([P, i+1])
    if S not in s:
        s.append(S)
s.sort()

for s_ in s:
    tmp = SP[s_]
    tmp.sort(reverse=True)
    for x in tmp:
        print(x[1])

Submission status: Accepted

Solution code:
from operator import itemgetter
n=int(input())
data=[]
for i in range(n):
    a = list(input().split())
    a[1] = int(a[1])
    a.append(i+1)
    data.append(a)
data = sorted(data, key=itemgetter(1), reverse=True)
data = sorted(data, key=itemgetter(0), reverse=False)
for i in data:
    print(i[2])

Submission status: Accepted

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

sorted_bag = sorted(bag, key=lambda x:x[0])
sorted_shi = sorted(list(set(shi)))


dic = {}
for s, p, i in bag:
    if s not in dic.keys():
        dic[s] = [[p, i+1]]
    else:
        dic[s].append([p, i+1])

for s in sorted_shi:
    if len(dic[s]) == 1:
        print(dic[s][0][1])
    else:
        so = sorted(dic[s], key=lambda x:x[0])[-1::-1]
        for e in so:
            print(e[1])

Submission status: Accepted

Solution code:
l = raw_input().split()
N = int(l[0])

S = []
P = []

for i in range(N):
    l = raw_input().split()
    S.append(l[0])
    P.append(int(l[1]))

S1 = []
for i in range(N):
    S1.append([i + 1, S[i], P[i]])
#print(N, S, P, S1)

S1.sort(key = lambda x: -x[2])
S1.sort(key = lambda x: x[1])
#print(S1)
for s in S1:
    print(s[0])

Submission status: Accepted

Solution code:
import math
import fractions
import copy
#以下てんぷら
def j(q):
    if q==1: print("YES")
    elif q == 0:print("NO")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


n = ip()                                     #入力整数1つ
#m,n= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
a =[]
for i in range(n):
    a.append(input().split())
    a[i][1] = 100-int(a[i][1])
b = copy.copy(a)
a.sort()
for i in range(n):
    print(b.index(a[i])+1)

Submission status: Accepted

Solution code:
n = int(input())
rest = []
for i in range(n):
  name,point = input().split()
  rest.append((name,-int(point),i))

rest.sort()
for i in range(n):
  print(rest[i][2]+1)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
n=int(input())
List=[]
for i in range(n):
    s,p=input().split()
    p=int(p)
    List.append([s,p,i+1])
List.sort()
S=List[0][0]
k=[]
for i in List:
    if i[0]==S:
        k.append([i[1],i[2]])
    else:
        k.sort(reverse=True)
        for j in k:
            print(j[1])
        S=i[0]
        k=[]
        k.append([i[1],i[2]])
k.sort(reverse=True)
for j in k:
    print(j[1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(raw_input())
r = []
for i in xrange(1,n+1):
	rest,score = raw_input().split()
	score=int(score)
	r.append((rest,score,i))
r = sorted(r,key=lambda x:(x[0], -x[1], x[2]))
for x in r:
	print x[2]

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import Counter

def main():
    N = II()
    SP = []
    for i in range(1, N + 1):
        s, p = LS()
        p = int(p)
        SP.append([s + '{:06}'.format(100 - p), i])
    SP.sort()
    for _, id in SP:
        print(id)
    return

main()

Submission status: Accepted

Solution code:
#ABC128B-GuideBook.py

from sys import stdin

input = stdin.readline

N = int(input())

SP = []

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

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

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

Submission status: Accepted

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


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

Submission status: Accepted

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

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

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

Submission status: Accepted

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


def solv(ds):
    ds = sorted(ds, key=lambda d: -d[2])
    ds = sorted(ds, key=lambda d: d[1])
    return ds


if __name__ == '__main__':

    n = int(input())

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

    ans = solv(ds)

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

Submission status: Accepted

Solution code:

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

for i in range(n):
    r, p = input().strip().split()
    rs.append((r, -int(p), i+1))

rs.sort()
for r, p, s in rs:
    print(s)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = []

for i in range(n):
  s,p = nn()
  a.append([s,-int(p),i])

a = sorted(a)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N = int(input())

l = []

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

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

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

Submission status: Accepted

Solution code:
N = int(input())

stores = dict()
for n in range(N):
    S, P = input().split()
    if S not in stores:
        stores[S] = []
    stores[S].append((int(P), n+1))

sorted_stores = sorted(list(stores.keys()))

for s in sorted_stores:
    stores[s].sort(key=lambda x: x[0], reverse=True)

    for ss in stores[s]:
        print(ss[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(key=lambda x: (x[0],-x[1]))
for l in L:
    print(l[-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
name=[]
m=[]
for i in range(1,n+1):
  s,p=input().split()
  p=int(p)
  if s not in name:
    name+=[s]
  m+=[[i,s,p]]
name.sort()
for n in name:
  aa=[]
  for a in m:
    if a[1]==n:
      aa+=[a]
  aa.sort(reverse=1,key=lambda x:x[2])
  for a in aa:
    print(a[0])

Submission status: Accepted

Solution code:
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N = int(stdin.readline().rstrip())
SP = [stdin.readline().rstrip().split() for _ in range(N)]
for i in range(N):
    SP[i].append(i+1)
    SP[i][1] = int(SP[i][1]) * -1

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

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

mem.sort()

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

Submission status: Accepted

Solution code:
n = int(input())

result = []
for i in range(n):
    tmp1,tmp2 = input().split(" ") 
    result.append((tmp1, int(tmp2),i+1))

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

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

Submission status: Accepted

Solution code:
N = int(input())
SP = sorted([[_ for _ in input().split()] + [i] for i in range(N)],
            key=lambda xs: xs[0] + 'Z' * (100 - int(xs[1])))
[print(_[2] + 1) for _ in SP]

Submission status: Accepted

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

i  = lambda: int(input())
ms = lambda: map(str, input().split())

N = i()

rank = dict()
for i in range(N):
  S, P = ms()
  if S in rank.keys():
    rank[S][i+1] = int(P)
  else:
    rank[S] = {i+1: int(P)}

for k, v in sorted(rank.items()):
  for vk, vv in sorted(rank[k].items(), key=lambda x:x[1], reverse=True):
    print(vk)

Submission status: Accepted

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

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

r = [(k,v) for k, v in ls.items()]
r.sort(key=(lambda x: x[0]))

for l in r:
    vals = l[1]
    vals.sort(key=(lambda x: x[1]), reverse=True)
    for v in vals:
        print(v[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])
sp.sort()

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

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(list)

el = int(input())

for ei in range(1,el+1):
    s,p = input().split()
    p = int(p)
    d[s] = d[s] + [(p,ei)]

d = list(d.items())
d.sort(key=lambda spei: spei[0])
for spei in d:
    peis = spei[1]
    peis.sort(key=lambda pei: -pei[0])
    for pei in peis:
        print(pei[1])

Submission status: Accepted

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

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

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

Submission status: Accepted

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

from operator import itemgetter
shops = sorted(shops, key=itemgetter(2), reverse=True)
shops = sorted(shops, key=itemgetter(1))

for num, s, p in shops:
    print(num)

Submission status: Accepted

Solution code:
def getlist():
	return list(map(int, input().split()))

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

for i in range(N):
	A = list(input().split())
	S = A[0]
	P = int(A[1])
	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())

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

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


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

Submission status: Accepted

Solution code:
from collections import defaultdict
N=int(input())
SP=defaultdict(list)
S=set()
for i in range(N):
    s,p=input().split()
    p=int(p)
    SP[s].append([p,i+1])
    S.add(s)
S=list(S)
S.sort()
for i in S:
    l=SP[i]
    l.sort(reverse=True)
    for k in l:
        print(k[1])

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

Submission status: Accepted

Solution code:
# coding: utf-8

N = int(input())
S_P = [input().split() for _ in range(N)]
S_P = [tuple([s_p[0], int(s_p[1]), i]) for i, s_p in enumerate(S_P)]

S_P = sorted(S_P, key=lambda x: x[1])[::-1]
S_P = sorted(S_P, key=lambda x: x[0])
print("\n".join([str(x[2] + 1) for x in S_P]))

Submission status: Accepted

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

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))
SP.sort(key = lambda k:k[1], reverse = True)
SP.sort(key = lambda k:k[0])
for j in SP:
    print(j[2] + 1)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


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


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N = I()
    #city = []
    city = set()
    sp = []
    for i in range(N):
        i += 1
        s, p = input().split()
        p = int(p)
        sp.append([s, p, i])
        city.add(s)
    city = list(city)
    city.sort()
    ans = [[] for i in range(len(city))]
    sp.sort(reverse=True, key=lambda x: x[1])
    for s, p, i in sp:
        for j, c in enumerate(city):
            if s == c:
                ans[j].append(i)

    for a in ans:
        print(*a, sep="\n")


if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
N = int(input())
X = [list(input().split()) for _ in range(N)]
for i, t in sorted(enumerate(X), key=lambda x: (x[1][0], -int(x[1][1]))):
  print(i + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
SP = [list(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(key=lambda x:(x[0],-x[1]))

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

Submission status: Accepted

Solution code:
N = int(input())
restaurant = []
for i in range(N):
    Sn, Pn = input().split()
    Pn = int(Pn)
    restaurant.append([i, Sn, -1 * Pn])

for r in sorted(restaurant, key=lambda x: (x[1], x[2])):
    print(r[0] + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())
d = defaultdict(list)
for i in range(1, n + 1):
    city, point = input().split()
    p = int(point)
    d[city].append((p, i))

for city in sorted(d):
    l = d[city]
    l.sort(reverse=True)
    for p, i in l:
        print(i)

Submission status: Accepted

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


def solve(N: int, S: "List[str]", P: "List[int]"):
    merged_list = [[i+1,s,p] for i, (s, p) in enumerate(zip(S, P))]
    merged_list = sorted(merged_list, key = lambda x:(x[1], -x[2]))
    for i in range(N):
        print(merged_list[i][0])
    return


# Generated by 1.1.4 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())
res = dict()
for i in range(N):
    S, P = input().split()
    if S in res.keys():
        res[S].append([int(P),i+1])
        res[S].sort(reverse = True)
    else:
        res[S] = [[int(P), i+1]]
dct = sorted(res.items())
for name, plist in dct:
    for i in range(len(plist)):
        print(plist[i][1])

Submission status: Accepted

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

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

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

for i in range(n):
    for j in range(n):
        if sorted_sp[i]==sp[j]:
            print(j+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
SP_list = [(str(i) + " " + input()).split() for i in range(1, N+1)]
key = lambda sp: (sp[1], int(sp[2])*(-1))
sorted_SP_list = sorted(SP_list, key=key)
for i, s, p in sorted_SP_list:
    print(i)

Submission status: Accepted

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

data=[]
for _ in range(N):

    S,P=input().split()
    data.append([_+1,S,int(P)])
    data.sort(key=lambda x:x[2])
    data.reverse()
    data.sort(key=lambda x:x[1])

for i,S,P in data:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())

r_list = [ [i,input().split()] for i in range(n)]

s_list = list(set([r[1][0] for r in r_list]))
s_list.sort()

r_map = {}
for r in r_list:
    if r[1][0] not in r_map:
        r_map[r[1][0]] = [[r[0], int(r[1][1])]]
    else:
        r_map[r[1][0]].append([r[0], int(r[1][1])])

for s in s_list:
    r_map[s].sort(key= lambda x: x[1], reverse=True)


for s in s_list:
    for r in r_map[s]:
        print(r[0]+1)

Submission status: Accepted

Solution code:
N = int(input())

data = []
for i in range(N):
  S, P = input().split()
  P = int(P)
  data.append((i+1, S, P))
  
data_sorted = sorted(data, key=lambda x: (x[1], -x[2]))

for d in data_sorted:
  print(d[0])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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([i+1,s,p])
L.sort(key=lambda x:x[2],reverse=True)
L.sort(key=lambda x:x[1])
for l in L:
  print(l[0])

Submission status: Accepted

Solution code:
n = int(input())

r = []

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

r = sorted(r, key=lambda i: i[1], reverse=True)
r = sorted(r, key=lambda i: i[0])

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

Submission status: Accepted

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

l = sorted([(i+1, s, int(p)) for i, (s, p) in enumerate(SP)], key=lambda x: (x[1], -x[2]))

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

SP=sorted(SP,key=lambda x:(x[0],(-1)*int(x[1])))
for lst in SP:
    print(lst[2])

Submission status: Accepted

Solution code:
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

n = inn()
sp = []
for i in range(n):
    s,p = input().split()
    sp.append((s,-int(p),i+1))
sp.sort()
for z in sp:
    print(z[2])

Submission status: Accepted

Solution code:
def run(N, lists):
    sorted_items = sorted(
        lists,
        key=lambda x: (x['P']),
        reverse=True
    )
    sorted_items = sorted(
        sorted_items,
        key=lambda x: (x['S']),
    )
    return sorted_items


def main():
    N = int(input())
    lists = []
    for i in range(N):
        S, P = input().split()
        P = int(P)
        lists.append({'id': i+1, 'S': S, 'P': P})
    sorted_lists = run(N, lists)
    for item in sorted_lists:
        print(item['id'])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
SP=[]
for i in range(N):
    tmp=list(input().split())
    SP.append([tmp[0], int(tmp[1]), 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:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return int(input())
from collections import defaultdict
from operator import itemgetter

n = SI()
dicts = []
for i in range(n):
    s, p = LS()
    p = int(p)
    dicts.append((i+1, s, p))
dicts = sorted(dicts, key=lambda x:(x[1],-x[2]))
for i, s, p in dicts:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
restaurants = []
for x in range(1, N + 1):
    name, point = list(input().split())
    restaurants.append([x, name, int(point)])
restaurants.sort(key=lambda x:(x[1],-x[2]))
for x in restaurants:
    print(x[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    p_dic ={}
    for i in range(N):
        input_raw = read_func().strip().split()
        [S, P] = [(input_raw[0]), int(input_raw[1])]
        if S not in p_dic:
            p_dic[S] = [(P, i + 1)]
        else:
            p_dic[S].append((P, i + 1))

    dct = sorted(p_dic.keys())

    for d in dct:
        p_dic[d].sort(reverse=True)
        for p in p_dic[d]:
            print p[1]




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
from collections import defaultdict
d = defaultdict(list)
for i in range(N):
    s,p = input().split()
    p = int(p)
    d[s].append((p, i+1))
k = list(d.keys())
k.sort()
for c in k:
    l = d[c]
    l.sort(key=lambda x:x[0], reverse= True)

    for p,i in l:
        print(i)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)

# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

def main():
	#A, P = map(int, input().split(" "))
	N = int(input())
	#S = input()

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

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

	for i in SP:
		a, b, c = i
		print(c)

	


if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

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

def readInt():
    return int(input())

def readList():
    return list(input().split())

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

def main():
    n = readInt()
    l = {}
    for i in range(n):
        s, p = readList()
        l[(s, -int(p), i+1)] = True
    l = sorted(l)
    for e in l:
        print(e[2])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
t = []
for i in range(n):
    tmp = input().split()
    t.append(tuple(tmp))
tmp = sorted(t, key=lambda x: int(x[1]),reverse = True)
res = sorted(tmp, key=lambda x: x[0])
for sp in res:
    print(t.index(sp)+1)