Problem:


Score : 200 points

Problem Statement

You have decided to write a book introducing good restaurants.
There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.
No two restaurants have the same score.

You want to introduce the restaurants in the following order:

The restaurants are arranged in lexicographical order of the names of their cities.

If there are multiple restaurants in the same city, they are arranged in descending order of score.

Print the identification numbers of the restaurants in the order they are introduced in the book.

Constraints

1 ≤ N ≤ 100

S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.

0 ≤ P_i ≤ 100

P_i is an integer.

P_i ≠ P_j (1 ≤ i < j ≤ N)

Input

Input is given from Standard Input in the following format:

N
S_1 P_1
:
S_N P_N

Output

Print N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.

Sample Input 1

6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40

Sample Output 1

3
4
6
1
5
2

The lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.

Sample Input 2

10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100

Sample Output 2

10
9
8
7
6
5
4
3
2
1



Sample input:
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40


Sample output:
3
4
6
1
5
2

Submission status: Accepted

Solution code:
n = int(input())
l = [{} for d in range(n)]
for i in range(n):
  s,p = input().split()
  l[i] = {'City': s, 'Point': int(p), 'Number': i+1}
l.sort(key=lambda x: (x['City'],-x['Point']))
for num in l:
  print(num['Number'])

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

sorted_data = sorted(data, key=lambda x:(x[0], x[1]), reverse=False)

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

Submission status: Accepted

Solution code:
N = int(input())

G = []

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

G = sorted(G)

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

Submission status: Accepted

Solution code:
n=int(input())
dic={}
count={}

for i in range(n):
  s,p=map(str,input().split()) 
  p=int(p)
  dic[p]=s
  count[p]=i+1
  
a=sorted(dic.items(),reverse=True)
a=sorted(a,key=lambda x:x[1])

for p,s in a:
  for q,i in count.items():
    if p==q:
      print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy
n = int(input())
r = []
for _ in range(n):
    city, x = input().split()
    x = int(x)
    r.append((city, x))

d = copy.deepcopy(r)
d = sorted(d, key=lambda x: -x[1])
d = sorted(d, key=lambda x: x[0])

for k in d:
    print(r.index(k) + 1)

Submission status: Accepted

Solution code:
n=int(input())
a=[]
for i in range(n):
  b,c=map(str,input().split())
  d=[str(i+1),b,int(c)*(-1)]
  a.append(d)
  
a.sort(key=lambda x:x[1])
r={}
ans=[]
q=[]

for f in a:
  e=f[1]
  t=[f[0],f[2]]
  if e not in r:
    q.sort(key=lambda x:x[1])
    ans.append(q)
    q=[]
    q.append(t)
    r[e]=0
    
  else:
    q.append(t)


q.sort(key=lambda x:x[1])
ans.append(q)

for y in ans:
  for w in y:
    print(w[0])

Submission status: Accepted

Solution code:
N = int(input())
cities = {}
citylist = []
for i in range(1,N+1):
    s,p = map(str,input().split())
    if s in cities:
        cities[s].append([int(p),i])
    else:
        cities[s] = [[int(p),i]]
        citylist.append(s)

