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):
from itertools import product

N = int(input())
c = product(range(2), repeat=N)
d = [[] for _ in range(N)]

for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        d[i].append((x, y))


ans = 0
for l in c:
    o = [None]*N
    is_conflict = False
    for i, j in enumerate(l):
        if j==0:continue
        for x, y in d[i]:
            if (o[x-1]!=None and o[x-1]!=y) or l[x-1]!=y:
                is_conflict = True
                break
            o[x-1] = y
        if is_conflict == True:
            break
    else:
        ans = mas(ans, sum(l))

print(ans)

from itertools import product

N = int(input())
c = product(range(2), repeat=N)
d = [[] for _ in range(N)]

for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        d[i].append((x, y))


ans = 0
for l in c:
    is_conflict = False
    for i, j in enumerate(l):
        if j==0:continue
        for x, y in d[i]:
            if l[x-1]!=y:
                is_conflict = True
                break
        if is_conflict == True:
            break
    else:
        ans = max(ans, sum(l))

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 itertools

N = int(input())
P = []
ans = 0

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

for YN in itertools.product([1,0], repeat = N):
  s = sum(YN)
  for j in range(len(YN)):
    if YN(j) == 1:
      for k in P[j]:
        if YN(k[0]) != k[1]:
          s = 0
          break
  ans = max(ans, s)

print(ans)

import itertools

N = int(input())
P = []
ans = 0

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

for YN in itertools.product([1,0], repeat = N):
  s = sum(YN)
  for j in range(len(YN)):
    if YN(j) == 1:
      for k in P[j]:
        YN(k[0]) != k[1]
        s = 0
        break
  ans = max(ans, s)

print(ans)

#C

N = int(input())
P = []
ans = 0

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


for i in range(2**N):
  Flag = True
  for j in range(N): 
    
    if (i >> j) & 1 == 1: 
      for YN in P[j]:
        if (i >> YN[0]) & 1 != YN[1]:
          Flag = False
          break

    if Flag:
      continue
    else:
      break

  if Flag:
    ans = max(ans, bin(i).count("1"))

print(ans)

Verdicts: 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())

a = []
x = [[] for _ in range(n)]

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

# print(x)
ans = 0
for i in range(1<<n):
    
    cnt = bin(i).count("1")
    if ans > cnt:
        continue
    flag = True
    for j in range(n):
        # if i==3:
        #     print(i,j,i>>j&1,cnt)
        if i>>j & 1:
            # True if 1
            # if i==3:
                # print(i,j)
            for t in x[j]:
                
                
                    # print(i,t[0]-1, i>>t[0]-1, t[1])
                if (i>>(t[0]-1) &1 ) != t[1]:
                    flag = False
                    break
    if flag == False:
        break
    if flag == True:
        # print(i) # 0 000
        ans = cnt

print(ans)


n = int(input())

a = []
x = [[] for _ in range(n)]

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

# print(x)
ans = 0
for i in range(1<<n):
    
    cnt = bin(i).count("1")
    if ans > cnt:
        continue
    flag = True
    for j in range(n):
        # if i==3:
        #     print(i,j,i>>j&1,cnt)
        if i>>j & 1:
            # True if 1
            # if i==3:
                # print(i,j)
            for t in x[j]:
                
                
                    # print(i,t[0]-1, i>>t[0]-1, t[1])
                if (i>>(t[0]-1) &1 ) != t[1]:
                    flag = False
                    break
        if flag == False:
            break
    if flag == True:
        # print(i) # 0 000
        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 = []
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a.append(int(input()))
    for j in range(a[i]):
        xx, yy = (int(i) for i in input().split())
        x[i].append(xx)
        y[i].append(yy)

testimony = [[2]*n for i in range(n)]

for i in range(n):
    for j in range(a[i]):
        if (y[i][j] == 1):
            testimony[i][x[i][j] - 1] = 1
        elif(y[i][j] == 0):
            testimony[i][x[i][j]-1] = 0

