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())
base_li = [0]*n

for i in range(n):
    l, p = input().split()
    base_li[i] = [i+1, (l, -int(p))]

sl = sorted(base_li, key=lambda w: w[1])
for c in sl:
    print(c[0])

Submission status: Accepted

Solution code:
N=int(input())
data=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)
#print(data_name_sort)
data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*200+int(data[i][1])
        else:
            continue
    data_point.append(num)
#print(data_point)
data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]
#print(data_sort)
for i in range(N):
    ans=int(data_sort[i])+1
    print(ans)

Submission status: Accepted

Solution code:
N=int(input())
l=[]
for i in range(N):
    S,P=map(str,input().split())
    b=' '
    if len(S)<10:
        S=S+b*(10-len(S))
    P=(100-int(P))
    l.append([S+str(P).zfill(3),i])
l.sort()

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

D.sort(key=lambda x:x[0])
#print(D[0])
#print(D[1])
T_ = [D[0]]
flg = True
A = []
for i in range(N-1):
    #print(T_)
    if D[i][0] == D[i+1][0]:
        T_.append(D[i+1])
    else:
        T_.sort(key=lambda x:x[1], reverse=True)
        A = A + T_
        T_ = [D[i+1]]
        flg = False
        #print('hoge')

if len(T_) > 0:
    T_.sort(key=lambda x:x[1], reverse=True)
    A = A + T_
#print(A)
for l in A:
    print(l[2])

Submission status: Accepted

