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 = []
cnt = 0
for _ in range(N):
    cnt += 1
    i,p = input().split()
    S.append([i,int(p),cnt+1])

S.sort(reverse = True)

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

Submission status: Wrong Answer

Solution code:
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
# 列ベクトルとかの受け取り
dic = {}
for i in range(1,n+1):
    dic[i] = list(input().split())
    dic[i][1] = int(dic[i][1])

print(dic)
ans = sorted(dic.items(),key=lambda x:(x[1][0],-x[1][1]))
print(ans)

for i in range(len(ans)):
    print(ans[i][0])
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()
d =  {}

res = []
qes = []
score = []
for i in xrange(n):
    r,s = raw_input().split()
    if r not in d:
        d[r] = [(i,s)]
    else:
        d[r].append((i,s))
    if r not in res:
        qes.append(r)
    res.append(r)
    score.append(s)
qes = sorted(qes)

for j in qes:
    for k in sorted(d[j]):
        print   k[0]+1

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(list(input().split()) for i in range(n))
a = sorted(l)
print(a)
for i in range(n-1):
  if a[i][0]==a[i+1][0]:
    x = a[i][1]
    a[i][1] = a[i+1][1]
    a[i+1][1]= x
print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = [[] for _ in range(N)]

for i in range(N):
    S, P = input().split()
    lst[i].append(S)
    lst[i].append(P)
    lst[i].append(i+1)
    
lst_a = sorted(lst, key=lambda x:x[0])
lst_a = sorted(lst_a, key=lambda x:x[1], reverse=True)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = [[] for _ in range(N)]

for i in range(N):
    S, P = input().split()
    lst[i].append(S)
    lst[i].append(P)
    lst[i].append(i+1)
    
lst_a = sorted(lst, key=lambda x:x[1], reverse=True)
lst_a = sorted(lst_a, key=lambda x:x[0])

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

Submission status: Wrong Answer

Solution code:
N = int(input())
city = dict()
restaurants = []
for _ in range(N):
    s, p = input().split()
    restaurants.append([s, int(p)])
    if s in city.keys():
        city[s].append(int(p))
    else:
        city[s] = [int(p)]

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

for c in city:
    points = c[1]
    points.reverse()
    for p in points:
        for i in range(N):
            s = c[0]
            r = restaurants[i]
            if r[0] == s and r[1] == p:
                print(i + 1)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
N = int(input())
S = []
P = []
Num = []
for _ in range(N):
    S1, P1 = [_ for _ in input().split()]
    Num.append(_)
    S.append(S1)
    P.append(P1)
P = [int(_) for _ in P]

c = zip(Num, S, P)
c = sorted(c, key=itemgetter(2))
c = sorted(c, key=itemgetter(1))
Num, S2, P2 = zip(*c)
for i in Num:
    print(i+1)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
N = int(input())
S = []
P = []
Num = []
for _ in range(N):
    S1, P1 = [_ for _ in input().split()]
    Num.append(_)
    S.append(S1)
    P.append(P1)
P = [int(_) for _ in P]

c = zip(Num, S, P)
c = sorted(c, key=itemgetter(2))
c = sorted(c, key=itemgetter(1))
Num, S2, P2 = zip(*c)
for i in Num:
    print(i)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l1=[]
l2=[]
for i in range(n):
    sp=input().rstrip().split()
    l1.append(sp[0])
    l2.append(-int(sp[1]))
l=list(zip(l1,l2))

ans=sorted(l)
print(ans)
for i in range(len(ans)):
    print(l.index(ans[i])+1)

Submission status: Wrong Answer

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

for i in range(n):
    s,p=input().split()
    a.append([s,100-int(p)])