ans = 0
for i in range(2**n):
    bit_list = []
    for j in range(n):
        if ((i >> j) & 1):
            bit_list.append(1)
        else:
            bit_list.append(0)
    flag = 1
    for k in range(n):
        if(bit_list[k] == 1):
            for l in range(n):
                if(testimony[k][l] != 2):
                    if(testimony[k][l] != bit_list[l]):
                        flag = 0
                        break
    if(flag == 1):
        ans = max(sum(bit_list),ans)
    print(ans)


n = int(input())
a = []
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a.append(int(input()))
    for j in range(a[i]):
        xx, yy = (int(i) for i in input().split())
        x[i].append(xx)
        y[i].append(yy)

testimony = [[2]*n for i in range(n)]

for i in range(n):
    for j in range(a[i]):
        if (y[i][j] == 1):
            testimony[i][x[i][j] - 1] = 1
        elif(y[i][j] == 0):
            testimony[i][x[i][j]-1] = 0

ans = 0
for i in range(2**n):
    bit_list = []
    for j in range(n):
        if ((i >> j) & 1):
            bit_list.append(1)
        else:
            bit_list.append(0)
            print(bit_list)
    flag = 1
    for k in range(n):
        if(bit_list[k] == 1):
            for l in range(n):
                if(testimony[k][l] != 2):
                    if(testimony[k][l] != bit_list[l]):
                        flag = 0
                        break
    if(flag == 1):
        ans = max(sum(bit_list),ans)
    print(ans)

n = int(input())

jud = [[-1 for i in range(n)] for j in range(n)]
xy = []
ayasi = []
for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        jud[i][x-1] = y
Max = 0
for i in range(2**n):
    li = []
    flag = True
    cnt = 0
    for j in range(n):
        if ((i >> j) & 1):
            li.append(1)

        else:
            li.append(0)
    for k in range(n):
        if li[k] == 1:
         for l in range(n):
             if jud[k][l] != -1:
                 if jud[k][l] != li[l]:
                     flag = False
                     break

    if flag:
        Max = max(sum(li),Max)
print(Max)


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())
evidence = [[] for _ in range(N)]
for i in range(N):
  A = int(input())
  for _ in range(A):
    x,y = map(int,input().split())
    evidence[i].append((x-1,y))
result = 0
for j in range(1,2**N):
  consistent = True
  for k in range(N):
    if (j >> k) & 1 == 0:
      continue
    for x,y in evidence[k]:
      if (j >> x) & 1 != y:
        consistent = False
        break
    if not consistent:
      break
  if consistent:
    result = max(result, bin(i)[2:].count("1"))
print(result)

N = int(input())
evidence = [[] for _ in range(N)]
for i in range(N):
  A = int(input())
  for _ in range(A):
    x,y = map(int,input().split())
    evidence[i].append((x-1,y))
result = 0
for j in range(1,2**N):
  consistent = True
  for k in range(N):
    if (j >> k) & 1 == 0:
      continue
    for x,y in evidence[k]:
      if (j >> x) & 1 != y:
        consistent = False
        break
    if not consistent:
      break
  else:
    result = max(result, bin(i)[2:].count("1"))
print(result)

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

for i in range(N):
  A = int(input())
  for _ in range(A):
    x,y = map(int,input().split())
    evidence[i].append((x-1,y))
  
result = 0
for i in range(1,2**N):
  consistent = True
  for j in range(N):
    if (i>>j)&1 == 1:
      for x,y in evidence[j]:
        if (i>>x)&1 != y:
          consistent = False
          break
      if not consistent:
        break
  if consistent:
    result = max(result,bin(i)[2:].count("1"))
    
print(result)

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_sum = []
for i in range(n):
    a_tmp=int(input())
    a_list_tmp=[list(map(int,input().split())) for _ in range(a_tmp)]
    a_list_sum_tmp=[]
    a_list_sum_tmp.append(a_tmp)
    a_list_sum_tmp.append(a_list_tmp)
    a_list_sum.append(a_list_sum_tmp)
    
