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:
n = int(input())

s = []
for i in range(n):
	s.append(list(input().split()))

for i in range(n):
	s[i][1] = int(s[i][1])

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

for a in ans:
  print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())

s = []
for i in range(n):
	s.append(list(input().split()))

for i in range(n):
	s[i][1] = int(s[i][1])

ans = sorted(s,key=lambda x : (x[0],x[1]))
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

s = []
for i in range(n):
	s.append(list(input().split()))

for i in range(n):
	s[i][1] = int(s[i][1])

Submission status: Wrong Answer

Solution code:
n = int(input())

s = []
for i in range(n):
	s.append(list(input().split()))
print(s)

Submission status: Wrong Answer

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

N = int(input())
str_list = [input() for x in range(N)]
str_sort = sorted(str_list, key=lambda x: x.split()[1], reverse=True)
str_sort2 = sorted(str_sort, key=lambda x: x.split()[0])

for x in str_sort2:
    print(str_list.index(x)+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from operator import itemgetter  
i = int(input())
#print(i)
point =[]
for n in range(0,i):
  s, p = list(input().split(' '))
  point.append((s,int(p)))

point2 = sorted(point, key=itemgetter(1),reverse=True) 
point3 = sorted(point2, key=itemgetter(0)) 
#print(point3)

for i in point:
  print(point3.index(i)+1)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter  
i = int(input())
#print(i)
point =[]
for n in range(0,i):
  s, p = list(input().split(' '))
  point.append((s,int(p)))

point2 = sorted(point, key=itemgetter(1),reverse=True) 
point3 = sorted(point2, key=itemgetter(0)) 
print(point3)

for i in point:
  print(point3.index(i)+1)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = []
    for i in range(N):
        line = [a for a in input().split()]
        S.append([i+1] + line)
    tmp = sorted(S, key=lambda x:x[2], reverse=True)
    ans = sorted(tmp, key=lambda x:x[1])
    for i in range(len(ans)):
        print(ans[i][0])

main()

Submission status: Wrong Answer

Solution code:
n = int(input())
# a, p = list(map(int, input().split()))
# a = list(map(int, input().split()))
# S = [list(map(int, input().split())) for i in range(n)]
S = [list(input().split()) for i in range(n)]

for i, s in enumerate(S):
    s.append(i+1)

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

for s, p, n in S:
    print(n)

Submission status: Wrong Answer

Solution code:
from functools import cmp_to_key


def cmp(xx,yy):
    x = xx[1]
    y = yy[1]
    print(x,y)
    print(x[0],x[1],y[0],y[1])
    if x[0] != y[0]:
        return -1 if x[0] < y[0] else 1
    return -1 if int(x[1]) > int(y[1]) else 1

n = int(input())
items = [input().split() for _ in range(n)]
items = list(enumerate(items))
items = sorted(items, key=cmp_to_key(cmp))
for res, *_ in items:
    print(res+1)

Submission status: Wrong Answer

Solution code:
# ABC 128, B - guidebook
from operator import itemgetter

n = int(input())

X = []
for i in range(n):
    tmp = input().split(' ')
    X.append((tmp[0], -int(tmp[1])))

Y = sorted(X, key=itemgetter(0,1))
for x in X:
    print(Y.index(x)+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = [list(input().split()) for _ in range(N)]
for i in range(N):
  l[i] += [i+1]
l.sort(key=lambda x:x[0])
l.sort(key=lambda x:-int(x[1]))
for j in range(N):
  print(l[j][2])

Submission status: Wrong Answer

Solution code:
N = int(input())
l = [list(input().split()) for _ in range(N)]
for i in range(N):
  l[i] += [i+1]
l.sort(key=lambda x:x[0])
l.sort(key=lambda x:int(x[1]))
for j in range(N):
  print(l[j][2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
for i in range(n):
    s,p = input().split()
    lis.append((s,int(p),i))
from operator import itemgetter
lis = sorted(lis,key=itemgetter(0))
lis = sorted(lis,key=itemgetter(1),reverse=True)
for i in range(n):
    print(lis[i][2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
dic = []
for _ in range(n):
  name, point = input().split()
  dic.append((name, int(point)))

srt = sorted(dic, reverse=True, key=lambda x: x[1])
srt_ind = sorted(range(n), reverse=True, key=lambda x: dic[x][1])
srt = sorted(srt_ind, key=lambda x: srt[x][0])

for i in srt:
  print(str(i+1))

Submission status: Wrong Answer

Solution code:
n = int(input())
dic = []
for _ in range(n):
  name, point = input().split()
  dic.append((name, int(point)))

srt = sorted(dic, reverse=True, key=lambda x: x[1])
srt = sorted(range(n), key=lambda x: srt[x][0])

for i in srt:
  print(str(i+1))

Submission status: Wrong Answer

Solution code:
n = int(input())
dic = []
for _ in range(n):
  name, point = input().split()
  dic.append((name, int(point)))

srt = sorted(range(n), reverse=True, key=lambda x: dic[x][1])
srt = sorted(range(n), key=lambda x: dic[x][0])

for i in srt:
  print(str(i+1))

Submission status: Wrong Answer

Solution code:
n = int(input())
dic = []
for _ in range(n):
  name, point = input().split()
  dic.append((name, int(point)))

srt = sorted(range(n), key=lambda x: dic[x][1])[::-1]
srt = sorted(range(n), key=lambda x: dic[x][0])

for i in srt:
  print(str(i+1))

Submission status: Wrong Answer

Solution code:
a=[]
n=int(input())
while n:
  a.append(tuple(input().split()))
  n=n-1
b=sorted(a)
for i in b:
  print(a.index(i)+1)

Submission status: Wrong Answer

Solution code:
n = int(input())

li = []
for i in range(n):
    li.append(list(map(str, input().split())))
    li[i].append(i+1)

li.sort( key = lambda li : (li[0], -int(li[1])))
print(li)

Submission status: Wrong Answer

Solution code:
n = int(input())
list = [input().split(' ') for i in range(n)]
restaurant = [[n+1, list[n][0], int(list[n][1])] for n in range(n)]

print(restaurant)

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

Submission status: Wrong Answer

Solution code:
a = [int(input()) for i in range(1)]
n = a[0]
restaurants = [list(input().split()) for i in range(n)]
#print(restaurants)

sorted_r = sorted(restaurants, key=lambda x: int(x[1]), reverse=True)
#print(sorted_r)
sorted_r = sorted(restaurants, key=lambda x: x[0])

#print(sorted_r)
for s in sorted_r:
  print(restaurants.index(s) + 1)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    a,b = input().split()
    l.append((a,-int(b),i+1))
    print(l)
l.sort()
for a,b,k in l:
    print(k)

Submission status: Wrong Answer

Solution code:
n = int(input())
restaurant = [[n+1]+input().split(' ') for n in range(n)]

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

Submission status: Wrong Answer

Solution code:
n = int(input())
restaurant = [[n]+input().split(' ') for n in range(n)]

restaurant.sort(key=lambda x: (x[1], x[2]))
for i,_,_ in restaurant:
    print(i)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
num = int(input())
scoreList = [input().split() for i in range(num)]
test = [[scoreList[i][0],int(scoreList[i][1])] for i in range(num)]
[test[i].append(i+1) for i in range(num)]
citySorted = sorted(test, key=lambda x:x[0], reverse = False)
cityList = [citySorted[0]]
for i in range(1,num):
    if(citySorted[i][0] == cityList[0][0]):
        cityList.append(citySorted[i])
        if(i == num-1):
            for s in sorted(cityList, key=lambda x:x[1], reverse = True):
                print(s[2])
            
    else:
        for s in sorted(cityList, key=lambda x:x[1], reverse = True):
            print(s[2])
            cityList = []
        cityList.append(citySorted[i])

Submission status: Wrong Answer

Solution code:
n = int(input())
array=[]

for i in range(n):
  s,p = input().split()
  num = 100 - int(p)
  num_zero = str(num).zfill(3)
  s2 = s + num_zero + str(i+1)
  array.append(s2)
  
array.sort()

for i in range(n):
  print(array[i][-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
array=[]

for i in range(n):
  s,p = input().split()
  num = 100 - int(p)
  s2 = s + str(num) + str(i+1)
  array.append(s2)
  
array.sort()

for i in range(n):
  print(array[i][-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [input().split()+[i+1] for i in range(n)]

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

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [input().split()+[i] for i in range(n)]

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

Submission status: Wrong Answer

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

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

for i in range(N):
  for j in range(N):
    if SP[i][0] == sorted_SP[j][0] and SP[i][1] == sorted_SP[j][1]:
      print(j+1)
      break

Submission status: Wrong Answer

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

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

for i in range(N):
  for j in range(N):
    if SP[i][0] == sorted_SP[j][0] and SP[i][1] == sorted_SP[j][1]:
      print(j+1)
      break

Submission status: Wrong Answer

Solution code:
N = int(input())
SP = []
name = []
for i in range(N):
    x = list(input().split())
    x = [x[0], int(x[1]), int(i)]
    name.append(x[0])
    SP.append(x)


# sort on secondary key
s = sorted(SP, key=lambda x: (x[0], x[1]),reverse=True)
# now sort on primary key, descending
#sorted(s, key=attrgetter('grade'), reverse=True)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
SP = []
name = []
for i in range(N):
    x = list(input().split())
    x = [x[0], int(x[1]), int(i)]
    name.append(x[0])
    SP.append(x)


# sort on secondary key
s = sorted(SP, key=lambda x: (x[0], x[1]))
# now sort on primary key, descending
#sorted(s, key=attrgetter('grade'), reverse=True)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
SP = []
name = []
for i in range(N):
    x = list(input().split())
    x = [x[0], int(x[1]), int(i)]
    name.append(x[0])
    SP.append(x)

sorted_name = sorted(SP)
#print(sorted_name)
for i in range(N):
    print(sorted_name[i][2])

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math


N = int(input())
S = [] 
for i in range(N): #入力
    S.append(input().split())
#print (S)

for i in range(N): #式通り
    S[i][1] = str(abs(int(S[i][1]) - 100))
#print (S)

for i in range(N): #語尾に番号をつけて結合
    S[i] = S[i][0] + S[i][1] + '0000'+str(1<<(i+1))
#print(S)

S.sort() #ソート
for i in range(N):
    print(int(math.log2(int(S[i][-4:]))))

"""""""""""""""""""""""""""""""""""""""""""""""""""""
            提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
"""""""""""""""""""""""""""""""""""""""""""""""""""""

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)


N = int(input())
S = [] 
for i in range(N): #入力
    S.append(input().split())
#print (S)

for i in range(N): #式通り
    S[i][1] = str(abs(int(S[i][1]) - 100))
#print (S)

for i in range(N): #語尾に番号をつけて結合
    S[i] = S[i][0] + S[i][1] + 'zzzzzzz0000'+str(i+1)
#print(S)

S.sort() #ソート
for i in range(N):
    print(int(S[i][-4:]))

"""""""""""""""""""""""""""""""""""""""""""""""""""""
            提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
"""""""""""""""""""""""""""""""""""""""""""""""""""""

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)


N = int(input())
S = [] 
for i in range(N): #入力
    S.append(input().split())
#print (S)

for i in range(N): #式通り
    S[i][1] = str(abs(int(S[i][1]) - 100))
#print (S)

for i in range(N): #語尾に番号をつけて結合
    S[i] = S[i][0] + S[i][1] + '0000'+str(i+1)
#print(S)

S.sort() #ソート
for i in range(N):
    print(int(S[i][-4:]))

"""""""""""""""""""""""""""""""""""""""""""""""""""""
            提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
"""""""""""""""""""""""""""""""""""""""""""""""""""""

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)


N = int(input())
S = [] 
for i in range(N): #入力
    S.append(input().split())
#print (S)

for i in range(N): #式通り
    S[i][1] = str(abs(int(S[i][1]) - 100))
#print (S)

for i in range(N): #語尾に番号をつけて結合
    S[i] = S[i][0] + S[i][1] + '000'+str(i+1)
#print(S)

S.sort() #ソート
for i in range(N):
    print(int(S[i][-3:]))

"""""""""""""""""""""""""""""""""""""""""""""""""""""
            提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
"""""""""""""""""""""""""""""""""""""""""""""""""""""

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)


N = int(input())
S = [] 
for i in range(N): #入力
    S.append(input().split())
#print (S)

for i in range(N): #式通り
    S[i][1] = str(abs(int(S[i][1]) - 100))
#print (S)

for i in range(N): #語尾に番号をつけて結合
    S[i] = S[i][0] + S[i][1] + '000'+str(i+1)
print(S)

S.sort() #ソート
for i in range(N):
    print(int(S[i][-3:]))

"""""""""""""""""""""""""""""""""""""""""""""""""""""
            提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
"""""""""""""""""""""""""""""""""""""""""""""""""""""

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)


N = int(input())
S = [] 
for i in range(N): #入力
    S.append(input().split())
#print (S)

for i in range(N): #式通り
    S[i][1] = str(abs(int(S[i][1]) - 100))
#print (S)

for i in range(N): #語尾に番号をつけて結合
    S[i] = S[i][0] + S[i][1] + str(i+1)
#print(S)

S.sort() #ソート
for i in range(N):
    print(S[i][-1:])

"""""""""""""""""""""""""""""""""""""""""""""""""""""
            提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
"""""""""""""""""""""""""""""""""""""""""""""""""""""

Submission status: Wrong Answer

Solution code:
a = int(input())
c = list()
for b in range(a):
  z, zz = input().split()
  c.append([z,int(zz)]) 

l = list()
tmp = sorted(c, key=lambda x:x[1], reverse=True)
x = sorted(tmp, key=lambda x:x[0])
for a in x:
  for y in c:
    if (a == y):
      l.append(c.index(a)+1)
print(l)

Submission status: Wrong Answer

Solution code:
def argsort(seq):
    return sorted(range(len(seq)), key=seq.__getitem__)

a=int(input())
s = [input() for i in range(a)]
li=argsort(s)
for i in li:
	print(int(i)+1)

Submission status: Wrong Answer

Solution code:
def argsort(seq):
    return sorted(range(len(seq)), key=seq.__getitem__)

a=int(input())
s = [input() for i in range(a)]
li=argsort(s)
for i in li:
	print(i)

Submission status: Wrong Answer

Solution code:
a = int(input())
c = [list(map(str, input().split())) for b in range(a)]
l = list()
for d in c:
  for i, e in enumerate(d):
    if (i % 2 == 1):
      l.append((int(e)))
f = sorted(l, reverse=True)

for d in c:
  for i, e in enumerate(d):
    if (i % 2 == 1):
      print(f.index(int(e))+1)

Submission status: Wrong Answer

Solution code:
a = int(input())
c = [list(map(str, input().split())) for b in range(a)]
l = list()
for d in c:
  for i, e in enumerate(d):
    if (i % 2 == 1):
      l.append((int(e)))
f = sorted(l)

for d in c:
  for i, e in enumerate(d):
    if (i % 2 == 1):
      print(f.index(int(e))+1)

Submission status: Wrong Answer

Solution code:
a=int(input())
s = [input() for i in range(a)]
sorted(range(len(s)), key=lambda k: s[k])
for i in s:
	print(s.index(i))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
town_names = dict()
assessments = []
for x in range(N):
  if x!=N:
    SP = input().split()
    assessments.append(SP[1])
    town_names.setdefault(SP[0],[]).append(assessments.index(SP[1])+1)
  else:
    break
result = []
for t in sorted(town_names):
  tmp = []
  for pointer in town_names[t]:
    tmp.append(assessments[pointer-1])
  for x in sorted(tmp, reverse=True,key=int):
    result.append(assessments.index(x)+1)
  tmp = []
print(result)

Submission status: Wrong Answer

Solution code:
#n, x = map(int,input().split())
n = int(input())
ls = [["",[[]]]]
for i in range(n):
  s, p = input().split()
  p = int(p)
  for j in ls:
    if s == j[0]:
      j[1].append([i+1,p])
      break
    elif j == ls[-1]:
      ls.append([s,[[i+1,p]]])
      break
#ls = list(map(int,input().split()))
#s = input()
ls.remove(ls[0])
print(ls)
ls.sort()
for i in ls:
  i[1].sort(key=lambda x: x[1],reverse=True)
  for j in i[1]:
    print(j[0])

Submission status: Wrong Answer

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

que=[]
prev_rest=sp[0][0]
for i in range(n):
    if prev_rest != sp[i][0]:
        que=sorted(que,key=lambda x:(x[0],x[1]))[::-1]
        for j in range(len(que)):
            ans_list=que.pop()
            print(ans_list[2])
    que.append(sp[i])
    prev_rest = sp[i][0]
que=sorted(que,key=lambda x:(x[0],x[1]))[::-1]
for j in range(len(que)):
    ans_list=que.pop()
    print(ans_list[2])

Submission status: Wrong Answer

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

que=[]
prev_rest=sp[0][0]
for i in range(n):
    if prev_rest != sp[i][0]:
        que=sorted(que,key=lambda x:(x[0],x[1]))[::-1]
        for j in range(len(que)):
            ans_list=que.pop()
            print(ans_list[2])
    que.append(sp[i])
    prev_rest = sp[i][0]

Submission status: Wrong Answer

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

que=[]
prev_rest=sp[0][0]
for i in range(n):
    if prev_rest != sp[i][0]:
        que=sorted(que,key=lambda x:(x[0],x[1]))[::-1]
        for j in range(len(que)):
            ans_list=que.pop()
            print(ans_list[2])
    else:
        que.append(sp[i])
        prev_rest = sp[i][0]

Submission status: Wrong Answer

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

que=[]
prev_rest=sp[0][0]
for i in range(n):
    if prev_rest != sp[i][0]:
        for j in range(len(que)):
            ans_list=que.pop()
            print(ans_list[2])
    else:
        que.append(sp[i])
        prev_rest = sp[i][0]

Submission status: Wrong Answer

Solution code:
n = int(input())
dic = {}
for x in range(n):
  dic[x+1] = input().split()
ls = sorted(dic.items(), key=lambda x:x[1][0])

for y in range(1,n-1):
  
  if ls[y][1][0] == ls[y+1][1][0]:
    
    if ls[y][1][1] < ls[y+1][1][1]:
      
      ls[y+1],ls[y] = ls[y],ls[y+1]
    
    
for b in range(len(ls)):
  print(ls[b][0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = []
for _ in range(N):
    s, p = input().split()
    s = '{:0<10}'.format(s)
    p = '{:0>3}'.format(str(100 - int(p)))
    lst.append(s + p)

m = {}
for idx, s in enumerate(sorted(lst), 1):
    m[s] = idx

for s in lst:
    print(m[s])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())

lis = []

for i in range(n):
    s, p = input().split()
    lis.append([i+1, s, p])
    
lis.sort(key=lambda x: x[1])

names =[]

for i in lis:
    if i[1] not in names:
        names.append(i[1])
        
score = 100000


for name in names:
    for l in lis:
        if name in l:
            l[2] = int(l[2]) + score
        else:
            score -= 200
            
for i in lis:
    print(i[0])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
import copy

data = []


for n in range(int(input())):
	data.append(input().split(" "))


for n in range(len(data)):
	data[n][1] = int(data[n][1])

base = copy.deepcopy(data)

print(data)



data.sort(key=itemgetter(1),reverse=True)

print(data)

data.sort(key=itemgetter(0))

print(data)

for n in range(len(data)):
	print(base.index(data[n])+1)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

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

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

Submission status: Wrong Answer

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

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

for j in range(len(book)):
    print(book[j][2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
SP=[]
for i in range(N):
    SP.append(input().split())
for j in range(N):
    SP[j].append(j)
SP.sort(key=lambda x:x[1])
SP.sort(key=lambda x:x[0])
for k in range(N):
    print(SP[k][2])

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = []
for i in range(N):
  s, p = input().split()
  ls.append((s,-int(p),i+1)) # reverse point for downer sort , and memorize order i+1
ls.sort()
print(ls) # for debug
for r in ls:
  print(r[2])

Submission status: Wrong Answer

Solution code:
N = int(input())

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

arr.sort()
for s, p, i in arr:
    print(i)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []
for Resturant_number in range(1, N+1):
    tmp = [Resturant_number]
    tmp += input().split()
    tmp[2] = int(tmp[2])
    L.append(tmp)
L.sort(reverse=True, key=lambda x:x[1])

for _ in range(len(L)):
    print(L.pop()[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []
for Resturant_number in range(N):
    tmp = [Resturant_number]
    tmp += input().split()
    tmp[2] = int(tmp[2])
    L.append(tmp)
L.sort(reverse=True, key=lambda x:x[1])

for _ in range(len(L)):
    print(L.pop()[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    SP = []
    for _ in range(N):
        temp = input().split()
        SP.append((temp[0], int(temp[1])))

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

    indices = [SP.index(x)+1 for x in sorted_SP]
    # print(sorted_SP)
    print(indices)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    store = []
    for i in range(n):
        s, p = input().split()
        #(順番、店名、点数)
        store.append((i, s, int(p)))

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
q=[input().split()+[i]for i in range(n)]
for i in range(n):
    q[i][1]=int(q[i][1])
p = sorted(sorted( q ,key=lambda x:x[1],reverse=1),key=lambda x:x[0])

print(p)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(n):
    a[i].append(i+1)

a_point = sorted(a, key = lambda x: int(x[1]), reverse = True)
print(a_point)
a_name = sorted(a_point, key = lambda x: x[0])
print(a_name)
ans = []

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

Submission status: Wrong Answer

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

for i in range(n):
    a[i].append(i+1)

a_point = sorted(a, key = lambda x: x[1], reverse = True)
a_name = sorted(a_point, key = lambda x: x[0])
ans = []
for i in a_name:
    print(i[2])

Submission status: Wrong Answer

Solution code:
N = int(input())
ranking = []
for i in range(N):
  si, pi = input().split()
  ranking.append((si,int(pi),i))
  
print(ranking)

Submission status: Wrong Answer

Solution code:
dict_SP = {}
N = int(input())

for i in range(N):
  S, P = input().split()
  dict_SP[i] = S + "_" +str(100 - int(P))
                 
sorted_dictSP = sorted(dict_SP.items(), key = lambda x: x[1])

for k in sorted_dictSP:
  print(k[0] + 1)

Submission status: Wrong Answer

Solution code:
dict_SP = {}
N = int(input())

for i in range(N):
  S, P = input().split()
  dict_SP[i] = S + "_" +str(100 - int(P))
                 
sorted_dictSP = sorted(dict_SP.items(), key = lambda x: x[1])

for k in sorted_dictSP:
  print(k[0])

Submission status: Wrong Answer

Solution code:
[print(i[2]+1) for i in sorted([[int(j) if j.isdecimal() else j for j in input().split()]+[i] for i in range(int(input()))], key=lambda x:x[1], reverse=True)]

Submission status: Wrong Answer

Solution code:
[print(i[2]) for i in sorted([[int(j) if j.isdecimal() else j for j in input().split()]+[i] for i in range(int(input()))], key=lambda x:x[1])]

Submission status: Wrong Answer

Solution code:
number=int(input())
book=[]
for n in range(number):
    book.append(input().split())

for i in range(len(book)):
    book[i].append(i+1)
    book[i][1]=int(book[i][1])

book1=sorted(book,key=lambda k:-k[1])
book2=sorted(book1,key=lambda k:k[0])
print("book2=",book2)

for i in range(len(book2)):
    print(book2[i][2])

Submission status: Wrong Answer

Solution code:
N = int(input())

names = []
points = []
ans = []

for i in range(N):
    name, point = str(input()).split(" ")
    ans.append(1)
    names.append(name)
    points.append(point)
    if i == 0:
        continue
    if i == 1:
        if name < names[0]:
            ans[0] += 1
        elif name == names[0] and point > points[0]:
            ans[0] += 1
        else:
            ans[1] += 1
        continue
    for j in range(len(ans) - 1):
        if name < names[j]:
            ans[j] += 1
        elif name == names[j] and point > points[j]:
            ans[j] += 1
        else:
            ans[i] += 1

for i in range(N):
    print(ans.index(min(ans)) + 1)
    ans[ans.index(min(ans))] = 101