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())
dic1 = {} # S: i
dic2 = {} # i: P
for i in range(1, N+1):
    s, p = input().split()
    p = int(p)
    if s not in dic1.keys():
        dic1[s] = []
    dic1[s].append(i)
    dic2[i] = p

sorted_dic1 = sorted(dic1.items())

for key, i_list in sorted_dic1:
    p_list = []
    for i in i_list:
        p_list.append((dic2[i], i))
    p_list.sort(reverse=True)
    for ans_i in p_list:
        print(ans_i[1])

Submission status: Accepted

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

for i in range(n):
  s[i].insert(0, i+1)

for i in range(1, n):
  tmp = s[i][:]
  for j in range(1, i+1):
    if tmp[1] < s[i-j][1]:
      s[i-j+1], s[i-j] = s[i-j], s[i-j+1]
    elif tmp[1] == s[i-j][1]:
      if int(tmp[2]) > int(s[i-j][2]):
        s[i-j+1], s[i-j] = s[i-j], s[i-j+1]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
sp = [0] * n
for i in range(n):
    sp[i] = input().split() + [i+1]
    sp[i][1] = int(sp[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:
N=int(input())

#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[0 for j in range(3)] for i in range(N)]

for i in range(N):
    A,B=map(str,input().split())
    B=int(B)
    S[i][0]=i+1
    S[i][1]=A
    S[i][2]=B


T=sorted(S,key=lambda x:x[2],reverse=True)
U=sorted(T,key=lambda x:x[1])
for i in range(N):
    print(U[i][0])

Submission status: Accepted

Solution code:
import copy
n = int(input())

lis = []

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

nlis = copy.deepcopy(lis)
nlis = sorted(lis)

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

Submission status: Accepted

Solution code:
n=int(input())
y=[input() for i in range(n)]
x=sorted(y)

a=[list(map(str,x[i].split())) for i in range(n)]
b=[]
e=[]

while len(a):
  d=[]
  c=a[0][0]
  b.append(a[0][0])
  d.append(int(a[0][1]))
  a.pop(0)
  while len(a):
    if c==a[0][0]:
      b.append(a[0][0])
      d.append(int(a[0][1]))
      a.pop(0)
    else:
      break
  e+=sorted(d,reverse=True)

for i in range(n):
  print(y.index(b[i]+' '+str(e[i]))+1)

Submission status: Accepted

Solution code:
import math
def ip():return int(input())
def inp():return map(int,input().split())
def inpstr():return map(str,input().split())
def linp():return list(map(int,input().split()))
def linpstr():return list(map(str,input().split()))

n=ip()
city=[]
score=[]
for i in range(n):
    s,p=inpstr()
    city.append([s,-int(p),i+1])
city.sort()
for i in range(n):print(city[i][2])

Submission status: Accepted

Solution code:
import math
def ip():return int(input())
def inp():return map(int,input().split())
def inpstr():return map(str,input().split())
def linp():return list(map(int,input().split()))
def linpstr():return list(map(str,input().split()))

n=ip()
city=[]
score=[]
for i in range(n):
    s,p=inpstr()
    city.append([s,int(p),i+1])
city.sort(key=lambda e:e[0])
city.sort(key=lambda e:(e[0],-e[1]),reverse=False)
for i in range(n):print(city[i][2])

Submission status: Accepted

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

#n = 6
#sp = [['khabarovsk', '20'], ['moscow', '10'], ['kazan', '50'], ['kazan', '35'], ['moscow', '60'], ['khabarovsk', '40']]

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 sp:
  print(i)

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

Submission status: Accepted

Solution code:
n=int(input())
key=[]
value=[]
for i in range(1,n+1):
    a,b=input().split()
    b=100-int(b)
    key.append((a,b))
    value.append(i)
dic=dict(zip(key,value))

key.sort()
for j in key:
    print(dic[j])

Submission status: Accepted

Solution code:
N = int(input())
citys = []
SP = []
for i in range(0,N,1):
    S,P = input().split()
    citys.append(S)
    SP.append([S,int(P)])
citys = list(set(citys))
citys.sort()
for i in citys:
    tmp = []
    for j in range(0,N,1):
        if i == SP[j][0]:
            tmp.append([SP[j][1],j])
    tmp.sort(reverse=True)
    for j in tmp:
        print(j[1]+1)

Submission status: Accepted

Solution code:
from operator import itemgetter

N = int(input())
SPi = [input().split()+[i] for i in range(N)]
for v in SPi:
    v[1] = int(v[1])
SPi.sort(reverse=True, key=itemgetter(1))
SPi.sort(key=itemgetter(0))
for v in SPi:
    print(v[2]+1)

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
d = defaultdict(list)
for i in range(n):
  s, p = map(str, input().split())
  d[s].append([int(p), i + 1])
d = dict(d)
d = sorted(d.items(), key=lambda x:x[0])
for e in d:
  e[1].sort(key=lambda x: x[0], reverse=True)
  for i in range(len(e[1])):
    print(e[1][i][1])

Submission status: Accepted

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

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

Submission status: Accepted

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

b=sorted(a, key=lambda x:(x[0], -int(x[1])))
for i in range(n):
	print(b[i][2])

Submission status: Accepted

Solution code:
n = int(input())
ls = [list(map(str,input().split())) for _ in range(n)]
nums = [e for e in range(1,n+1)]
for i in range(n):
    ls[i][1] = 100-int(ls[i][1])
    ls[i] = ls[i] + [nums[i]] 
ls = sorted(ls)
for i in range(n):
    print(ls[i][2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
restaurant = []
for i in range(N):
    s, p = input().split()
    restaurant += [(i + 1, s, - int(p))]
sorted_restaurant = sorted(restaurant, key=lambda x: (x[1], x[2]))
print('\n'.join([str(s[0]) for s in sorted_restaurant]))

Submission status: Accepted

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

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

a.sort()
for aa in a:
	print(aa[2]+1)

Submission status: Accepted

Solution code:
N = int(input())
A = []
for i in range(N):
    a,b=input().split()
    b=100-int(b)
    if b<10:
        A.append(a+'00'+str(b))
    elif b==100:
        A.append(a+str(b))
    else:
        A.append(a+'0'+str(b))
B=sorted(A)
for b in B:
    print(A.index(b)+1)

Submission status: Accepted

Solution code:

n = int(input())
sp = [[i for i in range(3)] for i in range(n)]



for _ in range(n):
    s,ps = map(str,input().split())
    p = ps
    sp[_][0] = _
    sp[_][1] = s
    sp[_][2] = p

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

for _ in sp:
    print(_[0]+1)

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

Submission status: Accepted

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

n = int(input())
d = defaultdict(list)
for i in range(n):
    s, p = input().split()
    d[s].append([int(p), i + 1])
keys = list(d.keys())
keys.sort()
ans = []
for key in keys:
    values = d[key]
    values = sorted(values, reverse=True)
    for i, j in values:
        ans.append(j)
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
S = []
P = []
Num = []
for i in range(N):
  s, p = input().split()
  S.append(s)
  P.append(int(p))
  Num.append(i+1)
for i in range(N):
  for m in range(i):
    if S[m] > S[i] or (S[m] == S[i] and P[i] > P[m]):
      S[m], S[i] = S[i], S[m]
      P[m], P[i] = P[i], P[m]
      Num[m], Num[i] = Num[i], Num[m]
for i in range(N):
  print("{}".format(Num[i]))

Submission status: Accepted

Solution code:
n = int(input())

data = [0] * n

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


data2 = sorted(data)

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

Submission status: Accepted

Solution code:
n = int(input())
lis = []
for i in range(n):
    a, b = input().split()
    lis.append((a, int(b), i + 1))
lis.sort(key=lambda x: x[1], reverse=True)
lis.sort(key= lambda x: x[0])
print(*[lis[i][2] for i in range(n)], sep="\n")

Submission status: Accepted

Solution code:
n=int(input())
lis=[]
for i in range(n):
    s,p=input().split()
    lis.append((i+1, str(s), int(p)))
ans=[]
lis=sorted(lis, key=lambda x:x[1])
tmp=[]
for l in lis:
    if tmp==[]:
        tmp.append(l)
    elif tmp[0][1]==l[1]:
        tmp.append(l)
    else:
        tmp=sorted(tmp,reverse=True,key=lambda x:x[2])
        for t in tmp:
            ans.append(t[0])
        tmp=[l]
tmp=sorted(tmp,reverse=True,key=lambda x:x[2])
for t in tmp:
    ans.append(t[0])

for i in ans:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
a = defaultdict(list)
for i in range(N):
    s, p = map(str, input().split())
    a[s].append([int(p),int(i+1)])
a = sorted(a.items())
for b in a:
    b[1].sort(reverse=True)
    for c in b[1]:
        print(c[1])

Submission status: Accepted

Solution code:
n=int(input())
a=[]
for i in range(n):
    b,c=input().split()
    c=int(c)
    a.append([b,c])
sa=sorted(a)
sa.append(["STOP"])
ssa=[]
ssaa=[]
while len(sa)>1:
    while True:
        ssa.append(sa[0])
        sa=sa[1:]
        if ssa[-1][0]!=sa[0][0] or sa[0]=="STOP":
            break
    ssa=ssa[::-1]
    for i in ssa:
        ssaa.append(i)
    ssa=[]
for i in ssaa:
    print(a.index(i)+1)

Submission status: Accepted

Solution code:
n = int(input())
sp = [0]*n
z = [0]*n
for i in range(n):
    sp[i]    = input().split() + [i+1]
    sp[i][1] = int(sp[i][1])
    z[i]     = sp[i][0]
a = sp
a.sort(key=lambda val : val[0])
import collections
c = collections.Counter(z)

i = 0
while i < n:
    b = c[a[i][0]]
    d = a[i:i+b][:]
    d.sort(key= lambda val : val[1],reverse=True)
    for j in range(b):
        print(d[j][2])
    i += b

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc128/submissions/13683823
from operator import itemgetter
n = int(input())

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

b = sorted(a, key=itemgetter(1), reverse=True)
guidebook = sorted(b, key=itemgetter(0))

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
N = int(input())
lst = []
for i in range(N):
    SP = list(map(str, input().split()))
    SP.append(i+1)
    lst.append(SP)

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

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

Submission status: Accepted

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

    Q = [[] for _ in range(N)]
    for i in range(N):
        pp, ss = input().split()
        Q[i] = [i + 1, pp, - int(ss)]

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

    for QQ in Q:
        print(QQ[0])


resolve()

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
S_list= []
P_list= []
for i in range(N):
    S,P = map(str,input().split())
    S_list.append(S+str(100-int(P)).zfill(3))

for j in np.argsort(S_list):
    print(j+1)

Submission status: Accepted

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

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.sort()
for s, p, i in a:
    print(i)

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:
n=int(input())
sp=[]
for i in range(n):
  s,p=input().split()
  p=int(p)
  sp.append([s,p,i+1])
sp.sort(key=lambda sp:(sp[0],-sp[1]))
for i in sp:
  print(i[2])

Submission status: Accepted

Solution code:
from operator import itemgetter

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

A = sorted(SP, key = itemgetter(1), reverse = True)
A = sorted(A, key = itemgetter(0))

for x in A:
    ans = SP.index(x)
    print(ans + 1)

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(1,n+1):
    s,p = map(str,input().split())
    dic[i]=s+str(1/(int(p)+1))
for s in sorted(dic.items(),key=lambda x:x[1]):
    print(s[0])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

s = []
p = []
num = []
for i in range(n):
  tmp = input().split()
  s.append(tmp[0])
  p.append(tmp[1])
  num.append(i)
sp = []
st = []
sn = []
spnum = zip(s,p,num)
spnum_s = sorted(spnum)
#print(spnum_s)
for i in range(0,len(spnum_s)):
  st.append(spnum_s[i][0])
  sp.append(int(spnum_s[i][1]))
  sn.append(spnum_s[i][2])
  #print(st)
  if(i == len(spnum_s)-1 or st[-1] != spnum_s[i+1][0]):
    tmp = zip(sp,sn)
    tmp2 = sorted(tmp, reverse=True)
    #print(tmp2)
    for j in range(0,len(tmp2)):
      print(tmp2[j][1]+1)
    st = []
    sp = []
    sn = []

Submission status: Accepted

Solution code:
n = int(input())
data = {}
for i in range(n):
    s,p = map(str,input().split())
    p = int(p)
    if s in data:
        data[s].append((p,i+1))
    else:
        data[s] = [(p,i+1)]
D = sorted(data.items())
for i in range(len(D)):
    P = D[i][1]
    P.sort()
    while P:
        print(P.pop()[1])

Submission status: Accepted

Solution code:
N = 6
ARR = [
    ["khabarovsk", 20],
    ["moscow", 10],
    ["kazan", 50],
    ["kazan", 35],
    ["moscow", 60],
    ["khabarovsk", 40]
]
N = int(input())
ARR = []

for i in range(N):
    arr = input().split()
    ARR.append([arr[0], int(arr[1])])


def calculate(n, arr):
    dict = {}
    for i in range(N):
        if dict.get(arr[i][0]) == None:
            dict.__setitem__(arr[i][0], [[arr[i][1], i]])
        else:
            rates = dict.get(arr[i][0])
            rates.append([arr[i][1], i])
            rates = sorted(rates, key=lambda x: -x[0])
            dict.__setitem__(arr[i][0], rates)

    keys = sorted(dict.keys())

    for key in keys:
        aaa = dict.get(key)
        for a in aaa:
            print(a[1] + 1)


calculate(N, ARR)

Submission status: Accepted

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

n = int(input())

data = {}
for i in range(n):
    s, p = list(map(str, input().split()))
    p = int(p)
    if s in data:
        data[s].append([p, i+1])
    else:
        data[s] = [[p, i+1]]

# print(data)
name_list = list(data.keys())
name_list.sort()


for i in name_list:
    data_tmp = data[i]
    data_tmp = sorted(data_tmp, key=lambda x: x[0], reverse=True)
    for j in data_tmp:
        print(j[1])

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LS(): return list(stdin.readline().rstrip().split())

n = I()
info = []
for i in range(n):
    tmp = LS()
    l = []
    l.append(i+1)
    l.append(tmp.pop(0))
    l.append(tmp.pop(0))
    info.append(l)


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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
sp = []
for _ in range(N):
  s, p = input().split()
  sp.append((s.strip(), int(p)))

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

for k,v in enumerate(sp_sorted):
  print(sp.index(v)+1)

Submission status: Accepted

Solution code:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
s=s3(n)
[s[i].append(i+1) for i in range(n)]

s.sort(key=lambda x:(x[0],-1*int(x[1])))

[print(x[2]) for x in s]

Submission status: Accepted

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

# sp.sort(key=lambda x: x[0])
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())
ans = []
for i in range(1, N+1):
    s, p = input().split()
    ans.append((s, int(p), i))
X = sorted([(k,v,i) for k,v,i in ans], key=lambda x: (x[0], -x[1]))
[print(x[2]) for x in X]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    N = int(input())
    restaurant = defaultdict(list)
    for i in range(N):
        tmp = input().split()
        restaurant[tmp[0]].append((int(tmp[1]), i+1))

    name_list = sorted(list(restaurant.keys()))

    for n in name_list:
        tmp = sorted(restaurant[n], key=lambda x: x[0], reverse=True)
        for t in tmp:
            print(t[1])


if __name__ == "__main__":
    main()

Submission status: Accepted

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


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

LS = sorted(L)

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

Submission status: Accepted

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


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

# print(s_p_list)

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

Submission status: Accepted

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

R_L2 = R_L.copy()
R_L2.sort( key=lambda x:(x[0],-x[1]))
for r in R_L2:
    print(R_L.index(r)+1)

Submission status: Accepted

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

R_L2 = R_L.copy()
R_L2.sort( key=lambda x:(x[0],-x[1]))
for r in R_L2:
    print(R_L.index(r)+1)

Submission status: Accepted

Solution code:
def inp():
    return(int(input()))


def invr():
    return(map(str, input().split()))


N = inp()
pos = [0] * 101
SP = dict()
for i in range(1, N+1):
    key, val = invr()
    val = int(val)
    if key in SP:
        temparr = SP[key]
        temparr.append(val)
        SP[key] = temparr
    else:
        SP[key] = [val]
    pos[val] = i

names = sorted(SP)

for key in names:
    values = SP[key]
    values = sorted(values, reverse=True)
    for i in values:

        print(pos[i])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    ans = 0
    N = int(input())
    sl = [input().split() + [i+1] for i in range(N)]
    sl.sort(key=lambda x: (x[0], -int(x[1])))
    for i in sl:
        print(i[2])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from operator import itemgetter
n = int(input())
l = []

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

l2 = sorted(l, key=itemgetter(1), reverse=True)
l2 = sorted(l2, key=itemgetter(0))

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from operator import itemgetter, attrgetter
n = int(input())
s = [input().split() for i in range(n)]
ss = []
ll = []
l = []
for i in range(0, n):
  l.insert(i, [s[i][0], int(s[i][1]), i+1])
ss = sorted(l, key=itemgetter(1), reverse=True)
ll = sorted(ss, key=itemgetter(0))
for i in ll:
  print(i[2])

Submission status: Accepted

Solution code:
N = int(input())
sp_list = []
sorted_list = []
for i in range(N):
  S,P = map(str, input().split(' '))
  sorted_list.append([S,int(P)])
  sp_list.append(S + ' ' + P)
sorted_list = sorted(sorted_list, key=lambda x:(x[1]), reverse=True)
sorted_list = sorted(sorted_list, key=lambda x:(x[0]))

for i in range(N):
  count=1
  for j in range(N):    
    if sorted_list[i][0]+' '+str(sorted_list[i][1]) ==sp_list[j]:
      print(count)
      break
    count+=1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
NSP = [[i] + input().split() for i in range(1,N+1)]
M = {}
for nsp in NSP:
    if nsp[1] in M:
        M[nsp[1]].append(nsp)
    else:
        M[nsp[1]] = []
        M[nsp[1]].append(nsp)
for m in sorted(M):
    m2 = sorted(M[m], key=lambda x: -int(x[2]))
    for m3 in m2:
        print(m3[0])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = sorted(s, key=lambda x: (x[0], -x[1]))
for x, y, a in ans:
    print(a)

Submission status: Accepted

Solution code:
n = int(input())
data = dict()
name = set()
for i in range(n):
    s, p = input().split()
    p = int(p)
    if s in data:
        data[s].append([p, i + 1])
    else:
        data[s] = []
        data[s].append([p, i + 1])
    name.add(s)
name = list(name)
name.sort()
for n in name:
    data[n].sort(reverse = True)
    for i in data[n]:
        print(i[1])

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = [None]*n
    for i in range(n):
        s, p = map(str, input().split())
        p = int(p)
        p *= -1
        a[i] = [s, p, i+1]
    a.sort(key=lambda x: (x[0], x[1]))
    for i in range(n):
        print(a[i][2])

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
# input
N = int(input())
page = []
p_append = page.append
for n in range(1, N + 1):
    S, P = map(str, input().split())
    p_append(
        {
            "number": n,
            "city": S,
            "point": int(P)
        }
    )

# check
page = sorted(page, key=lambda x: x["point"], reverse=True)
page = sorted(page, key=lambda x: x["city"])
for p in page:
    print(p["number"])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = set()       #市名種類
a = []          #インプットリスト
b = dict()          #市別処理
c = []          #結果

for i in range(n):
    t = list(input().split())
    t[1] = int(t[1])
    t.append(i+1)
    a.append(t)
    s.add(t[0])

s = list(s)
s.sort()

for j in range(len(s)):
    b = dict()
    for k in range(n):
        if a[k][0] == s[j]:
            b[a[k][2]] = a[k][1]
    x = sorted(b.items(),key=lambda x:x[1],reverse=True)
    for l in range(len(x)):
        c.append(x[l][0])

for m in range(len(c)):
    print(c[m])

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

Submission status: Accepted

Solution code:
N=int(input())
data=[]
for i in range(N):
    d=list(input().split())
    d[1]=int(d[1])
    d.append(i+1)
    data.append(d)
data.sort()
mem=[]; current=''
ans=[]
for i in data:
    if current!=i[0]:
        current=i[0]
        mem.sort(key=lambda x:x[1])
        d=[0]*len(mem)
        for j in range(len(mem)): d[len(mem)-(j+1)]=mem[j][2]
        ans.extend(d)
        mem=[i]
    else: mem.append(i)
mem.sort(key=lambda x:x[1])
d=[0]*len(mem)
for j in range(len(mem)): d[len(mem)-(j+1)]=mem[j][2]
ans.extend(d)
mem=[i]
for i in ans: print(i)

Submission status: Accepted

Solution code:
n=int(input())

#初期値が0の辞書
from collections import defaultdict
sp = defaultdict(lambda: [])
town=set([])

for i in range(1,n+1):
    s,p=map(str,input().split())
    town.add(s)
    sp[s].append((int(p),i))
town=list(town)
town.sort()
for item in town:
    tmp=sp[item]
    tmp.sort(reverse=True)
    for t in tmp:
        print(t[1])