import itertools
L = [0, 1] 
bit_list = list(itertools.product([0, 1], repeat=n))
print(bit_list)


for i in range(len(bit_list)):
    count = 0
    
    for j in range(len(a_list_sum)):
        
        if bit_list[i][j] == 1:
            
            for k in range(len(a_list_sum[j][1])):
                
                person_id = a_list_sum[j][1][k][0] - 1
                
                is_honest = a_list_sum[j][1][k][1]
                
                if bit_list[i][person_id] != is_honest:
                    count += 1
    if count == 0:
        ans = sum(bit_list[i])
print(ans)

n=int(input())
a_list_sum = []
for i in range(n):
    a_tmp=int(input())
    a_list_tmp=[list(map(int,input().split())) for _ in range(a_tmp)]
    a_list_sum_tmp=[]
    a_list_sum_tmp.append(a_tmp)
    a_list_sum_tmp.append(a_list_tmp)
    a_list_sum.append(a_list_sum_tmp)
    
import itertools
L = [0, 1] 
bit_list = list(itertools.product([0, 1], repeat=n))


for i in range(len(bit_list)):
    count = 0
    
    for j in range(len(a_list_sum)):
        
        if bit_list[i][j] == 1:
            
            for k in range(len(a_list_sum[j][1])):
                
                person_id = a_list_sum[j][1][k][0] - 1
                
                is_honest = a_list_sum[j][1][k][1]
                
                if bit_list[i][person_id] != is_honest:
                    count += 1
    if count == 0:
        ans = sum(bit_list[i])
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_list = []
for i in range(n):
  a = int(input())
  list_ = []
  for _  in range(a):
    tuple_a = (map(int,input().split()))
    list_.append(tuple_a)
  a_list.append(list_)
print(a_list)

case_list = []
for i in range(2**n):
  case = [0 for i in range(n)]
  for j in range(n):
    if ((i >> j) & 1): 
      case[j] = 1
  case_list.append(case)
print(case_list)

n = int(input())
a_list = []
for i in range(n):
  a = int(input())
  list_ = []
  for _  in range(a):
    tuple_a = list(map(int,input().split()))
    list_.append(tuple_a)
  a_list.append(list_)
case_list = []
for i in range(2**n):
  case = [0 for i in range(n)]
  for j in range(n):
    if ((i >> j) & 1): 
      case[j] = 1
  case_list.append(case)

ok_case = []
for case in case_list:
  frug = True
  for i  in range(n):
    if case[i] == 1:
      cheker = a_list[i]
      for c in cheker :
        if c[1] != case[c[0] - 1]:
          frug = False
  if frug == True:
    ok_case.append(case)
result_list = []
for ok in ok_case:
  result_list.append(sum(ok))
print(max(result_list))
  


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
N = int(input())
lis_hl = list(itertools.product('01',repeat = N))
A = []
X = []
for i in range(N):
    A.append(int(input()))
    Y =[]
    for j in range(A[-1]):
        Y.append(list(map(int,input().split())))
    X.append(Y)
honesty = 0
for hl in lis_hl:
    print(" ")
    print(" ")
    print("仮定検証：hl:" + str(hl))
    print(" ")
    flag = 0
    for i in range(N):
        if flag == 0:
            is_hl = hl[i]
            if is_hl == '1':
                pluse= 0
            else:
                pluse = 1
                
            for xi in X[i]:
                if ((xi[1] + pluse)%2)!= int(hl[xi[0]-1]):
                    print('証言が仮定に反します')
                    print(' ')
                    flag = 1
                    break
    if flag == 0:
        #print("hl:" +str(hl))
        honesty = max(honesty,hl.count('1'))
print(honesty)


import itertools
N = int(input())
lis_hl = list(itertools.product('01',repeat = N))

A = []
X = []
for i in range(N):
    A.append(int(input()))
    Y =[]
    for j in range(A[-1]):
        Y.append(list(map(int,input().split())))
    X.append(Y)
