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


def solve(N: int, S: "List[str]", P: "List[int]"):
    sps = list(zip(S, P))
    inds = sorted(range(N), key=lambda i: (sps[i][0], -sps[i][1]))
    for i in inds:
        print(i+1)
    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())
R = []
for i in range(N):
    s, p = map(str, input().split())
    R.append([i+1, s, int(p)])
R.sort(key=lambda x:x[2], reverse=True)
R.sort(key=lambda x:x[1])
for r in R:
    print(r[0])

Solution (Python):
N=int(input())
SP = [input().split() for _ in [0]*N]
for i,sp in enumerate(SP):
    SP[i][1] = int(sp[1])
    SP[i].append(i+1)
SP.sort(key=lambda x:(x[0],-x[1]))
for _,_,o in SP:
    print(o)

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

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

Solution (Python):
from collections import defaultdict

def read_input():
    n = int(input())

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

    return n, res


def submit():
    n, res = read_input()

    cities = defaultdict(list)

    for i, r in enumerate(res):
        cities[r[0]].append((i, r[1]))

    cities = list(cities.items())
    cities.sort(key=lambda x:x[0])

    for c in cities:
        temp = c[1]
        temp.sort(key=lambda x:x[1], reverse=True)

        for t in temp:
            print(t[0] + 1)



if __name__ == '__main__':
    submit()

Solution (Python):
from collections import defaultdict

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

for i,k in sorted(d.items()):
    for j in sorted(k,reverse=True):
        print(j[1])

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

for city in sorted(sps.keys()):
  for p, i in sorted(sps[city], key=lambda x: -x[0]):
    print(i)

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

for i,s,p in SP:
  print(i+1)

Solution (Python):


def main():
    N = int(input())
    a = [input().split() for _ in range(N)]
    a = [(x, y, i+1) for (i, (x, y)) in enumerate(a)]
    a = sorted(a, key=lambda x: (x[0], -int(x[1])))
    
    for _, _, i in a:
        print(i)


if __name__ == '__main__':
    main()

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

Solution (Python):

import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, S: "List[str]", P: "List[int]"):
    return [v for _, _, v in sorted([(s, -p, i + 1) for i , (s, p) in enumerate(zip(S, P))])]


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))
    result = solve(N, S, P)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()

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

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

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

SP = []

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

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

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

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

f = lambda i,x: (x[0], -int(x[1]), i)
R = sorted(f(i,input().split()) for i in range(N))

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

Solution (Python):
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

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

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

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



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

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, SP):
    SP = [(i+1, s, int(p)) for i, (s, p) in enumerate(SP)]
    SP.sort(key=lambda x: x[2], reverse=True)
    SP.sort(key=lambda x: x[1])

    for i, _, _ in SP:
        print(i)


def main():
    N = read_int()
    SP = [read_str_n() for _ in range(N)]
    slv(N, SP)


if __name__ == '__main__':
    main()

Solution (Python):
N = input()
N = int(N)
rest = []
for i in range(N):
    a,b = input().split(" ")
    b = int(b)
    rest.append([a,b,i+1])
rest.sort(key=lambda x: (x[0], -x[1]),reverse=False)
for i in range(N):
    print(rest[i][2])

Solution (Python):
def inpl(): return list(map(int, input().split()))

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

Solution (Python):
n = int(input())
rst = []
for i in range(n):
    s = input().split(' ')
    rst.append((s[0], -int(s[1]), i + 1))

rst.sort()

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

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

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

S_P_I = sorted(S_P_I, key=lambda spi: spi[1], reverse=True)
S_P_I = sorted(S_P_I, key=lambda spi: spi[0])

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

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

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

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

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

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

SP = [list(input().split()) for _ in range(N)]

iSP = [(i, (Si, int(Pi))) for i, (Si, Pi) in enumerate(SP)]

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

for i, (Si, Pi) in iSP:
    print(i + 1)

Solution (Python):
n = input()

l = []
for _ in xrange(n):
    s, p = raw_input().strip().split()
    p = int(p)
    l.append([s, -p, _ + 1])

l.sort()

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

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

Solution (Python):
N = input()
S = [""]*N
P = [0]*N
for i in range(N):
  S[i], P[i] = raw_input().split()
  P[i] = int(P[i])

for _, _, i in sorted((S[i], -P[i], i) for i in range(N)):
  print i+1

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

r.sort()
for _, _, i in r:
    print(i + 1)

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

restaurants.sort()
for _, _, i in restaurants:
    print(i + 1)

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

cities = []

for i in range(n):
    a, b = input().split()
    cities.append((a, -int(b), i + 1))
cities.sort()
for v in cities:
    print(v[-1])

Solution (Python):
n=int(input())
rest=[]
for i in range(n):
    list=input().split(" ")
    name=list[0]
    point=int(list[1])
    rest.append([name, 100-point, i])

rest=sorted(rest)

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

