Problem:


Score : 200 points

Problem Statement

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

You want to introduce the restaurants in the following order:

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

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

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

Constraints

1 ≤ N ≤ 100

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

0 ≤ P_i ≤ 100

P_i is an integer.

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

Input

Input is given from Standard Input in the following format:

N
S_1 P_1
:
S_N P_N

Output

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

Sample Input 1

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

Sample Output 1

3
4
6
1
5
2

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

Sample Input 2

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

Sample Output 2

10
9
8
7
6
5
4
3
2
1



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


Sample output:
3
4
6
1
5
2

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
n=int(input())
a,b=[],[]
for i in range(n):
  s,p=input().split();p=int(p)
  if not s in a:a.append(s);b.append([s,[[p,i]]])
  else:b[a.index(s)][1].append([p,i])
b.sort()
for i in range(len(b)):
  b[i][1].sort(reverse=1)
  for j in b[i][1]:print(j[1]+1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  stores = [[i + 1] + list(input().split()) for i in range(int(input()))]
  stores = [(i, s.strip(), int(p)) for i, s, p in stores]
  stores.sort(key=lambda x: (x[1], -x[2]))

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


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
N = int(input())

out = [(i+1, ) + tuple([x for x in input().split(' ')]) for i in range(N)]
out.sort(key=lambda x : int(x[2]), reverse=True)
out.sort(key=lambda x : x[1])

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

Submission status: Accepted

Solution code:
import math

n = list(map(int, input().split()))
lista = []

for i in range(n[0]):
    a,m = list(map(str, input().split()))
    m = int(m)
    lista.append([a,m,i+1])

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

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

Submission status: Accepted

Solution code:
from operator import itemgetter

N = int(input())
SP = []
for i in range(N):
    Si, Pi = input().split(" ")
    SP.append([Si, int(Pi), i+1])
SP = sorted(SP, key=itemgetter(0, 1))
before = SP[0][0]
stack = []
for Si, Pi, i in SP:
    if before == Si:
        stack.append(i)
    else:
        for j in reversed(stack):
            print(j)
        stack = [i]
        before = Si
if len(stack) > 0:
    for j in reversed(stack):
        print(j)

Submission status: Accepted

Solution code:
n = int(input())

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

ss = sorted(list(set(sp.keys())))
for s in ss:
    for p, i in sorted(sp[s], reverse = True):
        print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n = get_int()
    S, P = get_data(n, [str, int])
    R = [(i+1, s, p) for i, (s, p) in enumerate(zip(S, P))]
    R.sort(key=lambda r: r[2], reverse=True)
    R.sort(key=lambda r: r[1])
    for i, s, p in R:
        print(i)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


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


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


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

N = int(input())

X = []
for i in range(N):
    s, p = input().rstrip().split(' ')
    p = int(p)
    X.append([i+1, s, p])
    
X = sorted(X, key=lambda x: '{}{:03d}'.format(x[1], 100-x[2]))

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

Submission status: Accepted

Solution code:
N = int(input())
I = [i+1 for i in range(N)]
S, P = [], []
for _ in range(N):
    inp = input().split()
    S.append(inp[0])
    P.append(int(inp[1]))

for i in range(N-1):
    for j in range(i+1, N):
        if S[i] > S[j] or (S[i] == S[j] and P[i] < P[j]):
            tmp = S[i]
            S[i] = S[j]
            S[j] = tmp
            tmp = P[i]
            P[i] = P[j]
            P[j] = tmp
            tmp = I[i]
            I[i] = I[j]
            I[j] = tmp

for i in I:
    print(i)

Submission status: Accepted

Solution code:
import itertools
N=int(input())
a = []
for i in range(N):
	s,b = input().split()
	a.append([s, int(b), i+1])
#a=[["b", 2,1], ["a", 3,2],["a", 1,3]]

a.sort(key=lambda x:x[0])
for k,g in itertools.groupby(a, key=lambda x:x[0]):
	g= list(g)
	g.sort(key=lambda x:x[1],reverse=True)
	for a in g:
		print(a[2])

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
def resolve():
    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[0], -x[1]))
    for l in L:
        print(l[2])
        
