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


def main():
    N = int(input())
    restaurant = defaultdict(list)
    for i in range(N):
        tmp = input().split()
        restaurant[tmp[0]].append((tmp[1], i+1))

    name_list = sorted(list(restaurant.keys()))

    for n in name_list:
        tmp = sorted(restaurant[n], key=lambda x: x[0], reverse=True)
        for t in tmp:
            print(t[1])


if __name__ == "__main__":
    main()

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

LS = sorted(L)

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

Submission status: Wrong Answer

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


s_p_list.sort(key=lambda x: (x[0], -x[1]))

print(s_p_list)

for s, p, i in s_p_list:
    print(i)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
SP = []
for i in range(N):
    sp = list(input().split())
    sp[1] = int(sp[1])
    sp.append(i+1)
    SP.append(sp)
SP = np.array(SP)
SP = SP[np.argsort(SP[:,1].astype("int"))[::-1]]
SP = SP[np.argsort(SP[:,0])]

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

Submission status: Wrong Answer

Solution code:
N = int(input())
sp = []
for i in range(N):
  s, p = input().split()
  sp.append([s, int(p), i+1])
sp1 = sorted(sp, key = lambda x: x[0])
sp2 = sorted(sp1, key = lambda x: -1*x[1])
for i in range(N):
  print(sp2[i][2])

Submission status: Wrong Answer

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

for i in range(N):
  count=1
  for j in range(N):    
    if sorted_list[i][0]+' '+str(sorted_list[i][1]) ==sp_list[j]:
      print(count)
      break
    count+=1

Submission status: Wrong Answer

Solution code:
N = int(input())
sp_list = []
sorted_list = []
for i in range(N):
  S,P = map(str, input().split(' '))
  sorted_list.append([S,P])
  sp_list.append(S + ' ' + P)
sorted_list = sorted(sorted_list, key=lambda x:(x[1]), reverse=True)
sorted_list = sorted(sorted_list, key=lambda x:(x[0]))
for i in range(N):
  count=1
  for j in range(N):
    if sp_list[i] == sorted_list[j][0]+' '+sorted_list[j][1]:
      print(count)
      break
    count+=1

Submission status: Wrong Answer

Solution code:
n = int(input())
r = []
for i in range(n):
    name, point = input().split()
    point = int(point)
    r.append([n, -point, i + 1])
r.sort()
for i in r:
    print(i[2])

Submission status: Wrong Answer

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

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