print(a)
city=sorted(a)   
print(city)
for i in city:
    print(a.index(i)+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
sp = [input().split() for i in range(n)]
sp = [s+str(100-int(i)) for s, i in sp]
print(*sorted(range(1, n+1), key=lambda x: sp[x-1]), sep='\n')

Submission status: Wrong Answer

Solution code:
# B
# 2020/3/9  17:57-
n = int(input())
l = []
for i in range(n):
    ss, pp = map(str, input().split())
    l.append([ss, int(pp), i])
    
l.sort()
for v in l:
    print(v[2]+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
P = []
for i in range(N):
    tmp_S, tmp_P = input().split()
    S.append(tmp_S)
    P.append(int(tmp_P)*(-1))

index = [i for i in range(1,N+1)]

ZIP = zip(P, index, S)

ZIP = sorted(ZIP)

P, index, S = zip(*ZIP)

for i in range(N):
    print(index[i])
    print(S[i])

ZIP = zip(S, index)

ZIP = sorted(ZIP)

S, index = zip(*ZIP)

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

Submission status: Wrong Answer

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

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


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

Submission status: Wrong Answer

Solution code:
n = int(input())

d = [input().split() + [i+1] for i in range(n)]
d = sorted(d, key=lambda x:x[1], reverse=True)
d = sorted(d, key=lambda x:x[0], reverse=False)
for s in d:
    print(s[-1])

Submission status: Wrong Answer

Solution code:
print(1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]", P: "List[int]"):

    shop = {}
    for i in range(N):
        shop[str(S[i]) + str(100 - P[i])] = i + 1

    for k, v in sorted(shop.items()):
        print(v)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [str()] * (N)  # type: "List[str]"
    P = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        S[i] = next(tokens)
        P[i] = int(next(tokens))
    solve(N, S, P)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

L = [[] for _ in range(N)]

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


sort_L = sorted(L)

for i in range(N-1):
    for j in range(i+1, N):
        if sort_L[i][0] == sort_L[j][0]:
            if sort_L[i][1] <= sort_L[j][1]:
                sort_L[i], sort_L[j] = sort_L[j], sort_L[i]

for i in range(N):
    for j in range(N):
        if L[i] == sort_L[j]:
            print(sort_L.index(L[i])+1)

Submission status: Wrong Answer

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

for i in range(n):
    sp[i][1] = int(sp[i][1])
    sp[i] = sp[i]+[i+1]
    
sp_s0 = sorted(sp, key=lambda x:(x[0], -x[1]), reverse=False)
print(sp_s0)

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

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n=int(input())
s=[input().split() for i in range(n)]
t=sorted(s,key=lambda x:(x[0],-int(x[1])))
for i in s:
  print(t.index(i)+1)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n=int(input())
s=[input().split() for i in range(n)]
t=sorted(s,key=lambda x:(x[0],-int(x[1])))
print(s)
print(t)
for i in s:
  print(t.index(i)+1)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
N=int(input())
hako=[]
for i in range(N):
    A,B=input().split()
    hako.append([A,int(B)*-1])
kari=hako.copy()
#print(kari)
hako.sort()
hako=sorted(hako,key=itemgetter(0,1))
#print(hako)
for i in range(N):
    print(hako.index(kari[i])+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

for i in range(n):
    print(s.index(ls[i])+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [0] * n
for i in range(n):
    l[i] = list(map(str, input().split()))
    l[i][1] = int(l[i][1])
l_sorted = sorted(l, key=lambda l: l[1], reverse=True)
l_sorted = sorted(l_sorted, key=lambda l: l[0])
print(l_sorted)
for i in range(len(l)):
    print(l.index(l_sorted[i]) + 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = [[input().split(),i] for i in range(1,n+1)]
for i, v in d:
    i[1] = str(100 - int(i[1]))

ds = sorted(d)
for c, o in ds:
    print(o)

Submission status: Wrong Answer

Solution code:
n = int(input())

sp = []

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


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

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

Submission status: Wrong Answer

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

for i in range(N):
    U[i][1] = str(100 - int(U[i][1]))
    U[i][0] = "".join(U[i])
    U[i].append(i + 1)

U = sorted(U)

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

Submission status: Wrong Answer

Solution code:
n = int(input())

l = []
for i in range(n):
  x,y = map(str,input().split())
  l.append((x,y, i))


L = []

for i in range(n):
  L.append((l[i][0], int(l[i][1]), l[i][2]))

L.sort(key = lambda L:L[1])

L.sort(key = lambda L:L[0])

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

Submission status: Wrong Answer

Solution code:
n = int(input())

l = []
for i in range(n):
  x,y = map(str,input().split())
  l.append((x,y, i))


L = []

for i in range(n):
  L.append((l[i][0], int(l[i][1]), l[i][2]))

L.sort(key = lambda L:L[2])

L.sort(key = lambda L:L[1])

for i in range(n):
  A = n-i-1
  print(L[A][2] + 1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [input().split() for i in range(N)]
S_P = S[:]
for i in range(N):
    S_P[i][1] = -1*int(S_P[i][1])  
S_P.sort()
for i in range(N):
    S_P[i][1] = -1*int(S_P[i][1])
for i in range(N):
    print(S_P.index(S[i])+1)

Submission status: Wrong Answer

Solution code:
import sys
import math

N = int(input())

name_list = []
num_list = []
list = []

for i in range(N):
	value = input().split()
	list.append(value)
	name_list.append(value[0])
	num_list.append(int(value[1]))

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

Submission status: Wrong Answer

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

SP.sort()

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

Submission status: Wrong Answer

Solution code:
n = int(input())

sList = []
for i in range(n):
  sList.append(list(input().split())+[i+1])
  sList[i][1] = -1*int(sList[i][1])
sList.sort()

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

Submission status: Wrong Answer

Solution code:
N = int(input())

lst = list()
for i in range(1, N+1):
    s, p = input().split()
    lst.append({"id":i, "s":s, "p":p})

lst.sort(key=lambda x:x["p"], reverse=True)
lst.sort(key=lambda x:x["s"])

for i in range(0, len(lst)):
    print(lst[i]["id"])

Submission status: Wrong Answer

Solution code:

n = int(input())
a = ""
b = 0
l = []

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

#pprint.pprint(l)

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

Submission status: Wrong Answer

Solution code:
def Guide():
    N = int(input())
    lst = []
    for i in range(1, N + 1):
        city, score = input().split()
        lst.append([city, int(score), i])
    sorted_lst = sorted(lst, key=lambda x:(x[0], x[1]))

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


Guide()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    if n == 1:
        print(1)
        return 
    a = [list(input().split()) for i in range(n)]
    s = sorted(a, key=lambda x:(x[0],-int(x[1])))
    for i in a:
        print(s.index(i)+1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = [list(input().split()) for i in range(n)]
    s = sorted(a, key=lambda x:(x[0],-int(x[1])))
    for i in a:
        print(s.index(i)+1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

L2 = L1

ans=[]
for i in L1:
    seq = 1
    for j in L2:
        if i[0] > j[0]:
            seq += 1
        elif i[0] == j[0]:
            if int(i[1]) < int(j[1]):
                seq += 1
    ans.append(seq)
    

print(ans)

for i in range(N):
    print(ans.index(i+1)+1)

Submission status: Wrong Answer

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

L2 = L1

ans=[]
for i in L1:
    seq = 1
    for j in L2:
        if i[0] > j[0]:
            seq += 1
        elif i[0] == j[0]:
            if i[1] < j[1]:
                seq += 1
    ans.append(seq)

for i in range(N):
    print(ans.index(i+1)+1)

Submission status: Wrong Answer

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

L2 = L1

ans=[]
for i in L1:
    seq = 1
    for j in L2:
        if i[0] > j[0]:
            seq += 1
        elif i[0] == j[0]:
            if i[1] < j[1]:
                seq += 1
    ans.append(seq)

print(ans)

for i in range(N):
    print(ans.index(i+1)+1)

Submission status: Wrong Answer

Solution code:
input1 = int(input())

LIST = []

for i in range(input1):
    input2 = input()
    TOWN = input2.split()[0]
    SCORE = int(input2.split()[1])
    NUM = i
    LIST.append([TOWN,SCORE,NUM])

LIST.sort()

LIST_TOWN = []
for i in range(input1):
    LIST_TOWN.append(LIST[i][0])
LIST_TOWN = list(set(LIST_TOWN))



LIST_N = []

for t in range(len(LIST_TOWN)):
    
    LIST_A = []
    for i in range(input1):
        if LIST_TOWN[t] in LIST[i]:
            LIST_A.append(LIST[i])
    LIST_A.sort(reverse=True)
    LIST_N.append(LIST_A)


for a in range(len(LIST_TOWN)):
    for b in range(len(LIST_N[a])):
        print(LIST_N[a][b][2] + 1)

Submission status: Wrong Answer

Solution code:
A=[]
p = int(input())
for i in range(p):
  j,k = input().split()
  A.append([j,i+1,k])
A = sorted(A,reverse = False)
for j,k,l in A:
  print(k)

Submission status: Wrong Answer

Solution code:
A=[]
p = int(input())
for i in range(p):
  j,k = input().split()
  A.append([j,k,i+1])
A = sorted(A)
for j,k,l in A:
  print(l)

Submission status: Wrong Answer

Solution code:
n = int(input())
sp = [[0, 0, 0] for i in range(n)]
for i in range(n):
  sp[i][0], sp[i][1] = list(map(str, input().split()))
  sp[i][1] = int(sp[i][1])
  sp[i][2] = i+1
sp.sort()
print(sp)

c=1
for i in range(n-1):
  if sp[i][0] == sp[i+1][0]:
    c+=1
    i+=1
  else:
    for j in range(c):
      print(sp[i-j][2])
    c=1
for j in range(c):
  print(sp[n-1-j][2])

Submission status: Wrong Answer

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


def main():
    sc = Scan()
    N = sc.intarr()[0]
    data = []
    for i in range(N):
        city, score = input().split()
        d = {'index': i+1, 'city': city, 'score': score}
        data.append(d)
    tmp = sorted(data, key=lambda x: x['score'], reverse=True)
    sorted_data = sorted(tmp, key=lambda x: x['city'])

    for d in sorted_data:
        print(d['index'])


class Scan():

    def intarr(self):
        num_array = list(map(int, input().split()))
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


def gcd(a, b):  # 最大公約数
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):  # 最小公倍数
    return a * b // gcd(a, b)


main()

Submission status: Wrong Answer

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

for i in range(n):
    r[i].append(i+1)
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())
r = [input().split() for _ in range(n)]
r_sort = r
r_sort.sort(key=lambda x:x[1],reverse=True)
r_sort.sort(key=lambda x:x[0])
for i in range(n):
    print(r_sort.index(r[i]) + 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
r = [input().split() for _ in range(n)]
r_sort = sorted(r, key=lambda x:x[1])
r_sort = sorted(r)
for i in range(n):
    print(r_sort.index(r[i]) + 1)

Submission status: Wrong Answer

Solution code:
import functools

N = int(input())
l = [None] * N

def cmp1(l, r):
   
    if l[0] < r[0]:
        return -1
    elif l[0] == r[0]:
        if l[1] == r[0]:
            return 0
        elif l[1] < r[1]:
            return 1 
        else:
            return -1
    else:
        return 1
        
    
for i in range(N):
    city, rate = input().split()
    l[i] =  city, int(rate), i+1


l.sort(key=functools.cmp_to_key(cmp1))
print(l)


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

Submission status: Wrong Answer

Solution code:
N = int(input())
l = [None] * N

def cmp1(l, r):
   
    if l[0] < r[0]:
        return -1
    elif l[0] == r[0]:
        if l[1] == r[0]:
            return 0
        elif l[1] < r[1]:
            return 1 
        else:
            return -1
    else:
        return 1
        
    
for i in range(N):
    city, rate = input().split()
    l[i] =  city, int(rate), i+1

import functools
l.sort(key=functools.cmp_to_key(cmp1))
print(l)


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

Submission status: Wrong Answer

Solution code:
N = int(input())
l = [None] * N

def cmp1(l, r):
   
    if l[0] < r[0]:
        return -1
    elif l[0] == r[0]:
        if l[1] == r[0]:
            return 0
        elif l[1] < r[1]:
            return 1 
        else:
            return -1
    else:
        return 1
        
    
for i in range(N):
    city, rate = input().split()
    l[i] =  city, int(rate), i+1

import functools
l.sort(key=functools.cmp_to_key(cmp1))
print(l)


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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

lss = sorted(ls, key=lambda x: int(x[1]), reverse=True)

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())

S = [input().split() +[_+1] for _ in range(N)]

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

now = S[0][0]
pre = []

for i in range(N):
    if now == S[i][0]:
        pre.append(S[i])
    else:
        pre.sort(key=lambda x: x[1],reverse=True)
        for j in range(len(pre)):
            print(pre[j][2])
        pre = [S[i]]
        now = S[i][0]

pre.sort(key=lambda x: x[1],reverse=True)
for j in range(len(pre)):
    print(pre[j][2])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N = int(input())

restaurnats = []
for i in range(N):
    restraunt = input().split()
    restraunt.append(i+1)
    restaurnats.append(restraunt)

restaurnats = sorted(restaurnats, key=itemgetter(1), reverse=True)
restaurnats = sorted(restaurnats, key=itemgetter(0))
for i in restaurnats:
    print(i[2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n = int(input())
sp = ["" for _ in range(n)]

for i in range(n):
    sp[i] = list(map(str, input().split()))
    sp[i].insert(2, i+1)
#print(sp)

sp2 = sorted(sp, key=lambda x:x[1], reverse=True)
#print(sp2)

sp3 = sorted(sp2, key=lambda x:x[0], reverse=False)
#print(sp3)

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

Submission status: Wrong Answer

Solution code:
n=int(input())

l=[]
a=[]
b=[]
d={}
s=[]

for i in range(1,n+1):
    t=list(input().split())
    l.append([t[0],int(t[1])])
    if t[0] not in a:
        a.append(t[0])
    b.append(t[0])
c=l.copy()
for e in a:
    d[e]=b.count(e)
c.sort()
i=0
while i<n:
    if d[c[i][0]]==1:
        s.append(l.index(c[i]))
        i+=1
    else:
        for j in range(d[c[i][0]]):
            s.append(l.index(c[i+d[c[i][0]]-1-j])+1)
        i+=d[c[i][0]]

for i in range(n):
    print(s[i])

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

for i in range(len(sp)-1):
    if sp[i][1] == sp[i+1][1] and sp[i][2] < sp[i+1][2]:
        sp[i],sp[i+1] = sp[i+1],sp[i]

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

Submission status: Wrong Answer

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

s_p.sort(key=lambda x:x[1]+str(100-int(x[2])))

for x in s_p:
    print(x[0])

Submission status: Wrong Answer

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

s_p.sort(key=lambda x:x[1]+str(100-int(x[2])))

print([x[0] for x in s_p])

Submission status: Wrong Answer

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

s_p.sort(key=lambda x:x[1]+str(100-int(x[2])))

print([(x[0]) for x in s_p])

Submission status: Wrong Answer

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

s_p.sort(key=lambda x:x[1]+str(100-int(x[2])))

[print(x[0]) for x in s_p]

Submission status: Wrong Answer

Solution code:
N = int(input())

xy = []
for i in range(N):
    x, y = map(str, input().split())
    y = int(y)
    xy.append([x, y])

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

for i in range(N):
    for j in range(N):
        if xy[i][0] == sort_xy[j][0]:
            if xy[i][1] == sort_xy[j][1]:
                print(j + 1)

Submission status: Wrong Answer

Solution code:
N = int(input())

xy = []
for i in range(N):
    x, y = map(str, input().split())
    y = int(y)
    xy.append([x, y])

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

for i in range(N):
    for j in range(N):
        if xy[i][0] == sort_xy[j][0]:
            if xy[i][1] == sort_xy[j][1]:
                print(j + 1)

Submission status: Wrong Answer

Solution code:
N = int(input())

xy = []
for i in range(N):
    x, y = map(str, input().split())
    y = int(y)
    xy.append([x, y])

sort_xy = sorted(sorted(xy), key=lambda x: x[1], reverse=True)

for i in range(N):
    for j in range(N):
        if xy[i][0] == sort_xy[j][0]:
            if xy[i][1] == sort_xy[j][1]:
                print(j + 1)

Submission status: Wrong Answer

Solution code:
N = int(input())

xy = []
for i in range(N):
    x, y = map(str, input().split())
    y = int(y)
    xy.append([x, y])

print(xy)

sort_xy = sorted(sorted(xy), key=lambda x: x[1], reverse=True)

for i in range(N):
    for j in range(N):
        if xy[i][0] == sort_xy[j][0]:
            if xy[i][1] == sort_xy[j][1]:
                print(j + 1)

Submission status: Wrong Answer

Solution code:
N = int(input())

xy = []
for i in range(N):
    xy.append(input().split())

sort_xy = sorted(xy)

for i in range(N):
    for j in range(N):
        if xy[i][0] == sort_xy[j][0]:
            if xy[i][1] == sort_xy[j][1]:
                print(j + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

l = []
ans = []

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

ans = sorted(l)    
for j in ans:
    print(j[2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

dic = {}
for i in range(n):
    s[i][1] = int(s[i][1])
    s[i].append(i+1)
    restaurant = s[i][0]
    if restaurant not in dic:
        dic[restaurant] = [[s[i][1], s[i][2]]]
    else:
        dic[restaurant].append([s[i][1], s[i][2]])
print(dic)
keys = sorted(dic.keys())
print(keys)
for i in keys:
    for j in range(len(dic[i])):
        value = sorted(dic[i], key=lambda x: x[0], reverse=True)
        print(value[j][1])

Submission status: Wrong Answer

Solution code:
r_list = []
ans_list = []
N = int(input())
for i in range(1, N+1):
    Si, Pi = input().split()
    r_list.append((Si, int(Pi), i))
    
name_sorted_list = sorted(r_list, key=lambda x:x[0])
while len(name_sorted_list) > 0:
    test_list = []
    list_index = [i for i, x in enumerate(name_sorted_list) if x  == name_sorted_list[0]]
    for i in list_index:
        test_list.append(name_sorted_list[i])
        del name_sorted_list[i]
    test_list = sorted(test_list, key=lambda x:x[1], reverse = True)
    for item in test_list:
        ans_list.append(item)

for item in ans_list:
    print(item[2])

Submission status: Wrong Answer

Solution code:
N = int(input())

X=[]
for i in range(N):
    X.append([str(j) for j in input().split()])

sort1=sorted(X, key=lambda x:x[1], reverse=True)
sort2=sorted(sort1, key=lambda x:x[0])

for j in range(N):
    print(X.index(sort2[j])+1)

Submission status: Wrong Answer

Solution code:
N = int(input())

X=[]
for i in range(N):
    X.append([str(j) for j in input().split()])

sort1=sorted(X, key=lambda x:x[1], reverse=True)
sort2=sorted(sort1, key=lambda x:x[0])
print(sort2)

for j in range(N):
    print(X.index(sort2[j])+1)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[]
for i in range(N):
  a = list(input().split())
  A.append([a[0],int(a[1]),(i+1)])
A.sort(key=lambda x:x[1],reverse=True)  #二個目の要素で降順並び替え
A.sort(key=lambda x:x[0])  #二個目の要素で降順並び替え

print(A)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
N = int(input())
SP_1 = [list(input().split()) for i in range(N)]
for i in range(N) :
    SP_1[i][1] = int(SP_1[i][1])
buf = 0
SP_2 = SP_1
SP_1 = sorted(SP_1,key = itemgetter(0))
# print(SP_1)
for i in range(1,N) :
    if SP_1[i][0] != SP_1[i-1][0] :
        print(SP_1[buf:i])
        SP_1[buf:i] = sorted(SP_1[buf:i],key = itemgetter(1),reverse = True)
        buf = i
SP_1[buf:N] = sorted(SP_1[buf:N],key=itemgetter(1),reverse = True)
# print(SP_1) 
for i in range(N) :
    for j in range(N) :
        if SP_1[i] == SP_2[j] :
            print(j+1)
            break