citylist.sort()
for city in citylist:
    cities[city].sort(reverse = True)
    for j in range(len(cities[city])):
        print(cities[city][j][1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

a=[]
b=[]
for i in range(n):
  s,p=list(input().split())
  a.append([s,int(p)])
  b.append([s,int(p)])
  
a.sort(key=lambda x:x[1],reverse=True)
a.sort(key=lambda x:x[0])

for i in a:
  print(b.index(i)+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = []
r = []
sr = []
for i in range(n):
    s, r = map(str, input().split())
    sr.append([i+1, s, int(r)])
# print(sr)
sr1 = sorted(sr, key=lambda x:x[2], reverse=True)

ans = sorted(sr1, key=lambda x:x[1])

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

Submission status: Accepted

Solution code:
#B - Guidebook (別解)
N = int(input())

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


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

ans = sorted(ans, key = lambda x:x[1])

for j,k,l in ans:
    print(j)

Submission status: Accepted

Solution code:
#B - Guidebook AC(ヒント)
N = int(input())
S = []
P = []
for _ in range(N):
    s,p = input().split()
    S.append(s)
    P.append(int(p)*(-1))#負の値にして降順にソートできるようにする

book = list(zip(S,P))
book_sort = sorted(book)
ans = [book.index(i)+1 for i in book_sort]
for j in ans:
    print(j)

Submission status: Accepted

Solution code:
print('\n'.join(map(str, (x[2]+1 for x in sorted((s, -int(p), i) for i, (s, p) in enumerate(zip(*[iter(open(0).read().split()[1:])]*2)))))))

Submission status: Accepted

Solution code:
N, *A = open(0).read().split()
A = sorted((s, -int(p), i) for i, (s, p) in enumerate(zip(*[iter(A)]*2)))
print('\n'.join(map(str, (x[2]+1 for x in A))))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n=int(input())
s=[]
p=[]
for i in range(n):
    si,pi=input().split()
    s.append(si)
    p.append(int(pi))
ans=[0]*n
for i in range(n-1):
    for j in range(i+1,n):
        if s[i]>s[j]:
            ans[i]+=1
        elif s[i]<s[j]:
            ans[j]+=1
        else:
            if p[i]<p[j]:
                ans[i]+=1
            else:
                ans[j]+=1
z=[0]*n
for i in range(n):
    z[ans[i]]=(i+1)
for i in range(n):
    print(z[i])

Submission status: Accepted

Solution code:
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())

    data = {}

    for i in range(n):
        row = [x for x in input().rstrip().split(" ")]
        s = row[0]
        p = int(row[1])

        if s not in data.keys():
            data[s] = {}

        data[s][p] = i+1

    for city, res in sorted(data.items()):
        for point, num in sorted(res.items(), reverse=True):
            print(num)





if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(1,n+1):
    s,p = input().split()
    t = [s,int(p),i]
    l.append(t)
l.sort()
def check(m,i):
    z = list(l[m:i])
    z.sort(key = lambda x: x[1] , reverse = True)
    for j in range(i-m):
        print(z[j][2])
m = 0
for i in range(1,n):
    if l[m][0] != l[i][0]:
        check(m,i)
        m = i
check(m,n)

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
sp ={}
l = [] 
for i in range(n):
    s,p = input().split()
    sp ={}
    sp["index"] = i+1
    sp["name"] = s
    sp["score"] = int(p)
    l.append(sp)


for dic in sorted(l, key=lambda x: (x["name"], -x["score"])):
    print(dic["index"])

Submission status: Accepted

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

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

Submission status: Accepted

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

anspoint=sorted(ans,key=lambda x:x[1], reverse=True)
anscity=sorted(anspoint,key=lambda x:x[0])

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

Submission status: Accepted

Solution code:
N=int(input())
SP=[]
for i in range(N):
    SP.append(list(input().split()))
for i in range(N):
    SP[i].append(i+1)
A=[]
B=[]
C=[]
for i in range(N):
    A.append(SP[i][0])
A.sort()
B.append(A[0])
for i in range(0,N-1):
    if A[i]!=A[i+1]:
        B.append(A[i+1])
for i in range(len(B)):
    C.append([])
for i in range(len(B)):
    for j in range(len(SP)):
        if B[i]==SP[j][0]:
            C[i].append([int(SP[j][1]),SP[j][2]])
for i in range(len(C)):
    for j in range(1,len(C[i])):
        d=C[i][j]
        k=j-1
        while (k>=0 and C[i][k]<d):
            C[i][k+1]=C[i][k]
            k-=1
        C[i][k+1]=d
for i in range(len(C)):
    for j in range(len(C[i])):
        print(C[i][j][1])

Submission status: Accepted

Solution code:
N = int(input())
M = {}
S = set()
for i in range(N):
	s, p = input().split()
	if s in M:
		t = M[s]
		t.append((int(p), i + 1))
	else:
		t = []
		t.append((int(p), i + 1))
		M[s] = t		
	S.add(s)

for s in sorted(S):
	for t2 in (sorted(M[s], reverse = True)):
		print(t2[1])

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())

S=[]
for i in range(n):
    c,p = map(str,input().split())
    S.append( [c,int(p)] )

C=[0]*n
for i in range(n):
    for j in range(n):
        if S[i][0]>S[j][0]:
            C[i]+=1
        elif S[i][0]==S[j][0]:
            if S[i][1]<S[j][1]:
                C[i]+=1

A=[0]*n
for i in range(n):
    print( C.index(i)+1 )

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

sp = []

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

sp.sort()

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

Submission status: Accepted

Solution code:
from operator import itemgetter
N = int(input())
R = [list(input().split()) for i in range(N)]
R = [(R[i][0], int(R[i][1]), i+1) for i in range(N)]
S = sorted(R, key=itemgetter(1), reverse=True)
T = sorted(S, key=itemgetter(0))
for t in T:
    print(t[2])

Submission status: Accepted

Solution code:
N = int(input())

D = {}
q = set()
for i in range(N):
    s,p = input().split()
    if s in q:
        D[s].append([int(p),i])
    else:
        D[s] = [[int(p),i]]
        q.add(s)

ans = []
for i in sorted(list(q)):
    D[i].sort(reverse=True)
    for j in D[i]:
        ans.append(j[1])

[print(i+1) for i in ans]

Submission status: Accepted

Solution code:
n = int(input())

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

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

for x in shops:
  city, scores = x[0], sorted(x[1], reverse=True, key=lambda x : x[0])
  for score in scores:
    print(score[1])

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    sp_lst = [0] * n
    for i in range(n):
        sp_lst[i] = list(map(str, input().split()))

    turn_lst = []
    city_lst = []
    for i in range(n):
        city_lst.append(sp_lst[i][0])
    city_lst = list(set(city_lst))
    city_lst.sort()

    number_of_cities = len(city_lst)
    for i in range(number_of_cities):
        city = city_lst[i]
        score_lst = []
        for j in range(n):
            if city == sp_lst[j][0]:
                score_lst.append(int(sp_lst[j][1]))

        score_lst = sorted(score_lst)
        score_lst.reverse()
        number_of_score = len(score_lst)
        for k in range(number_of_score):
            score = str(score_lst[k])
            turn_lst.append(sp_lst.index([city, score]) + 1)

    for i in range(n):
        print(turn_lst[i])

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))
A.sort()
print(*list(i+1 for _, _, i in A))

