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

Solution (Python):
import sys
from fractions import gcd
import bisect
from operator import itemgetter

stdin = sys.stdin

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

s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]



n = ni()
r_list = list()


for i in range(n):
    s_i, p_i = ns().split(" ")
    r_list.append((s_i, int(p_i), i+1))

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

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

Solution (Python):
N = int(input())
sp = {}

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


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


for key,v in sp:
    v.sort()
    v.reverse()
    for i in range(len(v)):
        print(v[i][1])

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

for s in sorted(dict.keys()):
    for (p, i) in reversed(sorted(dict[s])):
        print(i)

Solution (Python):
import copy
n = int(input())
sp = [[i for i in input().split()] for i in range(n)]
for index,value in enumerate(sp):
    sp[index] = [value[0],-int(value[1])]
orig = copy.deepcopy(sp)
sp.sort()
rank = {}
index = 1
for value in sp:
    rank[(value[0],value[1])] = index
    index += 1
indexes = {}
counter = 1
for i in range(n):
    
    indexes[(rank[(orig[i][0],orig[i][1])])] = counter
    
    counter += 1

for i in range(1,n+1):
    print(indexes[i])

Solution (Python):
count = int(input())

sonomama = []
city = {}
for i in range(count):
    score = input().split()
    sonomama.append(' '.join(score))
    if score[0] not in city:
        city[score[0]] = []
    city[score[0]].append(score[1])

city = sorted(city.items())

for item in city:
    holder = sorted(map(int, item[1]), reverse=True)
    for i in range(len(item[1])):
        print(sonomama.index(item[0]+' '+str(holder[i]))+1)

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

Solution (Python):
N = int(input())
book= []
for i in range(N):
    a = input().split()
    city = a[0]
    score = (100-int(a[1]))
    book.append((city, score))
b=sorted(book)

for i in b:
    ans =  1
    for j in book:
        if i == j:
            print(ans)
        else:
            ans += 1

Solution (Python):
N=input()

s_li = []

for i in range(int(N)):
	S,P=map(str,input().split())
	s_li_tmp = {'Num':i+1, 'Point':int(P), 'Shop':S}
	s_li.append(s_li_tmp)

s_li_sorted = sorted(s_li, key=lambda x:(x['Shop'],-x['Point']))

for k in range(int(N)):
	print(s_li_sorted[k].get('Num'))

Solution (Python):
n = int(input())
ls = []
ls2 = []
count = 0
while count < n:
    ab = input().split()
    a, b = str(ab[0]), int(ab[1])
    ls.append([a, b])
    ls2.append([a, b])
    count = count + 1
ls2.sort(key=lambda x: x[1], reverse=True)
ls2.sort(key=lambda x: x[0])
ans = []
for s in ls2:
    for i, hoge in enumerate(ls):
        if hoge == s:
            ans.append(i+1)
for s in ans:
    print(s)

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
b = [list(map(str,input().split())) for p in [0]*n]
for i in range(n):
  b[i][1] = int(b[i][1])
  b[i].append(i+1)
b.sort(key=lambda q:(q[0],-q[1]))
for k in range(n):
  print(b[k][2])

Solution (Python):
N = int(input())
info_list = list()
for i in range(N):
    S, P = input().split()
    info_list.append((i + 1, S, int(P)))

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

for info in info_list:
    print(info[0])

Solution (Python):
from operator import itemgetter

dic = []
for i in range(int(input())):
  dic.append(input().split())
  dic[i][1] = int(dic[i][1])
  dic[i].append(i)

dic.sort(key=itemgetter(1), reverse=True)
dic.sort(key=itemgetter(0))
for listd in dic:
  print(listd[2]+1)

Solution (Python):
n=int(input())
s=[]
for i in range(n):
  a,b=map(str, input().split())
  s.append([a,-1*int(b),i+1])
s.sort()
sorted(s, key=lambda x:(x[0],x[1]))
ans=[]
for i in range(n):
  ans.append([s[i][1],s[i][2]])
  
ans.sort(reverse=True)
for i in range(n):
  
  print(s[i][2])

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

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

Solution (Python):
n = int(input())
guide = [input().split() for _ in range(n)]
for i in range(n):
    guide[i].append(i+1)
guide.sort(key = lambda x:int(x[1]), reverse = True)
guide.sort(key = lambda x:x[0])
for j in range(n):
    print(guide[j][2])

