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):
n=int(input())
array1=[[i+1]+input().split() for i in range(n)]
array1.sort(key=lambda x:(x[1],-int(x[2])))
for a,b,c in array1:
            print(a)

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

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

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

    def __lt__(self, other):
        if (self.city != other.city):
            return self.city < other.city
        else:
            return self.score > other.score


n = int(input())
restaurants = list()
for i in range(n):
    tmp = input().split()
    c = tmp[0]
    s = int(tmp[1])
    restaurants.append(Restaurant(i + 1, c, s))

restaurants.sort()

for r in restaurants:
    print(r.id)

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

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

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

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

SP.sort(key=lambda x: (x[0], -x[1]))
num = list(zip(*SP))[-1]
for i in num:
    print(i)

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

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

s = {}
for i in range(n):
    tmp, temp = input().split()
    if tmp not in s.keys():
        s[tmp] = [(i, int(temp))]
    else:
        s[tmp] += [(i, int(temp))]
    
    
s = sorted(s.items(), key=lambda x:x[0])

for i in s:
    a = sorted(i[1], key=lambda x:x[1], reverse=True)
    for j in a:
        print(j[0] + 1)

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

sp = []
for i in range(n):
    s, p = map(str, input().split())
    sp.append([s, int(p), i + 1])
    
sp.sort(key=lambda x:x[1], reverse=True)
sp.sort(key=lambda x:x[0])

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

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

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

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

sorted_d = sorted(d.items(), key=lambda x: x[0])
for s, pi in sorted_d:
    if len(pi) == 1:
        print(pi[0][1])
    else:
        pi.sort(key=lambda x: x[0], reverse=True)
        for p, i in pi:
            print(i)

Solution (Python):
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    ret = []
    for n in range(N):
        S, P = sl()
        ret.append([S, int(P), n + 1])
    ret.sort(key=lambda List: (List[0], -List[1]))
    for s, p, n in ret: print(n)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input().strip())
res = []
for i in range(1, n + 1):
    res.append(input().strip().split() + [i])
    res[-1][1] = int(res[-1][1])
    
res.sort(key=lambda s: (s[0], -s[1]))
for i in res:
    print(i[-1])

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

data=[list(map(str,input().split())) for _ in range(n)]

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

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

Solution (Python):
n = int(input())
dic = []
for i in range(n):
    inp = input().split()
    dic.append([inp[0], 100-int(inp[1]), i+1])
    temp = ''
    for j in range(10):
        try:
            temp += str(ord(dic[i][0][j])-80)
        except:
            temp += '00'
    dic[i][0] = int(temp)
dic = sorted(dic)
for i in range(n):
    print(dic[i][2])

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

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

for x in sorted(ans):
    print(x[-1])

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

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

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

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

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

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

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

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

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

d = dict()
l = list()
c = list()
for i in range(n):
    s, p = input().split()
    p = int(p)
    c.append([s, p, i+1])
    d[p] = [s, i+1]
p_sort = sorted(d)

for i in p_sort:
    l.append([d[i][0], i, d[i][1]])

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

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

Solution (Python):
n = int(input())
a = []
for i in range(1, n+1):
    s,p = map(str,input().split())
    a.append((s,int(p),i))
a.sort()
ans = [a[0][2]]
k = 0
for i in range(1,n):
    if a[i-1][0] == a[i][0]:
        ans.insert(k,a[i][2])
    else:
        k = i
        ans.append(a[i][2])

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

Solution (Python):
from operator import itemgetter
N = int(input())

lst = []
for i in range(N):
  dic = {}
  dic_i = {}
  s, p = map(str, input().split())
  dic['city'] = s
  dic['point'] = int(p)
  dic['index'] = i+1
  lst.append(dic)

a = sorted(lst, key=itemgetter('point'), reverse=True)
b = sorted(a, key=itemgetter('city'))

for i in b:
  print(i['index'])

Solution (Python):
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])

Solution (Python):
N = int(input())
array = []
for x in range(N):
    S, P = input().split()
    array.append([x + 1, S, int(P)])
sort_array = sorted(array, key=lambda x: (x[1], -x[2]))

