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:
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] += '0' * (i+1)

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

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()
print(S1)
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:
n = int(input())
sp = []
for i in range(n):
        sp.append(input().split())
for i in range(n):
        sp[i][1] = int(sp[i][1])
for i in range(n):
        sp[i].append(i+1)
sp.sort()
start = 0
sp2=[]
for i in range(n-1):
        if sp[i][0] != sp[i+1][0]:
                sp2 = sp2+sorted(sp[start:i+1],key = lambda x:x[1],reverse = True)
                start = i+1
sp2 = sp2+sorted(sp[start:],key = lambda x:x[1],reverse = True)
print(sp2)
for i in range(n):
        print(sp2[i][2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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]))
_ = [print(a[2]) for a in l]

Submission status: Wrong Answer

Solution code:

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

sorted_items = sorted(items.items(), key=lambda x:x[0], reverse=False)

for key, value in sorted_items:
  print(value)

Submission status: Wrong Answer

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

# 得点が高い＝100からの減算値が小さい。文字列を昇順に並べながら得点が高い特徴を並べやすく
# 文字列と入力順番値を辞書型で登録
sp = {s.lower()+' '+str(100-int(p)):n for n, (s, p) in enumerate(SP)}

# 昇順文字列に並べ、その文字列に対応する入力順番値を表示する
for n in sorted(sp):
    print(sp[n]+1)

Submission status: Wrong Answer

Solution code:
N = int(input())

news = []

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

print(sorted(news))
huga = sorted(news)

for i in range(N):
  for j in range(N):
    if huga[i] ==news[j]:
      print(j)

Submission status: Wrong Answer

Solution code:
from itertools import product
import bisect
import sys


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

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


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 temp:
    print(lista.index(i)+1)

Submission status: Wrong Answer

Solution code:
n =  int(input())

table = []
for i in range(n):
  city, score = input().split()
  score = int(score)

  table.append([i+1, city, score])

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
array = []
for i in range(N):
    array.append(list(map(str, input().split())))
array_new = sorted(array, key=lambda x: (x[0], x[1]))
for i in range(N):
    print(int(array.index(array_new[i])+1))

Submission status: Wrong Answer

Solution code:
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

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

import math
import string
import fractions
import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop

# from itertools import accumulate
# from collections import deque
import random


def main():
    n = int(input())
    dict={}
    for i in range(n):
        name, score= input().split()
        if not(name in dict):
            dict[name]=[((score,i+1))]
        else:
            dict[name].append((score,i+1))
            dict[name].sort(reverse=True)
    eprint(dict)
    ll=list(dict.items())
    eprint(ll)
    ll.sort()
    eprint(ll)
    for x in ll:
        for y in x[1]:
            print(y[1])
        
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
sp = [None]*n
for i in range(n):
    sp[i] = input().split(" ")
sp = list(map(lambda x: [x[0], int(x[1])], sp))
sl = list(map(lambda x: x[0], sp))
sp2 = []
for s in sorted(list(set(sl))):
    l = list(filter(lambda x: x[0] == s, sp))
    sp2.extend(sorted(l, key=lambda x:x[1], reverse=True))
for x in sp:
    print(sp2.index(x)+1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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)

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

for s in sp:
    for pp in s[1]:
        print("{} {}".format(s[0], pp))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N=int(input())
Slist=list()
Plist=list()
tmp=list()
for i in range(N):
    S,P=input().split()
    Slist.append(S)
    Plist.append(int(P))
    tmp.append(int(P))
change = True
while change:
    change = False
    for i in range(len(Plist) - 1):
        if Plist[i] < Plist[i + 1]:
            Plist[i], Plist[i + 1] = Plist[i + 1], Plist[i]
            Slist[i], Slist[i + 1] = Slist[i + 1], Slist[i]
            change = True
change = True
while change:
    change = False
    for i in range(len(Slist) - 1):
        if Slist[i] > Slist[i + 1]:
            Slist[i], Slist[i + 1] = Slist[i + 1], Slist[i]
            Plist[i], Plist[i + 1] = Plist[i + 1], Plist[i]
            change = True