Solution (Python):
n = int(input())

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

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

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

Solution (Python):
n = int(input())
r_l = []

for id_ in range(n):
    c_s = input().split()
    r_l.append((id_ + 1, c_s[0], 100-int(c_s[1])))

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

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

Solution (Python):
N = int(input())
SP = [0]*N
for n in range(N):
    SP[n] = list(input().split())+ [n+1]

for sp in SP:
    sp[1] = int(sp[1])

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

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

Solution (Python):

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

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

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

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

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

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

for x in SP:
    print(x[2]+1)

Solution (Python):
N = int(input())
res = []
for i in range(N):
    Si, Pi = input().split(' ')
    resi = [i+1, Si, int(Pi)]
    res.append(resi)

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

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

restaurants = {}
for i in range(N):
  city, score = tuple(map(str, input().split()))
  if city not in restaurants.keys():
    restaurants[city] = [(i + 1, int(score))]
  else:
    restaurants[city].append((i + 1, int(score)))

for k, v in sorted(restaurants.items()):
  sorted_restaurants = sorted(v, key=lambda x: x[1], reverse=True)
  for restaurant in sorted_restaurants:
    print(restaurant[0])

Solution (Python):
N = int(input())
S = []
P = []
for i in range(N):
    x, y = [str(i) for i in input().split()]
    S.append(x)
    P.append(int(y))
c = zip(S, P, range(1, N + 1))
c = sorted(c, key=lambda x: (x[0], -x[1]))
for _ in range(N):
    print(c[_][2])

Solution (Python):
def main():
    restaurant_map = {}
    n = int(input())
    for i in range(n):
        line = input()
        s, p = line.split(" ")
        p = int(p)
        if s not in restaurant_map:
            restaurant_map[s] = []
        restaurant_map[s].append({
            'no': i+1,
            'point': p,
        })
    for key in sorted(restaurant_map.keys()):
        restaurant_list = sorted(restaurant_map[key], key=lambda x: x['point'], reverse=True)
        for r in restaurant_list:
            print(r['no'])


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
sp = {}
for i in range(n):
    s, p = input().split()
    if s in sp:
        sp[s].append([int(p), i+1])
    else:
        sp[s] = []
        sp[s].append([int(p), i+1])
        
for i in sp.keys():
    sp[i].sort(reverse=True)
sp = sorted(sp.items(), key=lambda x:x[0])

for i in sp:
    for j in i[1]:
        print(j[1])

Solution (Python):
n = int(input())
li = []
for i in range(n):
  li.append([str(i+1),input().split()])
li = sorted(li,key = lambda x:int(x[1][1]),reverse=True)
li = sorted(li,key = lambda x:x[1][0])
for j in li:
  print(int(j[0]))

Solution (Python):
from operator import itemgetter
N = int(input())
ans = []
for i in range(N):
  s,p = input().split()
  ans.append([s,int(p),int(i+1)])
ans = sorted(ans)
ans_list = []
tmp = [ans[0]]
for i in range(1,N):
  if ans[i][0] == ans[i-1][0]:
    tmp.append(ans[i])
  else:
    tmp = sorted(tmp, key=itemgetter(1),reverse=True)
    for j in range(len(tmp)):
      ans_list.append(tmp[j])
    tmp = []
    tmp.append(ans[i])
tmp = sorted(tmp, key=itemgetter(1),reverse=True)
for j in range(len(tmp)):
  ans_list.append(tmp[j])
for i in range(N):
  print(ans_list[i][2])

Solution (Python):
num = int(input())

lists = []

for i in range(1, num+1):
  inpu = input()
  name = inpu.split()[0]
  score = int(inpu.split()[1])
  a = [int(i), name, int(score)]
  lists.append(a)
  
sor = sorted(lists, key=lambda x:(x[1], -x[2]))

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

Solution (Python):
from collections import defaultdict

N = int(input())

D = defaultdict(list)
for i in range(N):
    s,p = input().split()
    D[s].append((i+1,int(p)))
    
for k in sorted(D.keys()):
    for v in sorted(D[k],key=lambda x:x[1],reverse=True):
        print(v[0])

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

s = [_sp[0] for _sp in sp]
p = [int(_sp[1]) for _sp in sp]

s_idx = sorted(range(len(s)), key=s.__getitem__)

s_unique = list(set(s))
s_unique.sort()

