TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
N = int(input().strip())

list = [input().strip().split() for i in range(N)]

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

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

N = int(input().strip())

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

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

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


N = int(input().strip())

list = [input().strip().split() for i in range(N)]

from operator import itemgetter

sort1 = sorted(list, key=lambda x: int(x[1]), reverse=True)
sort2 = sorted(sort1, key=itemgetter(0))

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


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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])

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
d=[]

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

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

import numpy as np

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

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

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

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

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

d_ = sorted(d, key=lambda x:(x[0], -x[1]))

for i in range(n):
    print(d_[i][2]+1)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
l = []
for i in range(N):
    s, p = input().split(' ')
    l.append([s, int(p), i])
l.sort(key=lambda x:(x[0], -x[1]))
_ = [print(a[2]) for a in l]

N = int(input())
l = []
for i in range(N):
    s, p = input().split(' ')
    l.append([s, int(p), i+1])
l.sort(key=lambda x:(x[0], -x[1]))
_ = [print(a[2]) for a in l]


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
a=[[]*3 for ii in range(n)]
for ii in range(n):
  s=input().split()
  a[ii][0]=s[0]
  a[ii][1]=-int(s[1])
  a[ii][2]=ii
a.sort()
for ii in range(n):
  print(a[ii][2]+1)

n=int(input())
a=[[""]*3 for ii in range(n)]
for ii in range(n):
  s=input().split()
  #print(s)
  a[ii][0]=s[0]
  a[ii][1]=100-int(s[1])
  a[ii][2]=ii
a.sort()
for ii in range(n):
  print(a[ii][2]+1)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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

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

a = int(input())
h = []
for i in range(a):
  s,c= input().split()
  h.append([i+1,str(s),int(c)])
H = sorted(h,key=lambda x:(x[1],-x[2]))
for x in H:
  print(x[0])

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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_s:
    print(sp.index(i)+1)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
lst = []
for i in range(N):
  s,p = input().split()
  p=int(p)
  lst.append((s,-p,i+1))
for e in lst:
  print(e[2])

N = int(input())
lst = []
for i in range(N):
  s,p = input().split()
  p=int(p)
  lst.append((s,-p,i+1))
lst.sort()
for e in lst:
  print(e[2])


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
d=0

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

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

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

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

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


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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()

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())
listA=[]
for i in range(N):
    lis=input().split()
    listA.append([lis[0],int(lis[1]),i])
sort=sorted(listA,key=lambda x:(x[0],-x[1]))
for i in range(N):
    sort[i].append(i+1)
sort=sorted(sort,key=lambda x:x[2])
for disp in sort:
    print(disp[3])

N=int(input())
listA=[]
for i in range(N):
    lis=input().split()
    listA.append([lis[0],int(lis[1]),i])
sort=sorted(listA,key=lambda x:(x[0],-x[1]))
for i in range(N):
    sort[i].append(i+1)
for disp in sort:
    print(disp[2]+1)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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],reverse = True)

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

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 i in sp:
  print(i[2])

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
l = []
for i in range(n):
    sp = input().split()
    l.append((sp[0], int(sp[1]), i+1))

a = sorted(l, key=lambda i: (i[0], -l[1]))

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

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

s = sorted(l, key=lambda i: (i[0], -i[1]))

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
 N = int(input())
 SP = [list(map(str, input().split())) for _ in range(N)]

 for i in range(N):
   SP[i].append(i+1)
   SP[i][1] = int(SP[i][1])*(-1)

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

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


N = int(input())
SP = [list(map(str, input().split())) for _ in range(N)]

for i in range(N):
  SP[i].append(i+1)
  SP[i][1] = int(SP[i][1])*(-1)

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

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


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from operator import itemgetter, attrgetter

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

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

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

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

from operator import itemgetter, attrgetter

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

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

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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])

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
res=[]
city=[]
for i in range(n):
    s,p=map(str,input().split())
    p=int(p)
    res.append([s,p,i+1])
R=sorted(res,key=lambda x : x[1],reverse=True)
Res=sorted(R,key=lambda x : x[0])
print(Res)
for j in Res:
    print(j[2])

n=int(input())
res=[]
city=[]
for i in range(n):
    s,p=map(str,input().split())
    p=int(p)
    res.append([s,p,i+1])
