TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
import numpy as np
N=int(input())
A=[[]]
X=[[]]
Y=[[]]
for i in range(1,N+1):
    a=int(input())
    A.append(a)
    x=[[]]
    y=[[]]
    for j in range(a):
        b=list(map(int,input().split()))
        x.append(b[0])
        y.append(b[1])
    X.append(x)
    Y.append(y)
ans=0
for bits in range(1 << N):
    #print(bin(bits))
    ok=True
    for i in range(1,N+1):
        if not (bits & (1<<i-1)):
            continue
        for j in range(1,A[i]+1):
            if(((bits >> (X[i][j]-1)) & 1) ^ Y[i][j]):
                ok = False
        
    if ok:
#        print(ok,bin(bits))
        ans = max(ans, counter(bits))
print(ans)

def counter(x):
    if x==0:
        return 0
    return counter(x >> 1) + (x & 1)
N=int(input())
A=[[]]
X=[[]]
Y=[[]]
for i in range(1,N+1):
    a=int(input())
    A.append(a)
    x=[[]]
    y=[[]]
    for j in range(a):
        b=list(map(int,input().split()))
        x.append(b[0])
        y.append(b[1])
    X.append(x)
    Y.append(y)
ans=0
for bits in range(1 << N):
    #print(bin(bits))
    ok=True
    for i in range(1,N+1):
        if not (bits & (1<<i-1)):
            continue
        for j in range(1,A[i]+1):
            if(((bits >> (X[i][j]-1)) & 1) ^ Y[i][j]):
                ok = False
        
    if ok:
#        print(ok,bin(bits))
        ans = max(ans, counter(bits))
print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
n = int(input())
a = []
for i in range(n):
    num = int(input())
    for j in range(num):
        hi, tf = map(int,input().split())
        a.append([i,hi,tf])
print(a)

max = 0
for i in range(1,2**n):
    se = format(i,'b').zfill(n)


n = int(input())
a = []
for i in range(n):
    num = int(input())
    for j in range(num):
        hi, tf = map(int,input().split())
        a.append([i,hi-1,tf])

m = 0
for i in range(1,2**n):
    se = format(i,'b').zfill(n)
    fl = True
    for j in a:
        if se[j[0]] == "1":
            if int(se[j[1]])^j[2] == 1:
                fl = False
                break
    if fl:
        m = max([m,se.count("1")])

print(m)


Verdicts: Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
import itertools as it

N = int(input())
xy = []
for i in range(N):
    A_i = int(input())
    xy_i = []
    for j in range(A_i):
        tmp = [int(i) for i in input().split()]
        xy_i.append(tmp)
    xy.append(xy_i)
ans = 0
for conf in it.product(range(2), repeat=N):
    is_consist = True
    # honest 1, evil 0
    for i in range(N):
        if conf[i] == 0:
            continue
        # i is honest
        for jth_state in range(len(xy[i])):
            if xy[i][jth_state][1] != conf[xy[i][jth_state][0] - 1]:
                is_consist = False
                break
    if is_consist:
        ans = max(ans, sum(conf))
        if ans == sum(conf):
            print(conf)
print(ans)


import itertools as it

N = int(input())
xy = []
for i in range(N):
    A_i = int(input())
    xy_i = []
    for j in range(A_i):
        tmp = [int(i) for i in input().split()]
        xy_i.append(tmp)
    xy.append(xy_i)
ans = 0
for conf in it.product(range(2), repeat=N):
    is_consist = True
    # honest 1, evil 0
    for i in range(N):
        if conf[i] == 0:
            continue
        # i is honest
        for jth_state in range(len(xy[i])):
            if xy[i][jth_state][1] != conf[xy[i][jth_state][0] - 1]:
                is_consist = False
                break
    if is_consist:
        ans = max(ans, sum(conf))
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
#python3 
g = [[-1 for _ in range(15)] for _ in range(15)]

n = int(input())
for i in range(n):
  m = int(input())
  for j in range(m):
    x,y = map(int, input().split())
    g[i][x-1] = y

ans = 0
for i in range(1<<n):
  honests = [0 for _ in range(n)]
  for j in range(n):
    if (i>>j) &1:
      honests[j] = 1 
  ok = True
  for j in range(n):
    if honests[j]:
      for k in range(n):
        if g[j][k] == -1: continue
        if g[j][k] != honests[k]: ok = False
  if ok:
    ans = max(ans, honests.count('1'))

print(ans)

#python3