for i in range(len(s_unique)):
    l = []
    for j in range(n):
        if s[j] == s_unique[i]:
            l.append(j)
    _p = []
    for k in l:
        _p.append(p[k])
    _p_idx = sorted(range(len(_p)), key=_p.__getitem__)
    _p_idx = _p_idx[::-1]
    for x in _p_idx:
        print(l[x] + 1)

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

SP = []

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

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

for i in SP :
    print(i[0] + 1)

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

Solution (Python):
from operator import itemgetter

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

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

for city, score, index in b:
  print(index)

Solution (Python):

import sys
def p(*a):
  s=" ".join(map(str,a))
  
  sys.stderr.write(s+"\n")


N = int(input()) 


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


B = sorted(A, key=lambda x: (x[1],int(x[2])*(-1)))

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

Solution (Python):
n = int(input())

hyouka = []
for i in range(n):
    tmpS, tmpP = input().split()
    ss = ""
    for j in range(10-len(tmpS)):
        ss = ss + "a"
    tmpHyouka = tmpS + ss + str(9999-int(tmpP)-1)
    hyouka.append(tmpHyouka)

ans = sorted(range(len(hyouka)), key=lambda k: hyouka[k])

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

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

SP.sort(key = lambda x:x[0])
idx = 0
init = SP[idx][0]
while idx < N:
    D = []
    while idx  < N and SP[idx][0] == init:
        D += [SP[idx]]
        idx += 1
    D.sort(reverse = True,key = lambda x:int(x[1]))
    for i in range(len(D)):
        print(D[i][2])
    init = SP[min(idx,N-1)][0]

Solution (Python):
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    N = makeMultiInteger(input_string[0])
    S = makeStringMatrix(input_string[1:])
    for _i, s in enumerate(S):
        s.append(_i+1)
    S = sorted(S, key=lambda x: x[0])
    a = []
    i = 0
    for _i, s in enumerate(S):
        
        if a != []:
            if s[0] == a[i-1][0]:
                a.append(s)
            else:
                if len(a) > 1:
                    a = sorted(a, key=lambda x: int(x[1]), reverse=True)
                    
                    for _a in a:
                        print(_a[2])
                else:
                    for _a in a:
                        print(_a[2])
                i = 0
                a = []
                a.append(s)
        else:
            a.append(s)
    if a != []:
        if len(a) > 1:
            a = sorted(a, key=lambda x: int(x[1]), reverse=True)
            for _a in a:
                print(_a[2])
        else:
            for _a in a:
                print(_a[2])


def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    


if __name__ == '__main__':
    main()

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

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

Solution (Python):
n = int(input())

l = []


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

for i in range(n):
    l[i].append(i+1)
    
l.sort()
s = [0,0,0]
l.append(s)

i = 0

while i != n:
    if l[i][0] == l[i+1][0]:
        if int(l[i][1]) < int(l[i+1][1]):
            l[i][1], l[i+1][1] = l[i+1][1], l[i][1]
            l[i][2], l[i+1][2] = l[i+1][2], l[i][2]
            i = -1
    i += 1

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

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

Solution (Python):
from operator import itemgetter

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

for c in sorted(R):
    R[c].sort(reverse = True, key = itemgetter(0))
    for r in R[c]:
        print(r[1])

Solution (Python):
from sys import stdin
n = int(input())
data = {}
for i in range(n):
  key, val = input().split()
  if key not in data:
    data[key] = {}
  data[key][int(val)] = i+1


keys = sorted(data.keys())
for key in keys:
  li = sorted(data[key], reverse=True)
  for j in li:
    print(data[key][j])

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

cities = []
points = []
for i in range(N):
    s, p = input().split()
    p = int(p)
    cities.append(s)
    points.append([p, i])
    
dictionary = {city: [] for city in set(cities)}
for i in range(len(cities)):
    dictionary[cities[i]].append([points[i], i])
    
for key in sorted(list(dictionary.keys())):
    values = sorted(dictionary[key], key=lambda x: x[0],reverse=True)
    for v, i in values:
        print(1+i)

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

eva_list = []

for i in range(N):
    key, value = input().split()
    eva_list.append([key,int(value),i+1])

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

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

Solution (Python):
n = int(input())
L = []
i = 0
while i < n:
    s,p = map(str,input().split(' '))
    p = -1*int(p)
    L.append((s,p,i))
    i += 1
L.sort()
ans = ''
for l in L:
    ans += str(l[2]+1)+'\n'
print(ans[:-1])

