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:
def anprint():
    global fin
    global n
    b = -1
    p = -1
    for i in range(n):
        if lst[i][1] > b:
            p = i
            b = lst[i][1]
    print(p+1)
    lst[p][1] = 0
    fin -= 1
    if fin>0:
        anprint()




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

Submission status: Wrong Answer

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

for i in range(N):
    SPI[i].append(i+1)
SPI.sort()

B = []
cnt = 1

for i in range(N-1):
    if SPI[i][0] == SPI[i+1][0]:
        SPI[i][2], SPI[i+1][2] = SPI[i+1][2], SPI[i][2]

'''
cnt = 0
for i in range(1,N):
    if SPI[i-1][0] != SPI[i][0]:
        SPI[i:B[cnt]].reverse()
'''
for i in range(N):
    print(SPI[i][2])

Submission status: Wrong Answer

Solution code:
number = int(input())
review_list = []

for i in range(number):
    review = input().split()
    review_list.append(review)
    
review_lists = sorted(review_list, key=lambda x: x[0])

for i in range(number-1):
    if review_lists[i][0] == review_lists[i+1][0]:
        if int(review_lists[i][1]) < int(review_lists[i+1][1]):
            review_lists[i][1], review_lists[i+1][1] = review_lists[i+1][1],review_lists[i][1]

for i in review_lists:
    print(number - review_list.index(i))

Submission status: Wrong Answer

Solution code:
from functools import cmp_to_key
N = int(input())

my_list = []

for i in range(N):
    t, c = input().split()
    my_list.append((t, int(c), i+1))

def cmp(a, b):
    if a == b: return 0
    return -1 if a < b else 1

my_list.sort(key=cmp_to_key(lambda x, y: cmp(x[0], y[0]) or cmp(x[1], y[1])))

for mi in my_list:
    print(mi[2])

Submission status: Wrong Answer

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

e = list()
c = sorted(c,key=lambda x:(x[0],x[1]))
for i in range(1,len(c)):
    if(i == 1 and c[0][0] == c[1][0]):
        e.append(c[0][2])
    elif(i == 1 and c[0][0] != c[1][0]):
        print(c[0][2])
        e = list()
        
        
    if(c[i-1][0] == c[i][0]):
        e.append(c[i][2])
                  
    else:
        for j in reversed(range(0,len(e))):
            print(e[j])
                  
        e = list()
        e.append(c[i][2])
        

for j in reversed(range(0,len(e))):
        print(e[j])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter, attrgetter

a = int(input())
b = []
for i in range(a):
    c = input().split()
    b.append((c[0], int(c[1]), i+1))
s = sorted(b, key=itemgetter(0))
s = sorted(s, key=itemgetter(1), reverse=True)

for i in s:
    print(i[-1])

Submission status: Wrong Answer

Solution code:
n=int(input())
i = 1
alllist = []
while i < n+1 :
  a,b=map(str, input().split())
  c = [a ,int(b),i]
  alllist.append(c)
  i += 1
alllist.sort(key=lambda x:(x[0],-x[1]),reverse=True)
alllist.reverse()
print(alllist)
j = 0
while j < n :
  print(alllist[j][2])
  j += 1

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

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

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

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

        tmp_vals = [val]
        tmp_indexes = [index]

    before_key = tmp_key

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

for elm in out:
    print(elm+1)

Submission status: Wrong Answer

Solution code:
N=int(input())

name=[input().split() for i in range(N)]
score=[]

#print(name)

name2=sorted(name,key=lambda x:(x[0],-int(x[1])))
#name=sorted(name,key=lambda x:x[1], reverse=True)
#print(name2)