resolve()

Submission status: Accepted

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

    sort_with_score = sorted(data, key=lambda x: x[2], reverse=True)
    sort_with_name = sorted(sort_with_score, key=lambda x: x[1])

    for place in sort_with_name:
        print(place[0])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

class Restaurant():
    def __init__(self, i, name, point):
        self.i = i
        self.name = name
        self.point = point

def solve():
    N = int(input())
    restaurants = []
    for i in range(N):
        s, p = input().split()
        r = Restaurant(i, s, int(p))
        restaurants.append(r)
    
    sorted_restaurants = sorted(restaurants, key=lambda r: r.point, reverse=True)
    sorted_restaurants = sorted(sorted_restaurants, key=lambda r: r.name)

    for i in range(N):
        print(sorted_restaurants[i].i + 1)


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    SP = ii2ss(N)
    D = []
    for i, sp in enumerate(SP):
        s, p = sp.split(' ')
        p = int(p)
        D.append((i+1, s, p))
    D.sort(key=lambda v: v[2])
    D.reverse()
    D.sort(key=lambda v: v[1])
    for i, s, p in D:
        print(i)

main()

Submission status: Accepted

Solution code:
import sys  
input = sys.stdin.readline

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

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

for a, b, c in SP:
    print(a)

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
d = defaultdict(list)
city = set()
for i in range(N):
    S, P = input().split()
    P = int(P)
    d[S].append((P, i+1))
    city.add(S)

for s in d.keys():
    d[s].sort(reverse=True)

city = list(city)
city.sort()

for s in city:
    for p, i in d[s]:
        print(i)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
dic = defaultdict(list)
for i in range(N):
    S, P = input().split(" ")
    P = int(P)
    dic[S].append((P, i))

for c in sorted(dic.keys()):
    for v, i in sorted(dic[c], key=lambda x: x[0], reverse=True):
        print(i + 1)

Submission status: Accepted

Solution code:
from operator import itemgetter

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

Submission status: Accepted

Solution code:
from operator import itemgetter

N = int(input())

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

SP.sort(key=itemgetter(1), reverse=True)
SP.sort(key=itemgetter(0))
for sp in SP:
    print(sp[2])

Submission status: Accepted

Solution code:
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]

N = int(input())

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

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

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

Submission status: Accepted

Solution code:
ans = []
for i in range(1, int(input()) + 1):
    s, p = input().split()
    p = -int(p)
    ans.append([s, p, i])
ans.sort()
print(*list(zip(*ans))[2], sep="\n")

Submission status: Accepted

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

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

rest.sort()
for i in range(N):
  print(rest[i][2])

Submission status: Accepted

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


note.sort(key=lambda x:(x[1],-x[2]))
#print(note)

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

Submission status: Accepted

Solution code:
n = int(raw_input())

ans = []
for i in range(0, n):
    s, p = raw_input().split(" ")
    p = int(p)

    ans.append((s, p * -1, i + 1))

sort = sorted(ans)

for i in range(0, len(sort)):
    city, point, index = sort[i]
    print(index)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  N = readInts()[0]
  restaurants = []
  for i in range(N):
    S, P = input().split(" ")
    restaurants.append((S, int(P), i+1))
  restaurants.sort(key=lambda x: (x[0], -1 * x[1]))
  for _, _, n in restaurants:
    print(n)

if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
def li():
    return list(map(int, input().split()))


if __name__ == '__main__':
    n = int(input())
    sp = [input().split() for _ in range(n)]
    for index, spi in enumerate(sp):
        spi[1] = int(spi[1])
        spi.append(index + 1)

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

lis.sort()
for i in lis:
    print(i[-1])

Submission status: Accepted

Solution code:
import numpy as np
words = lambda t : list(map(t, input().split()))

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

cs = sorted(cs)
for (s,p,i) in cs:
    print(i)

Submission status: Accepted

