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())
tbl = []
s = []
p = []
for i in range(n):
    l = list(map(str,input().split()))
    l[1] = int(l[1])
    l2 = [l[1], l[0], i + 1]
    tbl.append(l2)
    s.append(l2[1])
    p.append(l2[0])

p.sort()
p.reverse()
tbl2 = []
for i in range(n):
    for j in range(n):
        if(tbl[j][0] == p[i]):
            tbl2.append(tbl[j])
s = list(set(s))

for i in range(len(s)):
    for j in range(len(tbl2)):
        if (tbl2[j][1] == s[i]):
            print(tbl2[j][2])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter 
n = int(input())
point = []
ans = []
for i in range(n):
    a,b = input().split()
    s = [a,int(b),i+1]
    point.append(s)
s_point = sorted(point)
name = s_point[0][0]
for j in range(n):
    if s_point[j][0] == name:
        m = s_point[j]
        ans.append(m)
        if j == n-1:
            s_ans = sorted(ans,key=itemgetter(1),reverse=True)
            for k in range(len(ans)):
                print(s_ans[k][2])
            exit()
    else:
        s_ans = sorted(ans,key=itemgetter(1),reverse=True)
        for k in range(len(ans)):
            print(s_ans[k][2])
        ans = []
        m = s_point[j]
        ans.append(m)
        name = s_point[j][0]

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[]
for i in range(n):
    tmp=input().split()
    tmp[1]=100-int(tmp[1])
    s.append(tmp+[str(i+1)])
print(s)
s=sorted(s)
print(s)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
P = []
for i in range(N):
    s,p = input().split()
    S.append(s)
    P.append(int(p))
Sset = sorted(list(set(S)))

dict1 = {}
for i in range(N):
    dict1[P[i]] = S[i]

print(Sset)

for k in Sset:
    U = [i for i, j in dict1.items() if j == k]
    V = sorted(U,reverse=True)
    for l in V:
        print(P.index(l) + 1)

Submission status: Wrong Answer

Solution code:
N=int(input())
place=[]
score=[]
for i in range(N):
  p,s=input().split()
  place.append(p)
  score.append(s)
  score[i]=-int(score[i])
mylist=[]
for num in range(N):
  mylist.append([place[num],score[num],num])
from operator import itemgetter
mylist.sort(key=itemgetter(0,1))
for num in range(N):
  mylist[num].append(num+1)
mylist.sort(key=itemgetter(2))
for num in range(N):
  print(mylist[num][3])

Submission status: Wrong Answer

Solution code:
N=int(input())
place=[]
score=[]
for i in range(N):
  p,s = input().split()
  place.append(p)
  score.append(-int(s))
mylist=[]
for num in range(N):
  mylist.append([place[num],score[num],num])
from operator import itemgetter
mylist.sort(key=itemgetter(0,1))
for num in range(N):
  mylist[num].append(num+1)
mylist.sort(key=itemgetter(2))
for num in range(N):
  print(mylist[num][3])

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[list((input().split())) for _ in range(N)]
for num in range(N):
  A[num][1]=int(A[num][1])
for num in range(N):
  A[num].append(num)
from operator import itemgetter
A.sort(key=itemgetter(0,1))
for num in range(N):
  A[num].append(num+1)
A.sort(key=itemgetter(2))
for num in range(N):
  print(A[num][3])

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[list((input().split())) for i in range(N)]
for num in range(N):
  A[num][1]=int(A[num][1])
for num in range(N):
  A[num].append(num+1)
from operator import itemgetter
A.sort(key=itemgetter(0,1))
for num in range(N):
  A[num].append(num+1)
A.sort(key=itemgetter(2))
for num in range(N):
  print(A[num][3])

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[list((input().split())) for i in range(N)]
for num in range(N):
  A[num].append(num+1)
from operator import itemgetter
A.sort(key=itemgetter(1,0))
for num in range(N):
  A[num].append(num+1)
A.sort(key=itemgetter(2))
for num in range(N):
  print(A[num][3])

Submission status: Wrong Answer

