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())
x = [list(map(str,input().split())) for _ in range(N)]
x_new=[]
for i in range(N):
  x_new.append([i+1,x[i][0],int(x[i][1])])
   
x_new.sort(reverse=True,key=lambda x: x[2])
x_new.sort(key=lambda x: x[1])

for j in range(N):
  x_new[j].append(j+1)
x_new.sort(key=lambda x:x[0])
for u in range(N):
  print(x_new[u][3])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
N=int(input())
SP = [input().split() for l in range(N)]
SP2 = []
for i in range(N):
    SP[i].append(i+1)
    SP2.append(tuple(SP[i]))
    
SP2 = sorted(SP2, key=itemgetter(1),reverse=True)
SP2 = sorted(SP2, key=itemgetter(0))
for j in range(N):
    print(SP2[j][2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# ABC 128: B – Guidebook
from operator import itemgetter

n = int(input(0))

s = []
p = []

for _ in range(n):
    tmp = [s for s in input().split()]
    s.append(tmp[0])
    p.append(int(tmp[1]))

restaurants = []
for i in range(n):
    restaurants.append([i + 1, s[i], p[i]])

restaurants.sort(key=itemgetter(2), reverse=True)
restaurants.sort(key=itemgetter(1))

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [0]*n
p = [0]*n
l = [[] for i in range(n)]

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

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [0]*n
p = [0]*n
l = [[] for i in range(n)]

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [input().split() for _ in range(N)]
a = []
for i in range(N):
  a.append([A[i][0], str(100 - int(A[i][1]))])
A = sorted(a)

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

Submission status: Wrong Answer

Solution code:
N = int( input() )
cities = {}
for i in range(1, N+1):
    a,b = input().split() 
    b = int(b)
    cities[a] = {"point":b,"number":i}
    
cities = sorted(cities.items(),key = lambda x: x[1]["point"])
cities.reverse()
cities.sort()
for i in cities:
    print(i[1]["number"])

Submission status: Wrong Answer

Solution code:
a=int(input())
c=[input().split(" ")for i in range(0,a)]
for i in c:
    i[1]=int(i[1])
#print(c)
d=sorted(c,key=lambda x:(x[0],-x[1]))
#print(d)
for i in c:
    print(d.index(i)+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
SP = {}
for i in range(N):
    line = input().split()
    SP[i] = [line[0], int(line[1])]
    
ans = []
for i, index in enumerate(sorted(SP.items(), key= lambda x: (x[1][0], -x[1][1]))):
    ans.append([index, i])
print(ans)

for ls in ans:
    print(ls[0][0] + 1)

Submission status: Wrong Answer

Solution code:
n=int(input())
z=[]
for i in range(n):
    z.append(input().split())
    z[i][1]=int(z[i][1])
    z[i].append(i+1)
z.sort()
#print(z)
for i in range(n-1):
    if z[i][0]==z[i+1][0]:
        if z[i][1]<z[i+1][1]:
            j=i
            while z[i+1][1]>z[j][1] and j>=0 and z[i+1][0]==z[j][0]:
                tmp=z[j][2]
                z[j][2]=z[i+1][2]
                z[i+1][2]=tmp
                j-=1
for k in range(n):
    print(z[k][2])

Submission status: Wrong Answer

Solution code:
n=int(input())
s,p=input().split()
p=int(p)
li=[]

for i in range(0,n):
  li.append((i+1,s,p))


new_li=sorted(li,key=lambda x:x[2] , reverse=True)
new2_li=sorted(new_li,key=lambda x:x[1])


for j in range(0,n):
  print(new2_li[j][0])

Submission status: Wrong Answer

Solution code:
n=int(input())
s,p=input().split()
p=int(p)
li=[]

for i in range(0,n):
  li.append((i+1,s,p))


new_li=sorted(li,key=lambda x:x[2] , reverse=True)
new2_li=sorted(new_li,key=lambda x:x[1])


for j in range(len(new2_li)):
  print(new2_li[j][0])

Submission status: Wrong Answer

Solution code:
n=int(input())
s,p=input().split()
p=int(p)
li=[]

for i in range(0,n):
  li.append((i+1,s,p))

new_li=sorted(li,key=lambda x:x[1])

new2_li=sorted(new_li,key=lambda x:x[2] , reverse=True)

for j in range(0,n):
  print(new2_li[j][0])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[list(input().split()) for i in range(n)]
from copy import deepcopy
b=deepcopy(a)
b.sort(key=lambda x: x[0])
for i in range(n-1):
    if b[i][0]==b[i+1][0]:
        b[i],b[i+1]=b[i+1],b[i]
print(b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
S=[]
for i in range(N):
    S.append(list(input().split()))
    S[i][1]=-int(S[i][1])
for i in range(N):
    print(sorted(range(N),key=lambda k : S[k])[i])

Submission status: Wrong Answer

Solution code:
n=int(input())
z=[]
for i in range(n):
    z.append(input().split())
y=[]
count1=0
count2=0
for j in range(n):
    y.append(0)
for m in range(n):
    z[m][1]=int(z[m][1])
for j in range(n):
    for i in range(j,n):
        if z[j][0]==z[i][0]:
            if z[j][1]>z[i][1]:
                y[i]+=1
            else:
                y[j]+=1
        else:
            if z[j][0]<z[i][0]:
                y[i]+=1
            else:
                y[j]+=1
for x in range(n):
    print(y[x])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N = int(input())
X=[]
S=[]
P=[]

for n in range(N):
    X.append([n+1])

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

for n, s in enumerate(S):
    X[n].append(s)

for n, p in enumerate(P):
    X[n].append(p)

Y =sorted(X, key=lambda x:x[1])
sorted(Y, key=lambda x:x[2], reverse=True)

for n in range(N):
    print(Y[n][0])

Submission status: Wrong Answer

Solution code:
N=int(input())

SP={}
ans=[]
for i in range(1,N+1):
    x=input().split()
    if x[0] not in SP:
        SP.update([[x[0],[int(x[1]+'%02d' % i)]]])
    else:
        SP[x[0]]+=[int(x[1]+'%02d' % i)]
        

for i in range(1,len(SP)+1):
    SP[min(SP)].sort(reverse=True)

    for j in range(len(SP[min(SP)])):
        print(int(str(SP[min(SP)][j])[-2:]))

    SP.pop(min(SP))

Submission status: Wrong Answer

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

for l in range(0,N):
	L.append(input().split())
	L[l][1] = (abs(int(L[l][1])-10**10),l+1)

L = sorted(L)

for i in range(N):
	print(L[i][1])

Submission status: Wrong Answer

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

for l in range(0,N):
	L.append(input().split())
	L[l][1] = (int(L[l][1])-10 ** 10,l+1)

L = sorted(L)
for i in range(N):
	print(L[i][1][1])

Submission status: Wrong Answer

Solution code:
# 行数
N = int(input().strip())

# 2次元配列
l = []
for i in range(N):
    array = list(input().split())
    array.append(i+1)
    l.append(array)

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

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

Submission status: Wrong Answer

Solution code:
# 行数
N = int(input().strip())

# 2次元配列
l = []
for i in range(N):
    array = list(input().split())
    array.append(i+1)
    l.append(array)
print(l)    

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
dic = {}
for i in range(N):
    sp = input().split()
    s = sp[0]
    p = sp[1]
    if s in dic:
        dic[s].append([p,i])
    else:
        dic[s] = [[p,i]]
for key in sorted(dic):
  for j in sorted(dic[key], reverse = True):
    print(j[1]+1)

Submission status: Wrong Answer

Solution code:
n=int(input())

lista=[]

for i in range(n): 
	s,p = map(str,input().split())
	p=int(p)
	lista.append([s,p,i+1])
	
	
#print(lista)
	
lista.sort(key=lambda x:-x[1])
#print(lista)

lista.sort(key=lambda x:x[0])
#print(lista)

ans=0
list_ans=[]
for i in range(n):
	ans=lista[i][2]
	list_ans.append(ans)
print(list_ans)

Submission status: Wrong Answer

Solution code:
n=int(input())

lista=[]

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

lista.sort(key=lambda x:x[0])
#print(lista)

ans=0
list_ans=[]
for i in range(n):
	ans=lista[i][2]
	list_ans.append(ans)
print(list_ans)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    s = [[int(i) if i.isdigit() else i for i in input().split()] for _ in range(n)]
    rank = {
        tuple(review): i
        for i, review in enumerate(
            sorted(sorted(s, key=lambda x: x[1], reverse=True), key=lambda x: x[0]),
            start=1,
        )
    }
    for r in s:
        print(rank[tuple(r)])


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

A.sort()
i=0
j=1
print(A)

while i<N-1:
    if j>N-1:
        break
    if A[i][0]==A[i+1][0]:
        j=i+1
        if j<N:
            while A[i][0]==A[j][0]:
                j+=1
                if j>=N:
                    break
    A[i:j]=sorted(A[i:j],key=lambda x:x[1],reverse=True)
    i=j

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
for i in range(N):
  S_tmp, P_tmp = input().split()
  P_reverse = 100 - int(P_tmp)
  S.append(S_tmp + str(P_reverse) + '_' + str(i+1))
for i in range(N):
  S_sort = sorted(S)
  print(S_sort[i].split('_')[-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
citynames = set()
citydict = dict()

for i in range(n):
  s,p = input().split()
  citynames.add(s)
  if not s in citydict:
    citydict[s] = [(int(p), i)]
  else:
    citydict[s].append((int(p), i))

for name in sorted(citynames):
  for point in sorted(citydict[name], reverse=True):
    print(point[1])

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())

scores = collections.defaultdict(list)

for i in range(1, n + 1):
    city, score = input().split()
    scores[city].append([i, score])

# print(scores)

for city in sorted(scores):
    sorted_score = sorted(scores[city], key=lambda x: x[1], reverse=True)
    for v in sorted_score:
        print(v[0])

Submission status: Wrong Answer

Solution code:
n= int(input())
a= []*n
for i in range(n):
    a.append(list(map(str,input().split()))+[i+1])

# print(a)
tmp = sorted(a,key=lambda a: a[1], reverse=True)
a = sorted(tmp, key=lambda a: a[0])
for i in a:
    print(i[2])

Submission status: Wrong Answer

Solution code:
n=int(input())
d=dict()

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

d2=sorted(d.items())
for i in range(len(d2)):
  print(d2[i][1])

Submission status: Wrong Answer

Solution code:
n=int(input())
d=dict()

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

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

for i in range(len(d2)):
  print(d2[i][1])

Submission status: Wrong Answer

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

for i in range(0,N):
    S[i][1]=int(S[i][1])

s=sorted(S)

temp=' '
for i in range(0,N):
    for j in range(i+1,N):
        if s[i][0]==s[j][0]:
            if s[i][1]<s[j][1]:
                temp=s[i][1]
                s[i][1]=s[j][1]
                s[j][1]=temp

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

i=N-1

while i>=0:
    print(S[i][2])
    i-=1

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

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

Submission status: Wrong Answer

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

for i in range(0,N):
    S[i].append(1)
    
for i in range(0,N):
    for j in range(0,N):
        if S[i][1]<S[j][1]:
            S[i][2]+=1
for i in range(0,N):
    print(S[i][2])

Submission status: Wrong Answer

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

s=sorted(S)

for i in range(0,N):
    print(s[i][0]+' '+s[i][1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
for n in range(N):
    S.append(input())
d={}
for s in S:
    s=s.split(" ")
    c=s[0]
    n=s[1]
    if c not in d:
        d[c]=[]
    d[c].append(n)
d_sorted=sorted(d.items(), key=lambda x:x[0])
for k in d_sorted:
    for p in k[1]:
        key = k[0] + " " + p
        print(S.index(key)+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
spList = [input().split() for _ in range(n)]
for i in range(n):
    spList[i][1] = str(100 - int(spList[i][1]))

spResultList = sorted(spList)
for i in range(n):
    print(spList.index(spResultList[i]) + 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
stack = [['zzzzzzzzzzz', -1]]
for i in range(n):
    s, p = input().split()
    p = int(p)
    stack.append([s, p])
cnt = {0}
for i in range(len(stack)-1):
    x = 0
    for j in range(1,len(stack)):
        if j in cnt:
            continue
        else:
            if stack[x][0] >= stack[j][0] and stack[x][1] < stack[j][1]:
                x = j
    cnt.add(x)
    print(x)

Submission status: Wrong Answer

Solution code:
n = int(input())
stack = [['zzzzzzzzzzz', -1]]
for i in range(n):
    s, p = input().split()
    p = int(p)
    stack.append([s, p])
cnt = set()
for i in range(len(stack)-1):
    x = 0
    for j in range(len(stack)):
        if j in cnt:
            continue
        else:
            if stack[x][0] >= stack[j][0] and stack[x][1] < stack[j][1]:
                x = j
    cnt.add(x)
    print(x)

Submission status: Wrong Answer

Solution code:
n = int(input())
stack = [['zzzzzzzzzz', -1]]
for i in range(n):
    s, p = input().split()
    p = int(p)
    stack.append([s, p])
cnt = set()
for i in range(len(stack)-1):
    x = 0
    for j in range(len(stack)):
        if j in cnt:
            continue
        else:
            if stack[x][0] >= stack[j][0] and stack[x][1] < stack[j][1]:
                x = j
    cnt.add(x)
    print(x)

Submission status: Wrong Answer

Solution code:
n=int(input())

info=[]

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

info=sorted(info,key=lambda x:x[2],reverse=True)
info=sorted(info,key=lambda x:x[1])

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

Submission status: Wrong Answer

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

sListSet = sorted(set(sList))
pListSet = sorted(set(pList), reverse=True)

spList = []
for i in range(n):
    spList.append(sListSet.index(sList[i]) * 1000 + pListSet.index(pList[i]))

for i in range(n):
    print(spList.index(sorted(spList)[i]) + 1)

Submission status: Wrong Answer

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

sListSet = sorted(set(sList))
pListSet = sorted(set(pList), reverse=True)

print(sListSet, pListSet)

spList = []
for i in range(n):
    spList.append(sListSet.index(sList[i]) * 1000 + pListSet.index(pList[i]))

print(spList, sorted(spList))

for i in range(n):
    print(spList.index(sorted(spList)[i]) + 1)

Submission status: Wrong Answer

Solution code:
N=int(input())
List=[[i+1]+input().split() for i in range(N)]
List.sort(key=lambda x:(x[1],int(x[2])))
for s,r,t in List:
          print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N= int(input())
li = list()

for i in range(N):
  res,score = input().split()
  score = int(score)
  li.append([res,score,i+1])
  
li.sort()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
R = []
for i in range(N):
    s, p = input().split()
    R.append([i+1, s, int(p)])
    
R_sort = sorted(R, key=lambda x : (x[1], x[2]))

for city in R_sort:
    print(city[0])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

for city in R_sort:
    print(city[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(str, input().split())
z = []
for i in range(n):
    z.append(x[i] +'z ' + str(100 - int(y[i])))
cz = z.copy()
cz.sort()
for i in cz:
    print(z.index(i) + 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(str, input().split())
z = []
for i in range(n):
    z.append(x[i] +' '+ str(100 - int(y[i])))
cz = z.copy()
cz.sort()
for i in cz:
    print(z.index(i) + 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(str, input().split())
z = []
for i in range(n):
    z.append(x[i] + str(100 - int(y[i])))
cz = z.copy()
cz.sort()
for i in cz:
    print(z.index(i) + 1)

Submission status: Wrong Answer

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

S=[""]*N
for i,x in enumerate(SP):
  SP[i] = x[0][0],int(x[0][1]),x[1]
  S[i]= x[0][0]

SP = sorted(SP)
s_ = np.unique(np.array(S))
flag=1
#bubble
while flag:
  for s in s_:
    swap_count=0
    same_s_count=0
    #check
    for i,sp in enumerate(SP):
      if sp[0]==s:
        if same_s_count==0:
          tmp = sp[1]
          pass
        else:
          if tmp<sp[1]:
            #swap
            tmp_SP = SP[i-1]
            SP[i-1] = sp
            SP[i] = tmp_SP
            swap_count+=1
        same_s_count+=1
  if swap_count==0:
    flag=0
        
for x in SP:
	print(x[2])

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
SP = [list((list(map(str,input().split())),i)) for i in range(N)]

S=[""]*N
for i,x in enumerate(SP):
  SP[i] = x[0][0],int(x[0][1]),x[1]
  S[i]= x[0][0]

SP = sorted(SP)
s_ = np.unique(np.array(S))
flag=1
#bubble
while flag:
  for s in s_:
    swap_count=0
    same_s_count=0
    #check
    for i,sp in enumerate(SP):
      if sp[0]==s:
        if same_s_count==0:
          tmp = sp[1]
          pass
        else:
          if tmp<sp[1]:
            #swap
            tmp_SP = SP[i-1]
            SP[i-1] = sp
            SP[i] = tmp_SP
            swap_count+=1
        same_s_count+=1
  if swap_count==0:
    flag=0
        
for x in SP:
	print(x[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
r = []
for i in range(n):
    city, score = map(str, input().split())
    score = int(score)
    r.append((city, score, i+1))

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
r={}


for i in range(n):
  a,b=map(str,input().split())
  r[a.ljust(10,"z")+str((100-int(b))).zfill(3)]=i
  
c=list(r.keys())
c.sort()
#print(r)
for i in c:
  print(r[i]+1)

Submission status: Wrong Answer

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

l = sorted(l, key=lambda x:x[1])
l = sorted(l)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [(i, tuple(input().split())) for i in range(1, N + 1)]

arr = sorted(S, key=lambda item: item[1][1], reverse=True)
arr2 = sorted(arr, key=lambda item: item[1][0])

for item in arr2:
    print(item[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = []
for i in range(1,N+1):
  S,P = input().split()
  #一つのリストとしてlstに追加する、番号もつけて
  lst.append([S,-1*int(P),i])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve():
  n = int(input())
  query = []
  for i in range(n):
    s,p = input().split()
    query.append((s+str(1010-int(p)),i+1))
  query.sort()
  for i in range(n):
    print(query[i][1])
solve()

Submission status: Wrong Answer

Solution code:
def solve():
  n = int(input())
  query = []
  for i in range(n):
    s,p = input().split()
    query.append((s+str(101-int(p)),i+1))
  query.sort()
  for i in range(n):
    print(query[i][1])
solve()

Submission status: Wrong Answer

Solution code:
N = int(input())
#リスト作成しまーす
k = []
city = []
point = []
point_city = 500
for i in range(N):
    k.append(list(map(str,input().split())))
#辞書順に市名を整理する
for i in range(N):
    city.append(k[i][0])
for i in range(N):
    point.append(0)
city = set(city)
sorted(city)
print(city)
city = list(city)
for i in range(N):
    point[i] += ((city.index(k[i][0]))*100*point_city)
    point[i] += int((k[i][1]))
print(point)
#pointが高い順に出力すればいいはず
for i in range(N):
    a = max(point)
    print((point.index(max(point)))+1)
    point[point.index(max(point))] = 0
#このコードにすると毎回出力が変わってしまう...

Submission status: Wrong Answer

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

# レストラン番号を付加する
for i in range(n):
  s[i].append(i+1)
# 配列要素の1番目(点数)でソートする
s.sort(key = lambda x:x[1], reverse=True)
# 配列要素の０番目(レストラン名)でソートする
s.sort(key = lambda x:x[0])

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

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = []
for _ in range(N):
    s, p = input().split()
    lst.append((s, int(p) * -1))

lst2 = sorted(lst)
for (x, y) in lst:
    for i, (a, b) in enumerate(lst2, 1):
        if x == a and y - b == 0:
            print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
mydict = []
for i in range(N):
  a, b=input().split()
  mydict.append([str(a), int(b), i])
mydict.sort()
for a,b,c in mydict:
  print(c)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
num_list = [i for i in range(n)]
city_list = []
point_list = []

for _ in range(n):
  temp = input().split()
  city_list.append(temp[0])
  point_list.append(int(temp[1]))
  
city_set = list(set(city_list))
city_set.sort()

ans=[]
for name in city_set:
  temp = list(filter(lambda x:city_list[x]==name,range(n)))
  temp_num = [num_list[i] for i in temp]
  temp_point = [point_list[i] for i in temp]
  #print(temp_num)
  #print(temp_point)
  while len(temp_num)!=0:
    ans.append(temp_num[np.argmax(temp_point)]+1)
    #print(temp_num[np.argmax(temp_point)])
    del temp_num[np.argmax(temp_point)]
    del temp_point[np.argmax(temp_point)]
for i in ans:
  print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = []
for i in range(n):
    l = input().split()
    lst.append([l[0], int(l[1]), i+1])
sorted_lst = sorted(lst, reverse=True)
print(sorted_lst)
while sorted_lst != []:
    p = sorted_lst.pop()
    temp = []
    while sorted_lst != [] and p[0] == sorted_lst[-1][0]:
        temp.append(sorted_lst.pop())
    while temp != []:
        print(temp.pop()[2])
    print(p[2])

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 = sorted(sp, key=lambda x: x[1], reverse=True)
sp = sorted(sp, key=lambda x: x[0])
print(sp)
for i in sp:
    print(i[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [list(input().split()) for i in range(n)]
d = sorted(set([i[0] for i in a]))
for i in a:
  for j in range(len(d)):
    if i[0] == d[j]:
      i[0] = 10000**(len(d)-(j+1))
c = [i[0]*int(i[1]) for i in a]
e = sorted(c,reverse=True)
for i in e:
  print(c.index(i)+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [list(input().split()) for i in range(n)]
d = sorted(set([i[0] for i in a]))
for i in a:
  for j in range(len(d)):
    if i[0] == d[j]:
      i[0] = 1000**(len(d)-(j+1))
c = [i[0]*int(i[1]) for i in a]
e = sorted(c,reverse=True)
for i in e:
  print(c.index(i)+1)

Submission status: Wrong Answer

Solution code:
n = int(input())

graph = {}
for i in range(1, n+1):
    s, p = input().split(' ')
    newMap = {'number': i, 'score': int(p)}
    if s not in graph:
        graph[s] = [newMap]
    else:
        graph[s].append(newMap)

keys = list(graph.keys())
keys.sort()
for key in keys:
    maps = sorted(graph[key], reverse=True, key=lambda x: x['score'])
    print(maps)
    for map in maps:
        print(map['number'])

Submission status: Wrong Answer

Solution code:
n = int(input())

graph = {}
for i in range(1, n+1):
    s, p = input().split(' ')
    newMap = {'number': i, 'score': p}
    if s not in graph:
        graph[s] = [newMap]
    else:
        graph[s].append(newMap)

keys = list(graph.keys())
keys.sort()
for key in keys:
    maps = sorted(graph[key], reverse=True, key=lambda x: x['score'])
    for map in maps:
        print(map['number'])

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
for i in range(n):
    name,point = input().split()
    s.append([name,int(point)])
for i in range(n):
    rank = 1
    for j in range(n):
        if s[i][0] > s[j][0]:
            rank += 1
        elif s[i][0] == s[j][0] and s[i][1] < s[j][1]:
                rank += 1
    print(rank)

Submission status: Wrong Answer

Solution code:
n=int(input())
rest=[0]*n
for i in range(n):
  a,b=map(str,input().split())
  b=int(b)
  rest[i]=[i,a,b]
rest.sort(key=lambda x:x[1])
rest.sort(key=lambda x:x[2])

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

Submission status: Wrong Answer

Solution code:
n = int(input())
data = []
for i in range(n):
    tw, sc = input().split()
    data.append([tw, int(sc), i+1])

data.sort()

for d in data:
    print (d[2])

Submission status: Wrong Answer

Solution code:
N = int(input())
j = []
for _ in zip(range(N)):
    p, q = map(str, input().split())
    j.append(int(q))

for i in range(N):
    p = max(j)
    q = j.index(p)
    print(q+1)
    j[q] = -1

Submission status: Wrong Answer

Solution code:
N = int(input())
j = []
for _ in zip(range(N)):
    p, q = map(str, input().split())
    j.append(int(q))

for i in range(N):
    p = max(j)
    q = j.index(p)
    print(q+1)
    j[q] = 0

Submission status: Wrong Answer

Solution code:
n = int(input())

s = []
for i in range(n):
	S,P=input().split()
	s.append([S,-int(P),i+1])

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

print(ans)

for a in ans:
  print(a[2])

Submission status: Wrong Answer

Solution code:
n = int(input())

s = []
for i in range(n):
	S,P=input().split()
	s.append((S,int(P),i+1))

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

for a in ans:
  print(a[2])