R=sorted(res,key=lambda x : x[1],reverse=True)
Res=sorted(R,key=lambda x : x[0])

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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

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

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


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

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
# ABC-128-B

r_list = []
ans_list = []
N = int(input())
for i in range(1, N+1):
    Si, Pi = input().split()
    r_list.append((Si, int(Pi), i))
    
name_sorted_list = sorted(r_list, key=lambda x:x[0])
while len(name_sorted_list) > 0:
    test_list = []
    list_index = [i for i, x in enumerate(name_sorted_list) if x  == name_sorted_list[1]]
    for i in list_index:
        test_list.append(name_sorted_list[i])
        del name_sorted_list[i]
    test_list = sorted(test_list, key=lambda x:x[1])
    for item in test_list:
        ans_list.append(item)

for item in ans_list:
    print(item[2])

r_list = []
ans_list = []
N = int(input())
for i in range(1, N+1):
    Si, Pi = input().split()
    r_list.append((Si, int(Pi), i))
    
name_sorted_list = sorted(r_list, key=lambda x:x[0])
while len(name_sorted_list) > 0:
    test_list = []
    list_index = [i for i, x in enumerate(name_sorted_list) if x  == name_sorted_list[0]]
    for i in list_index:
        test_list.append(name_sorted_list[i])
        del name_sorted_list[i]
    test_list = sorted(test_list, key=lambda x:x[1], reverse = True)
    for item in test_list:
        ans_list.append(item)

for item in ans_list:
    print(item[2])

r_list = []
ans_list = []
N = int(input())
for i in range(1, N+1):
    Si, Pi = input().split()
    r_list.append((Si, int(Pi), i))
    
name_sorted_list = sorted(r_list, key=lambda x:x[0])

while len(name_sorted_list) > 0:
    test_list = []
    list_index = [i for i, x in enumerate(name_sorted_list) if x[0]  == name_sorted_list[0][0]]
    for i in list_index:
        test_list.append(name_sorted_list[i])
    for i in reversed(list_index):
        del name_sorted_list[i]
    test_list = sorted(test_list, key=lambda x:x[1], reverse = True)
    for item in test_list:
        ans_list.append(item)
    
for item in ans_list:
    print(item[2])

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# B - Guidebook
import numpy as np
import pandas as pd 

N = int(input())
A, B = [[], []]

for _ in range(N):
  a, b = [i for i in input().split()]
  A.append(a)
  B.append(int(b))


A = np.array(A)[:, np.newaxis]
B = np.array(B)[:, np.newaxis]
C = np.concatenate([A, B], axis=1)

print(C)
df = pd.DataFrame(C, index=[i+1 for i in range(N)])
df = df.sort_values([0, 1])
for i in df.index:
  print(i)


# B - Guidebook
import numpy as np
import pandas as pd 

N = int(input())
A, B = [[], []]

for _ in range(N):
  a, b = [i for i in input().split()]
  A.append(a)
  B.append(int(b))


A = np.array(A)[:, np.newaxis]
B = np.array(B)[:, np.newaxis]
C = np.concatenate([A, B], axis=1)
df = pd.DataFrame(C, index=[i+1 for i in range(N)])
df = df.sort_values([0, 1])

for i in df.index:
  print(i)


# B - Guidebook
import numpy as np


N = int(input())
A, B = [[], []]

for _ in range(N):
  a, b = [i for i in input().split()]
  A.append(a)
  B.append(int(b))


A = np.array(A)[:, np.newaxis]
B = np.array(B)[:, np.newaxis].astype('int')
C = np.concatenate([A, B], axis=1)
C = C.tolist()

ans = sorted(C, key=lambda x:(x[0],-int(x[1])))

for i in ans:
  print(C.index(i)+1)




#  print(i)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
lst = []
for _ in range(N):
    s, p = input().split()
    s = '{:0<10}'.format(s)
    p = '{:0>3}'.format(str(100 - int(p)))
    lst.append(s + p)

m = {}
for idx, s in enumerate(sorted(lst), 1):
    m[s] = idx

for s in lst:
    print(m[s])

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)

N = int(input())
lst = []
for x in range(1, N + 1):
    s, p = input().split()
    lst.append((s, -int(p), x))