def main():
    n = int(input())
    g = [[-1 for _ in range(n)] for _ in range(n)]
    for i in range(n):
        a = int(input())
        for j in range(a):
            x, y = map(int, input().split())
            g[i][x-1] = y


    ans = -1
    for i in range(1<<n):
        honest = [0 for _ in range(n)]
        for j in range(n):
            if (i>>j) & 1:
                honest[j] = 1 
        
        flag = True 
        for j in range(n):
            if honest[j] == 1:
                for k in range(n):
                    if g[j][k] == -1:
                        continue
                    if g[j][k] != honest[k]:
                        flag = False
        if flag:
            ans = max(ans, honest.count(1))

    print(ans)

main()

Verdicts: Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
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():
    ans=0
    n=INT()
    xyall=[]
    for i in range(n):
        xyall.append([])
        a=INT()
        for j in range(a):
            x,y=INTM()
            xyall[i].append([x,y])
    
    for i in range(2**n):
        flg=True
        ct=0
        for j in range(n):
            if ((i >> j) & 1):
                #print('bb')
                ct+=1
                xys=xyall[j]
                for xy in xys:
                    #print(xy)
                    if ((i >> xy[0]-1) == xy[1]):
                        #print('cc')
                        pass
                    else:
                        flg=False
                        break
            else:
                pass
        if flg:
            #print('aa')
            ans=max(ans,ct)
    print(ans)



if __name__=='__main__':
    do()

import itertools
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():
    ans=0
    n=INT()
    A=[]
    for i in range(n):
        a=INT()
        A.append([])
        for k in range(a):
            x,y=INTM()
            x-=1
            A[i].append([x,y])

    #print(A)

    for i in itertools.product([0,1], repeat=n):
        #print(str(sum(i))+'aaaa')
        flg=True
        for k in range(n):
            if i[k]==1:
                for j in A[k]:
                    if i[j[0]]!=j[1]:
                        flg=False
                        break
        
        if flg:
            ans=max(ans,sum(i))

    print(ans)


if __name__=='__main__':
    do()

Verdicts: Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

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

S=[[-1]*N for _ in range(N)]
for _ in range(N):
  A=int(input())
  for i in range(A):
    x, y=map(int, input().split())
    
for s in range(2**N):
  ok=True
  for i in range(N):
    
    if (s<<i&1)==1:
      for j in range(N):
        
        if g[i][j]!=-1 and (s>>j&1)!=g[i][j]:
          ok=False
  if ok:
    ans=max(ans, bin(s).count("1"))
    
print(ans)
      

N=int(input())


L=[[-1]*N for _ in range(N)]
for i in range(N):
    A=int(input())
    for a in range(A):
        x,y=map(int, input().split())
        L[i][x-1]=y
ans=0
for b in range(2**N):
    ok=True
    for i in range(N):
        if b>>i&1==1:
            l=L[i]
            for j,x in enumerate(l):
                if x!=-1 and b>>j&1!=x:
                    ok=False
    if ok:
        ans=max(ans, bin(b).count("1"))

print(ans)


Verdicts: Runtime Error

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
import numpy as np

N = int(readline())
info = []
for i in range(N):
    A = int(readline())
    for _ in range(A):
        x,y = map(int,readline().split())
        info.append((i,x-1,y))
#print(info)

#info=[(0, 1, 1), (1, 0, 1), (2, 1, 0)]

N=3
#A = np.array(list(itertools.product([0,1],repeat=N)),np.bool)
A = np.array(list(itertools.product([0,1],repeat=N)),np.bool)

for i,x,y in info:
    # print(~A[:,i])
    # print(A[:,x])
    # bl = (~A[:,i]) | (A[:,x] == bool(y))
    bl = (A[:,i]) & A[:,x] == bool(y)
    A = A[bl]

answer = A.sum(axis = 1).max()
print(answer)

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
import numpy as np

N = int(readline())
info = []
for i in range(N):
    A = int(readline())
    for _ in range(A):
        x,y = map(int,readline().split())
        info.append((i,x-1,y))
#print(info)

#info=[(0, 1, 1), (1, 0, 1), (2, 1, 0)]

N=3
#A = np.array(list(itertools.product([0,1],repeat=N)),np.bool)
A = np.array(list(itertools.product([0,1],repeat=N)),np.bool)

for i,x,y in info:
    # print(~A[:,i])
    # print(A[:,x])
    bl = (~A[:,i]) | (A[:,x] == bool(y))
    # bl = (A[:,i]) & A[:,x] == bool(y)
    A = A[bl]

answer = A.sum(axis = 1).max()
print(answer)

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
import numpy as np

N = int(readline())
info = []
for i in range(N):
    A = int(readline())
    for _ in range(A):
        x,y = map(int,readline().split())
        info.append((i,x-1,y))
        