sp.sort(key=lambda x:(x[0], -int(x[1])))
print(sp)
for r in sp:
    print(r[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
s = set()       #市名種類
a = []          #インプットリスト
b = dict()          #市別処理
c = []          #結果

for i in range(n):
    t = list(input().split())
    t[1] = int(t[1])
    t.append(i+1)
    a.append(t)
    s.add(t[0])

s = list(s)
s.sort()

for j in range(len(s)):
    b = dict()
    for k in range(n):
        if a[k][0] == s[j]:
            b[a[k][2]] = a[k][1]
    x = sorted(b.items(),key=lambda x:x[1],reverse=True)
    for l in range(len(x)):
        c.append(x[l][0])

print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

rests.sort(key=lambda x: x[0]+str(100-x[1]) if x[1]!=0 else x[0]+"999")
for rest in rests:
    print(rest[2])

Submission status: Wrong Answer

Solution code:
N = int(input())
rests = []
scores = []

for _ in range(N):
    S, P = input().split()
    rests.append((S, int(P)))

rests_before = rests.copy()
rests.sort()
for i in range(N-1):
    if rests[i][0] == rests[i+1][0]:
        rests[i], rests[i+1] = rests[i+1], rests[i]

for rest in rests:
    print(rests_before.index(rest)+1)

Submission status: Wrong Answer

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


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

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

Submission status: Wrong Answer

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

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


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

Submission status: Wrong Answer

Solution code:

n=int(input())

sp=[]
for i in range(n):
    a=list(map(str,input().split()))
    a.append(i+1)
    sp.append(a)
    
sp=sorted(sp,key=lambda x:x[1],reverse=True)
sp=sorted(sp,key=lambda x:x[0])

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

Submission status: Wrong Answer

Solution code:
n=int(input())

sp=[]
for i in range(n):
    a=list(map(str,input().split()))
    a.append(i+1)
    sp.append(a)
    
sp=sorted(sp,key=lambda x:(x[0],x[1]))

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

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
data = [input().split() for _ in range(N)]
org = copy.deepcopy(data)
data.sort()
answer = []
city = data[0][0]
tmp = [data[0]]
for _ in range(1, N):
    if data[_][0] == city and not _ == N-1:
        tmp.append(data[_])
    else:
        if _ == N-1:
            tmp.append(data[_])
        city = data[_][0]
        trans = [[int(x[1]), x[0]] for x in tmp]

        trans.sort()
        trans.reverse()
        modo = [[x[1], str(x[0])] for x in trans]
        answer += modo
        tmp = [data[_]]

for a in answer:
    print(org.index(a)+1)

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
data = [input().split() for _ in range(N)]
org = copy.deepcopy(data)
data.sort()
answer = []
city = data[0][0]
tmp = [data[0]]
for _ in range(1, N):
    if data[_][0] == city and not _ == N-1:
        tmp.append(data[_])
    else:
        if _ == N-1:
            tmp.append(data[_])
        city = data[_][0]
        trans = [[x[1], x[0]] for x in tmp]

        trans.sort()
        trans.reverse()
        modo = [[x[1], x[0]] for x in trans]
        answer += modo
        tmp = [data[_]]

for a in answer:
    print(org.index(a)+1)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = []
B = []
E = []
for i in range(N):
  l = list(input().split())
  l[1] = int(l[1])
  A.append(l)
  B.append(l[0])
  E.append(l[1])
A.sort()
C = Counter(B)
C = dict(sorted(C.items(), key=lambda x:x[0]))
cnt = 0
for c in C.values():
  D = reversed(A[cnt:cnt+c])
  cnt += c
  for d in D:
    print(E.index(d[1])+1)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = []
B = []
for i in range(N):
  l = list(input().split())+[i+1]
  l[1] = int(l[1])
  A.append(l)
  B.append(l[0])
A.sort()
C = Counter(B)
C = dict(sorted(C.items(), key=lambda x:x[0]))
cnt = 0
for c in C.values():
  D = reversed(A[cnt:cnt+c])
  cnt += c
  for d in D:
    print(d[2])

Submission status: Wrong Answer

Solution code:
#Guide Book https://atcoder.jp/contests/abc128/tasks/abc128_b
N = int(input())
Shop_List=[]
for i in range(N):
    Temp_List=list(input().split())
    Temp_List[1]=int(Temp_List[1])
    Temp_List.append(i+1)
    Shop_List.append(Temp_List)


Shop_List_Sorted = sorted(Shop_List, key=lambda x:(x[0], x[1]))
for k in range(N):
    print(Shop_List_Sorted[k][2])

Submission status: Wrong Answer

Solution code:
N = int(input())

ss = dict()
sss = dict()
for i in range(N):
    s, p = input().split()
    sss[s, p] = i + 1
    if s in ss:
        ss[s] = ss[s] + ',' + p
    else:
        ss[s] = p

print(ss)
ss_sorted = sorted(ss.items())

for tmp_ss in ss_sorted:
    s = tmp_ss[0]
    ps = list(map(int, tmp_ss[1].split(',')))
    ps.sort(reverse=True)
    for p in ps:
        print(sss[s, str(p)])

Submission status: Wrong Answer

Solution code:
n = int(input())
L = [input().split() for _ in range(n)]
d = {}
for s, p in L:
    if s not in d.keys():
        d[s] = [int(p)]
    else:
        d[s].append(int(p))
for i, v in enumerate(L, start=1):
    v.append(i)
for i in sorted(d):
    for j in sorted(d[i], reverse=True):
        for k in range(n):
          if L[k][1] == d[i][d[i].index(j)]:
            print(L[k][2])

Submission status: Wrong Answer

Solution code:
n = int(input())
L = [input().split() for _ in range(n)]
d = {}
for s, p in L:
    if s not in d.keys():
        d[s] = [int(p)]
    else:
        d[s].append(int(p))
for i, v in enumerate(L, start=1):
    v.append(i)
for i in sorted(d):
    for j in sorted(d[i], reverse=True):
        print(d[i][d[i].index(j)])
        for k in range(n):
            if L[k][1] == d[i][d[i].index(j)]:
                print(L[k][2])

Submission status: Wrong Answer

Solution code:
n = int(input())
L = [input().split() for _ in range(n)]
d = {}
for s, p in L:
    if s not in d.keys():
        d[s] = [p]
    else:
        d[s].append(p)
for i, v in enumerate(L, start=1):
    v.append(i)
for i in sorted(d):
    for j in sorted(d[i], reverse=True):
        for k in range(n):
          if L[k][1] == d[i][d[i].index(j)]:
            print(L[k][2])

Submission status: Wrong Answer

Solution code:
n = int(input())
d = {}
for _ in range(n):
    s, p = input().split()
    if s not in d.keys():
        d[s] = [p]
    else:
        d[s].append(p)
c = 1
for i in sorted(d):
    for j in sorted(d[i], reverse=True):
        d[i][d[i].index(j)] = c
        c += 1
for k in d:
    for l in d[k]:
        print(l)

Submission status: Wrong Answer

Solution code:
N = int(input())
SP = [input().split() for _ in range(N)]
for k in range(N):
  City = "zzzzzzzzzzzzzz"
  Point = 0
  Num = 0
  for i in range(len(SP)):
    if SP[i][0] < City:
      City = SP[i][0]
  for j in range(len(SP)):
    if SP[j][0] == City and int(SP[j][1]) > Point:
      Point = int(SP[j][1])
      Num = j
  print(Num+1)
  SP[Num][0] = "zzzzzzzzzzzzzzzzz"
  SP[Num][1] = 0

Submission status: Wrong Answer

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

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

I = [j+1 for j in range(N)]

x = [(s, p, i) for s, p, i in zip(S, P, I)]

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

for s, p, i in x:
    print(i)

Submission status: Wrong Answer

Solution code:

D=[]
for i in range(int(input())):
    INPUT = [(j) for j in input().split()]
    D.append([INPUT[0],INPUT[1],i+1])
D.sort(key=lambda x:x[1],reverse=True)
D.sort(key=lambda x:x[0])
for d in D:
    print(d[2])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
D=[]
for i in range(int(input())):
    INPUT = [(j) for j in input().split()]
    D.append([INPUT[0],INPUT[1],i+1])
D.sort(key=lambda x:x[1],reverse=True)
D.sort(key=lambda x:x[0],reverse=False)
for d in D:
    print(d[2])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

n = int(input())
 
# data = [input().split() for _ in range(n)]
data = []
for i in range(n):
    city, point = input().split()
    data.append([city, point, i+1])

data = sorted(data, key=itemgetter(1), reverse=True)
data = sorted(data, key=itemgetter(0), reverse=False)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
T = [input().split() for _ in range(n)]
ans = list(range(1, n + 1))

for i in range(n):
    j = i
    while j > 0:
        if T[j][0] < T[j - 1][0]:
            T[j], T[j - 1] = T[j - 1], T[j]
            ans[j], ans[j - 1] = ans[j - 1], ans[j]
            j = j - 1
        else:
            break

for i in range(n):
    j = i
    while j > 0:
        if int(T[j][1]) > int(T[j - 1][1]) and T[j][0] == T[j - 1][0]:
            T[j], T[j - 1] = T[j - 1], T[j]
            ans[j], ans[j - 1] = ans[j - 1], ans[j]
            j = j - 1
        else:
            break


print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
rest_dict = {}
city_list = []
for i in range(N):
    city, score = input().split()
    if city not in city_list:
        city_list.append(city)
        rest_dict[city] = [[score, i]]
    else:
        rest_dict[city].append([score, i])

city_list = sorted(city_list)
for city in city_list:
    rest_list = rest_dict[city]
    rest_list = sorted(rest_list, reverse=True)
    for rest in rest_list:
        print(rest[1]+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
rest_dict = {}
city_list = []
for i in range(N):
    city, score = input().split()
    if city not in city_list:
        city_list.append(city)
        rest_dict[city] = [[score, i]]
    else:
        rest_dict[city].append([score, i])

coty_list = sorted(city_list)
for city in city_list:
    rest_list = rest_dict[city]
    rest_list = sorted(rest_list, reverse=True)
    for rest in rest_list:
        print(rest[1]+1)

Submission status: Wrong Answer

Solution code:
n = [(input().split()) for _ in range(int(input()))]
m = sorted(sorted(n,key=lambda x:x[1], reverse=True),key=lambda x:x[0])
print('\n'.join([str(n.index(li)+1) for li in m]))

Submission status: Wrong Answer

Solution code:
N = int(input())
rest_dict = {}
city_list = []
for i in range(N):
    city, score = input().split()
    if city not in city_list:
        city_list.append(city)
        rest_dict[city] = [[score, i]]
    else:
        rest_dict[city].append([score, i])

coty_list = sorted(city_list)
for city in city_list:
    rest_list = rest_dict[city]
    rest_list = sorted(rest_list)
    for rest in rest_list:
        print(rest[1])

Submission status: Wrong Answer

Solution code:
N=int(input())
S={}

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

print(*S,sep="\n")

Submission status: Wrong Answer

Solution code:
n = int(input())

s = [0]*n
p = [0]*n

list_2d = [[] for _ in range(n)]

for i in range(n):
    s, p = input().split()
    list_2d[i].append(s)
    list_2d[i].append(p)
list_2d_sorted = sorted(list_2d, key = lambda x: (x[0],x[1]))
for i in range(n):
    print(list_2d.index(list_2d_sorted[i])+1)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n = int(input())
restaurants = defaultdict(list)
for i in range(n):
    s, p = input().split()
    p = int(p)
    restaurants[s].append([p, i])

ans = [''] * n
cnt = 0
for k, v in sorted(restaurants.items(), key=lambda x: x[0]):
    for p, i in sorted(v, key=lambda x: -x[0]):
        cnt += 1
        ans[i] = cnt

for a in ans:
    print(a)

Submission status: Wrong Answer

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

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, 0])
l.sort()
for i in range(n):
    s = l[i][0]
    max = 0
    x = 0
    for j in range(n):
        if l[j][0] == s and max < l[j][1] and l[j][3] == 0:
            max = l[j][1]
            x = j
    print(l[x][2])
    l[x][3] = 1

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, 0])
l.sort()
for i in range(n):
    s = l[i][0]
    max = 0
    x = 0
    for j in range(n):
        if l[j][0] == s and max < l[j][1] and int(l[j][3]) == 0:
            max = l[j][1]
            x = j
    print(l[x][2])
    l[x][3] = 1

