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:
#https://atcoder.jp/contests/abc127
# -*- coding: utf-8 -*-

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

s2=sorted(s,key=lambda x: (x[1]),reverse = True)
s2=sorted(s2,key=lambda x: (x[0]))
for i in s2:
    for j in range(n):
        if i==s[j]:
            print(j+1)

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/abc127
# -*- coding: utf-8 -*-

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

s2=sorted(s,key=lambda x: (x[1]),reverse = True)
s2=sorted(s2,key=lambda x: (x[0]))
print(s2)
for i in s2:
    for j in range(n):
        if i==s[j]:
            print(j+1)

Submission status: Wrong Answer

Solution code:
for *_,a in sorted([input().split()+[-i]for i in range(int(input()))]):print(a+1)

Submission status: Wrong Answer

Solution code:
from collections import OrderedDict

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 = OrderedDict(sorted(X.items(), key=lambda x:x[0]))
print(X_sorted)
for i in X_sorted.keys():
    X_sorted[i] = sorted(X_sorted[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=[]
for i in range(int(input())):
    s, p = input().split()
    p=int(p)
    a.append((s,p,i+1))
a.sort(key=lambda x:(x[0],-x[1]))
print(a)
[print(x[2])for x in a]

Submission status: Wrong Answer

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

shop_list = sorted(shop_list, key=lambda x:x[2], reverse=True)
shop_list = sorted(shop_list, key=lambda x:(x[1], -x[2]), reverse=True)
for e in shop_list:
  print(e[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
SP = []
for i in range(N):
  s,p = map(str,input().split())
  pint = int(p)
  pint = 100-pint
  p2 = str(pint)
  SP.append([s,p2,str(i+1)])
SP.sort()
for i in range(N):
  print(int(SP[i][2]))

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
N = int(input())
SP = [[x for x in input().split()]+[i]for i in range(N)]
SP.sort(key=itemgetter(1),reverse=True)
SP.sort(key=itemgetter(0))
for i in SP:
    print(i[2]+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
SP = []
for i in range(N):
  s,p = map(str,input().split())
  pint = int(p)
  pint = -pint
  p = str(pint)
  SP.append([s,p,str(i+1)])
SP.sort()
for i in range(N):
  print(int(SP[i][2]))

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))
if N == 1:
  	print(1)
else:
    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)
            if i+1 > N-2:
            	ans.append(sort1[i+1])
            	kari = []
            	end = 1
    print(sort1)
    print(ans)
    for i in range(0,len(ans)):
        print(ans[i][2])

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]))
test={}
for i in X_sorted.keys():
    test[i] = sorted(X_sorted[i],reverse=True)

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
SP = []
for i in range(N):
  s,p = map(str,input().split())
  pint = int(p)
  pint = 100-pint
  p = str(pint)
  SP.append([s,p,str(i+1)])
SP.sort()
for i in range(N):
  print(int(SP[i][2]))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [0] * N
P = [0] * N
 
city_point = {}
 
for i in range(N):
    inp = input().split()
    S[i] = inp[0]
    P[i] = inp[1]
    city_point[i] = {'city': S[i], 'point': int(P[i])}
    
sorted_list = sorted(city_point.items(), key=lambda x: (x[1]['city'], x[1]['point']), reverse=True)
 
for item in sorted_list:
    print(item[0] + 1)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = [0]*N
Y = ["0"]*N
for i in range(N):
  a,b = map(str, input().split())
  X[i] = (a, int(b), i+1)
  Y[i] = a
Z = list(set(Y))
SUM = 0
for i in range(len(Z)):
  Q = Y.count(Z[i])
  B = X[SUM:SUM+Q]
  SUM += Q
  B=sorted(B, key = lambda x : x[1])
  for j in range(len(B)):
    print(B[j][2])

Submission status: Wrong Answer

Solution code:
N = int(input())
SP = []
for i in range(N):
  s,p = map(str,input().split())
  pint = int(p)
  pint = 100-pint
  p = str(pint)
  SP.append([s,p,str(i+1)])