Solution code:
N, = (int(x) for x in input().split())

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

I_arr = list(range(N))
I_arr.sort(key=lambda x: SP_arr[x][1], reverse=True)
I_arr.sort(key=lambda x: SP_arr[x][0])

for i in I_arr:
    print(i+1)

Submission status: Accepted

Solution code:
import sys
# gcd
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# fin = open('in_1.txt', 'r')
# sys.stdin = fin
# input = sys.stdin.readline
# 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())
# template


if __name__ == '__main__':

    # write code
    N = int(input())
    ans = []
    for i in range(N):
        S, P = input().split()
        # print(S, int(P))
        ans.append([i, S, int(P)])
    ans.sort(key=lambda x: x[2], reverse=True)
    ans.sort(key=lambda x: x[1])
    # print(ans)
    for i in range(N):
        print(ans[i][0]+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# # https://atcoder.jp/contests/abc128/abc128_b

N = int(input())
pairs = [input().split() for _ in range(N)]
pairs = [(a, int(b)) for a, b in pairs]
indices = list(range(N))
indices.sort(key=lambda idx: (pairs[idx][0], -pairs[idx][1]))
for idx in indices:
    print(idx + 1)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()

SP = [input().strip().split() for _ in range(N)]
# print(SP)
dic = defaultdict(str)
for i, (S, P) in enumerate(SP):
	# print(i, S, P)
	dic["{},{}".format(S, P)] = i+1
SP.sort(key=lambda x: (x[0], -int(x[1])))
for S, P in SP:
	print(dic["{},{}".format(S, P)])

Submission status: Accepted

Solution code:
import sys
INPUT = sys.stdin.readline

def SINGLE_INT(): return int(INPUT())
def MULTIPLE_INT_LIST(): return list(map(int, INPUT().split()))
def MULTIPLE_INT_MAP(): return map(int, INPUT().split())
def SINGLE_FLOAT(): return float(INPUT())
def MULTIPLE_FLOAT_LIST(): return list(map(float, INPUT().split()))
def MULTIPLE_FLOAT_MAP(): return map(float, INPUT().split())
def SINGLE_STRING(): return INPUT()
def MULTIPLE_STRING(): return INPUT().split()

N = SINGLE_INT()

ratings = []

for i in range(N):
    c, s = MULTIPLE_STRING()
    s_int = int(s)

    ratings.append((c, s_int, i+1))

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

for c, s_int, id in ratings:
    print(id)

Submission status: Accepted

Solution code:
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    N = int(single_input())
    point = dict()
    city = []
    for i in range(N):
        s, p = map(str, line_input())
        if s in point:
            point[s].append((int(p), i+1))
        else:
            point[s] = [(int(p), i+1)]
            city.append(s)
    city.sort()
    for s in city:
        l = point[s]
        l.sort(reverse = True)
        for p, i in l:
            print(i)
    return 0
  
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from collections import defaultdict



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

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

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    n = int(input())
    restaurants = defaultdict(list)
    for i in range(n):
        s, p = input().split()
        p = int(p)
        restaurants[s].append((p, i))
    for key, restaurant in restaurants.items():
        restaurants[key] = sorted(restaurant, reverse=True)
    list_ress = [(key, val) for key, val in restaurants.items()]
    for key, val in sorted(list_ress):
        for p, i in val:
            print(i+1)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

SP.sort()

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

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

def main():
  n=I()
  l=[]

  for i in range(n):
    a,b=LS()
    l.append([a,-int(b),i+1])

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

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

main()
# print(main())

Submission status: Accepted

Solution code:
from collections import Counter, deque, defaultdict
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

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

d = defaultdict(lambda: [])
for s, p in SP:
    d[s].append(int(p))

for s in sorted(d.keys()):
    d[s].sort(reverse=True)
    for p in d[s]:
        print(SP.index([s, str(p)]) + 1)

Submission status: Accepted

Solution code:
N=int(input())
info=[]
for i in range(N):
	name, p = input().split()
	p = int(p)
	info.append([i+1, name, p])

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

Submission status: Accepted

Solution code:
# from sys import exit
N = int(input())
NP = [0 for i in range(N)]
for i in range(N):
    NP[i] = [str(n) for n in input().split()]
    NP[i].append(i+1)
NP = sorted(NP, key=lambda x: -int(x[1]))
NP = sorted(NP, key=lambda x: x[0])
for i in NP:
    print(i[2])

Submission status: Accepted

Solution code:
import bisect
import heapq
N = int(input())
vals = {}
for i in range(N):
	s,p = input().split()
	p = int(p)
	if s in vals.keys():
		vals[s].append([p,i+1])
	else:
		vals[s] = [[p,i+1]]

keys = []
for k in vals.keys():
	vals[k].sort(key = lambda x: -x[0])
	keys.append(k)

keys.sort()
for k in keys:
	for v in vals[k]:
		print(v[1])

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())

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