Solution (Python):
from collections import defaultdict
N = int(input())
D = defaultdict(list)
d = set()
P = {}
for i in range(N):
    s, p = input().split()
    p = int(p)
    D[s].append(p)
    d.add(s)
    P[p] = i

d = sorted(list(d))
for i in d:
    k = sorted(D[i], reverse=True)
    for j in k:
        print(P[j] + 1)

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

for s, v, c in sorted(r):
    print(c)

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

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

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

for item in r:
	print(item[0]+1)

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

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

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

Solution (Python):
from operator import itemgetter

n = int(input())
info = []
for i in range(n):
    a, b = input().split()
    info.append([a, int(b), i])

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

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

Solution (Python):
def main():
    n = int(input())
    pairs = []
    for i in range(n):
        s, p0 = input().split()
        pairs.append((i + 1, s, int(p0)))
    pairs.sort(key=lambda q: (q[1], -q[2]))
    for i, _, _ in pairs:
        print(i)


if __name__ == "__main__":
    main()

Solution (Python):


import itertools
from collections import Counter
from collections import defaultdict
import bisect

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

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


if __name__ == '__main__':
    main()

Solution (Python):







import math, itertools, operator
from math import *
from math import factorial as fact
from operator import itemgetter, attrgetter
from itertools import permutations, combinations
from functools import reduce


from fractions import gcd

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))



N = int(input())

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

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

Solution (Python):
from operator import itemgetter
N=int(input())
table=[]
for i in range(N):
    s,p=input().split()
    table.append((s,int(p),i+1))
C=sorted(table,key=itemgetter(1),reverse=True)
D=sorted(C,key=itemgetter(0))

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

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

rest = [None for _ in range(N)]

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


rest.sort()

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

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

l = []
for i in range(N):
    s,p=input().split()
    p=int(p)
    l.append([s,p,i])
    
l=sorted(sorted(l,key=lambda x:x[1],reverse=True),key=lambda x:x[0])

for a in l:
    print(a[2]+1)

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

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

Solution (Python):
import sys
range = xrange
input = raw_input

n = int(input())
pairs = []
for _ in range(n):
     a,b = input().split()
     b = -int(b)
     pairs.append((a,b))

order = sorted(range(n), key = lambda i:pairs[i])

print '\n'.join(str(x+1) for x in order)

Solution (Python):
n=int(input())
d={}
for i in range(n):
     s,p=input().split()
     try:
          d[s][int(p)]=i+1
     except:
          d[s]={int(p):i+1}
k=sorted(d.keys())
for x in k:
     d_=d[x]
     k_=sorted(d_.keys())[::-1]
     for y in k_:
          print(d_[y])

Solution (Python):
from operator import itemgetter

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

A = sorted(A, key=itemgetter(0, 1))
for s, p, i in A:
    print(i)

Solution (Python):

n = int(input())
city = []
point = []
for i in range(n):
    c,p = map(str,input().split())
    p = -1*int(p)
    city.append([c,p,i+1])
    point.append([p,c,i+1])
city.sort()
point.sort()
for i in range(n):
    print(city[i][2])

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

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

list.sort()

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

Solution (Python):

import sys


def solve(N: int, S: "List[str]", P: "List[int]"):
    p = []
    for i in range(N):
        p.append([S[i], -P[i], i + 1])
    
    p.sort()
    for x in p:
        print(x[2])
    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):


from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict
import math


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    ret = math.factorial(x)
    ret = ret // (math.factorial(x - y) * math.factorial(y))

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)





def main():
    n = intin()
    splist = [input() for _ in range(n)]

    spplist = []
    for i, sp in enumerate(splist):
        spplist.append((sp.split()[0], -int(sp.split()[1]), int(sp.split()[1]), i+1))

    spplist.sort()

    for s, _, p, i in spplist:
        print(i)


if __name__ == '__main__':
    main()

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

Solution (Python):
from operator import itemgetter

n = int(input())

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

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

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

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

Solution (Python):



def solve():
    n = int(input())
    l = []
    for i in range(n):
        s, p = input().split()
        l.append((s, int(p), i + 1))
    l.sort(key=lambda x: (x[0], -x[1]))
    print('\n'.join(str(e[2]) for e in l))

if __name__=="__main__":
    solve()

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

SP = []

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

SP.sort()

for s,p,i in SP:
    print(i+1)

Solution (Python):
from collections import defaultdict
from heapq import heappush, heappop, heapify, heapreplace

class Solution:
    def main(self):
        N = int(input())
        sp = []
        for i in range(N):
            s, p = input().split()
            p = int(p)
            sp.append((s, p, i+1))

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

        for i in range(len(sp)):
            s, p, idx = sp[i]
            print(idx)


if __name__ == '__main__':
    Solution().main()

Solution (Python):
N=int(input())
A=[]
for i in range(N):
    a,b=map(str,input().split())
    A.append([a,100-int(b),i+1])