Submission status: Accepted

Solution code:
n = int(input())

res = []
for i in range(n):
  city, value = input().split()
  value = int(value)
  res.append([city, value, i+1])
res_s = sorted(res, key = lambda x: (x[0], -x[1]))
for i in range(n):
  print(res_s[i][2])

Submission status: Accepted

Solution code:
N = int(input())

SP =[]
for i in range(N):
    SP.append([i+1] + list(map(str,input().split())))
    SP[i][2] = int(SP[i][2])

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

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

Submission status: Accepted

Solution code:
N = int(input())
S_list = []
P_list = []
c = []

for i in range(N):
    S, P = input().split()
    S_list.append(S)
    P_list.append(int(P))

m = S_list
m = list(set(m))
m = sorted(m)

n = 0
a = []
b = []
for i in m:
    for j in range(N):
        if i == S_list[j]:
            a.append(j)
    n = len(a)
    if n != 1:
        for o in range(n):
            b.append(P_list[a[o]])
        b = sorted(b, reverse = True)
        for k in b:
            for l in range(N):
                if k == P_list[l]:
                    c.append(l)
    else:
        c.append(a[0])


    a = []
    b = []

for i in c:
    print(str(i + 1))

Submission status: Accepted

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

for s in sorted(S, key=lambda x: (x[1], -int(x[2]))):
    print(s[0])