SP.sort()
for i in range(N):
  print(SP[i][2])

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_sorted[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:
from collections import defaultdict

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

city_point = {}

for i in range(N):
    inp = input().split()
    S[i] = inp[0]
    P[i] = inp[1]
    city_point[i] = {'city': S[i], 'point': int(P[i])}
    
sorted_list = sorted(city_point.items(), key=lambda x: (x[1]['city'], x[1]['point']))

for item in sorted_list:
    print(item[0] + 1)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = list()
p = list()

for i in range(N) :
  S, P = map(str, input().split())
  s.append(S)
  p.append(P)

for j in range(N - 1) :
  for k in range(j + 1, N) :
    if(s[j] <= s[k]) :
      if(s[j] == s[k] and p[j] < p[k]) :
        a = j + 1
      elif(s[j] == s[k] and p[j] > p[k]) :
        a = k + 1
      else :
        a = k + 1
  print(a)

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

count = 0
count_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]
            count_list.append(count)
    count += 1
        
answer = []

for i in review_lists:
    answer.append(number - review_list.index(i))
    
for i in count_list:
    answer[i],answer[i+1]=answer[i+1],answer[i]    
  
for i in answer:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [[]*4]*N
S = ''
P = ''
for i in range(N):
  S, P = input().split()
  L[i] = [0, S, int(P)*-1, i, 0]
L.sort()
for i in range(N):
  print(L[i][4])

Submission status: Wrong Answer

Solution code:
N = int(input().strip())

list = [input() for i in range(N)]
print(list)

from operator import itemgetter
sort1 = sorted(list, key=itemgetter(0))
sort2 = sorted(sort1, key=itemgetter(1), reverse= True)
print(sort2)

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

Submission status: Wrong Answer

Solution code:
n=int(input())
cityLst=[]
for i in range(n):
	s,p=map(str,input().split(" "))
	cityLst.append(["{:<10}".format(s),p])
sCityLst=sorted(cityLst,key=lambda x:x[0]+"a"+chr(int(x[1])+97))
for o in sCityLst:
	print(cityLst.index(o)+1)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
from collections import OrderedDict

N = int(input())
li = []
lipay = []
linum = []
cnt = 1


datalist =[ list(map(str, input().split())) for i in range(N) ]

for i in range(0,N):
    datalist[i].append(cnt)
    cnt += 1

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