ans=list()
for i in range(N):
    ans.append(tmp.index(Plist[i]))
print(Plist)
for i in range(N):
    print(ans[i]+1)

Submission status: Wrong Answer

Solution code:
#B
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(int(number[i])+ 1)

Submission status: Wrong Answer

Solution code:
N=int(input())
listA=[]
for i in range(N):
    lis=input().split()
    listA.append([lis[0],int(lis[1]),i])
sort=sorted(listA,key=lambda x:(x[0],-x[1]))
for i in range(N):
    sort[i].append(i+1)
sort=sorted(sort,key=lambda x:x[2])
for disp in sort:
    print(disp[3])

Submission status: Wrong Answer

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

_dict = dict(sorted(_dict.items()))
for k, v in _dict.items():
    tt = sorted(v, key=lambda x: int(x[0]), reverse=True)
    for i in tt: print(i[1])

Submission status: Wrong Answer

Solution code:
from itertools import product
import bisect
import sys


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

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


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 = input().split()
    if P == "0":
        L.append([i,S])
    elif 100-int(P) < 10:
        L.append([i,S+"0"+str(100-int(P))])
    else:
        L.append([i,S+str(100-int(P))])

L.sort(key=lambda x:x[1])
for i in range(N):
    print(L[i][0])

Submission status: Wrong Answer

Solution code:
N = int(input())

l = []

for i in range(N):
    s , p = map(str, input().split())
    p = 100-int(p)
    if p == 0:
        l.append(s+str(999))
    elif p < 10:
        l.append(s+str(0)+str(p))
    else:
        l.append(s+str(p))
l_new = sorted(l)
# print(l)
# print(l_new)
for i in l_new:
    print(l.index(i)+1)

Submission status: Wrong Answer

Solution code:
#B問題
N = int(input())
R_list = []
for i in range(N):
    S, P=map(str, input().split())
    R_list.append([S , int(P)*-1 , i])
R_list.sort()
for i in range(N):
    R_list[i].append(i+1)
R_list.sort(key=lambda x:x[2])
for i in range(N):
    print(R_list[i][3])

Submission status: Wrong Answer

Solution code:
n=int(input())
sp=[list(map(str,input().split())) for l in range(n)]
sn=[]
ss=[]
sn2=[]
ss2=[]
for i in range(n):
    sn.append(sp[i][0])
    ss.append(sp[i][1])
sn2=sorted(sn)
ss=sorted(range(len(sn)), key=lambda k: sn[k])
for i in range(n):
    ss2.append(int(sp[ss[i]][1]))
#print(sn2)
#print(ss)
#print(ss2)
for i in range(n-1):
    if sn2[i]==sn2[i+1]:
        if ss2[i]<ss2[i+1]:
            ss[i+1],ss[i]=ss[i],ss[i+1]
            ss2[i+1],ss2[i]=ss2[i],ss2[i+1]
for i in range(n):
    print(ss[i]+1)

Submission status: Wrong Answer

Solution code:
import sys
args = sys.stdin.readlines()
N = int(args[0])
d = {}
for i, line in enumerate(args[1:]):
  S, p = line.split(' ')
  P = int(p)
  if S in d:
    d[S].append((i+1, P))
  else:
    d[S] = []
    d[S].append((i+1, P))
    
for key in d.keys():
    d[key].sort(key=lambda x:x[1], reverse=True)
    for (i, p) in d[key]:
        print(i)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from sys import stdin

N = int(input())
# print(N)

bcs = [list(x.split()) for x in stdin.readlines()]

for i in range(N):
	bcs[i].append(int(i+1))
	# print(bcs[i])

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

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