Solution (Python):
N = int(input())
Rests = [input().split() for l in range(N)]
sorted_rests = sorted(Rests, key=lambda x:(int(x[1])), reverse=True)
sorted_rests = sorted(sorted_rests, key=lambda x:(x[0]), reverse=False)
for i in sorted_rests:
    print(Rests.index(i) + 1)

Solution (Python):
n = int(input())
arr = []

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

for a in arr:
  print(a[2])

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

Solution (Python):
N = int(input())
s=[0]*N
p=[0]*N
a=[0]*N
for i in range(N):
  s[i], p[i] = input().split()
for i in range(N):
  a[i]=[s[i],int(p[i]),i+1]
a.sort(key=lambda x: x[1],reverse=True)
a.sort(key=lambda x: x[0])
for i in range(N):
  print(a[i][2])

Solution (Python):
n = int(input())

lib = {}

for _ in range(n):
    l = input().split()

    if not l[0] in lib.keys():
        lib[l[0]] = []

    lib[l[0]].append([l[1], _])


lib = sorted(lib.items())
for v in lib:
    for i in sorted(v[1], key=lambda x: -int(x[0])):
        print(i[1]+1)

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

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

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

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

Solution (Python):
def main():

    N = int(input())

    shop_list = []
    for i in range(N):
        Sn, Pn = input().strip().split()
        shop_list.append((i + 1, Sn, int(Pn)))

    shop_list = sorted(shop_list, key=lambda x: (x[1], -x[2]))

    print("\n".join([str(i) for i, _, _ in shop_list]))


if __name__ == "__main__":
    main()

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

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

Solution (Python):
from sys import stdin


def sortFirst(val):
    return val[0]
N=stdin.readline().rstrip()
N=int(N)
l={}
for i in range(1,N+1):
    S,P = stdin.readline().rstrip().split()
    if S in l.keys():
        l[S].append([int(P),i])

    else:
        l[S]=[[int(P),i]]


for key in l.keys():
    l[key].sort(key=sortFirst,reverse=True)
for key in sorted(l):
    for val in l[key]:
        print(val[1])

Solution (Python):
n=input()
sn=[]
for num in range(int(n)):
    st=input()
    st=st.split()
    st[1]=int(st[1])
    st.append(num)
    sn.append(st)

sn2=sorted(sn, key=lambda x:(x[0],-x[1]))
for n in sn2:
    print(int(n[2]+1))

Solution (Python):
n = int(input())
dic = []
dic3 = []
for i in range(n):
    a,b = input().split()
    b = int(b)
    dic3.append(b)
    for j in dic:
        if a in j:
            j.append(b)
            break
    else:
        dic.append([a,b])

dic.sort()

dic2 = []
for re in dic:
    del re[0]
    re.sort()
    re.reverse()
    for j in re: dic2.append(j)
for res in dic2:
    print(dic3.index(res)+1)

Solution (Python):
from operator import itemgetter
N=int(input())
S=[];P=[];R=[]
for i in range(N):
  s,p =[i for i in input().split()]
  p=int(p)
  r=i+1
  S+=[s];P+=[p];R+=[r]
Z=zip(S,P,R)
Y=sorted(Z,key=itemgetter(1),reverse=True)

X=sorted(Y,key=itemgetter(0))

S,P,R=zip(*X)

for i in R:
  print(i)

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

book = sorted(book, key=lambda x: (x[0], -x[1]))
for page in book:
    print(page[2])

Solution (Python):
import numpy as np
N = int(input())
B = []
for i in range(N):
    L1, R1 = input().split()
    R2 = -1 * int(R1)
    B.append((L1,R2))
BC = np.array(B,dtype= [('town', "U10"),("s", "i1")])
a= np.argsort(BC ,order = ['town', 's'])
for i in range(N):
    print(int(a[i])+1)

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

for n in range(N):
    rest[n][1] = int(rest[n][1])
    rest[n].append(n + 1)
    
rest.sort(key = lambda x: x[1], reverse = True)
rest.sort(key=lambda x: x[0], reverse=False)


for n in range(N):
    print(rest[n][2])

Solution (Python):
inputa = int(input())
inputlist = []
for i in range(inputa):
  temp = input().split()
  inputlist.append([i + 1, temp[0], int(temp[1])])
inputlist.sort(key=lambda x:(x[1],-x[2]))
for l in inputlist:
  print(l[0])