for s in sorted(d.keys()):
    # print(s)
    # print(d[s])
    d[s].sort(key=lambda x: x[0],reverse=True)
    for v in d[s]:
        print(v[1])

Submission status: Accepted

Solution code:
N = int(input())

res = []
for x in range(1, N+1):
    s, p2 = input().split()
    p = 100 - int(p2)
    res.append((s, p, x))

res = sorted(res)

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

Submission status: Accepted

Solution code:
N = int(input())
rs = []
for no in range(N):
    S, P = [i for i in input().split()]
    rs.append((S, int(P), no+1))
rs = sorted(rs, key=lambda x: x[1], reverse=True)
rs = sorted(rs, key=lambda x: x[0])
for r in rs:
    print(r[2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
from collections import defaultdict
city=set()
data=defaultdict(list)
for i in range(N):
    S,P=input().split()
    P=int(P)
    city|={S}
    data[S].append((P,i+1))
city=list(city)
city.sort()
for c in city:
    x=data[c]
    x.sort(key=lambda x:x[0],reverse=True)
    for p,k in x:
        print(k)

Submission status: Accepted

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

keys = list(sp.keys())
keys.sort()

for k in keys:
    sp[k].sort(reverse=True)
    for p,i in sp[k]:
        print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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 e in L :
    print(e[2])

Submission status: Accepted

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

result = sorted(
    sorted(s_p_list, key=lambda x: x[2], reverse=True),
    key=lambda x: x[1]
)
for i, s, p in result:
    print(i)

Submission status: Accepted

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

SP.sort()

print('\n'.join(str(spi[2]) for spi in SP))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    restrants = [None] * N
    for i in range(N):
        S, P = input().split()
        restrants[i] = (S, -int(P), i)
    restrants.sort()
    for i in range(N):
        _, _, i = restrants[i]
        print(i+1)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)
N=int(input())
D=[]
for i in range(N):
  s,p=input().split()
  D.append((s, int(p), i+1))
D.sort(key=lambda d: (d[0], -d[1], d[2]))

for d in D:
  print(d[2])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""



"""
import sys


def solve(N, restaurants):
    restaurants.sort(key=lambda x: [x[0], -x[1]])
    return [r[2] for r in restaurants]


def main(args):
    N = int(input())
    restaurants = []
    for i in range(N):
        s, p = input().split()
        p = int(p)
        restaurants.append([s, p, i+1])
    ans = solve(N, restaurants)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

lst = []
for i in range(N):
    S, P = map(str, input().split())
    P = int(P)
    lst += [[S, 100-P, i+1]]

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

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for i in range(n):
	c, s = input().split()
	if c not in d:
		d[c] = []
	d[c].append((int(s), i))
for c in sorted(d.keys()):
	for s, i in sorted(d[c], reverse=True):
		print(i + 1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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))  # type: int
    S = [str()] * (N)  # type: "List[str]" 
    P = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        S[i] = next(tokens)
        P[i] = int(next(tokens))
    solve(N, S, P)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:


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])))
    # print(a)
    for _, _, i in a:
        print(i)


if __name__ == '__main__':
    main()