for i in range(N):
    for j,city in enumerate(name2):
        if name[i]==city:
            print(j+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from bisect import insort_left as il
n=int(input())
a=[]

d={}
for i in range(n):
    s,p=input().split()
    p=int(p)
    a.append(p)
    
    if s not in d:
        d[s]=[p]
    else:
        il(d[s],p)
print(d)
s=sorted(d)
print(s)



for i in s:
    
    
    for j in range(len(d[i])):
        print(a.index(d[i].pop())+1)

Submission status: Wrong Answer

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

e = list()
c = sorted(c,key=lambda x:(x[0],x[1]))
for i in range(1,len(c)):
    if(i == 1 and c[0][0] == c[1][0]):
        e.append(c[0][2])
    elif(i == 1 and c[0][0] != c[1][0]):
        print(c[0][2])
        e = list()
        
        
    if(c[i-1][0] == c[i][0]):
        e.append(c[i][2])
                  
    else:
        for j in reversed(range(0,len(e))):
            print(e[j])
                  
        e = list()
        e.append(c[i][2])
        

for j in reversed(range(0,len(e))):
        print(e[j])

Submission status: Wrong Answer

Solution code:
N = int(input())
city_score = [[i for i in input().split()] for i in range(N)]
city = list()
score = list()
all = list()
for i in range(N):
    city.append(city_score[i][0])
    score.append(city_score[i][1])
    all.append([city_score[i][0], int(city_score[i][1]), i+1])
#print(all)

while(True):
    min_word = "zzzzzzzzzz"
    max_score = -1
    ans = 0
    index = 0
    for i in range(len(all)):
        if(all[i][0] <= min_word and all[i][1] > max_score):
                max_score = all[i][1]
                min_word = all[i][0]
                ans = all[i][2]
                index = i
    print(ans)
    all.pop(index)
    #print(all)
    if(len(all) == 0):
        break

Submission status: Wrong Answer

Solution code:
from operator import itemgetter, attrgetter

a = int(input())
b = []
for i in range(a):
    c = input().split()
    b.append((c[0], int(c[1]), i+1))
s = sorted(b, key=itemgetter(0))
sorted(s, key=itemgetter(1), reverse=True)
for i in s:
    print(i[-1])

Submission status: Wrong Answer

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

from operator import itemgetter

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

for i in ans:
    if i in sp:
        print(sp.index(i)+1)
    else:
        pass

Submission status: Wrong Answer

Solution code:
N = int(input())
sp=[[0]*3 for i in range(N)]
for i in range(N):
    sp[i][0], sp[i][1] = input().split()
    sp[i][1] = int(sp[i][1])
    sp[i][2] = i

sp = sorted(sp, key=lambda x:x[0])
sp = sorted(sp, key=lambda x:x[1])
for i in sp:
    print (i[2])

Submission status: Wrong Answer

Solution code:
N = int(input())

S = [""] * N
P = [0] * N

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


new_S = sorted(S)

same_v = []
same_i = []
for i, name in enumerate(new_S):
    for k in range(N):
        if new_S[i] == S[k]:
            same_v.append(P[k])
            same_i.append(k)
    x = same_i[same_v.index(max(same_v))]
    print(x + 1)
    same_v = []
    same_i = []
    P[x] = 0

Submission status: Wrong Answer

Solution code:
N = int(input())
sp=[[0]*3 for i in range(N)]
for i in range(N):
    sp[i][0], sp[i][1] = input().split()
    sp[i][1] = int(sp[i][1])
    sp[i][2] = i

sp = sorted(sp, key=lambda x:x[1])
sp = sorted(sp, key=lambda x:x[0])
for i in sp:
    print (i[2])

Submission status: Wrong Answer

Solution code:
n = int(input())

li = []

for i in range(n):
    [si, pi] = input().split()
    li.append((si, int(pi), i+1))

li.sort(key = lambda tup: tup[0])

li2 = []
while len(li) > 0:
  key = li[0][0]
  flag = True
  while flag and len(li) > 0:
    if key in li[0][0]:
      li2.append(li.pop(0))
    else:
      flag = False
  li2.sort(key = lambda tup: tup[1], reverse = True)
  for x in li2:
    print(x[2])
  li2 = []

Submission status: Wrong Answer

Solution code:
number = int(input())
review_list = []

for i in range(number):
    review = input().split()
    review_list.append(review)
    
review_lists = sorted(review_list)

for i in range(number-1):
    if review_lists[i][0] == review_lists[i+1][0]:
        if int(review_lists[i][1]) < int(review_lists[i+1][1]):
            review_lists[i][1], review_lists[i+1][1] = review_lists[i+1][1],review_lists[i][1]

for i in review_lists:
    print(number - review_list.index(i))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

d.sort()
for i in range(n):
    print(int(d[i][2])+1)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ss = list(set(S))
ss.sort()

a = []
b = []
for i in ss:
    for s, p in t:
        if i == s:
            a.append(p)
    b.extend(sorted(a, reverse=True))
    a = []

print(P)
print(b)
for i in range(len(b)):
    for j in range(len(P)):
        if b[i] == P[j]:
            print(j+1)
            break

Submission status: Wrong Answer

Solution code:
import numpy as np
from operator import itemgetter

N = int(input())

list = []
for i in range(N):
    a,b=input().split()
    list.append([a, int(b),i+1])
sort1 = sorted(list, key=itemgetter(0))
ans = []
kari = []
end = 1
k = 1
for i in range(0,N-1):
    if end == 1:
    	kari.append(sort1[i])
    else:
      	k = 0
    if sort1[i][0] == sort1[i+1][0]:  
        kari.append(sort1[i+1])
        end = 0
        if i+1 > N-2:
        	kari.sort(key=itemgetter(1),reverse=True)
        	ans.extend(kari)
    else:
        kari.sort(key=itemgetter(1),reverse=True)
        ans.extend(kari)
        kari = []
        end = 1

for i in range(0,len(ans)):
	print(ans[i][2])

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
for i in range(n):
    s,p = map(str,input().split())
    lis.append([s,100 - int(p)])
liss = lis.copy()
lis.sort()
print(liss)
for i in range(n):
    print(liss.index(lis[i]) + 1)

Submission status: Wrong Answer

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


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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
M = [0 for i in range(N*3)]
for i in range(N):
    M[i *3], M[i * 3 +1] = input().split()
    M[i * 3 + 2] = i + 1
arr = [[0 for column in range(3)] for row in range(N)]
for i in range(N):
    arr[i][0] = M[i *3]
    arr[i][1] = M[i * 3 +1]
    arr[i][2] = M[i * 3 +2]
arr = sorted(arr, key=lambda x:(x[0], x[1]), reverse = True)
arr = sorted(arr, key=lambda x:x[0])
for i in range(N):
    print(arr[i][2])

Submission status: Wrong Answer

Solution code:
n = int(input())
val = {}
c = []
for i in range(n):
    a,b = input().split()
    if a in val:
         val[a].append(int(b))
         c.append(int(b))
    else : 
        val[a] = [int(b)]
        c.append(int(b))

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

d = []
for i in range(len(val_1)):
    if len(val_1[i]) == 1 :
        d.append(val_1[i][1][0])
    else:
        val_1[i][1].sort(reverse= True)
        for h in val_1[i][1]:
            d.append(h)


for i in c:
    for j in range(n):
        if i == d[j] :
            print("{}".format(j+1))

Submission status: Wrong Answer

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


B = sorted(A, key=lambda x: x[1], reverse=True)

C = sorted(B, key=lambda x: x[0])

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

Submission status: Wrong Answer

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

for j in s:
    onon = 0
    for k in sorteds:
        onon += 1
        if j[1] == k[1]:
            print(onon)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
for i in range(n):
    s,p = map(str,input().split())
    lis.append([s,100 - int(p)])
liss = lis.copy()
lis.sort()
print(liss)
for i in range(n):
    print(lis.index(liss[i]) + 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
val = {}
c = []
for i in range(n):
    a,b = input().split()
    if a in val:
         val[a].append(int(b))
         c.append(int(b))
    else : 
        val[a] = [int(b)]
        c.append(int(b))

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

d = []
for i in range(len(val_1)):
    if len(val_1[i]) == 1 :
        d.append(val_1[i][1])
    else:
        val_1[i][1].sort(reverse= True)
        for h in val_1[i][1]:
            d.append(h)


for i in c:
    for j in range(n):
        if i == d[j] :
            print("{}".format(j+1))

Submission status: Wrong Answer

Solution code:
#from operater import itemgetter
from collections import Counter
import numpy as np
N=int(input())
c=[]
v=[]
ans=[]
c_v={}
for i in range(N):
    tmp=input().split()
    ans.append(tmp)
    c.append(tmp[0])
    v.append(int(tmp[1]))
    if tmp[0] in c_v.keys():
        c_v[tmp[0]].append(int(tmp[1]))
    else:
        c_v[tmp[0]]=[int(tmp[1])]
    
hoge=np.array(list(Counter(c).keys()))
huga=np.argsort(np.array(c))
for i in range(N):
    city=ans[i][0]
    if len(c_v[city])==1:
        print(huga[np.where(hoge==ans[i][0])][0]+1)
    else:
        tmp=np.array(c_v[city])
        h=np.argsort(tmp)[::-1]
        print(huga[np.where(hoge==ans[i][0])][0]+h[c_v[city].index(int(ans[i][1]))]+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
res = []
for i in range(n):
    a,b = input().split()
    res.append ((a,b))        
res_1 = sorted(res,key=lambda x: (x[0], -int(x[1])))
for i in range(len(res_1)):
    print(res.index(res_1[i]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
val = {}
c = []
for i in range(n):
    a,b = input().split()
    if a in val:
         val[a].append(int(b))
         c.append(int(b))
    else : 
        val[a] = [int(b)]
        c.append(int(b))

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

d = []
for i in range(len(val_1)):
    if len(val_1[i]) == 1 :
        d.append(val_1[i][0])
    else:
        val_1[i][1].sort(reverse= True)
        for h in val_1[i][1]:
            d.append(h)


for i in c:
    for j in range(n):
        if i == d[j] :
            print("{}".format(j+1))

Submission status: Wrong Answer

Solution code:
N = int(input())
X = {}
tmp1 = []
for i in range(N):
    tmp1.append(input())
    tmp2 = tmp1[i].split()
    if tmp2[0] in X:
        X[tmp2[0]].append(int(tmp2[1]))
    else:
        X[tmp2[0]] = [int(tmp2[1])]

X_sorted = dict(sorted(X.items(), key=lambda x:x[0]))

for i in X_sorted.keys():
    X_sorted[i] = sorted(X[i],reverse=True)

res = []
for i in X_sorted.keys():
    for j in range(len(X_sorted[i])):
        res.append(i+" "+str(X_sorted[i][j]))

for i in range(len(res)):
    print(tmp1.index(res[i])+1)

Submission status: Wrong Answer

Solution code:
a= input()
dict ={}
for num in range(int(a)):
    b= input().split()
    if b[0] in dict:
      dict[b[0]][b[1]]=num
    else:
      dict2={}
      dict2[b[1]]=num
      dict[b[0]] = dict2

dict = sorted(dict.items())
for i in dict:
  lits_i =i[1]
  dict2 = sorted(lits_i .items(), reverse=True)
  for j in dict2:
    print(j[1]+1)

Submission status: Wrong Answer

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

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

d.sort()
for i in range(n):
    print(int(d[i][2])+1)

Submission status: Wrong Answer

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

for row in SP:
    row[1] = int(row[1])

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

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

print(SPsort)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter as ite

n=int(input())
l=[]
name=[]
for i in range(n):
    l.append(list(input().split()))
    name.append(l[i][0])
name=set(name)
name=list(name)
name.sort()

na=len(name)
tmp=99
k=0
ma=0
while k!=na:
    for j in range(len(l)):
        if l[j][0]==name[k]:
            if ma<int(l[j][1]):
                ma=int(l[j][1])
                out=j
    if tmp==out:
        k+=1
    else:
        print(out+1)
        l[out][1]=0
    ma=0
    tmp=out

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
city = []
score = []
itetator = []
for i in range(N):
    city_i, score_str = input().split()
    city.append(city_i)
    score_i = int(score_str)
    score.append(score_str)
    itetator.append(i+1)
for j in range(N):
    for k in range(N-1):
        if city[k] > city[k + 1]:
            city[k], city[k + 1] = city[k + 1], city[k]
            score[k], score[k + 1] = score[k + 1], score[k]
            itetator[k], itetator[k + 1] = itetator[k + 1], itetator[k]

        elif city[k] == city[k + 1] and score[k] < score[k + 1]:
            score[k], score[k + 1] = score[k + 1], score[k]
            itetator[k], itetator[k + 1] = itetator[k + 1], itetator[k]



for m in range(N):
    print("{}".format(itetator[m]))

Submission status: Wrong Answer

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

from operator import itemgetter

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

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

for i in ans:
    print(my_index(sp, i)+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
SP = [input().split() for _ in range(N)]
for i in range(0, N): SP[i].append(i+1)
SP.sort(key=lambda x:(x[0]))
cp = [0]
for i in range(0, N):
    if i == 0:
        t = SP[i][0]
    else:
        if t != SP[i][0]:
            cp.append(i)
            t = SP[i][0]
cp.append(len(SP))
for j in range(0, len(cp)-1):
    a = SP[cp[j]:cp[j+1]]
    a.sort(key=lambda x:(x[1]), reverse=True)
    for k in range(0, len(a)): print(a[k][2])

Submission status: Wrong Answer

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


for i in range(n):
    s,p=input().split()
    p=int(p)
    a.append(s)
    b.append(p)

x=list(zip(a,b))

y=sorted(x,key=lambda x:(x[0],-x[1]))
print(y)
for i in range(n):
    print(int(x.index(y[i]))+1)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
city = []
score = []
itetator = []
for i in range(N):
    city_i, score_str = input().split()
    city.append(city_i)
    score_i = int(score_str)
    score.append(score_str)
    itetator.append(i+1)
for j in range(N):
    for k in range(N-1):
        if city[k] > city[k + 1]:
            city[k], city[k + 1] = city[k + 1], city[k]
            score[k], score[k + 1] = score[k + 1], score[k]
            itetator[k], itetator[k + 1] = itetator[k + 1], itetator[k]
            print("{},{}".format(itetator[k], itetator[k+1]))
        elif city[k] == city[k + 1] and score[k] < score[k + 1]:
            score[k], score[k + 1] = score[k + 1], score[k]
            itetator[k], itetator[k + 1] = itetator[k + 1], itetator[k]
            print("{},{}".format(score[k], score[k + 1]))
    for n in range(N):
        print("{}".format(score[n]))

for m in range(N):
    print("{},{},{}".format(city[m], itetator[m], score[m]))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


def main():
    D = defaultdict(list)
    names = set()
    N = int(input())
    for i in range(1, N+1):
        inp = input().split()
        s = inp[0]
        p = inp[1]
        names.add(s)
        D[s].append((p, i))
    names = sorted(list(names))
    for n in names:
        D[n].sort(key=lambda x: x[0], reverse=True)
        for x in D[n]: print(x[1])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
S=[0]*N
P=[0]*N
for i in range(N):
  x,a=input().split()
  S[i], P[i]=x,int(a)
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())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = list(map(str,input().split()))

B = sorted(A, key=lambda x: x[1], reverse=True)

C = sorted(B, key=lambda x: x[0])

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

Submission status: Wrong Answer

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


for i in range(n):
    s,p=input().split()
    a.append(s)
    b.append(p)

x=list(zip(a,b))

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

for i in range(n):
    print(int(x.index(y[i]))+1)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

list_sorted = lists.copy()

list_sorted.sort()
list_sorted.sort(key=lambda x:(x[0],x[1]),reverse =True)
for result in range(N):
    for sorted in range (N):
        if lists[result] == list_sorted[sorted]:
            print(sorted+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
val = list()
rey = set()
run = list()

for b in range(n):
  i,a = input().split(' ')
  val.append([b,i,int(a)])
  rey.add(i)
  run.append(int(a))

rey_sort = sorted(list(rey))
run_sort = list(reversed(sorted(run)))
print(run_sort)
for b in range(n):
  for i, city in enumerate(rey_sort):
    if city == val[b][1]:
      val[b].append(i)

for b in range(n):
  for i,num in enumerate(run_sort):
    if val[b][2] == num:
      val[b].append(i)
  
print(val)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter, attrgetter

class data:
    def __init__(self, i, c, n):
        self.ind = i
        self.city = c
        self.num = -int(n)

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

d.sort(key=attrgetter('city', 'num'))

for i in range(N):
    print(d[i].ind+1, d[i].city, d[i].num)

Submission status: Wrong Answer

Solution code:
N = int(input())
SP = [list(input().split()) for _ in range(N)]
s = [SP[i][0] for i in range(N)]
p = [SP[i][1] for i in range(N)]
s_new = SP.copy()
be = list(sorted(range(len(s_new)), key=lambda k: s_new[k]))
s_new.sort()
ans = []
for i in be:
    ans.append( i+ 1)

for i in range(N-1):
    if s_new[i][0] == s_new[i+1][0]:
        ans[i],ans[i+1] = ans[i+1],ans[i]
    

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())

S = []
P = []
for i in range(N):
	s, p = input().split()
	S.insert(i, s)
	P.insert(i, p)
print(S)
print(P)

list = []
for i in range(N):
	temp = [S[i], int(P[i])]
	list.append(temp)

clone = copy.copy(list)

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

print(list)
print(clone)

for i in range(N):
	print(list.index(clone[i])+1)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
N = int(input())
rest = []

for i in range(N) :
  raw = list(input().split())
  raw[1] = int(raw[1]) 
  raw.append(int(i + 1))
  rest.append(raw)

rest.sort(key=itemgetter(0, 1))

for k in range(N) :
  print(rest[k][2])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

n = int(input())

a = [input().split() for i in range(n)]

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

aaa = {i[0] for i in a}

if len(aaa) == 1:
    b = sorted(a, reverse=True)
else:
    b = sorted(a, key=lambda x: x[0])


c = list()

for i, b2 in enumerate(b):
    if i == 0:
        c.append(b2)
        continue

    if b2[0] == c[i-1][0]:
        if int(b2[1]) >=  int(c[i-1][1]):
            c.insert(i-1, b2)
        else:
            c.append(b2)
    else:
        c.append(b2)

for c2 in c:
    for j, a2 in enumerate(a):
        if c2 == a2:
            print(j+1)
            continue

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] += 'zzzzzzzzzzzzzzz' + 'z' * 10 * (i+1)

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
from copy import deepcopy


n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
for i, list in enumerate(data):
    list[1] = int(list[1])
    list.append(i+1)

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

for i, list in enumerate(sortdata):
    print(list[2])

Submission status: Wrong Answer

Solution code:
import copy
from operator import itemgetter
times = int(input())  # 3
n = []
for i in range(times):
    n.append(input().split())
    n[i][1] = int(n[i][1])
b = copy.copy(n)
b = sorted(b,key=itemgetter(1))
b.reverse()
b = sorted(b,key=itemgetter(0))
for i in range(times):
    for j in range(times):
        if n[i][0] == b[j][0] and n[i][1] == b[j][1]:
            print(j+1)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

list_sorted = lists.copy()
list_sorted.sort()
list_sorted.sort(key=lambda x: x[1],reverse =True)
for result in range(N):
    for sorted in range (N):
        if lists[result] == list_sorted[sorted]:
            print(sorted+1)