Solution code:
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N = int(input())
L = []
for i in range(N):
    c, p = input().split()
    p = int(p)
    L.append([i+1, c, 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:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    r = []
    for i in range(n):
        s, x = [x for x in input().split()]
        r.append((s, - int(x), i + 1))
    r.sort()
    for e in r:
        print(e[2])

    



t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

"""

Submission status: Accepted

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

for i in range(N):
  a, b = input().split()
  L.append((a, int(b), i))
  
L.sort(key = lambda x: (x[0], -x[1]) )

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

Submission status: Accepted

Solution code:
n = int(input())
l = [list(input().split()) for i in range(n)]
s,p = [list(i) for i in zip(*l)]
p = [int(i) for i in p]
z = list(set(s))
z.sort()
m = list(p)
m.sort(reverse = True)
l = []
 
k = 0
for i in range(len(z)):
    l.append(k)
    k += 200
 
o = []
for i in range(n):
    w = l[z.index(s[i])]
    w += m.index(p[i])
    o.append(w)
 
r = list(o)
r.sort()
for i in range(n):
    print(o.index(r[i]) + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

q = int(input())

r = set([])

g = {}

n = {}

for i in range(q):
    s,p = input().split()
    if s not in r:
        r.add(s)
        g[s] = [int(p)]
        n[int(p)] = i+1
    else:
        g[s].append(int(p))
        n[int(p)] = i+1
        
r = list(r)

r.sort()

for i in r:
    x = g[i]
    x.sort(reverse = True)
    for t in x:
        print(n[t])

Submission status: Accepted

Solution code:
n=int(input())

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

#print(l)
l.sort()
#print(l)

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

Submission status: Accepted

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

def main():
    n = int(input())
    res = dict()
    for i in range(n):
        s, n = input().split()
        if s in res:
            res[s].update({int(n): i+1})
        else:
            res[s] = {int(n): i+1}
    for i in sorted(res):
        for j in sorted(res[i].keys(), reverse=True):
            print(res[i][j])
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
L = [0] * N
for i in range(N):
  s, p = map(str, input().split())
  p = -1 * int(p)
  L[i] = [s, p, i + 1]
L = sorted(L)
#print(L)
for i in range(N):
  print(L[i][2])

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
li = []
for i in range(n):
    s,t = input().split()
    li.append([s,int(t),i+1])
li = sorted(li,key = lambda x:x[1], reverse = True)
li = sorted(li,key = lambda x:x[0])
for i in range(n):
    print(li[i][2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for i in range(1,n+1):
    s, p = input().split()
    if s in d.keys():
        d[s][i] = int(p)
    else:
        d[s] = {i:int(p)}
for k, v in sorted(d.items()):
    for kk, vv in sorted(v.items(), key=lambda x: -x[1]):
        print(kk)

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])
sort_sp = sorted(sp,key=lambda x:(x[0], x[1]))

for i in sort_sp:
    print(sp.index(i)+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7


N = int(readline())
SP = [list(readline().split()) + [i+1] for i in range(N)]
for i in range(N):
    SP[i][1] = int(SP[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:
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[input().rstrip().split(" ") for i in range(n)]
for i in range(n):
    lis[i][1]=int(lis[i][1])
nl=[]
for i in range(n):
    nl.append([lis[i][0],lis[i][1],i])
nl.sort(key=lambda x:(x[0],-x[1]))
#print(nl)
for i in range(n):
    print(nl[i][2]+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
d = []
for i in range(N):
    s, p = ins().split()
    p = int(p)
    d.append((s, -p, i + 1))
d.sort()


def solve():
    for _, _, i in d:
        print(i)


solve()

Submission status: Accepted

Solution code:
N = int(input())
data = []
ans = []
for i in range(1, N+1):
  city, score = input().split()
  score = int(score)
  data.append([city, score, i])
city_list = [x[0] for x in data]
score_list = [x[1] for x in data]
num_list = [x[2] for x in data]
city_unique = sorted(set(city_list))

for city_u in city_unique:
  city_index = [i for i, x in enumerate(city_list) if x == city_u]
  for score in sorted([score_list[x] for x in city_index], reverse=True):
    print(num_list[score_list.index(score)])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

s = [list(map(str, input().split())) for _ in range(n)]
for row in s:
    row[1] = int(row[1])
ss = sorted(s)
ins = 0
ans = list()
tmp = 0
for i in ss:
    if i[0] == tmp:
        ans.insert(ins,i)
    else:
        ins = len(ans)
        ans.append(i)
        tmp = i[0]
for j in ans:
    print(s.index(j)+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
S=[list(map(str,input().split())) for _ in range(N)]
for row in S:
    row[1]=int(row[1])
SS=sorted(S)
ins=0
ans=list()
tmp=0
for i in SS:
    if i[0]==tmp:
        ans.insert(ins,i)
    else:
        ins=len(ans)
        ans.append(i)
        tmp=i[0]
for j in ans:
    print(S.index(j)+1)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(1,len(s)+1), key=lambda k: s[k-1])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    l=[]
    for _ in range(N):
        s,n=input().split()
        n=int(n)
        l.append((s,-n))
    li=argsort(l)
    printl(li)






if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
i = int(input())
score = [input().split() for s in range(i)]
s_list = sorted(score)

for i in range(len(s_list)):
  for j in reversed(range(i+1, len(s_list))):
    if s_list[j-1][0] == s_list[j][0] and int(s_list[j-1][1]) < int(s_list[j][1]):
      s_list[j-1], s_list[j] = s_list[j], s_list[j-1]

for s in s_list:
  for index,sc in enumerate(score):
    if s == sc:
      print(index+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),i+1])
sp.sort(key=lambda x:x[1],reverse=True)
sp.sort(key=lambda x:x[0])
for e in sp:
    print(e[2])

Submission status: Accepted

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

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

for i in range(n):
  print(sp1.index(sp2[i])+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
List = [[]]*N
for T in range(0,N):
    Str,Num = input().split()
    List[T] = [Str,int(Num),T+1]
SorL = sorted(List, key=lambda x:(x[0],-x[1]))
SorI = list(str(x[2]) for x in SorL)
print('\n'.join(SorI))

Submission status: Accepted

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

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

X.sort()
for (_,_,c) in X:
    print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
from decimal import Decimal
from operator import mul

INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 組合せnCr
def combinations_count(n, r):
    if n < r:
        return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

# ここから書き始める
n = int(input())
s = [0 for i in range(n)]
p = [0 for i in range(n)]
x = [[] for i in range(n)]
for i in range(n):
    s[i], p[i] = input().split()
    p[i] = int(p[i])
    x[i] = [i + 1, s[i], p[i]]
x.sort(key=lambda t:(t[1], -t[2]))
for i in x:
    print(i[0])

Submission status: Accepted

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

Submission status: Accepted

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

for n in range(N):
  s,p = input().split()
  R.append((s,-int(p),n+1))
  
for s,p,n in sorted(R):
  print(n)

Submission status: Accepted

Solution code:
N  = int(input())
rs = [ [ *input().split(), n ] for n in range(N) ]

rs = sorted(
    [ (f'{s}{100 - int(p):03}', i + 1) for s, p, i in rs ],
    key=lambda t: t[0],
)

for r in rs:
    print(r[1])

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
R=list()
n=0
s=list()
p=list()
N=int(input())
for i in range(N):
  S,P=input().split()
  P=int(P)
  s.append([S,100-P,i+1])
  p.append(P)
  n=S
s=sorted(s)
for i in range(N):
  print(s[i][2])

Submission status: Accepted

Solution code:
N = int(input())
T = [input().split() for _ in range(N)]
T = [(i, t[0], int(t[1])) for i, t in enumerate(T, 1)]

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

Submission status: Accepted

Solution code:
N = int(input())
city={}
city_name=[]
for n in range(N):
    S = input().split()
    city[n+1]=S
    city_name.append(S[0])

city_name=list(set(city_name))
city_name.sort()

for c_name in city_name:
    city_temp = {}
    for c_key in city.keys():
        if city[c_key][0] == c_name:
            city_temp[int(city[c_key][1])]=c_key
            
    p_temp = list(city_temp.keys())
    p_temp.sort(reverse=True)
    for v in p_temp:
        print(city_temp[v])

Submission status: Accepted

Solution code:
from operator import itemgetter
n = int(input())
dic = {}
for i in range(1, n + 1):
  s, p = input().split()
  p = int(p)
  dic.setdefault(s, [])
  dic[s].append((i, p))
cities = sorted(list(dic.keys()))
for c in cities:
  dic[c].sort(key=itemgetter(1), reverse=True)
  for i in dic[c]:
    print(i[0])

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    inlis = []
    namelis = []
    for i in range(n):
        a, b = map(str, input().split())
        b = int(b)
        inlis.append([a,b])
        namelis.append(a)
    namelis.sort()    
    inlis_so = sorted(inlis)
    anslis = []
    for num in inlis:
        #print(num, num[0], inlis_so, inlis_so.count(num[0]))
        kazu = namelis.count(num[0])
        if kazu == 1:
            anslis.append(inlis_so.index(num)+1)
        else:
            kijun = namelis.index(num[0]) + 1
            kouho = list(filter(lambda word:True if word[0] == num[0] else False,inlis))
            kouho_so = sorted(kouho, key = lambda x:x[1], reverse = True)
            suujibun = kouho_so.index(num)
            anslis.append(kijun + suujibun)
    for i in range(1, n+1):
        #print(anslis)
        print(anslis.index(i)+1)

    

        
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

n = int(input())

r = []

for i in range(n):
    city, score = input().split()
    score = int (score)
    r.append((i+1, city, score))

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

for i in range(n):
    print(r[i][0])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
e = sorted([[str(i + 1)] + input().split() for i in range(n)],
           key=lambda x: int(x[2]),
           reverse=True)
d = dict()
for i in e:
    if i[1] not in d:
        d[i[1]] = []
    d[i[1]].append(i[0])
e = sorted(d.items(), key=lambda x: x[0])
for i in e:
    print(*i[1], sep="\n")

Submission status: Accepted

Solution code:
n = int(input())

r = []

for i in range(n):
    city, score = input().split()
    score = int (score)
    r.append((i+1, city, score))

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

for i in range(n):
    print(r[i][0])

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

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

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

for i in new_lis:
    print(lis.index(i) + 1)

Submission status: Accepted

Solution code:
N = int(input())

restaurants = {}
for i in range(1, N+1):
    s, p = input().split()
    restaurants[i] = (s, int(p) * -1)

key = lambda x: (x[1][0], x[1][1])
restaurants_sorted = sorted(restaurants.items(), key=key)

for k in restaurants_sorted:
    print(k[0])

Submission status: Accepted

Solution code:
N = int(input())

restaurants = {}
for i in range(1, N+1):
    s, p = input().split()
    restaurants[i] = (s, int(p))

key = lambda x: x[1]
restaurants_sorted = sorted(restaurants.items(), key=key)

city_restraurant = []
city = ""
for restaurant in restaurants_sorted:
    if not city:
        city = restaurant[1][0]
        city_restraurant.append((restaurant[0], restaurant[1][1]))
    elif city == restaurant[1][0]:
        city_restraurant.append((restaurant[0], restaurant[1][1]))
    else:
        city_restraurant.sort(key=lambda x: x[1], reverse=True)
        for c in city_restraurant:
            print(c[0])
        city_restraurant = [(restaurant[0], restaurant[1][1])]
        city = restaurant[1][0]
city_restraurant.sort(key=lambda x: x[1], reverse=True)
for c in city_restraurant:
    print(c[0])

Submission status: Accepted

Solution code:
n=int(input())
cnt=1
List=[]
for i in range(n):
    s,p=input().split()
    p=int(p)
    List.append([s,p,cnt])
    cnt+=1
List.sort()
for i in range(len(List)):
    for j in range(i+1,len(List)):
        if List[i][0]==List[j][0] and List[j][1]>=List[i][1]:
            List[i],List[j]=List[j],List[i]
for i in range(len(List)):
    print(List[i][2])

Submission status: Accepted

Solution code:
a=int(input())

n=[]
for _ in range(a):
    o,q=map(str,input().split())
    n.append([o,int(q)])

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

for i in m:
    print(n.index(i)+1)

Submission status: Accepted

Solution code:
from operator import itemgetter

n = int(input())
a = []
for i in range(n):
    s, p = input().split()
    a.append((i + 1, s, -int(p)))
a.sort(key=itemgetter(1, 2))
for i, _, _ in a:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
sp = [0] * n
for i in range(n):
    sp[i] = list(map(str,input().split()))
sp_sorted = sorted(sp, key=lambda x: int(x[1]), reverse=True)
sp_sorted_sorted = sorted(sp_sorted, key=lambda x: x[0])
for i in range(n):
    for j in range(n):
        if sp_sorted_sorted[i] == sp[j]:
            print(j+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 S: (S[0],-S[1]))
for i in range(N):
    print(S[i][2])

Submission status: Accepted

Solution code:
n = int(input())
city = []
nums = []
result = []
 
for i in range(n):
  s,p = input().split()
  p = int(p)
  city.append(s)
  nums.append(p)
  result.append([s,p,i+1])
 
for i in sorted(set(city)):
  for j in sorted(set(nums), reverse = True):
    for k in result:
      if k[0] == i and k[1] == j:
        print(k[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])