Solution (Python):
n=int(input())
q=[input().split()+[i]for i in range(n)]
for i in range(n):
    q[i][1]=int(q[i][1])
p=sorted(sorted( q ,key=lambda x:x[1],reverse=1),key=lambda x:x[0])
for s,t,r in p:
    print(r+1)

Solution (Python):
N = int(input())
args_list = [input().split() for i in range(N)]
tuples_list = [(args[0], int(args[1]), i+1) for i, args in enumerate(args_list)]
tuples_list.sort(key=lambda x: x[1], reverse=True)
tuples_list.sort(key=lambda x: x[0])
for tuples in tuples_list:
  print(tuples[2])

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

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

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

Solution (Python):
N = int(input())
r = []

for i in range(1, N+1):
    name, point = (x for x in input().split())
    r.append([name, int(point), i])
    r.sort(key=lambda x: x[1], reverse=True)
    r.sort(key=lambda x: x[0])

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

Solution (Python):
import sys
import numpy as np
import copy
sys.setrecursionlimit(1000000)
 
N = int(input())
SP =  [ input().split() for N in range(N)]

SP_raw = copy.deepcopy(SP)

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

SP.sort()

"""
print(SP)
print(SP_raw)

sys.exit()
"""
for i in range(N):
    SP[i][1] = str(-SP[i][1])
    




for i in range(N):
    print(SP_raw.index(SP[i])+1)

Solution (Python):
from operator import itemgetter
n = int(input())
spl = [('', 0)]*n
for i in range(n):
    sp = input().split()
    spl[i] = (i+1, sp[0], -int(sp[1]))
for i, j, k in sorted(spl, key=itemgetter(1,2)):
    print(i)

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

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

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

SP = sorted(SP, key=lambda x:x[0])


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

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


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

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

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

S = []


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

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

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

Solution (Python):
n = int(input())

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

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

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


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

Solution (Python):
class Restaurant:
	def __init__(self,id,name,score):
		self.id = id
		self.name = name
		self.score = score

N=int(input())

arr=[]

for n in range(N):
	name,score=input().split()
	arr.append(Restaurant(n+1,name,-1*int(score)))

arr.sort(key=lambda x: (x.name,x.score))

ans = ""
for a in arr:
	print(a.id)

Solution (Python):
inp_st = input()
n = int(inp_st)
s_dictionary = {}
for i in range(n):
    inp_st = input()
    split_input = inp_st.split()
    s = split_input[0]
    p = int(split_input[1])
    if s in s_dictionary:
        p_dictionary = s_dictionary[s]
        p_dictionary[p] = i + 1
    else:
        p_dictionary = {}
        p_dictionary[p] = i + 1
        s_dictionary[s] = p_dictionary

s_list = sorted(s_dictionary.keys())
for k_s in s_list:
    p_dictionary = s_dictionary[k_s]
    p_list = sorted(p_dictionary.keys())
    for k_p in reversed(p_list):
        print(p_dictionary[k_p])

Solution (Python):
N = int(input())
SP = [list(map(str, input().split())) for _ in range(N)]
SP2 = [[0] * 2 for i in range(N)]
for i in range(N):
    SP2[i][0] = SP[i][0]
    SP2[i][1] = int(SP[i][1])
    SP[i][1] = int(SP[i][1])
SP2.sort(key=lambda x:(x[0],-x[1]))
for i in range(N):
    print(SP.index(SP2[i]) + 1)

Solution (Python):
def main():
    N = int(input())
    ans = []

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

    ans.sort(reverse=True)  
    ans.sort(key=lambda x: x[1])  

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


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())


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

Solution (Python):
def main():
    n = int(input())
    restaurants = []

    for _ in range(n):
        city, point = input().split()
        restaurants.append((city, int(point)))
    
    for r in sorted(range(1, 1 + n), key=lambda i: (restaurants[i-1][0], -restaurants[i-1][1])):
        print(r)

main()

Solution (Python):

import sys


def solve(N: int, S: "List[str]", P: "List[int]"):
    SP =[]
    for i in range(N):
        SP.append([S[i],P[i]])

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

    

    ans = []
    for x in t:
        for j in range(N):
            x1,x2 = x
            if(x1 == S[j] and x2 == P[j]):
                ans.append(j+1)


    for i in ans:
        print(i)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = [str()] * (N)  
    P = [int()] * (N)  
    for i in range(N):
        S[i] = next(tokens)
        P[i] = int(next(tokens))
    solve(N, S, P)