Submission status: Wrong Answer

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

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

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
flag = False
for i in range(M):
    a = 0
    for n in range(M):
        if S1[i]==S[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:
n = int(input())

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

d = sorted(d.items(), key=lambda y:(y[1][0], -y[1][1]))
d = dict(d)
for i in d.keys():
    print(i)

Submission status: Wrong Answer

Solution code:
N=int(input())
L = []
for i in range(1,N+1):
    S,P = input().split()
    if 100-int(P) < 10:
        L.append([i,S+"0"+str(100-int(P))])
    else:
        L.append([i,S+str(100-int(P))])

L.sort(key=lambda x:x[1])
for i in range(N):
    print(L[i][0])

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import numpy as np
from functools import lru_cache
import time

def main(): 
    if True:
        N = int(input())
        SP = np.asarray([])
        for i in range(N):
            SP = np.append(SP,input().split()+[i+1])
    else:
        pass
    SP = SP.reshape((N,3))
    uSP = np.unique(SP[:,0])
    uSP = np.sort(uSP)
    for u in uSP:
        tSP = np.asarray(SP[SP[:,0]==u,1:3],dtype=int)
        ttSP = tSP[np.argsort(tSP[:,0][::-1])]
        for p in ttSP:
            print(p[1])
if __name__ =='__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

N = int(input())

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

Submission status: Wrong Answer

Solution code:
count = int(input())

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

city = sorted(city.items())

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

Submission status: Wrong Answer

Solution code:

def anprint():
    global fin
    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.5
        if lst[i][0][k] == 'a':
            lst[i][1] += 25*26**(9-k)*100
        elif lst[i][0][k] == 'b':
            lst[i][1] += 24*26**(9-k)*100
        elif lst[i][0][k] == 'c':
            lst[i][1] += 23*26**(9-k)*100
        elif lst[i][0][k] == 'b':
            lst[i][1] += 22*26**(9-k)*100
        elif lst[i][0][k] == 'e':
            lst[i][1] += 21*26**(9-k)*100
        elif lst[i][0][k] == 'f':
            lst[i][1] += 20*26**(9-k)*100
        elif lst[i][0][k] == 'g':
            lst[i][1] += 19*26**(9-k)*100
        elif lst[i][0][k] == 'h':
            lst[i][1] += 18*26**(9-k)*100
        elif lst[i][0][k] == 'i':
            lst[i][1] += 17*26**(9-k)*100
        elif lst[i][0][k] == 'j':
            lst[i][1] += 16*26**(9-k)*100
        elif lst[i][0][k] == 'k':
            lst[i][1] += 15*26**(9-k)*100
        elif lst[i][0][k] == 'l':
            lst[i][1] += 14*26**(9-k)*100
        elif lst[i][0][k] == 'm':
            lst[i][1] += 13*26**(9-k)*100
        elif lst[i][0][k] == 'n':
            lst[i][1] += 12*26**(9-k)*100
        elif lst[i][0][k] == 'o':
            lst[i][1] += 11*26**(9-k)*100
        elif lst[i][0][k] == 'p':
            lst[i][1] += 10*26**(9-k)*100
        elif lst[i][0][k] == 'q':
            lst[i][1] += 9*26**(9-k)*100
        elif lst[i][0][k] == 'r':
            lst[i][1] += 8*26**(9-k)*100
        elif lst[i][0][k] == 's':
            lst[i][1] += 7*26**(9-k)*100
        elif lst[i][0][k] == 't':
            lst[i][1] += 6*26**(9-k)*100
        elif lst[i][0][k] == 'u':
            lst[i][1] += 5*26**(9-k)*100
        elif lst[i][0][k] == 'v':
            lst[i][1] += 4*26**(9-k)*100
        elif lst[i][0][k] == 'w':
            lst[i][1] += 3*26**(9-k)*100
        elif lst[i][0][k] == 'x':
            lst[i][1] += 2*26**(9-k)*100
        elif lst[i][0][k] == 'y':
            lst[i][1] += 1*26**(9-k)*100


fin = n
anprint()

Submission status: Wrong Answer

Solution code:
count = int(input())

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

city = sorted(city.items())
print(city)

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

Submission status: Wrong Answer

Solution code:
#b.py
n = int(input())
lis = [list(input().split())+[x] for x in range(n)]
lis = sorted(lis,key=lambda x:x[0])
now = lis[0][0]
ans_lis = []
sublis = []
for x in lis:
    if x[0] == now:
        sublis.append(x)
    else:
        now = x[0]
        sublis = sorted(sublis,key=lambda x:int(x[1]),reverse=True)
        print(int(x[1]))
        ans_lis.append(sublis)
        sublis = []
        sublis.append(x)
sublis.sort(key=lambda x:int(x[1]),reverse=True)
ans_lis.append(sublis)
sublis = []
sublis.append(x)       
print(ans_lis)
ans_lis = [item for sublist in ans_lis for item in sublist]
for x in ans_lis:
    print(x[2]+1)

Submission status: Wrong Answer

Solution code:
N = int(input())

l = []

for i in range(N):
    s , p = map(str, input().split())
    p = 100-int(p)
    if p < 10:
        l.append(s+str(0)+str(p))
    else:
        l.append(s+str(p))
l_new = sorted(l)

for i in l_new:
    print(l.index(i)+1)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
N = int(input())
childs = [list(input().split()) for _ in range(N)]

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

for i in b:
    print(childs.index(i)+1)

Submission status: Wrong Answer

Solution code:
import numpy as np
def main():
    N = int(input())
    S = []; P= []
    for n in range(N):
        temp = input().split()
        S.append(temp[0]) 
        P.append(int(temp[1]))
    S_index = np.argsort(S)
    S_sort = np.sort(S)
    temp_city = S_sort[0]
    temp_p = []; temp_res = [];
    for i,x in enumerate(S_index):
        if(temp_city != S_sort[i]):
            temp_p_index = np.argsort(temp_p)
            for j in temp_p_index:
                res = str(temp_res[len(temp_p_index)-1-j]+1)
                print(res)
            temp_p = []; temp_res = [];
            temp_city = S_sort[i]
        temp_p.append(P[x])
        temp_res.append(x)
    temp_p_index = np.argsort(temp_p)
    for j in temp_p_index:
        res = str(temp_res[len(temp_p_index)-1-j]+1)
        print(res)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
book=[]
for i in range(n):
	s,p=map(str,input().split())
	book.append([s,int(p),i+1])
book.sort(key=lambda book:book[0])
ans=[]
for i in range(n):
	if len(ans)==0:
		ans.append(book[i])
	elif ans[0][0]!=book[i][0] or i==len(book)-1:
		if i==len(book)-1:
			ans.append(book[i])
		ans.sort(key=lambda ans:ans[1],reverse=True)
		for j in range(len(ans)):
			print(ans[j][2])
		ans.clear()
		if i!=len(book)-1:
			ans.append(book[i])
	else:
		ans.append(book[i])

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
N=int(input())

a=[]
b=[]

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())