A.sort()
for i in range(N):
    print(A[i][2])

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

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

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

Solution (Python):
def getN():
    return int(input())

def getMN():
    return list(map(int, input().split()))

def getlist():
    return list(map(int, input().split()))

n = getN()

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

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

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

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

s = [input().split() + [i + 1] for i in range(n)]

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

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

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

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

sps = sorted(sps)

for _, _, n in sps:
    print(n)

Solution (Python):


from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
ls = []
for i in range(N):
    S1, p = raw_input().split()
    p = int(p)
    ls += [(S1, -p, i)]
ls.sort()
ans = [0] * N
for i in range(N):
    S, p, pos = ls[i]
    ans[i] = pos + 1
for num in ans:
    print num

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

X = sorted(X)
for x in X:
    print(x[2])

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

R.sort(key= lambda x: (x[0], -x[1]))
for s, p, i in R:
    print(i + 1)

Solution (Python):
N=int(input())
A=[]
for _ in range(N):
    s,n=input().strip().split(" ")
    n=int(n)
    A+=[(s,-n,_+1)]
A=sorted(A)
for X in A:
    print(X[2])

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

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

S = sorted(S,key=lambda x:x[1],reverse=1)
S = sorted(S,key=lambda x:x[0])



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

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

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

restaurants = sorted(restaurants)

for restaurant in restaurants:
	print(restaurant[2])

Solution (Python):


import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIT = lambda: tuple(MI())
MIS = lambda: input().split()


def main():
    N = II()
    sp = [None] * N
    for i in range(N):
        s, p = MIS()
        sp[i] = (s, -int(p))
    for k in sorted(range(N), key = lambda i: sp[i]):
        print(k + 1)


if __name__ == "__main__":
    main()

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

l.sort(key=lambda x: [x[0], -x[1]])
for s, p, i in l:
    print(i)

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

SPs.sort()

for S, P, i in SPs:
    print(i)

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

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

for s, p, i in items:
    print(i+1)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    a,p = LI()
    print((a*3+p)//2)
    return


def B():
    n = I()
    s = [None for i in range(n)]
    for i in range(n):
        l = input().split()
        s[i] = l+[i]
    s.sort(key = lambda x:(x[0],-int(x[1])))
    for i,a,b in s:
        print(b+1)
    return


def C():
    n = I()

    return


def D():
    n = I()

    return


def E():
    n = I()

    return


def F():
    n = I()

    return


if __name__ == "__main__":
    B()

Solution (Python):
n = int(input())
mise = []
for i in range(n):
    name, rate = [item for item in input().split()]
    mise.append([name, -int(rate), i+1])

mise.sort()
for mise, rate, index in mise:
    print(index)

Solution (Python):


n = int(input())
a=[]
for j in range(n):
    m=[i for i in input().split()]
    mm = [m[0]]+[-int(m[1])]+[j+1]
    a.append(mm)
    
a.sort()

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

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

Solution (Python):


import sys
import math
import collections

N, = map(int, sys.stdin.readline().rstrip().split(" "))
restaurants = []
for i in range(N):
    S,P = sys.stdin.readline().rstrip().split(" ")
    P = int(P)
    restaurants.append((S, -P, i+1))
restaurants.sort()
for S, IP, i in restaurants:
    print(i)

exit(0)

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

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

Solution (Python):
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]





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

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

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

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

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

Solution (Python):

def main():
    n = input()
    sp = []
    for i in xrange(n):
        s, p = raw_input().split()
        sp.append([s, -int(p), i + 1])
    sp.sort()
    for _, _, i in sp:
        print i


if __name__ == '__main__':
    main()

Solution (Python):

def main():
    buf = input()
    N = int(buf)
    SP = []
    for i in range(N):
        buf = input()
        buflist = buf.split()
        SP.append((buflist[0], -int(buflist[1]), i+1))
    SP = list(sorted(SP))
    for x in SP:
        print(x[2])

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
S, P = (
    zip(*(
        (s, -int(p))
        for s, p in (input().split() for _ in range(N))
    )) if N else
    ((), ())
)

ans = '\n'.join(
    str(i)
    for _, _, i in sorted(zip(S, P, range(1, N + 1)))
)

print(ans)

Solution (Python):
import sys
input=sys.stdin.readline
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())
 
def ss_raw():
    return input().split()
 
def ints_raw():
    return tuple(map(int, ss_raw()))

def main():
    N = int(input())
    ress= []
    for idx in range(N):
        a,x = ss_raw()
        ress.append([a,-int(x),idx])
    ress.sort()
    for res in ress:
        print (res[2]+1)

main()

Solution (Python):
import sys
from collections import deque
from collections import defaultdict
import math
sys.setrecursionlimit(20000000)


n = int(input())
a = []
for i in range(n):
        x,y = input().split()
        a.append([x,int(y),i+1])
a.sort(key=lambda x : (x[0],-x[1]))
for i,j,k in a:
        print(k)