for i in range(0,N):

    print(datalist[i][2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
from collections import OrderedDict
k = int(input())
c = []
p = []
for i in range(k):
    l = input()
    s = l.split()
    c.append(s[1])
    p.append(tuple(s))
#print(p)
x=sorted(p, key=lambda s: s[0])
#print(c)
#print(x)

for j in range(k):
    #print(x[j][1])
    print(c.index(x[j][1])+1)

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)
        if i+1 > N-2:
        	ans.append(sort1[i+1])
        kari = []
        end = 1
for i in range(0,len(ans)):
	print(ans[i][2])

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [[]*4]*N
S = ''
P = ''
for i in range(N):
  S, P = input().split()
  L[i] = [0, S, int(P)*-1, i, 0]
L.sort()
for i in range(N):
  L[i][0] = L[i][3]
  L[i][4] = i+1

L.sort()
for i in range(N):
  print(L[i][4])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#from IPython import embed
N=int(input())
n = []

from collections import Counter

c = Counter()

for i in range(N):
    k = input().split()
    k.append(i+1)
    n.append(k)
    c.update([k[0]])



n.sort()
#n = n[::-1]
prev = ""
l = []
cnt = 0
#print(c)
for a in n:
    #print(a)

    if c[a[0]] > 1:
        l.append(a[1:])
        #print(a[1:])
        cnt+=1
        #print(a[0])
        #embed()
        if cnt == c[a[0]]:
            l.sort()
            #print(l)
            for i in l[::-1]:
                print(i[1])
            cnt = 0
            l = []
    else:
        print(a[2])

Submission status: Wrong Answer

Solution code:
N = int(input())
lists_S = []
lists_P = []
for i in range(N):
    S,P = map(str,str(input()).split())
    lists_S.append(S)
    lists_P.append(int(P))
c = list(zip(lists_S,lists_P))
c = sorted(c,key=lambda x:(x[0],-x[1]))
s,p = zip(*c)
print(s,p)
lists_index = []
for i in range(N):
    for j in range(N):
        if s[i] == lists_S[j] and p[i] == lists_P[j]:
            print(lists_S[i],s[j],p[j],lists_P[i])
            lists_index.append(p.index(p[j]) + int(1))
print(lists_index)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = [int(i) for i in input().split()][0]

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

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

for next,l in enumerate(new_ls):
  for i,tmp in enumerate(ls):
    if l[0]==tmp[0] and l[1]==tmp[1]:
      print(i+1)
      continue

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

p = [0]*100
store = []

for i in range(0,n):
    s,p[i] = map(str,input().split())
    store.append(s)


num_data = dict(zip(p,list(range(0,n))))
#num_data = dict((sorted(num_data.items())))

p = list(map(int,p))


for i in range(0,n - 1):
    for j in range(i, n):
        if(store[i] == store[j]):
            if(p[i] < p[j]):
                box = p[i]
                p[i] = p[j]
                p[j] = box
         

p_str = list(map(str,p))

for i in range(0,n):
    print(num_data[p_str[i]])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N=int(input())
d=[]
for _ in range(N):
    city,point=input().split()
    point=int(point)
    d.append([_,city,point])
sorted_list=sorted(d, key=lambda x:(x[1],x[2]), reverse=True)
for _ in range(len(d)):
    print(sorted_list[_][0]+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
P = []
I = []
Z = []

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

for i, j, k in zip(S,P,I):
    Z.append([i,j,k])

Z_sorted = sorted(Z)

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

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

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)
  ind_1=np.flipud(ind_1)
  S=S[ind_1]
  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:
#b.py
n = int(input())
lis = [list(input().split())+[x] for x in range(n)]
lis = sorted(lis,key=lambda x:x[0])
now = lis[0][0]
ans_lis = []
sublis = []
for x in lis:
    if x[0] == now:
        sublis.append(x)
    else:
        now = x[0]
        sublis = sorted(sublis,key=lambda x:int(x[1]),reverse=True)
        print(int(x[1]))
        ans_lis.append(sublis)
        sublis = []
        sublis.append(x)
sublis.sort(key=lambda x:int(x[1]),reverse=True)
ans_lis.append(sublis)
sublis = []
sublis.append(x)       
ans_lis = [item for sublist in ans_lis for item in sublist]
for x in ans_lis:
    print(x[2]+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import exit

N = int(input())

R = {}

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

    if s in R:
        R[s].append((int(p), i + 1))
    else:
        R[s] = [(int(p), i + 1)]

R = dict(sorted(R.items()))

ans = {}

for k in R:
    ans[k] = sorted(R[k], key=lambda x: -x[0])

for k in ans:
    for a in ans[k]:
        print(a[1])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n = int(input())
l = []
for i in range(n):
    pair = input().split()
    l.append([pair[0], pair[1]])
l2 = l[:]
# point rev. sort
sub = sorted(l2, key=itemgetter(1), reverse=True)
# name sort
l_sorted = sorted(sub, key=itemgetter(0))
for i in range(n):
    for j in range(n):
        if (l[j] == l_sorted[i]):
            print(j+1)

Submission status: Wrong Answer

Solution code:
n=int(input())
s =[]
l =[]
ans = []
count = 1
for i in range(n):
    s1,p = map(str,input().split())
    p1 = int(p)
    l.append(s1)
    s.append(list([s1,p1]))
l = sorted(list(set(l)))
for i in l:
    t =[]
    index_num = [n for n, v  in enumerate(s) if v[0] == i]
    for k in index_num:
        t.append(list([s[k][1],k]))
    t=sorted(t,reverse=True)
    for z in t:
        ans.append(list([z[1],count]))
        count+=1
ans = sorted(ans)
[print(ans[i][1]) for i in range(len(ans))]

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n = int(input())
l = []
for i in range(n):
    pair = input().split()
    l.append([pair[0], pair[1]])
l2 = l[:]
print(l)
# point rev. sort
sub = sorted(l2, key=itemgetter(1), reverse=True)
# name sort
l_sorted = sorted(sub, key=itemgetter(0))
print(l_sorted)
for i in range(n):
    for j in range(n):
        if (l[j] == l_sorted[i]):
            print(j+1)

Submission status: Wrong Answer

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

t.sort()

result = []

def bubble_sort(arr):
    change = True
    while change:
        change = False
        for i in range(len(arr) - 1):
            if arr[i][0] == arr[i+1][0] and int(arr[i][1]) < int(arr[i+1][1]):
                arr[i], arr[i + 1] = arr[i + 1], arr[i]
                change = True
    return arr
_list = bubble_sort(t)


for a in _list:
    for i, item in enumerate(t2):
        i+=1
        if a == item:
            result.append(i)

for r in result:
    print(r)

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+1))

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

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from operator import itemgetter
n = int(input())
restList = []
for i in range(n):
    city, p = map(str, input().split())
    restList.append([i + 1, city, int(p)])