eva_list = []

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

news = []

for i in range(N):
  hoge = input().split()
  news.append((str(hoge[0]),int(hoge[1])))
  
huga = sorted(range(len(news)), key=lambda k: news[k])
for i in range(len(huga)):
  print(huga[i])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

n=int(input())
list1=[]
for i in range(n):
    a=list(input().split())
    a.append(i)
    list1.append(a)
 
list1.sort(reverse=True,key=itemgetter(1))
list1.sort(key=itemgetter(0))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
S=[0]*N
P=[0]*N
for i in range(N):
  S[i], P[i]=input().split()
S=np.array(S)
P=np.array(P)
def guidebook(S,P):
  ind_1=np.argsort(P)
  S=S[ind_1]
  ind_1=np.flipud(ind_1)
  S=np.flipud(S) 
  ind_2=np.argsort(S)
  return ind_1[ind_2]+1

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

Submission status: Wrong Answer

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

L.sort(key=lambda x:x[1])
for i in range(N):
    print(L[i][0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import exit

N = int(input())

R = {}

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

    R[i] = (s, int(p))

ans = {}

for k, v in sorted(R.items(), key=lambda x: x[1][0]):
    if v[0] in ans:
        ans[v[0]].append((v[1], k))
    else:
        ans[v[0]] = [(v[1], k)]

for k in ans:
    ans[k] = sorted(ans[k], reverse=True)
    for a in ans[k]:
        print(a[1])

Submission status: Wrong Answer

Solution code:
def anprint():
    global fin
    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][0][k] == 'a':
            lst[i][1] += 25*26**(9-k)*100
        elif lst[i][0][k] == 'b':
            lst[i][1] += 24*26**(9-k)*100
        elif lst[i][0][k] == 'c':
            lst[i][1] += 23*26**(9-k)*100
        elif lst[i][0][k] == 'b':
            lst[i][1] += 22*26**(9-k)*100
        elif lst[i][0][k] == 'e':
            lst[i][1] += 21*26**(9-k)*100
        elif lst[i][0][k] == 'f':
            lst[i][1] += 20*26**(9-k)*100
        elif lst[i][0][k] == 'g':
            lst[i][1] += 19*26**(9-k)*100
        elif lst[i][0][k] == 'h':
            lst[i][1] += 18*26**(9-k)*100
        elif lst[i][0][k] == 'i':
            lst[i][1] += 17*26**(9-k)*100
        elif lst[i][0][k] == 'j':
            lst[i][1] += 16*26**(9-k)*100
        elif lst[i][0][k] == 'k':
            lst[i][1] += 15*26**(9-k)*100
        elif lst[i][0][k] == 'l':
            lst[i][1] += 14*26**(9-k)*100
        elif lst[i][0][k] == 'm':
            lst[i][1] += 13*26**(9-k)*100
        elif lst[i][0][k] == 'n':
            lst[i][1] += 12*26**(9-k)*100
        elif lst[i][0][k] == 'o':
            lst[i][1] += 11*26**(9-k)*100
        elif lst[i][0][k] == 'p':
            lst[i][1] += 10*26**(9-k)*100
        elif lst[i][0][k] == 'q':
            lst[i][1] += 9*26**(9-k)*100
        elif lst[i][0][k] == 'r':
            lst[i][1] += 8*26**(9-k)*100
        elif lst[i][0][k] == 's':
            lst[i][1] += 7*26**(9-k)*100
        elif lst[i][0][k] == 't':
            lst[i][1] += 6*26**(9-k)*100
        elif lst[i][0][k] == 'u':
            lst[i][1] += 5*26**(9-k)*100
        elif lst[i][0][k] == 'v':
            lst[i][1] += 4*26**(9-k)*100
        elif lst[i][0][k] == 'w':
            lst[i][1] += 3*26**(9-k)*100
        elif lst[i][0][k] == 'x':
            lst[i][1] += 2*26**(9-k)*100
        elif lst[i][0][k] == 'y':
            lst[i][1] += 1*26**(9-k)*100


fin = n
anprint()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())