honesty = 0
for hl in lis_hl:
    flag = 0
    for i in range(N):
        if flag == 0:
            is_hl = hl[i]
            if is_hl == '1':
                
                for xi in X[i]:
                    if xi[1] != int(hl[xi[0]-1]):
                        flag = 1
                        break
    if flag == 0:
        honesty = max(honesty,hl.count('1'))
print(honesty)


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):
def bin_(n):
    return str(bin(n))[2: ]

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

start = 2**N-1
max_ = 0
for i in range(2**N):
    num = i
    uso = 0
    
    keta=bin(num)[2:]
    
    while(len(keta)<N):
        keta = "0"+keta
    print(keta)
    for j in range(N):
        if(keta[j]=="1"):
            for p in range(len(syougen[j])):
                
                x,y = syougen[j][p]
                if(keta[x] != str(y)):
                    uso = 1
                    break
    
    suuji = str(bin(num))[2:]
    count  = 0
    for i in range(len(suuji)):
        if(suuji[i]=="1"):
            count += 1
            
    if(uso==0):
        max_ = max(max_,count)
        
print(max_)

def bin_(n):
    return str(bin(n))[2: ]

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

start = 2**N-1
max_ = 0
for i in range(2**N):
    num = i
    uso = 0
    
    keta=bin(num)[2:]
    
    while(len(keta)<N):
        keta = "0"+keta
    for j in range(N):
        if(keta[j]=="1"):
            for p in range(len(syougen[j])):
                
                x,y = syougen[j][p]
                if(keta[x] != str(y)):
                    uso = 1
                    break
    
    suuji = str(bin(num))[2:]
    count  = 0
    for i in range(len(suuji)):
        if(suuji[i]=="1"):
            count += 1
            
    if(uso==0):
        max_ = max(max_,count)
        
print(max_)

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_arr = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = int(map(int, input().split()))
        xy_arr[i].append(x, y)
        
max_res = 0
for i in range(2 ** n):           
    ok_flg = True
    bin_i = format(i, "015b")[::-1]
                                    
        for j in range(n):
            for x, y in xy_arr[j]:　
                if bin_i[j] == 1 and y != int(bin_i[x - 1]):
                    ok_flg = False
                    break
            else:
                continue
            break
        
    if ok_flg:
        res = sum(int(x) for x in bin_i)
        mas_res = (max_res, res)
        
print(max_res)

n = int(input())

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

max_res = 0
for i in range(2 ** n):           
    ok_flg = True
    bin_i = format(i, "015b")[::-1] 
                                    
    for j in range(n):
        for x, y in xy_arr[j]: 
            if bin_i[j] == "1" and y != int(bin_i[x - 1]):
                ok_flg = False
                break
        else:
            continue
        break
        
    if ok_flg:
        res = sum(int(x) for x in bin_i)
        max_res = max(max_res, res)
        
print(max_res)

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())
remarks = []
for i in range(N):
    w = []
    for j in range(int(input())):
        w.append(list(map(int, input().split())))
    remarks.append(w)

def power2(n):
    if n == 1:
        return [[1], [0]]
    res = []
    for l in power2(n-1):
        res.append([1] + l)
        res.append([0] + l)
    return res

ans = 0
patterns = power2(N)
for p in patterns:
    flag = True
    for i, remark in enumerate(remarks):
        if p[i] == 0: 
            continue
        for w in remark:
            if p[w[0]-1] != w[1]: 
                flag = False 
                break
            # print(w)
    if flag: 
        ans = max(ans, p.count(1))
        break

print(ans)

N = int(input())
remarks = []
for i in range(N):
    w = []
    for j in range(int(input())):
        w.append(list(map(int, input().split())))
    remarks.append(w)

def power2(n):
    if n == 1:
        return [[1], [0]]
    res = []
    for l in power2(n-1):
        res.append([1] + l)
        res.append([0] + l)
    return res