Solution code:
n=int(input())
A = [list(map(str,input().split())) for i in range(n)]
A_s = sorted(A, key=lambda x: x[1], reverse=True)
A_ss = sorted(A_s, key=lambda x: x[0], reverse=False)
for i in range(n):
    print(A.index( A_ss[i])+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

print(x)

Submission status: Wrong Answer

Solution code:
N=int(input())
d=[input().split() for i in range(N)]
name=[]
for i in range(N):
    d[i].append(i+1)
    name.append(d[i][0])
Name=list(set(name))
Name.sort()
d.sort()
for i in range(len(Name)):
    li=[]
    for j in range(N):
        if Name[i]==d[j][0]:
            li.append([d[j][1],d[j][2]])
        else:
            continue
    li.sort()
    Li=li[::-1]
    for k in range(len(li)):
        print(Li[k][1])

Submission status: Wrong Answer

Solution code:
N=int(input())
d=[input().split() for i in range(N)]
name=[]
for i in range(N):
    d[i].append(i+1)
    name.append(d[i][0])
Name=list(set(name))
Name.sort()
print(Name)
d.sort()
for i in range(len(Name)):
    li=[]
    for j in range(N):
        if Name[i]==d[j][0]:
            li.append([d[j][1],d[j][2]])
        else:
            continue
    li.sort()
    Li=li[::-1]
    for k in range(len(li)):
        print(Li[k][1])

Submission status: Wrong Answer

Solution code:
N=int(input())
d=[input().split() for i in range(N)]
name=[]
for i in range(N):
    d[i].append(i+1)
    name.append(d[i][0])
Name=list(set(name))
Name.sort()
d.sort()
for i in range(len(Name)):
    li=[]
    for j in range(N):
        if Name[i]==d[j][0]:
            li.append([d[j][1],d[j][2]])
    li.sort()
    Li=li[::-1]
    for j in range(len(li)):
        print(Li[j][1])

Submission status: Wrong Answer

Solution code:
N=int(input())
d=[input().split() for i in range(N)]
name=[]
for i in range(N):
    d[i].append(i+1)
    name.append(d[i][0])
Name=list(set(name))
Name.sort()
d.sort()
for i in range(len(Name)):
    li=[]
    for j in range(N):
        if Name[i]==d[j][0]:
            li.append([d[j][1],d[j][2]])
    li.sort()
    Li=li[::-1]
    for j in range(len(li)):
        print(Li[j][1])

Submission status: Wrong Answer

Solution code:
N = int(input())

SP = []
for _ in range(N):
  S,P = input().split()
  SP.append([S,-int(P)])
  
sort_SP = sorted(SP)

for i in SP:
  print(sort_SP.index(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=sorted(sp,key=lambda x: (x[0],-x[1]))
print(sp)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 10**9
for a in range(1,n):
    b = n - a
    a_sum = 0
    b_sum = 0
    for ai in str(a):
        a_sum += int(ai)
    for bi in str(b):
        b_sum += int(bi)
    v = a_sum+b_sum
    ans = min(ans,v)

print(ans)

Submission status: Wrong Answer

Solution code:
import copy
n = int(input())
r = []
for _ in range(n):
    city, x = input().split()
    x = int(x)
    r.append((city, x))

d = copy.deepcopy(r)
d = sorted(d, key=lambda x: -x[1])
d = sorted(d, key=lambda x: x[0])

print(d)
for k in d:
    print(r.index(k) + 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
res_list = []
for i in range(n):
    a,b=input().split()
    res_list.append((a,int(b)))
psorted_res_list = sorted(res_list, key=lambda x: x[1], reverse=True)
sorted_res_list = sorted(psorted_res_list, key=lambda x: x[0])
for i in range(n):
    print(sorted_res_list.index(res_list[i]) + 1)

Submission status: Wrong Answer

Solution code:
#B - Guidebook (別解)
N = int(input())

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


ans = sorted(iSP, key = lambda x:x[2], reverse = True)

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

for j,k,l in ans:
    print(j)

Submission status: Wrong Answer

Solution code:
n = int(input())
guide = [[i+1, list(int(x) if x.isdigit() else x for x in input().split())] for i in range(n)]
print(guide) ##
guide = sorted(guide, key = lambda x:(x[1][0],-x[1][1]))

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

Submission status: Wrong Answer

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

spoint=sorted(s,key=lambda x:x[1], reverse=True)
scity=sorted(spoint,key=lambda x:x[0])
print(scity)

Submission status: Wrong Answer

Solution code:
N=int(input())
SP=[]
for i in range(N):
    SP.append(list(input().split()))
for i in range(N):
    SP[i].append(i+1)
A=[]
B=[]
C=[]
for i in range(N):
    A.append(SP[i][0])
A.sort()
B.append(A[0])
for i in range(0,N-1):
    if A[i]!=A[i+1]:
        B.append(A[i+1])
for i in range(len(B)):
    C.append([])
for i in range(len(B)):
    for j in range(len(SP)):
        if B[i]==SP[j][0]:
            C[i].append([int(SP[j][1]),SP[j][2]])
for i in range(len(C)):
    for j in range(len(C[i])-1):
        if C[i][j]<C[i][j+1]:
            d=C[i][j]
            C[i][j]=C[i][j+1]
            C[i][j+1]=d
for i in range(len(C)):
    for j in range(len(C[i])):
        print(C[i][j][1])

Submission status: Wrong Answer

Solution code:
n = int(input())

res = []
for i in range(n):
  city, value = input().split()
  value = int(value)
  res.append([city, value, i])
res_s = sorted(res, key = lambda x: (x[0], -x[1]))
for i in range(n):
  print(res_s[i][2])

Submission status: Wrong Answer

Solution code:
n = int(input())

res = []
for i in range(n):
  city, value = input().split()
  value = int(value)
  res.append([city, value, i])
res_s = sorted(res, key = lambda x: (x[0], x[1]))
for i in range(n):
  res_s[i].append(i+1)
ans = sorted(res_s, key = lambda x: x[2])
for i in range(n):
  print(ans[i][3])

Submission status: Wrong Answer

Solution code:
N = int(input())
S_list = []
P_list = []
c = []

for i in range(N):
    S, P = input().split()
    S_list.append(S)
    P_list.append(int(P))

m = S_list
m = list(set(m))
m = sorted(m)
print(m)
n = 0
a = []
b = []
for i in m:
    for j in range(N):
        if i == S_list[j]:
            a.append(j)
    n = len(a)
    if n != 1:
        for o in range(n):
            b.append(P_list[a[o]])
        print(b)
        b = sorted(b, reverse = True)
        for k in b:
            for l in range(N):
                if k == P_list[l]:
                    c.append(l)
    else:
        c.append(a[0])


    a = []
    b = []

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

Submission status: Wrong Answer

Solution code:
n = int(input())

res = []
for i in range(n):
  city, value = input().split()
  value = int(value)
  res.append([city, value, i])
res_s = sorted(res, key = lambda x: (x[0], x[1]))
for i in range(n):
  res_s[i].append(i)
ans = sorted(res_s, key = lambda x: x[2])
for i in range(n):
  print(ans[i][3])

Submission status: Wrong Answer

Solution code:
N = int(input())
S_list = []
P_list = []
c = []

for i in range(N):
    S, P = input().split()
    S_list.append(S)
    P_list.append(int(P))

m = S_list
m = list(set(m))
m = sorted(m)
print(m)
n = 0
a = []
b = []
for i in m:
    for j in range(N):
        if i == S_list[j]:
            a.append(j)
    n = len(a)
    if n != 1:
        for o in range(n):
            b.append(P_list[a[o]])
        print(b)
        b = sorted(b, reverse = True)
        for k in b:
            for l in range(N):
                if k == P_list[l]:
                    c.append(l)
    else:
        c.append(a[0])


    a = []
    b = []

for i in c:
    print(i + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())

l=[]
for i in range(n):
  a,b=map(str, input().split())
  b=100-int(b)
  if b<10:
    b=str('0')+str(b)
  else:
    b=str(b)
  a=a+b
  l.append(a)

l2=sorted(l)

for i in range(n):
  print(l.index(l2[i])+1)

Submission status: Wrong Answer

Solution code:
n=int(input())

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

l2=sorted(l)

for i in range(n):
  print(l.index(l2[i])+1)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n = int(input())

dict_all = defaultdict(list)
i = 1
for _ in range(n):
    restaurant_name, score = map(str,input().split())
    dict_all[restaurant_name].append([i,int(score)])
    i += 1
dict_all = sorted(dict_all.items(), key=lambda x:x[0])

for k,v in dict_all:
    if len(v) > 1:
        v = sorted(v, reverse=True, key=lambda x: x[1])
        for i in range(len(v)):
            print(v[i][0])              
    else :
        print(v[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
r = [input() + ' ' + str(i + 1) for i in range(N)]

R = []
for i in r:
    R.append(i.split()[0] + ' ' + str(100 -int(i.split()[1])) + ' ' + i.split()[2])
R = sorted(R)

for i in R:
    print(i.split()[2])

Submission status: Wrong Answer

Solution code:
N = int(input())
r = [input() + ' ' + str(i + 1) for i in range(N)]

R = []
for i in r:
    R.append(i.split()[0] + ' ' + str(1000 -int(i.split()[1])) + ' ' + i.split()[2])
R = sorted(R)

for i in R:
    print(i.split()[2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

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

note = sorted(s.items(), key=lambda x: (x[1][0],x[1][1]) )
for i in note:
	print(i[0])
print(note)

Submission status: Wrong Answer

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

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

note = sorted(s.items(), key=lambda x: x[1][0])
note.append( (10, ["LOL", 10] ) )
print(note)
memo = note[0][1][0]
a = []
for i in note:
	if memo != i[1][0]:
		memo = i[1][0]
		a = sorted(a, key=lambda x: x[1][1])
		for j in range(len(a)):
			print(a[j][0])
		a = []
		a.append(i)
	else:
		a.append(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l.sort(key=lambda x: (x[1],(x[2]*-1)))

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

Submission status: Wrong Answer

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


l.sort(key=lambda x: [x[1],-1*x[2]])

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

Submission status: Wrong Answer

Solution code:
N=int(input())
d={}
k=[]
for x in range(N):
  S,P=input().split()
  if S not in k:
    k.append(S)
    d[S]=[]
  d[S].append([P,x+1])
k.sort()
for y in k:
  d[y].sort(reverse=True)
  for z in range(len(d[y])):
    print(d[y][z][1])

Submission status: Wrong Answer

Solution code:
N,que=int(input()),[]
for i in range(N):
    s,p=list(input().split())
    que.append((s,int(p),i+1))
que.sort()
for x in que:
    print(x[-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
list = []
for xi in range(n):
    add1, add2 = input().split()
    add = [add1, add2, xi+1]
    list.append(add)
list.sort()

name = list[0][0]
list2 = [list[0]]
count = 1
for xi in range(1,n):
    if name == list[xi][0]:
        list2.append(list[xi])
        count += 1
    else:
        list2.sort(key=lambda list2: list2[1],reverse=True)
        for yi in range(count):
            print(list2[yi][2])
        name = list[xi][0]
        list2 = [list[xi]]
        count = 1
        
list2.sort(key=lambda list2: list2[1],reverse=True)
for yi in range(count):
    print(list2[yi][2])
name = list[xi][0]
list2 = [list[xi]]
count = 1

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
List = []
for i in range(N):
  List.append(list(map(str, input().split())))
Names = []
Points = []
for i in range(N):
  Names.append(List[i][0])
  Points.append(List[i][1])
slName = set(Names)
NewName = list(slName)
NewName.sort()
Points.sort(reverse = True)
for i in range(len(NewName)):
  for j in range(len(Points)):
    for k in range(N):
      if List[k][0] == NewName[i] and List[k][1] == Points[j]:
        print(k+1)
      else:
        pass

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

book = dict()

for i in range(n):
    s,p = input().split()
    if s in book:
        book[s][int(p)] = i+1
    else:
        book[s] = {int(p):i+1}

book = sorted(book.items())
print(book)

for k,v in book:
    v=sorted(v.items(),reverse=True)
    for i,j in v:
        print(j)

Submission status: Wrong Answer

Solution code:
N = int(input())
rev = {}
ind_dic = {}
for i in range(1, N+1):
    k, v = input().split()
    
    if k in rev:
        rev[k].append(v)
    else:
        rev[k] = [v]
    ind_dic[v] = i

for v in rev.values():
    for i in range(len(v)):
        v[i] = int(v[i])
    v.sort(reverse=True)

key_lst = []
for k in rev.keys():
    key_lst.append(k)
key_lst.sort()

new_dic = {}
for k in key_lst:
    new_dic[k] = rev[k]

for k in new_dic.keys():
    for i in range(len(new_dic[k])):
        print(new_dic[k][i])

Submission status: Wrong Answer

Solution code:
N = int(input())
rev = {}
ind_dic = {}
for i in range(1, N+1):
    k, v = input().split()
    
    if k in rev:
        rev[k].append(v)
    else:
        rev[k] = [v]
    ind_dic[v] = i

for v in rev.values():
    v.sort(reverse=True)

key_lst = []
for k in rev.keys():
    key_lst.append(k)
key_lst.sort()

new_dic = {}
for k in key_lst:
    new_dic[k] = rev[k]

for k in new_dic.keys():
    for i in range(len(new_dic[k])):
        print(ind_dic[new_dic[k][i]])

Submission status: Wrong Answer

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

lc = set()
for c in base_li:
    lc.add(c[0])
lc = sorted(lc)
for c in lc:
    f_li = [r for r in base_li if r[0] == c]
    li = sorted(f_li, key=lambda w: w[1], reverse=True)

    for fr in li:
        print(base_li.index(fr) + 1)

Submission status: Wrong Answer

Solution code:
N=int(input())
data=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)
data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*200+int(data[i][1])
        else:
            continue
    data_point.append(num)
data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]
for i in range(N):
    ans=int(data_sort.index(i))+1
    print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
data=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)
data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*101+int(data[i][1])
        else:
            continue
    data_point.append(num)
data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]
for i in range(N):
    ans=int(data_sort.index(i))+1
    print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
data=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)
data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*100+int(data[i][1])
        else:
            continue
    data_point.append(num)
data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]
for i in range(N):
    ans=int(data_sort.index(i))+1
    print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
l=[]
for i in range(N):
    S,P=map(str,input().split())
    b=' '
    if len(S)<10:
        S=S+b*(10-len(S))
    P=(100-int(P))
    l.append([S+str(P),i])
l.sort()

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

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [list(input().split()) for i in range(n)]
s,p = [list(i) for i in zip(*l)]
p = [int(i) for i in p]
z = list(set(s))
z.sort()
m = list(p)
m.sort(reverse = True)
l = []

k = 0
for i in range(len(z)):
    l.append(k)
    k += 200

o = []
for i in range(n):
    w = l[z.index(s[i])]
    w += m.index(p[i])
    o.append(w)

r = list(o)
r.sort()
for i in range(n):
    print(r.index(o[i]) + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
data = []
ans = []
for i in range(1, N+1):
  city, score = input().split()
  score = int(score)
  data.append([city, score, i])
city_list = [x[0] for x in data]
score_list = [x[1] for x in data]
num_list = [x[2] for x in data]
city_unique = sorted(set(city_list))

for city_u in city_unique:
  city_index = [i for i, x in enumerate(city_list) if x == city_u]
  for score in sorted([score_list[x] for x in city_index], reverse=True):
    ans.append(num_list[score_list.index(score)])
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

s = [list(map(str, input().split())) for _ in range(n)]
for row in s:
    row[1] = int(row[1])
ss = sorted(s)
print(ss)
ins = 0
ans = list()
tmp = 0
for i in ss:
    if i[0] == tmp:
        ans.insert(ins,i)
    else:
        ins = len(ans)
        ans.append(i)
        tmp = i[0]
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
res = []
for i in range(n):
    s,p=map(str, input().split())
    res += [(s,int(p))]
res1=res
res.sort(key=lambda x:(x[0],-x[1]))
for i in range(n):
    print(res1.index(res[i])+1)

Submission status: Wrong Answer

Solution code:
n = int(input())

rs=[]

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

rs_obj = {r[0]:[] for r in rs}

for r in rs:
  rs_obj[r[0]].append(r[1:])

print(rs_obj)

Submission status: Wrong Answer

Solution code:
n = int(input())

rs=[]

for i in range(n):
  rs.append(input().split())
  rs[i][1]=int(rs[i][1])
  print(rs)

Submission status: Wrong Answer

Solution code:
N = int(input())
city={}
city_name=[]
for n in range(N):
    S = input().split()
    city[n+1]=S
    city_name.append(S[0])

city_name=list(set(city_name))
city_name.sort()

for c_name in city_name:
    city_temp = {}
    for c_key in city.keys():
        if city[c_key][0] == c_name:
            city_temp[city[c_key][1]]=c_key
            
    p_temp = list(city_temp.keys())
    p_temp.sort(reverse=True)
    for v in p_temp:
        print(city_temp[v])

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = [(input() + " " + str(i+1)).split() for i in range(N)]
 
lis = [k for k in lis]
 
lis.sort(key=lambda k: int(k[1]))
lis.sort(key=lambda k: k[0])
 
 
for i in lis:
    print(i[2])

Submission status: Wrong Answer

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

for _ in range(N):
    name, score = map(str, input().split())
    restaurants.append([name, int(score)])

sorted_restaurants = restaurants.copy()
sorted_restaurants = sorted(sorted_restaurants, key=lambda x: (x[0], -x[1]))

for i in range(N):
    name = restaurants[i][0]
    score = restaurants[i][1]
    for j in range(N):
        sorted_name = sorted_restaurants[j][0]
        sorted_score = sorted_restaurants[j][1]
        if name == sorted_name and score == sorted_score:
            print(j+1)
            break

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = [(input() + " " + str(i+1)).split() for i in range(N)]

lis.sort(key=lambda k: k[1], reverse=True)
lis.sort(key=lambda k: k[0])

for j in lis:
    print(j[2])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[6]:


N = int(input())
sp = []
for i in range(N):
    sp.append([i]+input().split())


# In[9]:


mylist = sorted(sp, key=lambda x: x[2], reverse=True)
mylist = sorted(mylist, key=lambda x: x[1])
for i in range(len(mylist)):
    print(mylist[i][0]+1)


# In[ ]:

Submission status: Wrong Answer

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

for i in range(n):
  s[i].insert(0, i+1)
#print(s)
for i in range(1, n):
  tmp = s[i][:]
  for j in range(1, i+1):
    #print( i, i-j, )
    if tmp[1] < s[i-j][1]:
   #   print('lex', s[i-j], s[i-j+1])
      s[i-j+1], s[i-j] = s[i-j], s[i-j+1]
    elif tmp[1] == s[i-j][1]:
      if tmp[2] > s[i-j][2]:
    #    print('ord', s[i-j], s[i-j+1])
        s[i-j+1], s[i-j] = s[i-j], s[i-j+1]
  #print(s[0][0], s[1][0], s[2][0], s[3][0], s[4][0], s[5][0], s[6][0], s[7][0], s[8][0], s[9][0])

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

Submission status: Wrong Answer

Solution code:
n=int(input())
key=[]
value=[]
for i in range(1,n+1):
    a,b=input().split()
    b=100-int(b)
    c="{0}+{1}".format(a,b)
    key.append(c)
    value.append(i)
dic=dict(zip(key,value))
key.sort()
for j in key:
    print(dic[j])

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = [list(map(str,input().split())) for _ in range(n)]
nums = [e for e in range(1,n+1)]
for i in range(n):
    ls[i][0] = ls[i][0] + str(100-int(ls[i][1]))
    ls[i] = ls[i] + [nums[i]] 
ls = sorted(ls)
for i in range(n):
    print(ls[i][2])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
for i in range(N):
    a,b=input().split()
    b=100-int(b)
    if b<10:
        A.append(a+'0'+str(b))
    else:
        A.append(a+str(b))
B=sorted(A)
for b in B:
    print(A.index(b)+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
for i in range(N):
    a,b=input().split()
    b=100-int(b)
    A.append(a+str(b))
B=sorted(A)
for b in B:
    print(A.index(b)+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
P = []
Num = []
for i in range(N):
  s, p = input().split()
  S.append(s)
  P.append(int(p))
  Num.append(i+1)
print(Num)
for i in range(N):
  for m in range(i):
    if S[m] > S[i] or (S[m] == S[i] and P[i] > P[m]):
      S[m], S[i] = S[i], S[m]
      P[m], P[i] = P[i], P[m]
      Num[m], Num[i] = Num[i], Num[m]
  print(Num)
for i in range(N):
  print("{}".format(Num[i]))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
for i in range(n):
    b,c=input().split()
    c=int(c)
    a.append([b,c])
sa=sorted(a)
sa.append(["STOP"])
ssa=[]
ssaa=[]
while len(sa)>1:
    while True:
        ssa.append(sa[0])
        sa=sa[1:]
        if ssa[-1][0]!=sa[0][0] or sa[0]=="STOP":
            break
    ssa=ssa[::-1]
    for i in ssa:
        ssaa.append(i)
    ssa=[]
for i in a:
    print(ssaa.index(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])
  
n_s = ""
n_p = -1

for i in range(N):
  t_s = "Z"
  t_p = -1
  v = -1
  for j in range(N):
    if t_s > L[i][0] and L[i][0] > n_s:
      t_s = L[i][0]
      t_p = L[i][1]
      v = i
    elif t_s == L[i][0] and L[i][0] > n_s and t_p < L[i][1]:
      t_p = L[i][1]
      v = i
  print(v)
  n_s = t_s
  n_p = t_p