book = []

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

for num in book:
  print(int(num[0])+1)

Submission status: Wrong Answer

Solution code:
N = int(input())

news = []

for i in range(N):
  hoge = input().split()
  news.append((str(hoge[0]),int(hoge[1])))
  
print(sorted(range(len(news)), key=lambda k: news[k]))

Submission status: Wrong Answer

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

# 得点が高い＝100からの減算値が小さい。文字列を昇順に並べながら得点が高い特徴を並べやすく
# 文字列と入力順番値を辞書型で登録
sp = {s.lower()+str(100-int(p)):n for n, (s, p) in enumerate(SP)}

# 昇順文字列に並べ、その文字列に対応する入力順番値を表示する
for n in sorted(sp):
    print(sp[n]+1)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
i = int(input())

data = []

def chg(x,y):
	print("hoge")
	if x[0] == y[0]:
		return x[1] > y[1]
	else:
		return x[0] > y[0]

for i in range(i):
	ip = input().split(' ')
	dt = [ip[0],int(ip[1])]
	data.append(dt)


ls = sorted(data,key=itemgetter(1),reverse=True)
ls = sorted(ls,key=itemgetter(0))

print(ls)

for i in ls:
	cnt = 0
	for j in data:
		if i == j:
			break
		cnt += 1
	
	print(cnt + 1)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
restlist = []
for i in range(N):
    name,point = input().split()
    restlist.append([name,str(100-int(point)),i+1])
restlist.sort()

for j in range(N):
    print(restlist[j][2])

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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