Submission status: Wrong Answer

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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()
    sp = [readstrs() for _ in range(N)]
    S = sorted(list(map(lambda x: x[0], sp)))
    P = list(map(lambda x: x[1], sp))
    t = {x: [] for x in S}
    for v in sp:
        t[v[0]].append(v[1])

    for k in t.keys():
        t[k] = sorted(list(map(int, t[k])), reverse=True)

    for k, v in t.items():
        for vv in v:
            print(sp.index([k, str(vv)]) + 1)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

N = int(input())
l=list()#empty list

for i in range(1,N+1):
    tempS,tempP = input().split()
    l.append([tempS,-int(tempP),i])

sortedList = sorted(l,key=lambda item:(item[0],item[1]))

print(sortedList)
for i in range(1,N+1):
    print(sortedList[i-1][2])

Submission status: Wrong Answer

Solution code:
n = int(input())
n_list = [0]*n
for i in range(n):
    n_list[i] = input().split()
    n_list[i].append(i+1)
for i in range(n):
    n_list[i][1] = int(n_list[i][1])
n_list.sort()
n_list.append("dum")
print(n_list)
L = 0
for i in range(n):
    if n_list[i][0] != n_list[i+1][0]:
        for j in range(i,L-1,-1):
            print(n_list[j][2])
        L = i+1