A = np.array(list(itertools.product([0,1],repeat=N)),np.bool)
for i,x,y in info:
    bl = (A[:,i]) & (A[:,x] == bool(y))
    A = A[bl]

answer = A.sum(axis = 1).max()
print(answer)


def honestcount(i):
    return bin(i).count("1")

def is_honest(i,j):
    return (i>>j)%2 == 1

N = int(input())

A = [0] * N
shogens=[]

for i in range(N):
    a = int(input())
    shogen=[]
    for j in range(a):
        x,y = map(int, input().split())
        shogen.append((x-1,y))
    shogens.append(shogen)


count=0
for i in range(1<<N):
    is_ok =True
    for j in range(N):
        if not is_honest(i,j):
            continue
        for x,y in shogens[j]:
            if y!=is_honest(i,x):
                is_ok=False
                break
    if is_ok:
        count=max(count,honestcount(i))
print(count)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

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

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

for i in range(n):
    a_tmp = int(input())
    for _ in range(a_tmp):
        x,y = map(int,input().split())
        s[i].append([x,y])

#print(s)

mx = 2**n -1


def hantei(num):
    flag=0
    bi =[0 for _ in range(n)]
    for j in range(n):
        if((num>>j)%2 == 1):
            for x,y in s[j]:
                if(y != bi[x-1]):
                    flag = 1
                    return flag
    
    return flag

ans = 0 
for i in range(mx):
    if(hantei(i) == 0):
        #print(i)
        ans = max(ans,bin(i)[2::].count("1"))
        
print(ans)

#print(bin(3)[2::].count("1"))


n = int(input())

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

for i in range(n):
    a_tmp = int(input())
    for _ in range(a_tmp):
        x,y = map(int,input().split())
        s[i].append([x,y])

#print(s)

mx = 2**n


def hantei(num):
    flag=0
    bi =[0 for _ in range(n)]
    for j in range(n):
        bi[j] = (num>>j)%2
    
    for j in range(n):
        if((num>>j)%2 == 1):
            for x,y in s[j]:
                if(y != bi[x-1]):
                    flag = 1
                    return flag
    
    return flag

ans = 0 
for i in range(mx):
    if(hantei(i) == 0):
        #print(i)
        ans = max(ans,bin(i)[2::].count("1"))
        
print(ans)

#print(bin(3)[2::].count("1"))


Verdicts: Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
N = int(input())
testimony = [[] for _ in range(N)]
#print(testimony)
for i in range(N):
 num = int(input())
 for j in range(num):
  person, state = map(int, input().split())
  testimony[i].append([person-1, state])

#print(testimony)

honest = 0
for i in range(i, 2**N):
 flag = 0
 for j in range(N):
  if (i>>j)&1 == 1:
   for x, y in testimony[j]:
    if (i>>x)&1 != y:
     flag = 1
     break
   if flag == 0:
    honest = max(honest, bin(i)[2:].count('1'))

print(honest)











N = int(input())
testimony = [[] for _ in range(N)]
#print(testimony)
for i in range(N):
 num = int(input())
 for j in range(num):
  person, state = map(int, input().split())
  testimony[i].append([person-1, state])

#print(testimony)

honest = 0
for i in range(1, 2**N):
 flag = 0
 for j in range(N):
  if (i>>j)&1 == 1:
   for x, y in testimony[j]:
    if (i>>x)&1 != y:
     flag = 1
     break
 if flag == 0:
  honest = max(honest, bin(i)[2:].count('1'))

print(honest)











Verdicts: Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
n = int(input())
xy = []
ansp = []
people =[-1]*n
sp = [-1]*n



for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int,input().split())
        xy.append([x-1,y])
def dfs(now,ok):
    global sp
    global people
    if now ==n:
        ansp.append(people.count(1))
        sp = [-1]*n
        people = [-1]*n
        return
    if len(xy[now]) >0:
        for i in range(len(xy[now])):
            x = xy[i][0]
            y = xy[i][1]
            if ok:
                if sp[x] == y or sp[x] == -1:
                    sp[x] = y
                else:continue
            else:
                if sp[x] == y^1 or sp[x] == -1:
                    sp[x] == y^1
                else:continue
    
        
        
    people[now] = ok    
    dfs(now+1,ok)
    dfs(now+1,ok^1)
dfs(0,0)
dfs(0,1)
if len(ansp) == 0:
    print(0)
    exit(0)
print(max(ansp))    
        
        


        
            

