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: Wrong Answer

Solution code:
#import sys
#if sys.version_info[0] == 2:
#    input = raw_input
#sys.setrecursionlimit(2 ** 31 -1)

import numpy as np

N = int(input())
pairs = []
same_dict = {}
keys = []

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

inputs = sorted(inputs, key=lambda x: x[0])
#print("inputs", inputs)

#for S, P, i in inputs:
#    pair = [S, P, i]
#    pairs.append(pair)
#    
#    key = S
#
#    if S in keys:
#        same_dict[key].append(i)
#    else:
#        same_dict[key] = [i]
#        keys.append(key)
#
#    #print(same_dict)
#
#print("pairs", pairs)

#out_pairs = np.asarray(pairs, dtype=object)
#keys= []

pairs = inputs

before_key = inputs[0][0]
tmp_indexes = [inputs[0][2]]
tmp_vals = [inputs[0][1]]

out = []
for pair in pairs[1:]:
    tmp_key, val, index = pair
    #print(before_key, tmp_key)
    if before_key == tmp_key:
        tmp_indexes.append(index)
        tmp_vals.append(val)
    else:
        both_l = []
        ss = [[elm1, elm2] for elm1, elm2 in zip(tmp_indexes, tmp_vals)]
        #print("abdd", ss)
        ss = sorted(ss, key=lambda x: -x[1])
        #print("tmp_indexes", tmp_indexes)
        #print("tmp_vals", tmp_vals)
        #print("elm12", elm1, elm2)
        #print("ss", ss)
        for a, b in ss:
            out.append(a)
        #out += junban
        tmp_vals = [val]
        tmp_indexes = [index]

    before_key = tmp_key

 

#print("tmp_indexes", tmp_indexes)
#print("tmp_vals", tmp_vals)
ss = sorted([[elm1, elm2] for elm1, elm2 in zip(tmp_indexes, tmp_vals)], key=lambda x: -x[0])
#print("final ss", ss)
for a, b in ss:
    out.append(a)
#junban = ss[1]
#out += junban

#print("len", out)

for elm in out:
    print(elm+1)


##outs = []
#for key in keys:
#    indexes = same_dict[key]
#    print(indexes)
#    tmp_pairs = out_pairs[indexes]
#    #print("tmp", tmp_pairs)
#    tmp_pairs = sorted(tmp_pairs, key=lambda x: -x[1])
#    #out_pairs[indexes] = tmp_pairs

Submission status: Wrong Answer

Solution code:
N = int(input())
list_all = list()
list_name = list()
list_number = list()

for n in range(N):
  par = input()
  pars = par.split(' ')
  list_all.append([n+1,pars[0],pars[1]])
  list_name.append(pars[0])
list_unique = sorted(list(set(list_name)))

for name in list_unique:
  l = list()
  for elem in list_all:
    if elem[1] == name:
      l.append([elem[2],elem[0]])
  l = sorted(l, reverse=True)
  for tmp in l:
    list_number.append(tmp[1])

for num in list_number:
  print(num)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

n = int(input())

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

a = sorted(res) + ['end', '0', '0']

tmp = [a[0]]
ans = []
for i in range(1, n+1):
	if a[i][0] != a[i-1][0]:
		ans += sorted(tmp, key=itemgetter(1), reverse=True)
		tmp = [a[i]]
	else:
		tmp.append(a[i])

[print(c[2]) for c in ans]

Submission status: Wrong Answer

Solution code:
n=int(input())
cityLst=[]
for i in range(n):
	s,p=map(str,input().split(" "))
	cityLst.append([s,p])