Submission status: Wrong Answer

Solution code:
n=int(input())
sp=[0]*n
for i in range(n):
	s,p=input().split()
	p=str(100-int(p))
	if len(p)==1:
		p="0"+p
	sp[i]=[s+p,i+1]
sp.sort()
for i in range(n):
	print(sp[i][1])

Submission status: Wrong Answer

Solution code:
n = int(input())
s =  [input().split() for i in range(n)]
temp = s
data = sorted(s,key=lambda x:(x[0],-int(x[1])))


for i in range(n):
    y = temp[i]
    result = data.index(y)
    print(result+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
W = [list(input().split()) for _ in range(N)]
S = sorted(W)
for i in range(N):
  for j in range(i+1, N):
    if S[i][0] == S[j][0] and int(S[i][1]) < int(S[j][1]):
      a = S[i]
      S[i] = S[j]
      S[j] = a
    else:
      break
for k in range(N):
  print(W.index(S[k])+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
lines = [input().split(" ") for i in range(N)]
for i in lines:
    i[1] = int(i[1])
# 数字でソート
l = sorted(lines, key=lambda x: (x[1]), reverse=True)
# 文字でソート
l = sorted(l, key=lambda x: (x[0]))
print(l)
for u in l:
    for o in lines:
        if o == u:
            print(lines.index(o) + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
lst = [input().split()+[str(i+1)] for i in range(int(input()))]
print("\n".join([i[2] for i in sorted(lst, key=lambda x:(-1*int(x[1]), x[0]))]))

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

tmp = sorted(sp, key=itemgetter(1), reverse = True)
res = sorted(tmp, key=itemgetter(0))

for i in range(n):
    print(sp.index(res[i])+1)

Submission status: Wrong Answer

Solution code:
import copy
n = int(input())
sp = [input().split() for i in range(n)]
#newsp = sorted(sp)
newsp = copy.deepcopy(sp)
newsp.sort() ###辞書順
ans = []

###点数順にする
for i in range(n-1):
    if newsp[i][0] == newsp[i+1][0] and newsp[i][1] < newsp[i+1][1]:
        newsp[i][0], newsp[i+1][0] = newsp[i+1][0], newsp[i][0]
        newsp[i][1], newsp[i+1][1] = newsp[i+1][1], newsp[i][1]
"""
for i in range(n):
    print(sp[i], " ", newsp[i])
"""
###元の配列のindexを取得
for i in range(n):
    ans.append(sp.index(newsp[i])+1)
for i in range(n):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
n = int(input())
keep=[]
ans=[0]*n
for i in range(n):
    lis = list(input().split())
    keep.append(lis)
for j in range(len(keep)):
    num=1
    for k in (keep[0:j]+keep[j+1:n]):
        if keep[j][0]>k[0]:
            num+=1
        elif keep[j][0]==k[0] and keep[j][1]<k[1]:
            num+=1
    ans[j]=num
for l in range(n):
    print(ans.index(l+1)+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
inp = [input() for i in range(N)]

import numpy as np

s_list = []
p_list = []
for i in inp:
    s_list.append(i.split()[0])
    p_list.append(int(i.split()[1]))

sp_list = []
for i in range(N):
    sp_list.append([s_list[i],p_list[i]])

# 市を辞書順
sort_sp_list = sorted(sp_list)

# 市の種類
s_type = sorted(list(set(s_list)))
tmp_list = []
for type in s_type:
    tmp_list.append(sorted([s for s in sort_sp_list if s[0] == type],reverse=True))

rank_list = []
for tmp in tmp_list:
    for l in tmp:
        rank_list.append(l)

for sp in sp_list:
    print(rank_list.index(sp)+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
sp = [input().split() for _ in range(n)]
sp_s = sorted(sp, key=lambda x:(x[0], -int(x[1])))
for i in sp:
    print(sp_s.index(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] = str(100 - int(l[i][1]))
m = sorted(l, reverse = True)
for i in range(n):
    for j in range(n):
        if m[n - i - 1] == l[j]:
            print(j + 1)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
SP = [input().split() for _ in range(N)]
print(SP)
for i in range(1, N+1):
	SP[i-1].append(i)

print(SP)

SP.sort(key = lambda x: (x[0], -int(x[1])))
print(SP)

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

Submission status: Wrong Answer

Solution code:
N = int(input())

d = {}
S = set()

for i in range(N):
    s,p = input().split()
    p = int(p)
    S.add(s)
    if s in d:
        d[s].append([p, i+1])
        continue
    d[s] = []
    d[s].append([p, i+1])
print(d)
S = list(S)
S.sort()

for key in S:
    L = d[key]

    L = sorted(L, reverse=True)
    for l in L:
        print(l[1])

Submission status: Wrong Answer

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

rc = (list(enumerate(rc)))

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

print(rc)
for i in rc:
    print(i[0]+1)

Submission status: Wrong Answer

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

rc = (list(enumerate(rc)))

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

for i in rc:
    print(i[0]+1)

Submission status: Wrong Answer

Solution code:
#abc128_b.py
'''
こういうのも苦手、配列とか Map のソートとか SQL の order by で書きたくなる…
とりあえず解説ACというか、回答読んで理解する。
tuple の配列は sorted 関数使うと左から順に昇順になるってこと…？
↓が詳しそう。
https://qiita.com/tag1216/items/95dc6bff5422e26601bf
'''
n = int(input())
rs = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    rs.append((s, -p, i+1))
print(rs)
rs = sorted(rs)
print(rs)
for r in rs:
    print(r[2])

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
s = [input().split() for i in range(n)]
points = [int(pt) for k, pt in s]

dicts = {key:[] for key in sorted(list(set([k for k, v in s])))}
for area, pt in s:
  dicts[area].append(int(pt))

for area, pts in dicts.items():
  for pt in sorted(pts)[::-1]:
    print(points.index(pt)+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
for i in range(1, n+1):
    s,p = map(str,input().split())
    a.append((s,int(p),i))
a.sort()
print(a)
ans = [a[0][2]]
k = 0
for i in range(1,n):
    if a[i-1][0] == a[i][0]:
        ans.insert(k,a[i][2])
    else:
        k = i
        ans.append(a[i][2])

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

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
l = []
for i in range(n):
    tmp = isl()
    tmp.append(i+1)
    l.append(tmp)
#print(l)
l = sorted(l,key=lambda x:x[1],reverse=True)
#print(l)
l = sorted(l,key=lambda x:x[0])
for j in l:
    print(j[2])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter


N=int(input())
A=[0]*N
for i in range(N):
    A[i]=input().split()

i=0
while i<N:
    A[i][1]=int(A[i][1])
    i+=1

i=0
while i<N:
    A[i]=tuple(A[i])
    i+=1

B1 = sorted(A, key=itemgetter(1),reverse=True)
B2 = sorted(B1,key=itemgetter(0))

print(B2)

for i in B2:
    print(A.index(i)+1)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[list(input().split())+[i] for i in range(n)]
for i in range(n):
  a[i][1]=-int(a[i][1])
a.sort()
ans=[0]*n
for i in range(n):
  ans[a[i][2]]=i+1
print(*ans,sep='\n')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[list(input().split())+[i] for i in range(n)]
for i in range(n):
  a[i][1]=-int(a[i][1])
a.sort()
ans=[0]*n
for i in range(n):
  ans[a[i][2]]=i+1
print(*ans,sep='¥n')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []
D = {}
for _ in range(N):
  k, v = input().split()
  v = int(v)
  L.append((k, v))
  if k not in D.keys():
    D[k] = [v]
  else:
    D[k].append(v)
print(D)
for v in D.values():
  v.sort(reverse=True)
D = sorted(D.items(), key=lambda x: x[0])
print(D)
for d in D:
  for i in range(len(d[1])):
    print(L.index((d[0], d[1][i]))+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []
D = {}
for _ in range(N):
  k, v = input().split()
  L.append((k, v))
  if k not in D.keys():
    D[k] = [v]
  else:
    D[k].append(v)
for v in D.values():
  v.sort(reverse=True)
D = sorted(D.items(), key=lambda x: x[0])
for d in D:
  for i in range(len(d[1])):
    print(L.index((d[0], d[1][i]))+1)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
 
n = int(input())
l = [list(input().split())+[i+1] for i in range(n)]
 
l.sort(key = itemgetter(0))
l = sorted(l, key = lambda x:(x[1]),reverse = True)
print(l)

Submission status: Wrong Answer

Solution code:
N = int(input())
dict = {}
for i in range(1, N+1):
    S, P_str = tuple(input().split())
    P = int(P_str)
    try:
        dict[S].append((P, i))
    except:
        dict[S] = [(P, i)]

items = sorted(dict.items(), key=lambda x: x[1], reverse=True)
for city, info in items:
    for p, n in sorted(info, key=lambda x: x[0], reverse=True):
        print(n)

Submission status: Wrong Answer

Solution code:
N = int(input())
dict = {}
for i in range(1, N+1):
    S, P_str = tuple(input().split())
    P = int(P_str)
    try:
        dict[S].append((P, i))
    except:
        dict[S] = [(P, i)]

items = sorted(dict.items(), key=lambda x: x[1], reverse=True)
for city, info in items:
    for p, n in sorted(info, reverse=True):
        print(n)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

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

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

sp = sorted(sp, key=itemgetter(1), reverse=True)
sp = sorted(sp, key=itemgetter(0))

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

Submission status: Wrong Answer

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    sp=[]
    for i in range(n):
        s,p=STRM()
        sp.append([s,p,i+1])
    sorted_sp1=sorted(sp, key=lambda x:x[1], reverse=True)
    sorted_sp2=sorted(sorted_sp1, key=lambda x:x[0])
    for i in range(n):
        print(sorted_sp2[i][2])
    
if __name__ == '__main__':
    do()

Submission status: Wrong Answer

Solution code:
n = int(input())

lst = []

for i in range(n):
    s, p = input().split()
    lst.append([s, 100 - int(p), i + 1])
    # ([])でも(())でもいい(?)
# print(lst)

# 番号はただのおまけ
# 最初の順番の並びが,入れ替えた後に何番目だったかわかるだけ
lst.sort()
# lstの前の要素から優先的に昇順(1,2,3...a,b,c...)にsortされる

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