import sys
sys.setrecursionlimit(10**7)
n = int(input())
people = []
shogens = [[]for i in range(n)]
def check():
    for i in range(n):
        if i not in people:continue
        for shogen in shogens[i]:
            person = shogen[0]
            honest = shogen[1]
            if honest and person not in people:return False
            if (not honest) and person in people:return False
    return True
        
            
            
            
        
for i in range(n):
    a = int(input())
    for j in range(a):
        p,q = map(int,input().split())
        p -= 1
        shogens[i].append((p,q))
def dfs(d,people):
    if d == n:
        
        if check():
            
            return len(people)
        else:
            return 0
    res = dfs(d+1,people)
    people.append(d)
    res = max(res,dfs(d+1,people))
    people.pop()
    return res
print(dfs(0,people))


Verdicts: Runtime Error

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
import numpy as np
N = int(input())
data_xy = []
for i in range(N):
    A = int(input())
    xy = []
    for i in range(A):
        [x,y] = list(map(int,input().split()))
        xy.append([x-1, y])
    data_xy.append(xy)
data_xy = np.array(data_xy)
p_list = np.zeros(N)
ans = 0
for i in range(2**N):
    for j in range(N):
        if (i>>j) & 1 == 1:
            p_list[j] = 1
    flag = True
    for j in range(N):
        if p_list[j] == 1:
            for k in range(len(data_xy[j])):
                x = data_xy[j][k][0]
                y = data_xy[j][k][1]
                if p_list[x] != y:
                    flag = False
    if flag == True:
        ans = max(sum(p_list),ans)
print(ans)

import numpy as np
N = int(input())
data_xy = []
for i in range(N):
    A = int(input())
    xy = []
    for i in range(A):
        [x,y] = list(map(int,input().split()))
        xy.append([x-1, y])
    data_xy.append(xy)
data_xy = np.array(data_xy)
ans = 0
for i in range(2**N):
    p_list = np.zeros(N)
    for j in range(N):
        if (i>>j) & 1 == 1:
            p_list[j] = 1
    flag = True
    for j in range(N):
        if p_list[j] == 1:
            for k in range(len(data_xy[j])):
                x = data_xy[j][k][0]
                y = data_xy[j][k][1]
                if p_list[x] != y:
                    flag = False
    if flag == True:
        ans = max(sum(p_list),ans)
print(ans)


import numpy as np
N = int(input())
data_xy = []
for i in range(N):
    A = int(input())
    xy = []
    for i in range(A):
        [x,y] = list(map(int,input().split()))
        xy.append([x-1, y])
    data_xy.append(xy)
ans = 0
for i in range(2**N):
    p_list = [0]*N
    for j in range(N):
        if (i>>j) & 1 == 1:
            p_list[j] = 1
    flag = True
    for j in range(N):
        if p_list[j] == 1:
            for k in range(len(data_xy[j])):
                x = data_xy[j][k][0]
                y = data_xy[j][k][1]
                if p_list[x] != y:
                    flag = False
    if flag == True:
        ans = max(sum(p_list),ans)
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

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

a_list = []
for _ in range(n):
  mini_list = []
  a = int(input())
  for _ in range(a):
    mini_list.append(list(map(int, input().split())))
  a_list.append(mini_list)

ans = 0
for i in range(n**2):
  ans_list = [0]*n
  while i!=0:
    ans_list[i%2] = 1
    i//=2
  flg = True
  for j, syogens in enumerate(a_list):
    if ans_list[j]!=0:
      pass
    else:
      for syogen in syogens:
        person = syogen[0]-1
        status = syogen[1]
        if ans_list[person] != status:
          flg=False
  if flg:
    ans = max(ans,sum(ans_list))
print(ans)


n = int(input())

a_list = []
for _ in range(n):
  mini_list = []
  a = int(input())
  for _ in range(a):
    mini_list.append(list(map(int, input().split())))
  a_list.append(mini_list)

ans = 0
for i in range(2**n):
  ans_list = [0]*n
  cnt=0
  while i!=0:
    ans_list[cnt] = i%2
    cnt+=1
    i//=2
  
  flg = True
  for j, syogens in enumerate(a_list):
    if ans_list[j]==0:
      pass
    else:
      for syogen in syogens:
        person = syogen[0]-1
        status = syogen[1]
        if ans_list[person] != status:
          flg=False
  if flg:
    ans = max(ans,sum(ans_list))
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
N = int(input())
A = [[] for _ in range(N)]
for i in range(N):
    for _ in range(int(input())):
        A[i].append([int(s) for s in input().split()])