ans = 0
patterns = power2(N)
for p in patterns:
    flag = True
    for i, remark in enumerate(remarks):
        if p[i] == 0: 
            pass
        else:
            for w in remark:
                if p[w[0]-1] != w[1]: 
                    flag = False 
                    break
                # print(w)
    if flag: 
        ans = max(ans, p.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 = [[] for _ in range(N)]
for i in range(N):
    Ai = int(input())
    for _ in range(Ai):
        x, y = map(int, input().split())
        A[i].append((x - 1, y))


def countBit(x):
    if x == 0:
        return 0
    else:
        return countBit(x >> 1) + (x & 1)


res = 0
for bits in range(2 ** N):
    consistency = True
    for i, testimony in enumerate(A):
        if not (bits & (1 << i)):
            continue
        for t in testimony:
            if (bits & (1 << t[0])) ^ t[1]:
                consistency = False

    if consistency:
        res = max(res, countBit(bits))

print(res)


N = int(input())
T = [[] 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
        T[i].append((x, y))

ans = 0
for i in range(1 << N):
    isPossible = True
    bit = [0] * N
    for k in range(N):
        if (i >> k) & 1:
            bit[k] = 1
    for idx, b in enumerate(bit):
        if b == 1:
            for x, y in T[idx]:
                isPossible &= (bit[x] == y)
    if isPossible:
        ans = max(ans, bit.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):
i=input
n=int(i())
a=eval('eval("list(map(int,i().split())),"*int(i())),'*n)
#print(max(all([y==i>>x-1&1for j,t in enumerate(a)if i>>j&1for x,y in t]+[1])*bin(i).count('1')for i in range(2**n)))

I=int
i=input
n=I(i())
a=eval('[i().split()for _ in"_"*I(i())],'*n)
print(max(all(I(y)==i>>I(x)-1&1for j,t in enumerate(a)if i>>j&1for x,y in t)*bin(i).count('1')for i in range(1<<n)))

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())
LST = [0] * n
for i in range(n):
    p = int(input()) # people num
    lst = [[0]*2 for _ in range(p)]
    for j in range(p):
        a, b = list(map(int, input().split())) 
        lst[j][0] = a - 1 # 0-indexed
        lst[j][1] = b
    LST[i] = lst

def checker(bit):
    flag = True
    
    for i in range(n):
        
        if not ((bit >> 2-i) & 1):
            continue
        
        num = len(LST[i])  
        for j in range(num):
            people = LST[i][j][0] 
            TF = LST[i][j][1] が0(=正直者でない)なのか1(=正直者)
            if TF == 0 and ((bit >> 2-people) & 1) == 1:
                flag = False
            if TF == 1 and ((bit >> 2-people) & 1) != 1:
                flag = False
    return flag

max_num = 0
for k in range(n ** 2 - 1):
    cnt = 0
    if checker(k):
        
        for l in range(n):
            if((k >> l) & 1):
                cnt += 1
        if cnt > max_num:
            max_num = cnt

print(max_num)

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

ans = 0
for i in range(2 ** n):
    peoples = []
    flag = True
    for j in range(n):
        if (i >> j & 1):
            peoples.append(1)
        else:
            peoples.append(0)
    for k in range(n):
        if peoples[k] == 1:
            words = words_list[k]
            for word in words:
                if peoples[word[0]] != word[1]:
                    flag = False
                    break
    if flag:
        ans = max(ans, sum(peoples))

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())
testimony_list=[[[-1,-1] for _ in range(n-1)] for i in range(n)]
for i in range(n):
	a=int(input())
	for j in range(a):
		x,y=map(int,input().split())
		testimony_list[i][j][0]=x-1
		testimony_list[i][j][1]=y