lst.sort()
for (_, _, idx) in lst:
    print(idx)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a = int(input())
c = [list(map(str, input().split())) for b in range(a)]
l = list()
for d in c:
  for i, e in enumerate(d):
    if (i % 2 == 1):
      l.append((int(e)))
f = sorted(l)

for d in c:
  for i, e in enumerate(d):
    if (i % 2 == 1):
      print(f.index(int(e))+1)

a = int(input())
c = [list(map(str, input().split())) for b in range(a)]
l = list()
for d in c:
  for i, e in enumerate(d):
    if (i % 2 == 1):
      l.append((int(e)))
f = sorted(l, reverse=True)

for d in c:
  for i, e in enumerate(d):
    if (i % 2 == 1):
      print(f.index(int(e))+1)

a = int(input())
c = list()
for b in range(a):
  z, zz = input().split()
  c.append([z,int(zz)]) 

l = list()
tmp = sorted(c, key=lambda x:x[1], reverse=True)
x = sorted(tmp, key=lambda x:x[0])
for a in x:
  for y in c:
    if (a == y):
      l.append(c.index(a)+1)
print(l)

a = int(input())
c = list()
for b in range(a):
  z, zz = input().split()
  c.append([z,int(zz)]) 

l = list()
tmp = sorted(c, key=lambda x:x[1], reverse=True)
x = sorted(tmp, key=lambda x:x[0])
for a in x:
  for y in c:
    if (a == y):
      l.append(c.index(a)+1)
[print(i) for i in l]

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())
S=[list(map(str,input().split())) for i in range(N)]

A=sorted(S,key=lambda x: int(x[1]), reverse=True)
A=sorted(A,key=lambda x: x[0])


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


# coding: utf-8
# Your code here!
N=int(input())
S=[list(map(str,input().split())) for i in range(N)]

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

for i in range(N):
    ans=S.index(B[i])+1
    print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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])



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





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





Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
lst = [[] for _ in range(N)]

for i in range(N):
    S, P = input().split()
    lst[i].append(S)
    lst[i].append(P)
    lst[i].append(i+1)
    
lst_a = sorted(lst, key=lambda x:x[0])
lst_a = sorted(lst_a, key=lambda x:x[1], reverse=True)

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

N = int(input())
lst = [[] for _ in range(N)]

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
SP = [(i + 1, input().split()) for i in range(N)]
P = [[0, 0, 0] for _ in range(N)]
for i in range(N):
    P[i][0] = SP[i][0]
    P[i][1] = SP[i][1][0]
    P[i][2] = int(SP[i][1][1])
P.sort(key=lambda x: x[1][1], reverse=True)
P.sort(key=lambda x: x[1][0])

for p in P:
    print(p[0])


N = int(input())
SP = [(i + 1, input().split()) for i in range(N)]
P = [[0, 0, 0] for _ in range(N)]
for i in range(N):
    P[i][0] = SP[i][0]
    P[i][1] = SP[i][1][0]
    P[i][2] = int(SP[i][1][1])
P.sort(key=lambda x: x[2], reverse=True)
P.sort(key=lambda x: x[1])

for p in P:
    print(p[0])


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
list = []
for i in range(N):
    S, P = input().split()
    list.append([S, int(P), i+1])

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


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

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


Verdicts: Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
import intertools

n , m = map(int,input().split())
sw = [[] for _ in range(m)]
for i in range(m):
    sw[i] = list(map(int,input().split()[1::]))

ans = 0

for tpl in intertools.product([0,1],repeat = n):
    bl = True
    for i in range(m):
        s = sum(tpl[s-1] for s in sw[i])
        if (s-p[i])%2 != 0:
            bl = False
            break
    if bl:
        ans +=1
print(ans)

import itertools
n , m = map(int,input().split())
sw = [[] for _ in range(m)]
for i in range(m):
    sw[i] = list(map(int,input().split()[1::]))
p = [int(x) for x in input().split()]
ans = 0

for tpl in itertools.product([0,1],repeat = n):
    bl = True
    for i in range(m):
        s = sum(tpl[s-1] for s in sw[i])
        if (s-p[i])%2 != 0:
            bl = False
            break
    if bl:
        ans +=1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
, M = [int(x) for x in input().split()]
K = [[0]*N]*M
for i in range(M):
  K[i] = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]