ret = 0
for i in range(2 ** N):
    bits = [i >> j & 1 for j in range(N)]
    #print(bits)
    for i, a in enumerate(A):
        if bits[i] == 0:
            continue
        for x, y in a:
            # print(bits, bits[x - 1], y)
            if bits[x - 1] == y:
                continue
            break　　　　　　　　　
        else:
            continue
        break
    else:
        ret = max(ret, sum(bits))
print(ret)

N = int(input())
A = [[] for _ in range(N)]
for i in range(N):
    for _ in range(int(input())):
        A[i].append([int(s) for s in input().split()])

ret = 0
for i in range(2 ** N):
    bits = [i >> j & 1 for j in range(N)]
    #print(bits)
    for i, a in enumerate(A):
        if bits[i] == 0:
            continue
        for x, y in a:
            # print(bits, bits[x - 1], y)
            if bits[x - 1] == y:
                continue
            break
        else:
            continue
        break
    else:
        ret = max(ret, sum(bits))
print(ret)

Verdicts: Runtime Error

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
from sys import stdin, setrecursionlimit
setrecursionlimit(10**6)
from copy import deepcopy

def S(): return stdin.readline().rstrip()
def I(): return int(stdin.readline().rstrip())
def LS(): return list(stdin.readline().rstrip().split())
def LI(): return list(map(int,stdin.readline().rstrip().split()))
def R(x):
    r = round(x)
    if r+0.5 <= x:
        r += 1
    return r

def BFS(table, honest, next):
    p = next.pop(0)
    swt = 1
    for i in range(len(table[p])):
        q = table[p][i]
        if q!=-1:         
            if honest[i]!=-1:
                if honest[p]:
                    if q^honest[i]:
                        return False
                else:
                    if swt:
                        if not q^honest[i]:
                            honest[p] = 1
                        else:
                            honest[p] = 0
                            swt = 0
            else:
                next.append(i)
                honest[i] = q
    if 0<len(next):
        return BFS(table,honest,next)
    else:
        for i,h in enumerate(honest):
            if h==-1:
                return BFS(table,honest,[i]) 
        return True

n = I()
a = []
table = [[-1]*n for _ in range(n)]
for i in range(n):
    A = I()
    a.append(A)
    for _ in range(A):
        tmp = LI()
        table[i][tmp.pop()-1] = tmp.pop()

ans = 0
for i in range(n):
    honest = [-1]*n
    honest[i] = 1
    tmp = BFS(deepcopy(table),honest,[i])
    if tmp:
    
        x = honest.count(1)
        if ans<x:
            ans = x
print(ans)

from sys import stdin, setrecursionlimit
setrecursionlimit(10**6)
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

def judge(x,y,a,bit):
    for i in range(len(a)):
        if bit&(1<<i):
            for j in range(a[i]):
                if ((bit>>x[i][j])&1)^y[i][j]:
                    return False
    return True

n = I()
a = []
x = []
y = []
for i in range(n):
    A = I()
    a.append(A)
    xt = []
    yt = []
    for _ in range(A):
        tmp = LI()
        xt.append(tmp.pop(0)-1)
        yt.append(tmp.pop(0))
    x.append(xt)
    y.append(yt)

ans = 0
length = 2**n
for i in range(length):
    result = judge(x,y,a,i)
    if result:
        ans = max(ans,bin(i).count('1'))
    
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

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

talk = [[-1 for i in range(N)] for j in range(N)]

for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        talk[i][x-1] = y

ans = 0

for i in range(1 << N):
    honest = []
    ansi = 0
    for j in range(N):
        if(1 << j and i):
            honest.append(1)
        else:
            honest.append(0)

    for j in range(N):
        if(honest[i] == 0):
            continue
        flag = True
        for k in range(N):
            if(honest[k] != talk[j][k] and talk[j][k] != -1):
                flag = False

        if(flag):
            ansi += 1

    ans = max(ans, ansi)

print(ans)



N = int(input())
people = [[-1 for __ in range(N)] for _ in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        x -= 1
        people[i][x] = y

ans = 0


for i in range(1 << N):
    ansi = 0
    flag = True
    for j in range(N):
        peoplei = 0
        if (i & 1 << j):
            peoplei = 1
            ansi += 1
        for k in range(N):
            if (i & 1 << k):
                if(people[k][j] != -1 and people[k][j] != peoplei):
                    flag = False

    if flag:
        ans = max(ans, ansi)


print(ans)





Verdicts: Runtime Error

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
N = int(input())
A = []
xy = []
for i in range(N):
    a =  int(input())
    A.append(a)
    for j in range(a):
        x, y = map(int, input().split())
        
        xy.append([x, y])
print(xy)

honest = 0

for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        
        if (i>>j)&1 == 1:
            for x,y in xy[j]:
                
                if (i>>x)&1 != y:
                    flag = 1
                    break
    
    if flag == 0:
        honest = max(honest, bin(i)[2:].count('1'))
print(honest)

N = int(input())
 
testimony = [[] for _ in range(N)]
 
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])

honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1 == 1: 
            for x,y in testimony[j]:
                if (i>>x)&1 != y: 
                    flag = 1
                    break
    if flag == 0:  
        honest = max(honest, bin(i)[2:].count('1'))  
print(honest)

Verdicts: Runtime Error

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
N = int(input())
xy = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        xy_ = tuple(map(int,input().split()))
        xy[i].append(xy_)

bN = 2**N
ans = 0
for b in range(bN):
    for n in range(N):
        if (b >> n) & 1:
            for x,y in xy[n]:
                if y != b >> (x-1):
                    break
            else:
                continue
            break
    else:
        ans = max(ans,bin(b).count("1"))
print(ans)


N = int(input())
xy = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        xy_ = tuple(map(int,input().split()))
        xy[i].append(xy_)

bN = 2**N
ans = 0
for b in range(bN):
    lis = [int(("00000000000000"+bin(b)[2:])[-1-i]) for i in range(N)]
    
    for n,l in enumerate(lis):
        
        if l:
            for x,y in xy[n]:
                if y != lis[x-1]:
                    break
            else:
                continue
            break
    else:
        ans = max(ans,lis.count(1))
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
n = int(input())
comments = {}
for i in range(n):
  a = int(input())
  comments[i] = []
  for _ in range(a):
    x, y = [int(x) for x in input().split()]
    comments[i].append([x-1, y==1])

ans = 0
for i in range(2**n):
  results = [None] * n
  for j in range(n):
    candidate = (i >> j) & 1
    if results[j] is None:
      results[j] = candidate
    if results[j] != candidate:
      break
    if candidate == False:
      continue
    if candidate == True:
      failed = False
      for comment in comments[j]:
        if results[comment[0]] is None:
          results[comment[0]] = comment[1]
        if results[comment[0]] != comment[1]:
          failed = True
          break
      if failed:
        break
  else:
    cnt = len([r for r in results if r is True])
    if cnt > ans:
      ans = cnt

print(ans)


n = int(input())
comments = {}
for i in range(n):
  a = int(input())
  comments[i] = []
  for _ in range(a):
    x, y = [int(x) for x in input().split()]
    comments[i].append([x-1, y==1])

ans = 0
for i in range(2**n):
  results = [None] * n
  for j in range(n):
    candidate = ((i >> j) & 1) == 1
    if results[j] is None:
      results[j] = candidate
    elif results[j] != candidate:
      break
    if candidate == False:
      continue
    elif candidate == True:
      failed = False
      for comment in comments[j]:
        if results[comment[0]] is None:
          results[comment[0]] = comment[1]
        if results[comment[0]] != comment[1]:
          failed = True
          break
      if failed:
        break
  else:
    cnt = len([r for r in results if r is True])
    if cnt > ans:
      ans = cnt

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

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

a = []
xys = [[] for i in range(n)]

for j in range(n):
    a.append(int(input()))
    for i in range(a[j]):
        xys[j].append(list(map(int,input().split())))


ps = []
p = [0 for i in range(n)]
for i in range(n+1):
    for combi in itertools.combinations(range(n),i):
        p = [0 for i in range(n)]
        combi = list(combi)
        for i in combi:
            p[i] = 1
        ps.append(p)


for l in range(2**n):
    for i in range(n):
        if  (ps[l])[i] == 1:
            for j in range(a[i]):
                if ps[l][xys[i][j][0] - 1] != xys[i][j][1]:
                    ps[l] = [0,0,0]

print(max(sum(ps[l]) for l in range(2**n)))

n = int(input())

a = []
xys = [[] for i in range(n)]

for j in range(n):
    a.append(int(input()))
    for i in range(a[j]):
        xys[j].append(list(map(int,input().split())))

p = [1 for i in range(n)]
for i in range(n):
    for j in range(a[i]):
        if ((xys[i])[j])[1] == 0:
            p[((xys[i])[j])[0] - 1] = min(1 - p[i],0)
        else:
            p[((xys[i])[j])[0] - 1] = min(1 + p[i],1)

t = 1
for i in range(n):
    if p[i] == 1:
        for j in range(a[i]):
            if p[xys[i][j][0] - 1] != xys[i][j][1]:
                t = 0

if t == 0:
    print(0)