Submission status: Accepted

Solution code:
def nig (x,y):
    if x[0] == y[0]: return -1 if x[1]>y[1] else 1
    return -1 if x[0] < y[0] else 1
cuc_fuk = []
for x in range(input()):
    a,b = raw_input().split()
    cuc_fuk.append((a,int(b),x+1))
for piss in sorted(cuc_fuk, cmp = nig ):
    print piss[2]

Submission status: Accepted

Solution code:
def resolve():
    n=int(input())
    d=[]
    for i in range(n):
        s,p=input().split()
        d.append([s,100-int(p),i])
    d.sort()
    ans=[0]*n
    for i in range(n):
        ans[i]=d[i][2]
    for m in ans:
        print(m+1)
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
dic = {}
for i in range(N):
    S,P = map(str,input().split())
    if S not in dic:
        dic[S] = [(-1*int(P), i+1)]
    else:
        dic[S].append((-1*int(P), i+1))
ls = list(dic.items())
ls.sort()
for city in ls:
    points = sorted(city[1])
    for point in points:
        print(point[1])

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

Submission status: Accepted

Solution code:
N = int(input())
city = {}
for i in range(N):
    s,p = map(str,input().split())
    if s not in city:
        city[s] = [[int(p),i+1]]
    else:
        city[s].append([int(p),i+1])
        city[s].sort(reverse=True)

city = sorted(city.items())

for i in city:
    for j in i[1:]:
        for k in j:
            print(k[1])

Submission status: Accepted

Solution code:
n = int(input())

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
restaurants = []
for i in range(n):
    s, p = list(input().split())
    restaurants.append([s, int(p), i + 1])