if __name__ == '__main__':
    main()

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

Solution (Python):

"""
Created on Sun May 26 21:06:51 2019

@author: aono
"""

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

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

info.sort(key=lambda x: x[1])
info.reverse()
info.sort(key=lambda x: x[0])

for i in range(len(info)):
    print(info[i][2] + 1)

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

Solution (Python):
N = int(input())
S_P = []
for i in range(N):
    S , P = input().split()
    S_P.append([ S , int(P) , i])
S_P.sort( key = lambda x : x[0] )
state = S_P[0][0]
S_P_sort = []
temp = []
for S , P , i in S_P:
    if S != state:
        temp.sort( key = lambda x : x[1] , reverse = True)
        S_P_sort.extend(temp)
        state = S
        temp = []
        temp.append([S , P, i])
    else:
        temp.append([S , P, i])
temp.sort( key = lambda x : x[1] , reverse = True)
S_P_sort.extend(temp)
for j in range(N):
    print(S_P_sort[j][2]+1)

Solution (Python):
N=int(input())
c=[]
for i in range(N):
    city,point=input().split()
    c.append([city,int(point),i+1])
    c.sort(key=lambda c:c[1],reverse=True)
    c.sort(key=lambda c:c[0])
for i in range(N):
    c[i].append(i)
c.sort(key=lambda c:c[3])
for i in range(N):
    print(c[i][2])

Solution (Python):
N = int(input())
SP = [[i, [_ for _ in input().split()]] for i in range(1, N + 1)]

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

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

Solution (Python):
from operator import attrgetter

class Rest:
    def __init__(self, city, point, index):
        self.city = city
        self.point = point
        self.index = index + 1


def main():
    N = int(input())
    restList = []
    for index in range(N):
        SP = input().split()
        city = SP[0]
        point = int(SP[1])
        restList.append(Rest(city, point, index))

    restList = sorted(restList, key=attrgetter("city"))
    citylistlist = []
    dummylist = [Rest("dummydummydummy",0,1000)]
    citylistlist.append(dummylist)
    for rest in restList:
        if citylistlist[-1][-1].city == rest.city:
            citylistlist[-1].append(rest)
        else:
            citylistlist.append([rest])
    citylistlist.pop(0)


    truelist = []
    for lis in citylistlist:
        truelist = truelist + sorted(lis, key=attrgetter("point"), reverse=True)

    for rest in truelist:
        print(rest.index)



main()

Solution (Python):
n = int(input())
sp = [input().split() for _ in range(n)]
ans = []
for i in range(len(sp)):
    ans.append([i, sp[i][0], int(sp[i][1])])
ans = sorted(ans, key=lambda x: (x[1], -x[2]))
for i in range(len(ans)):
    print(ans[i][0] + 1)

Solution (Python):
n=int(input())
hoge=[]
for i in range(n):
  a,b=map(str,input().split())
  c=int(b)
  hoge.append([a,c,i+1])
hoge=sorted(hoge,key=lambda x:(x[1]),reverse=True)
hoge=sorted(hoge,key=lambda x:(x[0]),reverse=False)
for i in range(n):
  print(hoge[i][2])

Solution (Python):
source = []
for i in range(int(input())):
    name, score = input().split(" ")
    source.append([i+1, name, 100-int(score)])
[print(i[0]) for i in sorted(source, key=lambda x: (x[1], x[2]))]

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

S = []
for i in range(N):
    S.append(list(map(str,input().split())))

B = []
for i in range(N):
    B.append([int(S[i][1]),S[i][0],i+1])

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

for c in C:
    print(c[2])

Solution (Python):
n = int(input())
lis = []
li = []
l = []
cou = 0
for i in range(n):
  a,b = map(str,input().split())
  if a not in li:
    lis.append([[int(b),i+1]])
    li.append(a)
    l.append([a,cou])
    cou += 1
  else:
    lis[li.index(a)].append([int(b),i+1])
l.sort()
for i in range(len(l)):
  lis[l[i][1]].sort(reverse=True)
  for num,nu in lis[l[i][1]]:
    print(int(nu))

Solution (Python):
N=int(input())
SP=[[0 for i in range(3)] for j in range(N)]
for x in range(N):
    SP[x][0],SP[x][1]= input().split()
    SP[x][1] =int(SP[x][1])
    SP[x][2]=x+1

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

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