else:
    print(sum(p))


n = int(input())

a = []
xys = [[] for i in range(n)]

for j in range(n):
    a.append(int(input()))
    for i in range(a[j]):
        xys[j].append(list(map(int,input().split())))


ans = 0
for i in range(1,2**n):
    cont = True
    for j in range(n):
        if (i >> j) & 1 == 1:
            for x,y in xys[j]:
                if (i >> (x-1)) & 1 != y:
                    cont = False
                    break
        if not cont:
            break
    if cont:
        ans = max(ans,bin(i)[2:].count('1'))

print(ans)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
import itertools
 
n = int(input())
l =[]
 
for _ in range(n):
  a = int(input())
  m = []
  for _ in range(a):
    xn, yn = map(int, input().split())
    m.append([xn-1, yn])
  l.append(m)
 
for i in itertools.product([1, 0], repeat=n):
  i = list(i)
  print(i)
  flg = 0
  for j in range(n):
    for k in l[j]:
      if i[j] == 1:
        if i[k[0]] != k[1]:
          flg += 1
          break
  if flg == 0:
    break
    
print(sum(i))

import itertools
 
n = int(input())
l =[]
 
for _ in range(n):
  a = int(input())
  m = []
  for _ in range(a):
    xn, yn = map(int, input().split())
    m.append([xn-1, yn])
  l.append(m)
 
for i in itertools.product([1, 0], repeat=n):
  i = list(i)
  print(i)
  flg = 0
  for j in range(n):
    for k in l[j]:
      if i[j] == 1:
        if i[k[0]] != k[1]:
          flg += 1
          break
      if flg != 0:
        break
  if flg == 0:
    break
    
print(sum(i))

import itertools
 
n = int(input())
l =[]
 
for _ in range(n):
  a = int(input())
  m = []
  for _ in range(a):
    xn, yn = map(int, input().split())
    m.append([xn-1, yn])
  l.append(m)
 
for i in itertools.product([1, 0], repeat=n):
  i = list(i)
  flg = 0
  for j in range(n):
    for x, y in l[j]:
      if i[j] == 1 and i[x] != y:
        flg += 1
        break
  if flg == 0:
    break
    
print(sum(i))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
N = int(input())
g = [[-1 for _ in range(N)] for _ in range(N)]
for i in range(N):
    m = int(input())
    for j in range(m):
        x,y = map(int,input().split())
        g[i][x-1] = y

ans = 0
for i in range(1 << N):
    hornest = [0] * N
    for j in range(N):
        if (i << j)&1:
            hornest[j] = 1
    is_ok = 1
    for j in range(N):
        if hornest[j]:
            for k in range(N):
                if g[j][k] == -1:
                    continue
                if g[j][k] != hornest[k]:
                    is_ok = 0
    if is_ok:
        ans = max(ans,hornest.count(1))
        
print(ans)

N = int(input())
g = [[-1 for _ in range(N)] for _ in range(N)]
for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = map(int,input().split())
        g[i][x-1] = y
ans = 0
for i in range(1 << N):
    hornest = [0] * N
    for j in range(N):
        if (i >> j)&1:
            hornest[j] = 1
    is_ok = 1
    for j in range(N):
        if hornest[j] and is_ok:
            for k in range(N):
                if g[j][k] == -1:
                    continue
                if g[j][k] != hornest[k]:
                    is_ok = 0
    if is_ok:
        ans = max(ans,hornest.count(1))
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
n = int(input())
a = []
xy = [[] for i in range(n)]
for i in range(n):
  a.append(int(input()))
  for j in range(a[i]):
    xy[i].append(list(map(int, input().split())))

tf = [0]*n
ans = 0
b = 1
for i in range(n**2):
  for j in range(n):
    if (i >> j) & 1:
      tf[j] = 1
  for k in range(n):
    if tf[k] == 1:
      for l in range(a[k]):
        if tf[xy[k][l][0]-1] != xy[k][l][1]:
          b = 0
          break
    if b == 1 and sum(tf) > ans:
      ans = sum(tf)

print(ans)

n = int(input())
a = []
xy = [[] for i in range(n)]
for i in range(n):
  a.append(int(input()))
  for j in range(a[i]):
    xy[i].append(list(map(int, input().split())))

tf = [0]*n
ans = 0
for i in range(n**2):
  for j in range(n):
    if (i >> j) & 1:
      tf[j] = 1
    else:
      tf[j] = 0
  print(tf)
  b = 1
  for k in range(n):
    if tf[k] == 1:
      for l in range(a[k]):
        if tf[xy[k][l][0]-1] != xy[k][l][1]:
          b = 0
          break
  print(i, b)
  if b == 1 and sum(tf) > ans:
    ans = sum(tf)