restList.sort(key=itemgetter(1))

city = restList[0][1]
same_list = []
for R in restList:
    if R[1] == city:
        same_list.append(R)
    else:
        if same_list:
            same_list.sort(key=itemgetter(2), reverse=True)
            for s in same_list:
                print(s[0])
            same_list = []
            same_list.append(R)
    city = R[1]
if same_list:
    for s in same_list:
        print(s[0])

Submission status: Wrong Answer

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

N = int(input())
list = [input().split() for i in range(N)]
list2 = copy.deepcopy(list)
list2.sort(key=lambda x:(x[0],-int(x[1])))
print(list2)

for i in range(N):
    a = list2[i]
    b = list.index(a)
    print(int(b + 1))

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)
        if i+1 > N-2:
        	ans.append(sort1[i+1])
        kari = []
        end = 1

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

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(name):
        if name2[i]==city:
            print(j+1)

Submission status: Wrong Answer

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

N = int(input())
list = [input().split() for i in range(N)]
list2 = copy.deepcopy(list)
list2.sort(key=lambda x:(x[0],-int(x[1])))
print(list2)

for i in range(N):
    a = list2[i]
    b = list.index(a)
    print(b + 1)

Submission status: Wrong Answer

Solution code:
from sys import exit

N = int(input())

R = {}

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

R = dict(sorted(R.items()))

ans = {}

for k in R:
    ans[k] = sorted(R[k], key=lambda x: -x[0])


for k in ans:
    for a in ans[k]:
        print(a[1])

Submission status: Wrong Answer

Solution code:
#任务B
read = input
N = int(read())
guidebook = []
name = []
for i in range(N):
    line = read().split()
#     name.append(line[0])
#     score.append(line[1])
    a = (line[0],int(line[1]))
    guidebook.append(a)
    
name = sorted(guidebook, key=lambda x:x[0])
# print(name)
for item in guidebook:
    n = item[0]
    s = item[1]            
    p = [i for i,x in enumerate(name) if x[0] == n]
#     print(p)
    if len(p)>1:
        score = [(name[k][1],p[0]) for k in p]
        score = sorted(score, key=lambda x:x[0], reverse=True)
#         print(score)
        for i,x in enumerate(score):
#             print(x[0])
            if x[0] == s:
                print(x[1]+i+1)
                break
    else:
        print(p[0]+1)

Submission status: Wrong Answer

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

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(int(C[i][2])+1)

Submission status: Wrong Answer

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

S.sort()

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

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

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

Submission status: Wrong Answer

Solution code:
from sys import exit