ans=0
for i in range(2**n):
	kind_l=[0 for _ in range(n)]
	for j in range(n):
		if ((i>>j) & 1):
			kind_l[j]=1
	for k in range(n):
		if kind_l[k]==1:
			for m in range(a):
				subject=testimony_list[k][m][0]
				judge=testimony_list[k][m][1]
				if subject or judge==-1:continue
				if kind_l[subject]!=judge:
					kind_l=[0 for _ in range(n)]
					break
	ans=max(ans,sum(kind_l))
print(ans)


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

ans=0
for i in range(2**n):
	kind_l=[0 for _ in range(n)]
	for j in range(n):
		if ((i>>j) & 1):
			kind_l[j]=1
	print(kind_l)
	for k in range(n):
		if kind_l[k]==1:
			for m in range(a):
				subject=testimony_list[k][m][0]
				judge=testimony_list[k][m][1]
				if kind_l[subject]!=judge:
					kind_l=[0 for _ in range(n)]
					break
	ans=max(ans,sum(kind_l))
print(ans)

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

ans=0
for i in range(2**n):
	kind_l=[0 for _ in range(n)]
	for j in range(n):
		if ((i>>j) & 1):
			kind_l[j]=1
	for k in range(n):
		if kind_l[k]==1:
			for m in range(a):
				subject=testimony_list[k][m][0]
				judge=testimony_list[k][m][1]
				if subject or judge==-1:continue
				if kind_l[subject]!=judge:
					kind_l=[0 for _ in range(n)]
					break
	ans=max(ans,sum(kind_l))
print(ans)

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

ans=0
for i in range(2**n):
	kind_l=[0 for _ in range(n)]
	for j in range(n):
		if ((i>>j) & 1):
			kind_l[j]=1
	flag=True
	for k in range(n):
		if kind_l[k]:
			for m in range(n-1):
				subject=testimony_list[k][m][0]
				judge=testimony_list[k][m][1]
				if subject==-1:continue
				if kind_l[subject]!=judge:
					flag=False
	if flag:
		ans=max(ans,sum(kind_l))
print(ans)

Verdicts: Wrong Answer

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())
Nloop = N + 1
A = [[0] * Nloop for _ in range(Nloop)]

for i in range(1, Nloop):
    Acount = int(input())
    for _ in range(Acount):
        x, y = map(int,input().split())
        A[i, x] = 1 if y == 1 else -1

honest_loop = 2 ** N
is_honest = [False] * Nloop

ans = 0

for i in range(1, honest_loop):
    for l in range(1, Nloop):
        is_honest[l] = (i >> (l - 1) & 1 == 1)

    honest_check = True
    for l in range(1, Nloop):
        
        if is_honest[l]:
            
            for j in range(1, Nloop):
                if A[l, j] == 1:
                    if not is_honest[j]:
                        honest_check = False
                elif A[l, j] == -1:
                    if is_honest[j]:
                        honest_check = False
                if not honest_check:
                    break
        if not honest_check:
            break

    if honest_check:
        ans = max(sum(is_honest), ans)

print(ans)


N = int(input())
Nloop = N + 1
A = [[0] * Nloop for _ in range(Nloop)]

for i in range(1, Nloop):
    Acount = int(input())
    for _ in range(Acount):
        x, y = map(int, input().split())
        if y == 1:
            A[i][x] = 1
        else:
            A[i][x] = -1

honest_loop = 2 ** N
is_honest = [False] * Nloop

ans = 0

for i in range(1, honest_loop):
    for l in range(1, Nloop):
        is_honest[l] = (i >> (l - 1) & 1 == 1)

    honest_check = True
    for l in range(1, Nloop):
        
        if is_honest[l]:
            
            for j in range(1, Nloop):
                if A[l][j] == 1:
                    if not is_honest[j]:
                        honest_check = False
                elif A[l][j] == -1:
                    if is_honest[j]:
                        honest_check = False
                if not honest_check:
                    break
        if not honest_check:
            break

    if honest_check:
        ans = max(sum(is_honest), ans)

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 math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

#n = int(input())
#s = int(input())

#table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]



#s = input()

#list = list(s)
#a = [0 for _ in range(n+1)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]