restaurants.sort(key=lambda x: x[1], reverse=True)
restaurants.sort(key=lambda x: x[0])
for i in range(n):
    print(restaurants[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:
SP_list = []
N = int(input())

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

SP_list.sort(key=lambda i:i[2], reverse=True)
SP_list.sort(key=lambda i:i[1])

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

Submission status: Accepted

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

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

Submission status: Accepted

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

shop_list_sorted = sorted(shop_list,key=lambda x:(x[0],-x[1]))
for k in range(n):
    print(shop_list_sorted[k][2])

Submission status: Accepted

Solution code:
n=int(input())
city={}

for i in range(1,n+1):
    c,p=input().split()
    p=int(p)

    if c in city:
        city[c].append((i,p))
    else:
        city[c]=[(i,p)]

clst=sorted(list(city.keys()))

for c in clst:
    plst=sorted(city[c],key=lambda x:x[1],reverse=True)

    for i,_ in plst:
        print(i)

Submission status: Accepted

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

shop_list_sorted = sorted(shop_list,key=lambda x:(x[0],-x[1]))
for k in range(n):
    print(shop_list_sorted[k][2])

Submission status: Accepted

Solution code:
N = int(input())
rank = []
for i in range(N):
  name, point = input().split(" ")
  rank.append({
    "name": name,
    "point": 100 - int(point),
    "id": i + 1
  })

rank.sort(key = lambda x: (x["name"], x["point"]))
print("\n".join(list(map(lambda r: str(r["id"]), rank))))

Submission status: Accepted

Solution code:
# 複数の値をキーにするソートを行うため、クラスを作成した。

# レストランを紹介する本のクラス。
class Book:
    """
    =======================
    Book: レストランを紹介する本のクラス。
    =======================
    """
    # インスタンス
    def __init__(self, no, name, value):
        # レストラン番号(0から開始する)
        self.no = no
        # レストラン名
        self.name = name
        # レストラン評価
        self.value = value
	# ドキュメント
    def usage(self):
        print(self.__doc__)

# 本のクラスの配列。
book = []
n = int(input())
for i in range(n):
    # レストラン名、レストラン評価
    s, p = input().split()
    book.append(Book(i, s, int(p)))

# レストラン評価の降順で整列する。
book = sorted(book, key=lambda b: b.value, reverse=True)
# レストラン名で整列する。
book = sorted(book, key=lambda b: b.name)
for b in book:
    # 本に紹介されるレストラン順で表示する。
    print(b.no+1)
# book[0].usage()

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
# 複数の値をキーにするソートを行うため、クラスを作成した。

# レストランを紹介する本のクラス。
class Book:
  	# インスタンス
    def __init__(self, no, name, value):
      	# レストラン番号(0から開始する)
        self.no = no
        # レストラン名
        self.name = name
        # レストラン評価
        self.value = value
# 本のクラスの配列。
book = []
n = int(input())
for i in range(n):
  	# レストラン名、レストラン評価
    s, p = input().split()
    book.append(Book(i, s, int(p)))

# レストラン評価の降順で整列する。
book = sorted(book, key=lambda b: b.value, reverse=True)
# レストラン名で整列する。
book = sorted(book, key=lambda b: b.name)
for b in book:
  	# 本に紹介されるレストラン順で表示する。
    print(b.no+1)

Submission status: Accepted

Solution code:
class Book:
    def __init__(self, no, name, value):
        self.no = no
        self.name = name
        self.value = value

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

book = sorted(book, key=lambda b: b.value, reverse=True)
book = sorted(book, key=lambda b: b.name)
for b in book:
    print(b.no+1)

Submission status: Accepted

Solution code:
n=int(input())
l=[]
for i in range(n):
    s=input().split()
    s[1]=int(s[1])
    l.append(s)
l1=sorted(l, key=lambda l:l[1], reverse=True)
l2=sorted(l1, key=lambda l:l[0])
for i in l2:
    print(l.index(i)+1)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc128_b

N = int(input())
numbers = []
cities = []
points = []

for i in range(N):
    city, point = input().split()
    numbers.append(i+1)
    cities.append(city)
    points.append(int(point))

def switch_order(l, i, j):
    tmp = l[i]
    l[i] = l[j]
    l[j] = tmp

for i in range(N):
    for j in range(i):
        if cities[j] < cities[i]:
            continue
        if cities[j] > cities[i]:
            switch_order(numbers, i, j)
            switch_order(cities, i, j)
            switch_order(points, i, j)
        if cities[j] == cities[i] and points[j] < points[i]:
            switch_order(numbers, i, j)
            switch_order(cities, i, j)
            switch_order(points, i, j)

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())

import collections
d = collections.defaultdict(list)

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

ordered = list(d.keys())
ordered.sort()

for city in ordered:
    mises = d[city]
    mises = sorted(mises, key=lambda x: x[1], reverse=True)
    for mise in mises:
        print(mise[0])

Submission status: Accepted

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

Submission status: Accepted

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

l=[]
for i in range(n):
  a,b=map(str, input().split())
  b=100-int(b)
  if b<10:
    b=str('0')+str(b)
  elif b==100:
    b="999"
  else:
    b=str(b)
  a=a+b
  l.append(a)

l2=sorted(l)

for i in range(n):
  print(l.index(l2[i])+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

citydic = {}
for i in range(n):
    s,p = map(str,input().split())
    if s not in citydic:
        citydic[s] = [[int(p),i+1]]
    else:
        citydic[s].append([int(p),i+1])
        citydic[s].sort(reverse=True)

citydic = sorted(citydic.items())

for k in citydic:
    for v in k[1:]:
        for n in v:
            print(n[1])

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

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


n = ni()
res = [list(input().split() + [i + 1]) for i in range(n)]
res = list(map(lambda x: (x[0], int(x[1]), x[2]), res))
res = sorted(res, key=lambda x: x[0])
start = 0
start_res = res[0][0]
sor_res = []
ans = []
for i in range(n):
    if start_res != res[i][0]:
        end = i - 1
        sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True)
        start = i
        start_res = res[i][0]
    if i == n - 1:
        end = i
        sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True)