total = 0
for i in range(2 ** N):
    lamp = [0] * N
    for j in range(N):
        if ((i >> j) & 1):
            lamp[j] = 1
    flag = True
    for x in range(M):
      result = 0
      for y in K[x][1:]:
        if lamp[y-1] == 1:
          result += 1
      result %= 2
      if result != P[x]:
        flag = False
    if flag:
      total += 1
print(total)


N, M = [int(x) for x in input().split()]
K = [[0]*N]*M
for i in range(M):
  K[i] = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]
total = 0
for i in range(2 ** N):
    lamp = [0] * N
    for j in range(N):
        if ((i >> j) & 1):
            lamp[j] = 1
    flag = True
    for x in range(M):
      result = 0
      for y in K[x][1:]:
        if lamp[y-1] == 1:
          result += 1
      result %= 2
      if result != P[x]:
        flag = False
    if flag:
      total += 1
print(total)


Verdicts: Runtime Error

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
from itertools import product
N, M = map(int, input().split())
denkyu = []
for i in range(M):
    denkyu.append([int(j) for j in input().split()])
p = [int(i) for i in input().split()]
ls = [0, 1]
ans = 0
for x in product(ls, repeat=N):
    num = 0
    for denkyu_, j in enumerate(denkyu):
        judge_light_on = 0
        for s, i in enumerate(denkyu_):
            if i != 0 and x[s-1] == 1:
                judge_light_on += 1
        if judge_light_on%2 == p[j]:
            num += 1
    if num == 0 or num == M:
        ans += 1
print(ans)

from itertools import product
N, M = map(int, input().split())
denkyu = []
for i in range(M):
    denkyu.append([int(j) for j in input().split()])
p = [int(i) for i in input().split()]
ls = [0, 1]
ans = 0
for x in product(ls, repeat=N):
    num = 0
    for j, denkyu_ in enumerate(denkyu):
        num_light_on = 0
        for i, s in enumerate(denkyu_):
            if i != 0 and x[s-1] == 1:
                num_light_on += 1
        if num_light_on%2 == p[j]:
            num += 1
    if num == M:
        ans += 1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
N,M = map(int, input().split())
 
s = [list(map(int, input().split()))[1:] for _ in range(M)]
p = list(map(int, input().split()))

cnt = 0

for i in range(2 ** N):
    flag = True
    for j in range(M):
        if not([(i >> k-1) for k in s[j]].count(1) % 2 == p[j] & 1):
            flag = False
    if flag:
        cnt += 1

print(cnt)

N,M = map(int, input().split())
 
s = [list(map(int, input().split()))[1:] for _ in range(M)]
p = list(map(int, input().split()))

cnt = 0

for i in range(2 ** N):
    flag = True
    for j in range(M):
        if not([(i >> k-1) & 1  for k in s[j]].count(1) % 2 == p[j]):
            flag = False
    if flag:
        cnt += 1

print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):




N,M = map(int,input().split())
sw = [[] for _ in range(M)]
# print(sw) # [[], [], ..., []]

for i in range(M):
    sw[i] = list(map(int,input().split()[1:]))


import itertools

answer = 0
for tpl in itertools.product([0,1],repeat=N):
  bl = True
  for i in range(M):
    
    s = sum([tpl[s-1] for s in sw[i]])
    if (s-p[i])%2 != 0:
      bl = False
      break
  if bl:
    answer += 1
print(answer)





N,M = map(int,input().split())
sw = [[] for _ in range(M)]
# print(sw) # [[], [], ..., []]

for i in range(M):
    sw[i] = list(map(int,input().split()[1:]))


p = [int(x) for x in input().split()]
import itertools

answer = 0
for tpl in itertools.product([0,1],repeat=N):
  bl = True
  for i in range(M):
    
    s = sum([tpl[s-1] for s in sw[i]])
    if (s-p[i])%2 != 0:
      bl = False
      break
  if bl:
    answer += 1
print(answer)


Verdicts: Runtime Error

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
N, M = input().split()
K = []
P = []
adjacent = [[0] for i in range(M)]
for i in range(M):
  A = list(input())
  K[i] = A[0]
  adjacent[i] = A[1:]