n = int(input())
word_list = [[] for i in range(n)]

for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = [int(i) for i in input().split()]
        word_list[i].append((x-1,y))

ans = 0

for i in range(2**n):
    peoples = []
    flag = 1
    for j in range(n):
        if(i >> j & 1):
            peoples.append(1)
        else:
            peoples.append(0)
    
    for k in range(n):
        if peoples[k] == 1
            words = words_list[k]
            for word in words:
                if peoples[word[0]] != word[1]:
                    flag = 0
                    break
    
    if flag:
        ans = max(ans,sum(peoples))

print(ans)

import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

#n = int(input())
#s = int(input())

#table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]



#s = input()

#list = list(s)
#a = [0 for _ in range(n+1)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]

n = int(input())
word_list = [[] for i in range(n)]

for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = [int(i) for i in input().split()]
        word_list[i].append((x-1,y))

ans = 0

for i in range(2**n):
    peoples = []
    flag = 1
    for j in range(n):
        if(i >> j & 1):
            peoples.append(1)
        else:
            peoples.append(0)

    for k in range(n):
        if peoples[k] == 1:
            words = word_list[k]
            for word in words:
                if peoples[word[0]] != word[1]:
                    flag = 0
                    break

    if flag:
        ans = max(ans,sum(peoples))

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
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())

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



ans = 0
for i in range(2**(N)):
    if len(str(bin(i))[2:]) < N:
        K = ["0"] * (N-len(str(bin(i))[2:])) + list(str(bin(i))[2:])
    else:
        K = list(str(bin(i))[2:])
    for j in range(N):
        flag = 1
        if K[j] == "0":
            continue
        for l in range(N):

            
            if L[j][l] == -1:
                continue
            elif L[j][l] == 0:
                if K[l] == "1":
                    flag = 0
                    break
            elif L[j][l] == 1:
                if K[l] == "0":
                    flag = 0
                    break
        if flag == 0:
            break
        if j == N-1:
            ans = max(ans, K.count("1"))

print(ans)

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())

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



ans = 0
for i in range(2**(N)):
    if len(str(bin(i))[2:]) < N:
        K = ["0"] * (N-len(str(bin(i))[2:])) + list(str(bin(i))[2:])
    else:
        K = list(str(bin(i))[2:])
    for j in range(N):
        
        flag = 1
        if K[j] == "0":
            pass
        else:
            for l in range(N):

                if L[j][l] == -1:
                    continue
                elif L[j][l] == 0:
                    if K[l] == "1":
                        flag = 0
                        break
                elif L[j][l] == 1:
                    if K[l] == "0":
                        flag = 0
                        break
        if flag == 0:
            break
        if j == N-1:
            ans = max(ans, K.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())
xy = [[-1] * N for i in range(N)]
for i in range(N):
  A = int(input())
  for j in range(A):
    x, y = map(int, input().split())
    xy[i][x-1] = y
#print(xy)
for i in range(N):
  xy[i][i] = 1

count = 0
for i in range(N):
  count0 = 0
  count1 = 0
  for j in range(N):
    if xy[j][i] == 0:
      count0 += 1
    elif xy[j][i] == 1:
      count1 += 1
  if count1 * count0 != 0:
    count += 1
print(min(N - count, 1))

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

count = 0
for i in range(N):
  count0 = 0
  count1 = 0
  for j in range(N):
    if xy[j][i] == 0:
      count0 += 1
    elif xy[j][i] == 1:
      count1 += 1
  if count1 * count0 != 0:
    count += 1
print(min(N - count, 1))

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

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

    
c = 0
for i in range(1 << n):
    Flag = True
    for j in range(n):
      if ((i>>j) & 1) == 1:
        for k in a[j]:
          if i >> (k[0]-1) & 1 != k[1]:
            Flag = False
      
      if Flag == False:
        break
      if (j == n - 1) & (Flag == True):
        honest = sum([i>>j & 1 for j in range(n)])
        
        c = max(c,honest)