N = int(input())

R = {}

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

    if s not in R:
        R[s] = []

    R[s].append((int(p), i + 1))

R = dict(sorted(R.items()))

ans = {}

for k in R:
    ans[k] = sorted(R[k], key=lambda x: -x[0])

for k in ans:
    for a in ans[k]:
        print(a[1])

Submission status: Wrong Answer

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

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 = "zzzzzzzzzzzzzzzzzzz"
    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:
N = int(input())
A = []
for i in range(N) :
    S, P = input().split()
    A.append([S])
    A[i].append(100-int(P))
new_A_list = sorted(A)
for i in range(N) :
    print(new_A_list.index(A[i])+1)

Submission status: Wrong Answer

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

N = int(input())
list = [input().split() for i in range(N)]
list2 = copy.deepcopy(list)
list2.sort(key=lambda x:(x[0],-int(x[1])))
print(list2)

for i in range(N):
    a = list[i]
    b = list2.index(a)
    print(b + 1)

Submission status: Wrong Answer

Solution code:
a = int(input())
#List = [input().split() for i in range(a)]
#List = map(int, List[,[1]])
List = []
for i in range(a):
	b, c = input().split()
	c = int(c)
	List.append([b, c, i])
List = sorted(List, key = lambda x:x[0])
List = sorted(List, key = lambda x:x[1])

List2 = []
for i in range(a):
  List2.append(a - List[i][2])
  
print(*List2)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
def solve():
    n = input()
    s = []
    p = []
    m = defaultdict(list)
    mm = {}
    for i in range(0, int(n)):
        si, pi = map(str, input().split())
        s.append(si)
        p.append(int(pi))
        m[si].append(int(pi))
        mm[int(pi)] = i + 1
    s.sort()
    ss = set(s)
    sss = list(ss)
    sss.sort()
    for i in range (len(sss)):
        s2 = sss[i]
        pd = m[s2]
        pd.reverse()
        for j in range (len(pd)):
            
            print(mm[pd[j]])


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
n = int(input())
restaurants = [ input().split() for i in range(n) ]
names = [ restaurants[i][0] for i in range(n) ]
names = set(names)
names = sorted(list(names))
for name in names:
    list_city_scores = [ restaurants[k][1] for k in range (n) if restaurants[k][0] == name ]
    list_city_scores.sort(reverse = True)
    for l in range(len(list_city_scores)):
        print(restaurants.index([name,list_city_scores[l]]) + 1)

Submission status: Wrong Answer

Solution code:
N = int(input())
city_list = []
score_list = []
for i in range(N):
    city,score = input().split()
    score = int(score)
    city_list.append(city)
    score_list.append(score)
city_sort = sorted(city_list)
for i in sorted(list(set(city_list))):
    if(city_list.count(i) == 1):
        print(score_list[city_list.index(i)])
    else:
        list_a = []
        len_same_city = city_list.count(i)
        for j in range(len_same_city):
            list_a.append(score_list[city_list.index(i)])
            city_list[city_list.index(i)] = -1
        list_a = sorted(list_a,reverse=True)
        for k in list_a:
            print(score_list.index(k)+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,reverse=False):
  print(l.index(i) + 1)

Submission status: Wrong Answer

Solution code:
N = int(input())
SP = [input().split() for _ in range(N)]
ans = [0] * N
tmp = sorted(SP, key=lambda x:(x[0],x[1]))
cnt = 0

for s, p in SP:
    for i in range(N):
        if tmp[i][0]==s and tmp[i][1]==p:
            ans[cnt] = i
    cnt += 1

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

Submission status: Wrong Answer

Solution code:
import fractions
import numpy as np
import os
import sys

n=int(input())
tt=[]
for i in range(n):
    a,b=input().split()
    tt.append([a,b])
t=tt.copy()
t=sorted(t,key=lambda x: x[1],reverse=True)
t=sorted(t,key=lambda x: x[0])

for i in t:
    print(tt.index(i)+1)