for y in sort_array:
    print(y[0])

Solution (Python):
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])

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
l = []
for i in range(n):
    tmp = isl()
    tmp.append(i+1)
    l.append(tmp)

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

l = sorted(l,key=lambda x:x[0])
for j in l:
    print(j[2])

Solution (Python):
from operator import itemgetter

N = int(input())

table = []
for i in range(N):
    value = list(input().split())
    value[1] = int(value[1])
    value.append(str(i + 1))
    table.append(value)

point_sort = sorted(table, key=itemgetter(1), reverse=True)
alphabet_sort = sorted(point_sort, key=itemgetter(0))

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

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

Solution (Python):
N = int(input())
L = []
for i in range(N):
  x = input().split()
  S = x[0]
  P = int(x[1])
  T = "n"
  for y in L:
    if S == y[0]:
        T = "y"
        y[1].append([P,i+1])
  if T == "n":
    L.append( [ S, [[P,i+1]] ] )

K = sorted(L)
for x in K:
  y = sorted(x[1],reverse=True)
  for a in y:
    print(a[1])

Solution (Python):
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])

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

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

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

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

SP.sort()

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

Solution (Python):
n = int(input())
t = []
for i in range(n):
	s,p = map(str,input().split())
	t.append([s,int(p)])
a = list(enumerate(t))
a = sorted(a,key=lambda x: x[1][1],reverse=True)
a = sorted(a,key=lambda x: x[1][0])
for i in a:
	print (i[0]+1)

Solution (Python):
N = int(input())
sp = [list(input().split())+[i] for i in range(N)]

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

sp.sort()

for _,_,i in sp:
  print(i+1)

Solution (Python):
N = int(input())
sp = [list(input().split())+[i] for i in range(N)]

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

sp.sort()

for _,_,i in sp:
  print(i+1)

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

s=sorted(s)

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

Solution (Python):

from collections import defaultdict

n = int(input())

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


ks = sorted(d.keys())
for k in ks:
    vs = d[k]
    score_d = {}
    for v in vs:
        score_d[v[0]] = v[1]

    score_keys = sorted(score_d.keys(), reverse=True)
    for sk in score_keys:
        print(score_d[sk])

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

Solution (Python):
n,*l=open(0).read().split()
print(*sorted(range(1,int(n)+1),key=lambda i:(l[~-i*2],-int(l[~-i*2+1]))))

Solution (Python):
_,*l=open(0).read().split()
print(*sorted(range(1,len(l)//2+1),key=lambda i:(l[~-i*2],-int(l[~-i*2+1]))))

Solution (Python):
_,*l=open(0).read().split()
[print(i + 1)for i in sorted(range(len(l)//2),key=lambda i:(l[i*2],-int(l[i*2+1])))]

Solution (Python):
from operator import itemgetter

N=int(input())
A=[0]*N
for i in range(N):
    A[i]=input().split()

i=0
while i<N:
    A[i][1]=int(A[i][1])
    i+=1

i=0
while i<N:
    A[i]=tuple(A[i])
    i+=1

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

for i in B2:
    print(A.index(i)+1)

Solution (Python):
n=int(input())
a=[list(input().split())+[i] for i in range(n)]
for i in range(n):
  a[i][1]=-int(a[i][1])
a.sort()
for _,_,i in a:
  print(i+1)

Solution (Python):
from operator import itemgetter
import sys
input = sys.stdin.readline

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

n=I()
eva=[]
for i in range(n):
    eva.append(input().rstrip().split(" "))
for i in range(n):
    eva[i][1]=int(eva[i][1])

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

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

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

Solution (Python):
from functools import cmp_to_key

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


def cmp(a, b):
    if a[0] == b[0]:
        if int(a[1]) == int(b[1]): return 0
        return 1 if int(a[1]) <= int(b[1]) else -1
    return -1 if a[0] <= b[0] else 1

def cmpstr(a, b):
    return cmp(a, b)

sorted_SN = sorted(SN, key=cmp_to_key(cmpstr))

answer = "\n".join([str(sorted_SNi[2]) for sorted_SNi in sorted_SN])

print(answer)

Solution (Python):
n = int(input())
city_point = []
for i in range(n):
    s,p = input().split()
    city_point.append([s,-int(p),i])
city_point = sorted(city_point)

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

Solution (Python):
N = int(input())
L = []
D = {}
for _ in range(N):
  k, v = input().split()
  v = int(v)
  L.append((k, v))
  if k not in D.keys():
    D[k] = [v]
  else:
    D[k].append(v)

for v in D.values():
  v.sort(reverse=True)
D = sorted(D.items(), key=lambda x: x[0])

for d in D:
  for i in range(len(d[1])):
    print(L.index((d[0], d[1][i]))+1)

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

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

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

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

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

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

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

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

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

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
SP = [sr().split() for _ in range(N)]
SP = [(s, 100 - int(p), i) for i, (s, p) in enumerate(SP, 1)]
SP.sort(key=lambda x: (x[0], x[1]))
for s, p, i in SP:
    print(i)

Solution (Python):
N = int(input())
L = []
for i in range(N):
  S, P = map(str, input().split())
  tmp = 100 - int(P)
  s1, s2, s3 = (tmp // 100) % 10, (tmp // 10) % 10, (tmp // 1) % 10
  s1, s2, s3 = str(s1), str(s2), str(s3)
  tmp2 = i + 1
  t1, t2, t3 = (tmp2 // 100) % 10, (tmp2 // 10) % 10, (tmp2 // 1) % 10
  t1, t2, t3 = str(t1), str(t2), str(t3)
  S = S[:] + s1 + s2 + s3 + t1 + t2 + t3
  L.append(S)
L.sort()
for i in range(N):
  tmp3 = 0
  base = 1
  for j in range(3):
    tmp3 += base * int(L[i][-j-1])
    base *= 10
  print(tmp3)

Solution (Python):
n = int(input())
Lists = [list(input().split())+[i+1] for i in range(n)]
SP = [[s, -int(p), i] for s, p, i in Lists]
SP.sort(key=lambda x: (x[0], x[1]))
for p, q, r in SP:
  print(r)

Solution (Python):
a = int(input())
ans_list = []
for i in range(a):
    city,point = input().split()
    ans_list.append((city, -int(point),i+1))
ans_list.sort(key = lambda x:(x[0],x[1]))
    
for xs in ans_list:
    print(xs[2])

Solution (Python):
import sys







from operator import attrgetter, itemgetter






readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    spi = []

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

    spi.sort(key=itemgetter(0,1))

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

if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input()) 

restaurants = []
for i in range(n):
    s, p = 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 restaurants:
    print(i)

Solution (Python):
def q2():
    N = int(input())
    T = []
    for n in range(N):
        s, p = (i for i in input().split())
        T.append({'n': n+1, 's': s, 'p': int(p)})
    T = sorted(T, key=lambda x: x['p'], reverse=True)
    T = sorted(T, key=lambda x: x['s'])

    for t in T:
        print(t['n'])


if __name__ == '__main__':
    q2()

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

Solution (Python):

import sys
input = sys.stdin.readline










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)

Solution (Python):
import sys

input = sys.stdin.readline


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


if __name__ == "__main__":
    main()

Solution (Python):


from collections import defaultdict
N = int(input())
S = [0]*N
P = [[0]*2 for _ in range(N)]
d = defaultdict(lambda :[])
for i in range(N):
    tmp = input().split()
    d[tmp[0]].append([int(tmp[1]),i+1])

key = sorted(dict(d))
for k in key:
    tmp = sorted(d[k],reverse = True)
    for t in tmp:
        print(t[1])

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

Solution (Python):

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

sp.sort()

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

Solution (Python):

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

sp.sort()

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

"""
from operator import itemgetter

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

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

l.sort(key = itemgetter(0))
l = sorted(l, key = lambda x:(x[1]),reverse = True)
print(l)
"""

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

sp.sort()

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

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    n = int(input())
    R = {}
    for i in range(1, n+1):
        s, p = input().split()
        p = int(p)
        if not s in R.keys():
            R[s] = [(i, p)]
        else:
            R[s].append((i, p))
    index = sorted(R)
    for idx in index:
        ids = R[idx]
        ids.sort(key=lambda x: x[1])
        for i in reversed(ids):
            print(i[0])

if __name__ == '__main__':
    main()

Solution (Python):


import sys













def main():
    mod = 10000007                  
    inf = float('inf')
    input = sys.stdin.readline      
    sys.setrecursionlimit(10**6)    
    def ii():  return int(input())
    def mi():  return map(int, input().rstrip().split())
    def lmi(): return list(map(int, input().rstrip().split()))
    def li():  return list(input().rstrip())
    
    
    n = ii()
    L = []
    for i in range(n):
        line = input().lstrip().split()
        line[1] = int(line[1])
        line.append(i+1)
        L.append(line)
    L.sort(key=lambda x: x[1], reverse=True)
    L.sort(key=lambda x: x[0])
    for elm in L:
        print(elm[2])


if __name__ == "__main__":
    main()

Solution (Python):


import sys













def main():
    mod = 10000007                  
    inf = float('inf')
    input = sys.stdin.readline      
    sys.setrecursionlimit(10**6)    
    def ii():  return int(input())
    def mi():  return map(int, input().rstrip().split())
    def lmi(): return list(map(int, input().rstrip().split()))
    def li():  return list(input().rstrip())
    
    
    n = ii()
    L = []
    for i in range(n):
        line = input().lstrip().split()
        line[1] = int(line[1])
        line.append(i+1)
        L.append(line)
    L.sort(key=lambda x: x[1], reverse=True)
    L.sort(key=lambda x: x[0])
    for elm in L:
        print(elm[2])


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
s=[list(map(str,input().split())) for i in range(n)]
for i in range(n):
  s[i][1]=int('-'+s[i][1])
  s[i].append(i+1)
s=sorted(s)
for i in range(n):
  print(s[i][2])

Solution (Python):

from operator import itemgetter
n = int(input())
sp=[]
for i in range(n):
    s,p=map(str,input().split())
    sp.append([s, int(p), i + 1])





sp.sort(key=itemgetter(1), reverse=True)
sp.sort(key=itemgetter(0))

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

Solution (Python):
N, = map(int, input().split())
rs = []
for i in range(N):
    s, a = input().split()
    a = int(a)
    rs.append((i+1, s, -a))
rs.sort(key=lambda x : (x[1], x[2]))
for i, s, a in rs:
    print(i)

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

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



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

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

Solution (Python):
N = int(input())
dict = {}
for i in range(1, N+1):
    S, P_str = tuple(input().split())
    P = int(P_str)
    try:
        dict[S].append((P, i))
    except:
        dict[S] = [(P, i)]

items = sorted(dict.items())
for city, info in items:
    for p, n in sorted(info, reverse=True):
        print(n)

Solution (Python):
N=int(input())
restaulant=[]
for i in range(N):
    restaulant.append(input().split())
    restaulant[i][1]=-1*int(restaulant[i][1])
sorted_rest=sorted(restaulant)
for i in sorted_rest:
    for j in range(N):
        if i==restaulant[j]:
            print(j+1)

Solution (Python):
n = int(input())
restaulant = []
for i in range(n): restaulant.append(input().split())
for i in range(n): restaulant[i][1] = -1 * int(restaulant[i][1])

sorted_rest = sorted(restaulant)
for i in sorted_rest:
    for j in range(n):
        if i == restaulant[j]: print(j+1)

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

sp = []

for i in range(n):
    tmp = list(map(str,input().split()))
    tmp.append(i+1)
    sp.append(tmp)

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

num = 0
while num < n:
    string = sp[num][0]
    l = []
    l.append(sp[num][2])
    while True:
        num += 1
        if num > n-1:
            break
        if sp[num][0] == string:
            l.append(sp[num][2])
        else:
            break

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

Solution (Python):
from operator import itemgetter

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

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

sp = sorted(sp, key=itemgetter(1), reverse=True)
sp = sorted(sp, key=itemgetter(0))

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

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

def resolve():
    N = int(input())
    SP = [input().split() for _ in range(N)]

    SP = enumerate(SP)
    SP = sorted(SP, key=lambda x: (x[1][0], -int(x[1][1])))
    for i in SP:
        print(i[0]+1)    

if __name__ == '__main__':
    resolve()

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


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

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

Solution (Python):
from operator import itemgetter

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

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

dictionary.sort(key=itemgetter(1, 2))

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

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

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

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

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

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

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

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

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

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    sp=[]
    for i in range(n):
        s,p=STRM()
        sp.append([s,int(p),i+1])
    sorted_sp1=sorted(sp, key=lambda x:x[1], reverse=True)
    sorted_sp2=sorted(sorted_sp1, key=lambda x:x[0])
    for i in range(n):
        print(sorted_sp2[i][2])
    
if __name__ == '__main__':
    do()

Solution (Python):
N = int(input())
Book = [0] * N
for i in range(N):
    s,q = input().split()
    p = int(q)
    Book[i] = (s, 100-p, i)

Book.sort()

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

Solution (Python):
from operator import itemgetter
n = int(input())
SP = []
for i in range(1, n+1):
    s, p = input().split()
    SP.append([i, s, -int(p)])
SP.sort(key=itemgetter(1, 2))
print(*map(itemgetter(0), SP), sep='\n')

Solution (Python):
from operator import itemgetter
n = int(input())
SP = []
for i in range(1, n+1):
    s, p = input().split()
    p = int(p)
    SP.append([i, s, -p])
SP.sort(key=itemgetter(1, 2))
print(*map(itemgetter(0), SP), sep='\n')

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

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

d = sorted(d,key = lambda x:x[1],reverse=True)
d = sorted(d,key = lambda x:x[0])
for D in d:
    print(D[2])

Solution (Python):

import math
import itertools
import statistics



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

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

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

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

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

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

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

lst = []

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




lst.sort()



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

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

for i in range(n):
    city, rate = map(str,input().split())
    rate = int(rate) * -1
    res.append([city,rate,i+1])
res.sort(key=lambda x: (x[0],x[1]))
for i in range(n):
    print(res[i][2])

Solution (Python):
N = int(input())
M = [input().split() for i in range(N)]
O = [M[j][0] for j in range(N)]
P = list(set(O))
P.sort()
Q = [int(M[k][1]) for k in range(N)]
Q.sort()
Q.reverse()
for l in P:
  for m in Q:
    R = [l, str(m)]
    if (R in M) == True:
      print(M.index(R) + 1)

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


lst.sort(key=lambda el:el[2], reverse=True)
lst.sort(key=lambda el:el[1])

for el in lst:
    print(el[0])

Solution (Python):
n = int(input())
sp = [[0]*3 for _ in range(n)]

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

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

Solution (Python):
N = int(input())
SP = [[0]*3 for i in range(N)]
for i in range(N):
    S,P = map(str,input().split())
    SP[i][0] = S
    SP[i][1] = int(P)*-1
    SP[i][2] = i+1
SP = sorted(SP)
for i in range(N):
	print(SP[i][2])

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
SP = [(x.split()[0].decode('utf-8'),int(x.split()[1])) for x in readlines()]

SP = sorted((name,-pt,i+1) for i,(name,pt) in enumerate(SP))

answer = '\n'.join(str(x[2]) for x in SP)
print(answer)

Solution (Python):
N = int(input())
l1 = [input().split() for i in range(N)]
for i in range(len(l1)):
    l1[i][1] = int(l1[i][1])
    l1[i].append(i+1)
l2 = l1
l2.sort(key=lambda x:(x[0],-x[1]))
for j in l2:
    print(j[2])

Solution (Python):
n = int(input())
l = list(list(input().split()) for i in range(n))
a = sorted(l)
for i in range(n):
  l[i][1]= -int(l[i][1])
a = sorted(l)
for i in range(n):
  l[i][1]= -int(l[i][1])
for q in a:
  print(l.index(q)+1)

Solution (Python):
N = int(input())
'''
SP = [list(input().split()) for _ in range(N)]

tmp = sorted(SP)

print(tmp)
'''

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

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

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