print(c)


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):
2
1
2 0
1
1 0

n = int(input())
A = [0]*n
for i in range(n):
  a = int(input())
  A[i] = [ tuple(map(int, input().split())) for _ in range(a) ]
ans = 0
for i in range(2**n):
  P = [2]*n
  f = False
  for j in range(n):
    if i >> j & 1:
      if P[j] != 2 and P[j] ^ 1:
          f = True
          break
      P[j] = 1
      for x, y in A[j]:
        if P[x-1] != 2 and P[x-1] ^ y:
          f = True
          break
        P[x-1] = y
  if f:
    continue
  c = bin(i).count("1")
  if P.count(1) <= c:
    ans = max(ans, c)
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())
all=[]
for i in range(N):
    A_N=int(input())
    grid=[]
    for j in range(A_N):
        a=list(map(int, input().split()))
        grid.append(a)
    all.append(grid)
print(all)
ans=[]
for i in range(N):
    b = format(i,'b').zfill(N)
    c_l = [int(p) for p in list(b)]

    for l in range(N):
        for m in range(len(all[l])):
            if c_l[all[l][m][0]-1]!=all[l][m][1]:
                break
        else:
            continue
        break
else:
    ans.append(c_l.count(1))
print(max(ans))


N=int(input())
all=[]
for i in range(N):
    A_N=int(input())
    grid=[]
    for j in range(A_N):
        a=list(map(int, input().split()))
        grid.append(a)
    all.append(grid)
ans=[]
for i in range(2**N):
    b = format(i,'b').zfill(N)
    c_l = [int(p) for p in list(b)]
    for l in range(N):
        for m in range(len(all[l])):
            if c_l[l]==1:
                if c_l[all[l][m][0]-1]!=all[l][m][1]:
                    c_l=[0]*N
    ans.append(c_l.count(1))
print(max(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())
xys = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        x,y = map(int,input().split())
        xys[i].append((x-1,y))

ans = 0
for b in range(1<<N):
    cnt = bin(b).count('1')
    if cnt <= ans: continue
    for i in range(N):
        if b&(1<<i):
        for x,y in xys[i]:
                if y==1 and b&(1<<x): continue
                if y==0 and b&(1<<x)==0: continue
                break
            else:
                continue
            break
    else:
        ans = cnt
print(ans)

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

ans = 0
for b in range(1<<N):
    for i in range(N):
        if b&(1<<i):
            for x,y in A[i]:
                if y:
                    if b&(1<<x)==0:
                        break
                else:
                    if b&(1<<x):
                        break
            else:
                continue
            break
    else:
        t = bin(b).count('1')
        ans = max(ans, t)
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):
from itertools import product

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



ans=0
for i in product([0,1],repeat=N):
    ok=True
    for j in datas:
        if i[j[0]]==1 and i[j[1]]!=j[2]:
            ok=False
            break
    if ok:
        ans+=1
print(ans)


from itertools import product

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



ans=0
for i in product([0,1],repeat=N):
    ok=True
    for j in datas:
        if i[j[0]]==1 and i[j[1]]!=j[2]:
            ok=False
            break
    if ok:
        ans=max(ans,sum(i))
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())

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

result = 0
for i in range(1, 2**N):
    consistent = True
    for j in range(N):
        if (i >> j) & 1 == 0:
            continue
        for x, y in evidences[j]:
            if (i >> x) & 1 != y:
                consistent = False
                break
        if not consistent:
            break
    if consistent:
        result = max(result, bin(i)[2:].count('1'))
print (result)
print(evidences)

N = int(input())

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

result = 0
for i in range(1, 2**N):
    consistent = True
    for j in range(N):
        if (i >> j) & 1 == 0:
            continue
        for x, y in evidences[j]:
            if (i >> x) & 1 != y:
                consistent = False
                break
        if not consistent:
            break
    if consistent:
        result = max(result, bin(i)[2:].count('1'))
print (result)

Verdicts: Wrong Answer

Accepted