sCityLst=sorted(cityLst,key=lambda x:x[0]+";"+str(-1*(int(x[1])-100)))
for o in sCityLst:
	print(cityLst.index(o)+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
S = []
count = [0] * n
for i in range(n):
    a,b = input().split()
    S.append([a,int(b),i+1])


S.sort()


for i in range(n-1):
    if S[i][0] != S[i+1][0]:
        count[i] = 1

for j in range(n):
    for i in range(n-1):
        if S[i][1] < S[i+1][1] and count[i+1] - count[i] >= 0:
            a = S[i][:]
            S[i][:] = S[i+1][:]
            S[i+1][:] = a
        if count[i+1] - count[i] < 0:
            continue


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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

N = int(input())

S = [] 
P = []
num = []

for i in range(N):
    s,p = input().split()
    S.append(s)
    num.append(i+1)
    P.append(p)

S = np.array(S, dtype='U10')
P = np.array(P, dtype='int64')
num = np.array(num, dtype='int64')

# 点数順で並べ替え
S = S[np.argsort(P)[::-1]]
num = num[np.argsort(P)[::-1]]

# 名前順で並べ替え
num = num[np.argsort(S)]

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

Submission status: Wrong Answer

Solution code:

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

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

list.sort(key=lambda x:(x[1],x[2]))
for l in list:
    print(l[0])

Submission status: Wrong Answer

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

newSP = sorted(SP,key = lambda tup:(tup[1],-tup[2]))

print(newSP)

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

Submission status: Wrong Answer

Solution code:
N=int(input())
lis=[]
for i in range(N):
    A,B=input().split()
    B=str(100-int(B))
    lis.append(A+B+'_'+str(i))
               
lis=sorted(lis)
for i in range(N):
    print(int(lis[i].split('_')[1])+1)

Submission status: Wrong Answer

Solution code:
N = int(input())

lists = []
for _ in range (N):
    S = input().split(' ')
    lists.append(S)

list_sorted = lists.copy()
list_sorted.sort()
for result in range(N):
    for sorted in range (N):
        if lists[result] == list_sorted[sorted]:
            print(sorted+1)

Submission status: Wrong Answer

Solution code:
def bSort(a,b):
    for i in range(len(a)):
        for j in range(len(a)-1, i, -1):
            if a[j] < a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]
                b[j], b[j-1] = b[j-1], b[j]   

    return

num = int(input())
city = []*num
number = []*num
for i in range(num):
    tensu = input()
    tensu = tensu.split(" ")
    tensu[1] = 100 - int(tensu[1])
    tensu[1] = str(tensu[1])
    tensu = ''.join(tensu)
    city.append(tensu)
    number.append(str(i))
bSort(city,number)
for i in range(num):
    print(str(int(number[i])+ 1))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
SP=[]
SPs=[]
for i in range(n):
    SP=[i]
    for j in input().split():
        
        SP.append(j)
    SPs.append(SP)
    
SPs=np.array(SPs)


SPs2=SPs[SPs[:,2].argsort()[::-1],:]
SPs3=SPs2[SPs2[:,1].argsort(),:][:,0]

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

Submission status: Wrong Answer

Solution code:

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

for i in range(n):
    print("str: ")
    sp = input().split()
    s = str(sp[0])
    p = int(sp[1])

    #s, p = sp[0], int(sp[1])
    list.append([i+1, s, p])
"""
list.append([1, "test2", 3])
list.append([2, "test3", 1])
list.append([3, "test1", 5])
list.append([4, "test1", 4])
"""