for r in sor_res:
    print(r[2])

Submission status: Accepted

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

for i in range(N):  # 地名をキーとした辞書に、[店番号、点数]を付加する
    place, score = input().split()
    tmp = [i+1, int(score)]
    if place in town:
        town[place].append(tmp)
    else:
        town[place] = [tmp]

index = list(town.keys())
index.sort()

for _ in index:
    tmp = town[_]
    tmp = sorted(tmp, reverse=True, key=lambda x: x[1])
    for num in tmp:
        print(num[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

n = int(input())
a = []
for i in range(n):
    s, p = map(str, input().split())
    p = int(p)
    a.append((s,p,i+1))
# 要素[1]を逆ソート
a.sort(key=lambda x:x[1], reverse=True)
# 要素[0]を順ソート
a.sort(key=lambda x:x[0])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
xs = [0] * n
for i in range(n):
    s, p = input().split()
    xs[i] = [s, int(p), i + 1]
xs.sort(key=lambda v: (v[0], 100 - v[1]))
print(*map(lambda v: v[2], xs), sep="\n")

Submission status: Accepted

Solution code:
N = int(input())
SP = []
for i in range(N):
    line = input().split()
    s = line[0]
    p = int(line[1])
    # レストラン番号と紐付けておく
    SP.append([s, p, i + 1])
# SPの中身はそれぞれ[市名, 点数, 店番号]
# 市名で昇順ソート、更に点数で降順ソート
SP = sorted(SP, key=lambda x: (x[0], -x[1]))
for spi in SP:
    print(spi[2])

Submission status: Accepted

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
s = {}
for i in range(n):
	S,P = map(str,input().split())
	s[i+1] = [S, -int(P)]

note = sorted(s.items(), key=lambda x: x[1][0])
note.append( (10, ["LOL", 10] ) )
memo = note[0][1][0]
a = []
for i in note:
	if memo != i[1][0]:
		memo = i[1][0]
		a = sorted(a, key=lambda x: x[1][1])
		for j in range(len(a)):
			print(a[j][0])
		a = []
		a.append(i)
	else:
		a.append(i)

Submission status: Accepted

Solution code:
#! env/bin/local python3
# -*- coding: utf-8 -*-

n = int(input())

restaurants = {}
for i in range(1, n + 1):
    info = input().split()
    restaurants[i] = {
        # 'name': info[0] + str(100 - int(info[1]))
        'name': info[0],
        'score': int(info[1])
    }

# {1: hoge} -> ([1, hoge])
results = sorted(restaurants.items(), key=lambda x: (x[1]['name'], 100 - x[1]['score']))
output = [r[0] for r in results]
print(*output, sep='\n')

Submission status: Accepted

Solution code:
N=int(input())
S=[""]*N
T=[""]*N
for i in range(N):
  S[i]=list(input().split())
  S[i][1]=-int(S[i][1])
  T[i]=S[i]
S.sort(key=lambda x:(x[0],x[1]))
for i in range(N):
  for j in range(N):
      if(T[j]==S[i]):
        print(j+1)

Submission status: Accepted

Solution code:
N = int(input())
list1 = []
for i in range(N):
  aa = input().split()
  a = aa[0]
  b = -int(aa[1])
  xxx = [a,b,i]
  list1.append(xxx)
list1.sort()

for i in range(N):
  list1[i].append(i)

for i in range(N):
  for j in list1:
    if j[3] == i:
      print(j[2]+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(reverse=True, key=lambda x:x[1])
sp.sort(key=lambda x:x[0])

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

Submission status: Accepted

Solution code:
n  = int(input())

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

city_points.sort()

for i in city_points:
    print(i[-1])

Submission status: Accepted

Solution code:
n = int(input())
city_to_points = dict()

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

kyes = list(city_to_points.keys())
kyes.sort()

for i in kyes:
    restrans = city_to_points[i]
    restrans.sort(reverse=True)
    for j in restrans:
        print(j[1])