print(ans)

n = int(input())
a = []
xy = [[] for i in range(n)]
for i in range(n):
  a.append(int(input()))
  for j in range(a[i]):
    xy[i].append(list(map(int, input().split())))

tf = [0]*n
ans = 0
for i in range(2**n):
  for j in range(n):
    if (i >> j) & 1:
      tf[j] = 1
    else:
      tf[j] = 0
  b = 1
  for k in range(n):
    if tf[k] == 1:
      for l in range(a[k]):
        if tf[xy[k][l][0]-1] != xy[k][l][1]:
          b = 0
          break
  if b == 1 and sum(tf) > ans:
    ans = sum(tf)

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
N = int(input())
S = []
for _ in range(N):
    s = list(input())
    s.sort()
    # s = ''.join(s)
    S.append(s)

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(10):
            a = S[i]
            b = S[j]
            if a[k] != b[k]:
                break
        else:
            ans += 1
print(ans)


N = int(input())

XY = []
for _ in range(N):
    A = int(input())
    tmp = []
    for _ in range(A):
        x, y = map(int, input().split())
        tmp.append((x - 1, y))
    XY.append(tmp)


def judge(bit):
    for i in range(N):
        if not (bit & (1 << i)):
            continue
        for x, y in XY[i]:
            if y == 1 and (not (bit & (1 << x))):
                return False
            if y == 0 and (bit & (1 << x)):
                return False
    return True


ans = 0
for bit in range(1 << N):
    if (judge(bit)):
        # print('bit', bit, bin(bit))
        cnt = 0
        for i in range(N):
            if (bit & (1 << i)):
                cnt += 1
        ans = max(ans, cnt)
print(ans)


Verdicts: Runtime Error

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
import re
n=int(input())
A=[]
for i in range(n):
    B=["."]*n
    for x,y in [list(map(int,input().split())) for k in range(int(input()))]:
        B[x-1]=str(y)
    A.append("".join(B))
    
ans=0
for i in range(2**n):
    num=format(i,"b").zfill(n)
    cnt,flag=0,1
    for k,j in enumerate(num):
        result=re.search(r"".join(A[k]),num)
        if result is not None and j=="1":
            cnt +=1
        else:
            flag=0
            break
    if flag:ans=max(ans,cnt)
print(ans)

import re
n=int(input())
A=[]
for i in range(n):
    B=["."]*n
    for j in range(int(input())):
        x,y=map(int,input().split())
        B[x-1]=str(y)
    A.append("".join(B))

ans=0
for i in range(2**n):
    num=format(i, "b").zfill(n)
    flag,cnt=1,0
    for j,k in enumerate(num):
        result=re.fullmatch(r"".join(A[j]),num)
        if result is not None and k=="1":
            cnt +=1
        elif (result is not None and k=="0") or (result is None and k=="1"):
            flag=0
            break
    if flag:ans=max(ans,cnt)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
n = int(input())
xy = []
xyz =[]
a_list = []
ans = [1]*n

count = 0
for _ in range(n):
    a = int(input())
    a_list.append(a)
    for i in range(a):
        x,y = map(lambda x: int(x),input().split())
        xy.append([x,y])
    xyz.append(xy)
    xy = []

for j in range(n):
    for k in range(a_list[j]) :
        hoge = xyz[j][k][:]
        if ans[hoge[0]-1] != hoge[1]:
            count+= 1

if ans == [1]*n :
    print(1)
else:
    print(n - count)


import itertools


n = int(input())

all = list(itertools.product([0,1], repeat=n))
xy,xyz = [],[]
for _ in range(n):
    a = int(input())
    for i in range(a):
        x,y = map(lambda x: int(x),input().split())
        xy.append([x,y])
    xyz.append(xy)
    xy = []


test = ['None']*n
ans = []
ans_list = []
j_list = []
bool = True
hoge = 0
for i in range(len(all)):
    for j,k in enumerate(all[len(all) - 1 - i]):
        if k == 1:
            ans.append(xyz[j])
            j_list.append(j)
    ans = list(itertools.chain.from_iterable(ans))

    test = all[len(all) - 1 - i]
    for x in range(len(ans)):
        if test[ans[x][0]-1] != ans[x][1]:
            bool = False
            break

    if bool :
        hoge = all[len(all) - 1 - i]
        break
    bool = True
    test = ['None']*n
    ans = []
    j_list = []
print(sum(hoge))


Verdicts: Wrong Answer

Accepted