list.sort(key=lambda x:(x[1],x[2]))
for l in list:
    print(l[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
SP = [input().split()+[0] for _ in range(N)]
r = []
for x, y, z in SP:
  r.append([x, int(y), z])

sortV = sorted(r, key = lambda x: -x[1])
sortK = sorted(sortV, key = lambda x: x[0])

g = 1
for i in range(N):
  sortK[i][2] = g
  g += 1

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

Submission status: Wrong Answer

Solution code:
n=int(input())
rows=[input().split() for i in range(n)]
new_rows=sorted(rows)
new_rows.sort(key=lambda x: x[1], reverse=True)
for i in range(n):
    print(rows.index(new_rows[i])+1)

Submission status: Wrong Answer

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

nsp = sorted(sp, key=lambda x: x[1], reverse=True)
nsp = sorted(nsp, key=lambda x: x[0])

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

Submission status: Wrong Answer

Solution code:
def anprint():
    global fin
    global n
    b = -1
    p = -1
    for i in range(n):
        if lst[i][1] > b:
            p = i
            b = lst[i][1]
    print(p+1)
    lst[p][1] = 0
    fin -= 1
    if fin>0:
        anprint()




n = int(input())
lst = []
ans = []
for i in range(n):
    lst.append(input().split())
    ans.append(0)
    for k in range(len(lst[i][0])):
        lst[i][1] = int(lst[i][1])
        if lst[i][1] == 0:
            lst[i][1] += 0.01
        if lst[i][0][k] == 'a':
            lst[i][1] += 25*26**(9-k)*1000
        elif lst[i][0][k] == 'b':
            lst[i][1] += 24*26**(9-k)*1000
        elif lst[i][0][k] == 'c':
            lst[i][1] += 23*26**(9-k)*1000
        elif lst[i][0][k] == 'b':
            lst[i][1] += 22*26**(9-k)*1000
        elif lst[i][0][k] == 'e':
            lst[i][1] += 21*26**(9-k)*1000
        elif lst[i][0][k] == 'f':
            lst[i][1] += 20*26**(9-k)*1000
        elif lst[i][0][k] == 'g':
            lst[i][1] += 19*26**(9-k)*1000
        elif lst[i][0][k] == 'h':
            lst[i][1] += 18*26**(9-k)*1000
        elif lst[i][0][k] == 'i':
            lst[i][1] += 17*26**(9-k)*1000
        elif lst[i][0][k] == 'j':
            lst[i][1] += 16*26**(9-k)*1000
        elif lst[i][0][k] == 'k':
            lst[i][1] += 15*26**(9-k)*1000
        elif lst[i][0][k] == 'l':
            lst[i][1] += 14*26**(9-k)*1000
        elif lst[i][0][k] == 'm':
            lst[i][1] += 13*26**(9-k)*1000
        elif lst[i][0][k] == 'n':
            lst[i][1] += 12*26**(9-k)*1000
        elif lst[i][0][k] == 'o':
            lst[i][1] += 11*26**(9-k)*1000
        elif lst[i][0][k] == 'p':
            lst[i][1] += 10*26**(9-k)*1000
        elif lst[i][0][k] == 'q':
            lst[i][1] += 9*26**(9-k)*1000
        elif lst[i][0][k] == 'r':
            lst[i][1] += 8*26**(9-k)*1000
        elif lst[i][0][k] == 's':
            lst[i][1] += 7*26**(9-k)*1000
        elif lst[i][0][k] == 't':
            lst[i][1] += 6*26**(9-k)*1000
        elif lst[i][0][k] == 'u':
            lst[i][1] += 5*26**(9-k)*1000
        elif lst[i][0][k] == 'v':
            lst[i][1] += 4*26**(9-k)*1000
        elif lst[i][0][k] == 'w':
            lst[i][1] += 3*26**(9-k)*1000
        elif lst[i][0][k] == 'x':
            lst[i][1] += 2*26**(9-k)*1000
        elif lst[i][0][k] == 'y':
            lst[i][1] += 1*26**(9-k)*1000
    lst[i][1] += (26**(10-len(lst[i][0]))-1)*1000+(10-len(lst[i][0]))*100
fin = n
anprint()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n = int(input())
d = {}
di = defaultdict(list)
for i in range(n):
    s, p = input().split()
    d[(s, p)] = i+1
    di[s].append(p)
dii = list(di.items())
dii.sort(key=lambda x: x[0])
#print(dii, "\n", d)
for i in dii:
    si, pi = i[0], i[1]
    pi.sort(reverse=True)
    for j in pi:
        print(d[(si, j)])

Submission status: Wrong Answer

Solution code:
n = int(input())
num = 0
mydict = {}
for i in range(n):
    s, p = input().split()
    mydict[s+p] = int(i)
mydict = sorted(mydict.items())
for i in mydict:
    print(i[1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n = int(input())
arr_ = [[str(i) for i in input().split()] for _ in range(n)]
for i in range(n):
    arr_[i].append(i+1)
    arr_[i][1] = int(arr_[i][1])

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

Submission status: Wrong Answer

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

N = int(input())

SP = [input().split() for i in range(N)]
SP = [[sp[0], sp[1], i+1] for i, sp in enumerate(SP)]
SP.sort(key=lambda x: x[1], reverse=True)
SP.sort(key=lambda x: x[0])
for sp in SP:
    print(sp[2])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

n = int(input())

wrap = []

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

wrap.sort(key=itemgetter(2), reverse=True)
wrap.sort(key=itemgetter(1))
print(wrap)

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

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
N=int(input())
R=[]
for i in range(N):
    s,p=input().split()
    p=int(p)
    R.append([s,p])

sorted_R=sorted(R,key = itemgetter(1),reverse=True)
sorted_R=sorted(sorted_R, key = itemgetter(0))
print(sorted_R)
for i in range(len(R)):
    for j in range(len(R)):
        if R[j]==sorted_R[i]:
            print(j+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
list = []
for i in range(N):
    input_list = input()
    S = input_list.split(" ")[0]
    P = int(input_list.split(" ")[1])
    list.append([i, S, P])

#from operator import itemgetter

list.sort(key=lambda x: x[2] ,reverse=True)
list.sort(key=lambda x: x[1])
for i in range(N):
    list[i].append(i)
list.sort()
for i in range(N):
    print(list[i][3]+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = []
count = [0] * n
for i in range(n):
    a,b = input().split()
    S.append([a,int(b),i+1])


S.sort()


for i in range(n-1):
    if S[i][0] != S[i+1][0]:
        count[i] += 1
S.append([0,0,1])
count.append(1)
for j in range(n):
    for i in range(n):
        if S[i][1] < S[i+1][1] and count[i+1] - count[i] >= 0:
            a = S[i][:]
            S[i][:] = S[i+1][:]
            S[i+1][:] = a

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

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

n = int(input())
sp = [list(map(str, 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()

t = []

t.append(sp[0])

for i in range(n - 1):
    i += 1
    if sp[i][0] == sp[i-1][0]:
        t.append(sp[i])
        print(t)
    else:
        t.sort(key=lambda t: t[1], reverse=True)
        for j in t:
            print(j[2])
        t = []
        t.append(sp[i])

t.sort(key=lambda t: t[1], reverse=True)
for j in t:
    print(j[2])

Submission status: Wrong Answer

Solution code:
N = int(input())
X =[]
for i in range(N):
  SS,PP = map(str,input().split())
  X.append([int(i+1), SS, int(PP)])

A = sorted(X, key=lambda X:(X[1],-X[2]))
print (A)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = []
count = [0] * n
for i in range(n):
    a,b = input().split()
    S.append([a,int(b),i+1])


S.sort()


for i in range(n-1):
    if S[i][0] != S[i+1][0]:
        count[i] += 1
S.append([0,0,1])
count.append(1)
for j in range(n):
    for i in range(n):
        if S[i][1] < S[i+1][1] and count[i+1] - count[i] >= 0:
            a = S[i][:]
            S[i][:] = S[i+1][:]
            S[i+1][:] = a

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

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
ss = []
for i in range(n):
    s, p = input().split()
    ss.append(s+chr(ord("木")-int(p)))

sss = ss.copy()
sss.sort()
for s in sss:
    print(ss.index(s)+1)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

N = int(input())
S = [0] * N
P = [0] * N

city_point = {}

for i in range(N):
    inp = input().split()
    S[i] = inp[0]
    P[i] = inp[1]
    city_point[i] = [S[i], P[i]]

score_sorted = sorted(city_point.items(), key=lambda x:x[1][0])

for l in score_sorted:
    print(l[0] + 1)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n = int(input())
arr_ = [[str(i) for i in input().split()] for _ in range(n)]
for i in range(n):
    arr_[i].append(i+1)

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

Submission status: Wrong Answer

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

ans = {}
for k,v in sorted(e.items()):
    ans[k]=v

for k,v in ans.items():
    for p,q in sorted({a:b for a,b in v}.items(),key=lambda x: -x[0]):
        print(q)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

n = int(input())
A = []
city = []
for _ in range(n):
    s,p = input().split()
    city.append([s,-int(p)])
    A.append([s,-int(p)])

A = sorted(A, key=itemgetter(0,1))
for c in city:
    print(A.index(c)+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
data = [[i for i in input().split()] for j in range(N)]
for i in range(N):
    data[i].append(i+1)
sort_data = sorted(data)
start = sort_data[0][0]
num = [sort_data[0][2]]
for i in range(1,N):
    if sort_data[i][0] == start:
        num.append(sort_data[i][2])
    else:
        start = sort_data[i][0]
        for j in range(len(num)):
            print(num[len(num)-1-j])
        num = [sort_data[i][2]]
for j in range(len(num)):
    print(num[len(num)-1-j])

Submission status: Wrong Answer

Solution code:
n=int(input())
cityLst=[]
max=0
for i in range(n):
	s,p=map(str,input().split(" "))
	cityLst.append([s,p])
	if max<int(p):
		max=int(p)
sCityLst=sorted(cityLst,key=lambda x:x[0]+";"+str(max-int(x[1])))
for o in sCityLst:
	print(cityLst.index(o)+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
data = [[i for i in input().split()] for j in range(N)]
for i in range(N):
    data[i].append(i+1)
sort_data = sorted(data)
print(sort_data)
start = sort_data[0][0]
num = [sort_data[0][2]]
for i in range(1,N):
    if sort_data[i][0] == start:
        num.append(sort_data[i][2])
    else:
        start = sort_data[i][0]
        for j in range(len(num)):
            print(num[len(num)-1-j])
        num = [sort_data[i][2]]
for j in range(len(num)):
    print(num[len(num)-1-j])

Submission status: Wrong Answer

Solution code:
N = int(input())
all_point_list = [input().split() for _ in range(N)]
for each_list in all_point_list:
    each_list[1] = int(each_list[1])
sorted_all_list = sorted(all_point_list)
for sorted_point in sorted_all_list:
    print(all_point_list.index(sorted_point)+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
SP = []
for i in range(n):
  sp = input().split()
  sp.append(i+1)
  SP.append(sp)
sortedSP = sorted(SP, key = lambda x:x[0])
for i in range(n-1):
  for j in range(n-1-i):
    if sortedSP[j][0] == sortedSP[j+1][0] and int(sortedSP[j][1]) > int(sortedSP[j+1][1]):
      sortedSP[j], sortedSP[j+1] = sortedSP[j+1], sortedSP[j]
for i in range(n):
  print(n+1-sortedSP[i][2])

Submission status: Wrong Answer

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

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

def main():
    N = i2n()
    r = {}
    for i in range(N):
        s, p = i2s().split()
        p = int(p)
        if s in r.keys():
            r[s] += [(p, i)]
        else:
            r[s] = [(p, i)]

    rname = list(r.keys())
    rname.sort()
    for n in rname:
        out = [x[1] for x in sorted(r[n], reverse=True)]
        for m in out:
            print(m)

main()

Submission status: Wrong Answer

Solution code:

import sys


def input():
    return sys.stdin.readline()[:-1]


n = int(input())
temp = []
for i in range(n):
    a, b = map(str, input().split())
    c = 100 - int(b)
    temp.append(a+str(c))
lista = temp.copy()
lista.sort()
for i in lista:
    print(temp.index(i)+1)

Submission status: Wrong Answer

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

l.sort()
tmp_city = l[0][0]
tmp_l = []
result = []
for i in range(N):
    if i == (N-1):
        tmp_l.append(l[i])
        tmp_l.sort(key=lambda x:x[1], reverse=True)
        for n in range(len(tmp_l)):
            result.append(tmp_l[n]) 
    elif tmp_city == l[i][0]:
        tmp_l.append(l[i])
    else:
        tmp_l.sort(key=lambda x:x[1], reverse=True)
        for n in range(len(tmp_l)):
            result.append(tmp_l[n]) 
        tmp_l = []
        tmp_city = l[i][0]
        tmp_l.append(l[i])

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

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N = int(input())
A = [[i for i in input().split()] for i in range(N)]
B = []

for i in range(N):
    B.append([A[i][0], A[i][1], i])
    
B.sort(key = itemgetter(1), reverse = True)
for i in range(N):
    B[i][0] += '0000000000' * (i+1)

B.sort(key = itemgetter(0))
for i in range(N):
    print(B[i][2] + 1)

Submission status: Wrong Answer

Solution code:
N =int(raw_input())
S =[]
P =[]
for i in range(N):
    s,p=map(str,raw_input().split())
    S.append(s)
    P.append(int(p))
ss=sorted(list(set(S)))
for sss in ss:
    a =[]
    b =[]
    for j in range(N):
        if sss==S[j]:
            a.append(j)
            b.append(P[j])
    if len(b)>0:
        c = sorted(b,reverse=True)
        #print c,b
        for k in c:
            for j in range(len(b)):
                if k == b[j]:
                    print(a[j])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N = int(input())

news = []

for i in range(N):
  hoge = input().split()
  news.append((str(hoge[0]),int(hoge[1])))

b = sorted(news, key=itemgetter(1), reverse=True)
c = sorted(b, key=itemgetter(0))
print(c)

for i in range(N):
  for j in range(N):
    if c[i] ==news[j]:
      print(j+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
ANS = [(input() + ' ' + str(i)).split() for i in range(1,N+1) ]

dic = {i[0]+str(100-int(i[1])) : i[2] for i in ANS}
for i in sorted(dic.items()):
    print(i[1])

Submission status: Wrong Answer

Solution code:
def bSort(a,b):
    for i in range(len(a)):
        for j in range(len(a)-1, i, -1):
            if a[j] < a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]
                b[j], b[j-1] = b[j-1], b[j]   

    return

num = int(input())
city = []*num
number = []*num
for i in range(num):
    tensu = input()
    tensu = tensu.split(" ")
    new = ''.join(str(100 - int(tensu[1])))
    tensu.append(new)
    del tensu[1]
    tensu = ''.join(tensu)
    city.append(tensu)
    number.append(str(i))
bSort(city,number)
for i in range(num):
    print(str(int(number[i])+ 1))

Submission status: Wrong Answer

Solution code:

N=int(input())
if N==1:
    print(1)
else:

    a=[]

    for i in range(N):
        d=list(map(str,input().split()))
        d.append(i+1)
        a.append(d)

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

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


    k=0
    b=[]
    c=[]
    c.append(a[0])
    for i in range(N-1):
        if a[i][0]==a[i+1][0]:
            c.append(a[i+1])
        else:
            c.sort(key=lambda x:x[1])
            c.reverse()
            k=len(c)

            for j in range(k):
                b.append(c[j][2])
            c=[]
            c.append(a[i+1])

    k=len(c)
    c.reverse()
    for j in range(k):
        b.append(c[j][2])


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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = []
for n in range(1,N+1):
    S, P= map(str, input().split())
    a.append([S, P, n])

a.sort()

for i in range(N-1):
    if a[i][0] == a[i+1][0]:
        if a[i][1] < a[i+1][1]:
            tmp = a[i]
            a[i] = a[i+1]
            a[i+1] = tmp

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

Submission status: Wrong Answer

Solution code:
n = int(input())
book = []
for i in range(n):
    name, rate = input().split()
    book.append((i+1, name, int(rate)))
b = sorted(book, key=lambda s: s[2], reverse=True)
b2 = sorted(b, key=lambda s: s[1])

print(b2)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
c = list()
num = 0
for i in range(1,n+1):
    a,p = [x for x in input().split()]
    c.append([a,p,i])

b = sorted(c, key = lambda x:(x[0],x[1]),reverse = False)
d = list()
for i in range(len(b)-1):
    if(b[i][0] == b[i+1][0]):
        d.append(b[i])
    else:
        d.append(b[i])
        for j in reversed(range(0,len(d))):
            print(d[j][2])
        d = list()
        
    if(i == len(b)-2):
        d.append(b[i+1])
        for j in reversed(range(0,len(d))):
            print(d[j][2])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

def main():
  N = input()
  SP = [tuple(input().split()) for i in range(N)]
  sorted(SP, key=itemgetter(0, 1))
  print(SP)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
N=int(input())
R=[]
for i in range(N):
    s,p=input().split()
    int(p)
    R.append([s,p])

sorted_R=sorted(R,key = itemgetter(1),reverse=True)
sorted_R=sorted(sorted_R, key = itemgetter(0))

for i in range(len(R)):
    for j in range(len(R)):
        if R[j]==sorted_R[i]:
            print(j+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = []
count = [0] * n
for i in range(n):
    a,b = input().split()
    S.append([a,int(b),i+1])


S.sort()


for i in range(n-1):
    if S[i][0] != S[i+1][0]:
        count[i] += 1

for j in range(n):
    for i in range(n-1):
        if S[i][1] < S[i+1][1] and count[i+1] - count[i] >= 0:
            a = S[i][:]
            S[i][:] = S[i+1][:]
            S[i+1][:] = a

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n = int(input())
ll = []
d = {}
in_k = []
for i in range(n):
    s, p = map(str, input().split())
    if not s in d:
        d[s] = [[int(p), i+1]]
    else:
        d[s].append([int(p), i+1])
    if not s in in_k:
        in_k.append(s)
tmp = 1
num = 1
keys = sorted(d.keys())
for k in keys:
    d[k].sort(key=lambda x: x[0], reverse=True)
    for i in range(len(d[k])):
        d[k][i].append(num)
        num += 1
    d[k].sort(key=lambda x: x[1])
for k in d.keys():
    for j in range(len(d[k])):
        ll.append(d[k][j][1:])
ll.sort(key=lambda x: x[0])
for l in ll:
        print(l[1])

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
for i in range(n):
    d = {}
    d["index"] = i+1
    d["city"], d["score"] = input().split()
    l.append(d)
results = []
citys = list(set([l[i]["city"] for i in range(n)]))
citys.sort()
for city in citys:
    sorted_scores = sorted([l[i]["score"] for i in range(n) if l[i]["city"] == city], reverse=True)
    for score in sorted_scores:
        candidate = [l[i]["index"] for i in range(n) if (l[i]["city"] == city)&(l[i]["score"] == score)][0]
        results.append(candidate)
print(*results, sep="\n")

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n=int(input())
l=[]
for i in range(1,n+1):
    a,b=input().split()
    t=tuple([a,b,i])
    l.append(t)
b = sorted(l, key=itemgetter(1), reverse=True)
c = sorted(b,key=itemgetter(0))
for i in c:
    print(i[2])

Submission status: Wrong Answer

Solution code:
N = int(input())
raw_list = [list(input().split()) for _ in range(N)]
#print(raw_list)
copylist = raw_list[:]
a=sorted(copylist,key=lambda x:x[1],reverse=True) # 点でソート
#print(a)
b=sorted(a, key=lambda x:x[0]) #　所在地でソート
#print(b)
#print(raw_list)

for mise in b:
    #print(mise)
    print(raw_list.index(mise)+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
sp = [input().split() + [i+1] for i in range(n)]
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])

Submission status: Wrong Answer

Solution code:
N = int(input())
l = [[x for x in input().split()] for _ in range(N)]
for i in sorted(l):    
    print(l.index(i))

Submission status: Wrong Answer

Solution code:
import copy
M =int(input())
S1 =[]
P1 =[]
for i in range(M):
    S,P = input().split()
    P = int(P)
    S1.extend([S])
    P1.extend([P])
S = copy.deepcopy(S1)
S1.sort()
A =[0]*M
for i in range(M):
    a = 0
    for n in range(M):
        if S[i]==S1[n]:
            if a<P1[n]:
                if  not n+1 in A:
                    a = P1[n]
                    A[i] = n+1
for i in range(M):
    print(A[i])

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

slist = []
plist = []

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

slist = np.array(slist)
plist = np.array(plist)

index = np.argsort(slist)

pre = slist[index[0]]

tmp = []
tmp2 = []
check = 0
for i in index:
    if slist[i] == pre:
        tmp.append(plist[i][0])
        tmp2.append(plist[i][1])
        check = 1
    else:
        idx = np.argsort(tmp2)[::-1]
        for j in idx:
            print(tmp[j]+1)
        tmp = []
        tmp2 = []
        tmp.append(plist[i][0])
        tmp2.append(plist[i][1])
        check = 0
        pre = slist[i]

if check == 1:
    idx = np.argsort(tmp)[::-1]
    for j in idx:
        print(tmp[j]+1)