P = list(input())
X = 0
a = [[0] for i in range(M)]
for i in range(2**N):
  b = []
  for j in range(N):
    if i%2 == 1:
      b.append(j)
    i = i//2
  for j in range(M):
    if len(set(b)&set(adjacent[j]))%2 == P[j]:
      a[j] = 1
  if sum(a) == M:
    X += 1
print(X)
    

N, M = map(int, input().split())
K = [[0] for i in range(M)]
adjacent = [[0]*N for i in range(M)]
for i in range(M):
    A = list(input().split())
    K[i] = A[0]
    for j in A[1:]:
        adjacent[i][int(j)-1] = 1
P = list(input().split())
X = 0
for i in range(2**N):
  a = 0
  b = [0]*N
  for j in range(N):
    if i%2 == 1:
      b[j] = 1
    i = i//2
  for j in range(M):
    if  sum([x*y for (x,y) in zip(b, adjacent[j])])%2 == int(P[j]):
      a += 1
  if a == M:
    X += 1
print(X)

Verdicts: Runtime Error

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
N, M = map(int, input().split())
k = []
lis = []
P = []
for _ in range(M):
    x = list(map(int, input().split()))
    k.append(x[0])
    lis.append(x[1:])
for p in map(int, input().split()):
    P.append(p)
count = 0
for i in range(2**N):
    flag = True
    string = str(bin(i)[2:])[::-1]
    for index in range(M):
        total = 0
        for s in lis[index]:
            if s < len(string):
                if string[s - 1] == '1':
                    total += 1
        if total % 2 != P[index]:
            flag = False
            break
    if flag:
        count += 1
print(count)

N, M = map(int, input().split())
k = []
lis = []
P = []
for _ in range(M):
    x = list(map(int, input().split()))
    k.append(x[0])
    lis.append(x[1:])
for p in map(int, input().split()):
    P.append(p)
count = 0
for i in range(2**N):
    flag = True
    string = str(bin(i)[2:])[::-1]
    for index in range(M):
        total = 0
        for s in lis[index]:
            if s <= len(string):
                if string[s - 1] == '1':
                    total += 1
        if total % 2 != P[index]:
            flag = False
            break
    if flag:
        count += 1
print(count)

Verdicts: Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
n, m = map(int, input().split())


k = []
s = []
ans = 0

for i in range(m):
    k_temp, *s_temp = list(map(int, input().split()))
    k.append(k_temp)
    s.append(s_temp)

p = list(map(int, input().split()))

for bit in range(1 << n):
    light_on = 0
    for i in range(m):
        switch_on = 0
        for j in range(k[i]):
            if (bit >> s[i][j]) & 1:
                switch_on += 1

        if switch_on % 2 == p[i]:
            light_on += 1

    if light_on == m:
        ans += 1

print(ans)


n, m = 10, 10


k = [4, 3, 4, 5, 6, 5, 4, 4, 4, 4]
s = [[6, 3, 7, 5], [1, 10, 5], [8, 7, 1, 2], [5, 10, 2, 7, 8],
     [3, 1, 6, 8, 2, 5], [6, 10, 7, 1, 3], [3, 5, 7, 6],
     [3, 9, 7, 5], [3, 6, 5, 7], [2, 7, 1, 8]]
ans = 0


#     k_temp, *s_temp = list(map(int, input().split()))
#     k.append(k_temp)
#     s.append(s_temp)

p = [0, 0, 1, 1, 1, 0, 0, 0, 0, 1]

for bit in range(1 << n):
    light_on = 0
    for i in range(m):
        switch_on = 0
        for j in range(k[i]):
            if (bit >> s[i][j]) & 1:
                switch_on += 1

        if switch_on % 2 == p[i]:
            light_on += 1

    if light_on == m:
        ans += 1

print(ans)


n, m = map(int, input().split())


k = []
s = []
ans = 0

for i in range(m):
    k_temp, *s_temp = list(map(int, input().split()))
    k.append(k_temp)
    s.append(s_temp)

p = list(map(int, input().split()))

for bit in range(1 << n):
    light_on = 0
    for i in range(m):
        switch_on = 0
        for j in range(k[i]):
            if (bit >> (s[i][j] - 1)) & 1:
                switch_on += 1

        if switch_on % 2 == p[i]:
            light_on += 1

    if light_on == m:
        ans += 1

print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted