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):
n = int(input())
test = []
count = 0
for i in range(0, n):
    num_test = int(input())
    for j in range(0, num_test):
        answer = input().split()
        a = answer[1]
        if a == '1':
            count += 1
        else:
            continue
print(count)
return 1

n = int(input())
test = []
count = 0
for i in range(0, n):
    num_test = int(input())
    for j in range(0, num_test):
        answer = input().split()
        a = answer[1]
        if a == '1':
            count += 1
        else:
            continue
            return 1
print(count)


n = int(input())
s_dict = {}
for i in range(n):
  add_dict = {}
  a = int(input())
  for j in range(a):
    b = list(map(int, input().split()))
    add_dict[b[0]-1] = b[1]
  s_dict[i] = add_dict
max_num = 0

def rec_get_list(i, tmp_num_list, tmp_honest, tmp_unkind):
  add_dict = s_dict[i]
  tmp_num_list.add(i)
  tmp_honest.add(i)
  for k, v in add_dict.items():
      if v:
        if k not in tmp_num_list:
        	tmp_num_list, tmp_honest, tmp_unkind = rec_get_list(k, tmp_num_list, tmp_honest, tmp_unkind)
        tmp_honest.add(k)
      else:
        tmp_unkind.add(k)
  return tmp_num_list, tmp_honest, tmp_unkind

def rec_check(i, tmp_num_list, tmp_honest, tmp_unkind):
  global max_num
  global n
  for j in range(i, n):
    if j in tmp_num_list:
      continue
    use_num_list = tmp_num_list.copy()
    use_honest = tmp_honest.copy()
    use_unkind = tmp_unkind.copy()
    use_num_list, use_honest, use_unkind = rec_get_list(j, use_num_list, use_honest, use_unkind)
    check_flg = len(use_honest & use_unkind)
    if check_flg:
      continue
    else:
      if len(use_num_list) > max_num:
        max_num = len(use_num_list)
    if j+1 < n:
      rec_check(j+1, use_num_list, use_honest, use_unkind)
  
rec_check(0, set(), set(), set()) 
    
print(max_num)

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())
L=[[list(map(int,input().split())) for _ in range(int(input()))] for _ in range(n)]
h=0
for i in range(1,2**n):
  H=[2 for _ in range(n)]
  f=0
  for j in range(n):
    if i>>j&1:
      if H[j]==0:
        f=1
        break
      H[j]=1
      for l in L[j]:
        if H[l[0]-1] == 2:
          H[l[0]-1]=l[1]
        elif H[l[0]-1] != l[1]:
          f=1
          break
      if f:break
    else:
      if H[j]==1:
        f=1
        break
      H[j]=0
  if not f:
    print(i,j,H)
    h=max(h,H.count(1))
print(h)


n=int(input())
L=[[list(map(int,input().split())) for _ in range(int(input()))] for _ in range(n)]
h=0
for i in range(2**(n-1)):
  H=[2 for _ in range(n)]
  f=0
  for j in range(n):
    print(i,j)
    if i>>j&1:
      for l in L[j]:
        H[j]=1
        if H[l[0]-1] == 2:
          H[l[0]-1]=l[1]
        elif H[l[0]-1] != l[1]:
          f=1
          break
      if f:break
    else:
      H[j]=0
  if not f:
    h=max(h,H.count(1))
print(h)


n=int(input())
L=[[list(map(int,input().split())) for _ in range(int(input()))] for _ in range(n)]
a=0
for i in range(1, 2**n):
  f=True
  for j in range(n):
    if (i>>j)&1==0:
      continue
    for x,y in L[j]:
      if (i>>(x-1))&1!=y:
        f=False
        break
    if not f:
      break
  if f:
    a=max(a, bin(i)[2:].count('1'))
print(a)        


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]*N for _ in range(N)]
ans=0
for i in range(N):
    A=int(input())
    for _ in range(A):
        x,y=map(int,input().split())
        g[i][x-1]=y
for s in range(2**N):
    flag=1
    for i in range(N):
        if (s>>i)==1:
            for j in range(N):
                if g[i][j]!=-1 and (s>>j)!=g[i][j]:
                    flag=0
    if flag==1:
        t=0
        x=s
        while x>0:
            t+=x%2
            x//=2
        ans=max(ans,t)
print(ans)

N=int(input())
g=[[-1]*N for _ in range(N)]
ans=0
for i in range(N):
    A=int(input())
    for _ in range(A):
        x,y=map(int,input().split())
        g[i][x-1]=y
for s in range(2**N):
    flag=1
    for i in range(N):
        if (s>>i&1):
            for j in range(N):
                if g[i][j]!=-1 and (s>>j&1)!=g[i][j]:
                    flag=0
                    break
        if flag==0:break
    if flag==1:
        t=0
        x=s
        while x>0:
            t+=x%2
            x//=2
        ans=max(ans,t)
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())
g = [[-1 for j in range(n)] for i 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 s in range(2**n):
    ok = True
    for i in range(n):
        k = 0
        if (s >> i & 1) == 1:
            k += 1
            for j in range(n):
                if g[i][j] == -1:
                    continue
                if (s >> j & 1) != g[i][j]:
                    ok = False
    if ok:
        ans = max(ans, k)

print(ans)

n = int(input())
g = [[-1 for j in range(n)] for i 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 s in range(2**n):
    ok = True
    k = 0
    for i in range(n):
        if (s >> i & 1) == 1:
            k += 1
            for j in range(n):
                if g[i][j] == -1:
                    continue
                if (s >> j & 1) != g[i][j]:
                    ok = False
    if ok:
        ans = max(ans, k)

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


from itertools import combinations
import numpy as np
N = int(input())

A = []
x = []
y = []
for i in range(N):
	
	Ai = int(input())
	A.append(Ai)
	x.append([])
	y.append([])
	for j in range(Ai):
		xyij = input().split(" ")
		x[i].append(int(xyij[0]) - 1)
		y[i].append(int(xyij[1]))

def judge_contradiction(honest_index, N, A, x, y):
	
	all_people_judge = np.zeros(N, dtype="int")
	all_people_judge[:] = -1
	for i in honest_index:
		all_people_judge[i] = 1
	for ind in honest_index:
		
		
		for i in range(A[ind]):
			
			target, testimony = x[ind][i], y[ind][i]
			if all_people_judge[target] == -1:
				all_people_judge[target] = testimony
				continue
			elif all_people_judge[target] == testimony:
				continue
			else:
				
				return False
	
	for i in range(N):
		if all_people_judge[i] == 1:
			if np.any(np.array(honest_index) == i):
				continue
			else:
				return False
	return True

def doit(N, A, x, y):
	for numHonest in range(N, 0-1, -1):
		
		for honest_index in combinations(np.arange(N), numHonest):
			
			
			# import pdb; pdb.set_trace()
			if judge_contradiction(honest_index, N, A, x, y) == True:
				return numHonest
			else:
				continue
	return "hey"

doit(N, A, x, y)





from itertools import combinations
import numpy as np
N = int(input())

A = []
x = []
y = []
for i in range(N):
	
	Ai = int(input())
	A.append(Ai)
	x.append([])
	y.append([])
	for j in range(Ai):
		xyij = input().split(" ")
		x[i].append(int(xyij[0]) - 1)
		y[i].append(int(xyij[1]))

def judge_contradiction(honest_index, N, A, x, y):
	
	all_people_judge = np.zeros(N, dtype="int")
	all_people_judge[:] = -1
	for i in honest_index:
		all_people_judge[i] = 1
	for ind in honest_index:
		
		
		for i in range(A[ind]):
			
			target, testimony = x[ind][i], y[ind][i]
			if all_people_judge[target] == -1:
				all_people_judge[target] = testimony
				continue
			elif all_people_judge[target] == testimony:
				continue
			else:
				
				return False
	
	for i in range(N):
		if all_people_judge[i] == 1:
			if np.any(np.array(honest_index) == i):
				continue
			else:
				return False
	return True

def doit(N, A, x, y):
	for numHonest in range(N, 0-1, -1):
		
		for honest_index in combinations(np.arange(N), numHonest):
			
			
			# import pdb; pdb.set_trace()
			if judge_contradiction(honest_index, N, A, x, y) == True:
				return numHonest
			else:
				continue
	return "hey"

print(doit(N, A, x, y))



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())
data = []
for x in range(n):
    for y in range(int(input())):
        k, l = map(int, input().split())
        data.append((x, k - 1, l))
ans = 0
for i in itertools.product([1,0], repeat=n):
    s = sum(list(i))
    for g in data:
        if i[g[0]] == 1 and i[g[1]] != g[2]:
            print("{}".format(g))
            s = 0
            break
    ans = max(ans, s)
print(ans)

import itertools
n = int(input())
data = []
for x in range(n):
    for y in range(int(input())):
        k, l = map(int, input().split())
        data.append((x, k - 1, l))
ans = 0
for i in itertools.product([1,0], repeat=n):
    s = True
    for g in data:
        if i[g[0]] == 1 and i[g[1]] != g[2]:
            s = False
            break
    if s:
        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())
li = []
for i in range(n):
  a = int(input())
  li_2 = [list(map(int, input().split())) for _ in range(a)]
  li.append(li_2)
def judge(bit): 
  b =1
  
  for i in range(n):
    if bit & (1<<i) == False:
      continue
    else:
      for xy in li[i]:
        x = xy[0]
        y = xy[1]
        if y == 1 and bit & (1<<x)==False:
          b = 0
        if y == 0 and bit & (1<<x):
          b = 0
      if b == 1:
        return True
      else:
        return False
res = 0
for bit in range(n):
  if judge(bit):
    count = 0
    for i in range(n):
      if bit & (1<<i):
        count += 1
    res = max(res,count)
print(res)

def judge(bit):
	
	b = 1
	for i in range(n):
		
		if (bit>>i) & 1 == 0:
			continue
		for k in range(len(li[i])):
			x = li[i][k][0] 
			y = li[i][k][1]
			if (bit>>x) & 1 == 1 and y == 0:
				b = 0
			if (bit>>x) & 1 == 0 and y == 1:
				b = 0
	return b
		
n = int(input())
li = []
for i in range(n):
	a = int(input())
	li_xy = [list(map(int, input().split())) for _ in range(a)]
	li.append(li_xy)
ans = 0
for bit in range(n):
	if judge(bit) == 1:
		count = 0
		for i in range(n):
			if (bit >>i) & 1 == 1:
				count += 1
		ans = max(ans,count)
print(ans)

def judge(bit): 
  ok = True
  for i in range(n):
    if ((bit >> i) & 1) == 1: 
      for j in range(len(li[i])):
        x = li[i][j][0]
        y = li[i][j][1]
        if y == 1 and ((bit >> (x-1)) & 1) == 0:
          ok = False
        if y == 0 and ((bit >> (x-1)) & 1) == 1:
          ok = False
  return ok
n = int(input())
li = []
ans = 0
for i in range(n):
  a = int(input())
  xy =  [list(map(int, input().split())) for _ in range(a)]
  li.append(xy)
for bit in range(1<<n):
  if judge(bit):
    cnt = 0
    for i in range(n):
      if ((bit >> i) & 1) == True:
        cnt += 1
    ans = max(ans,cnt)
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):
from collections import deque
n = int(input())
lists = deque()
A = deque() 
ans = 0
for _ in range(n):
    a = int(input())
    A.append(a)
    tmp = [list(map(int, input().split())) for _ in range(a)]
    lists.append(tmp)

for bit in range(1<<n):
    flag = True
    is_honest = [(bit>>i)&1 for i in range(n)]
    print(is_honest)
    for i in range(n):
        if is_honest[i] == 0:
            continue
        for k in range(A[i]):
            x,y = lists[i][k]
            x -= 1
            
            if is_honest[x] != y:
                flag = False
    if flag:
        ans = max(ans, sum(is_honest))
print(ans)
    


from collections import deque
n = int(input())
lists = deque()
A = deque() 
ans = 0
for _ in range(n):
    a = int(input())
    A.append(a)
    tmp = [list(map(int, input().split())) for _ in range(a)]
    lists.append(tmp)

for bit in range(1<<n):
    flag = True
    is_honest = [(bit>>i)&1 for i in range(n)]
    for i in range(n):
        if is_honest[i] == 0:
            continue
        for k in range(A[i]):
            x,y = lists[i][k]
            x -= 1
            
            if is_honest[x] != y:
                flag = False
    if flag:
        ans = max(ans, sum(is_honest))
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())
li = list()
for i in range(N):
    Ai = int(input())
    Alist = list()
    for j in range(Ai):
        x,y = map(int,input().split())
        Alist.append([x-1,y])
    li.append(Alist)
num =(2**(N))
while True:
    ok = True
    num -=1
    numlist = format(num, 'b')
    print(list(numlist))
    zero = str()
    if N != len(numlist):
        for i in range(N-len(numlist)):
            zero += "0"

        numlist = zero + numlist
    print(numlist)
    for i in range(len(numlist)):
        if numlist[i] == "1":
            for j in range(len(li[i])):
                if int(numlist[li[i][j][0]]) != li[i][j][1]:
                    ok = False
                    break
        if ok == False:
            break
    if ok == True:
        print(numlist.count("1"))
        break
    if num == 0:
        print(0)
        break


N = int(input())
li = list()
for i in range(N):
    Ai = int(input())
    Alist = list()
    for j in range(Ai):
        x,y = map(int,input().split())
        Alist.append([x-1,y])
    li.append(Alist)
num =(2**(N))
while True:
    ok = True
    num -=1
    numlist = format(num, 'b')
    #print(list(numlist))
    zero = str()
    if N != len(numlist):
        for i in range(N-len(numlist)):
            zero += "0"

        numlist = zero + numlist
    #print(numlist)
    for i in range(len(numlist)):
        if numlist[i] == "1":
            for j in range(len(li[i])):
                if int(numlist[li[i][j][0]]) != li[i][j][1]:
                    ok = False
                    break
        if ok == False:
            break
    if ok == True:
        print(numlist.count("1"))
        break
    if num == 0:
        print(0)
        break


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())
word=[]

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

ans=0

for i in range(2**n):
    m=bin(i)[2:].rjust(n, "0")
    cnt=0
    flag=0

    for j in range(n):
        if m[j]=="0":
            pass
        elif m[j]=="1":
            for k in range(len(word[j])):
                target=word[j][k][0]-1
                if m[target]=="1" and word[j][k][1]==1:
                    cnt+=1
                elif m[target]!=str(word[j][k][1]):
                    flag=1
    
    if flag==0 and cnt>ans:
        ans=cnt


n=int(input())
ans=0

for i in range(2**n):
    m=bin(i)[2:].rjust(n, "0")
    cnt=0
    flag=0
    for j in range(n):
        A=int(input())
        if m[j]=="0":
            for k in range(A):
                b, c =input().split()

        elif m[j]=="1":
            for k in range(A):
                b ,c =input().split()
                b=int(b)
                if m[b-1]!=int(c):
                    flag=1
                elif m[b-1]==int(c) and c=="1":
                    cnt+=1
    
    if flag==0 and cnt>ans:
        ans=cnt

print(ans)

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

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

ans=0

for i in range(2**n):
    flag=0
    cnt=0
    for j in range(n):
        if((i>>j)&1)==1 and flag==0:
            for k in range(len(word[j])):
                if ((i>>word[j][k][0]-1)&1) != word[j][k][1]:
                    flag=1
                    break
    
    if flag==0:
        cnt=bin(i).count("1")
        ans=max(ans, cnt)

print(ans)

Verdicts: Wrong Answer

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())
alist = []
xy = [[] for i in range(n)]
ans = 0
for i in range(n):
    xy[i] =  []
for i in range(n):
    alist.append(int(input()))
    for j in range(alist[i]):
        a,b=input().split()
        xy[i].append([int(a), int(b)])
g = [[] for i in range(2**n-1)]
for i in range(1,2**n):
    for j in range(n):
        if list(format(i,'0b').zfill(n))[j] == '1':
            g[i-1].append(xy[j])
def lie(xy,p):
    z = list(format(p,'0b').zfill(n)) 
    for i in range(len(xy)):
        for j in range(len(xy[i])):
            print(str(xy[i][j][1]),z[xy[i][j][1]-1])
            if str(xy[i][j][1]) == z[xy[i][j][0]-1]:
                continue
            else:
                return 'No'
                break
    return 'Yes'
for k in range(2**n-1):
    if lie(g[k],k+1) == 'Yes':
        print(k+1)
        ans = max(ans,list(str(format(k+1,'0b'))).count('1'))
print(ans)

n = int(input())
alist = []
xy = [[] for i in range(n)]
ans = 0
for i in range(n):
    xy[i] =  []
for i in range(n):
    alist.append(int(input()))
    for j in range(alist[i]):
        a,b=input().split()
        xy[i].append([int(a), int(b)])
g = [[] for i in range(2**n-1)]
for i in range(1,2**n):
    for j in range(n):
        if list(format(i,'0b').zfill(n))[j] == '1':
            g[i-1].append(xy[j])
def lie(xy,p):
    z = list(format(p,'0b').zfill(n)) 
    for i in range(len(xy)):
        for j in range(len(xy[i])):
            if str(xy[i][j][1]) == z[xy[i][j][0]-1]:
                continue
            else:
                return 'No'
                break
    return 'Yes'
for k in range(2**n-1):
    if lie(g[k],k+1) == 'Yes':
        ans = max(ans,list(str(format(k+1,'0b'))).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):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())
M = []
for i in range(N):
    A = int(input())
    XY = []
    for j in range(A):
        X, Y = map(int, input().split())
        XY.append([X, Y])
    M.append(XY)


def check(n, l):
    
    if n == 0:
        l += [1] * (N - len(l))
        return judge(l)
    
    if n > N - len(l):
        return False

    
    if check(n - 1, l + [0]):
        return True
    
    if check(n, l + [1]):
        return True

    return False


def judge(l):
    for i in range(len(M)):
        ii = M[i]
        for j in range(len(ii)):
            jj = ii[j]
            if l[jj[0] - 1] != jj[1]:
                return False
    return True

for i in range(N + 1):
    if check(i, []):
        print(i)
        break;

print(0)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())
M = []
for i in range(N):
    A = int(input())
    XY = []
    for j in range(A):
        X, Y = map(int, input().split())
        XY.append([X, Y])
    M.append(XY)


def check(n, l):
    
    if n == 0:
        l += [1] * (N - len(l))
        return judge(l)
    
    if n == N - len(l):
        l += [0] * (N - len(l))
        return judge(l)

    
    if check(n, l + [1]):
        return True
    
    if check(n - 1, l + [0]):
        return True

    return False


def judge(l):
    for i in range(len(M)):
        
        if l[i] == 0:
            continue
        
        ii = M[i]
        for j in range(len(ii)):
            jj = ii[j]
            if l[jj[0] - 1] != jj[1]:
                return False
    return True


for i in range(N + 1):
    if check(i, []):
        print(N - i)
        break;


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 numpy as np

def acinput():
    return list(map(int, input().split(" ")))


def chk(x,d):
    for l,xx in enumerate(x):
        if xx==1:
            for dd in d[l]:
                #print(dd)
                #print(x)
                if dd[1]==1 and x[dd[0]-1]==0:
                    return False
                if dd[1]==0 and x[dd[0]-1]==1:
                    return False
    return True


N=int(input())

d=[]
for k in range(N):
    aa=int(input())
    print(aa)
    d.append([])
    for j in range(aa):
        d[-1].append(acinput())


#print(d)
res=0

for x in range(2**N):
    x=list(map(int,list(bin(x)[2:].zfill(N))))
    #print(x)
    if chk(x,d):
        res=sum(x)
    
print(res)


import numpy as np

def acinput():
    return list(map(int, input().split(" ")))


def chk(x,d):
    for l,xx in enumerate(x):
        if xx==1:
            for dd in d[l]:
                #print(dd)
                #print(x)
                if dd[1]==1 and x[dd[0]-1]==0:
                    return False
                if dd[1]==0 and x[dd[0]-1]==1:
                    return False
    return True


N=int(input())

d=[]
for k in range(N):
    aa=int(input())
    #print(aa)
    d.append([])
    for j in range(aa):
        d[-1].append(acinput())


#print(d)
res=0

for x in range(2**N):
    x=list(map(int,list(bin(x)[2:].zfill(N))))
    #print(x)
    if chk(x,d):
        res=sum(x)
    
print(res)


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 is_consistent(bit, testimony):
    all_consistence = True
    for shift in range(n):
        mask, tf = testimony[shift]
        if (bit & mask) != (tf & mask):
            all_consistence = False
    if all_consistence:
        return True
    else:
        return False

n = int(input())
testimony = [0] * n
for i in range(n):
    mask, tf = 0, 0
    for j in range(int(input())):
        x, y = map(int, input().split())
        mask += 1 << (x - 1)
        tf += y << (x - 1)
    testimony[i] = (mask, tf)

max_honest = 0
for bit in range(1 << n):
    if is_consistent(bit, testimony) and (max_honest < bin(bit).count('1')):
        max_honest = bin(bit).count('1')
print(max_honest)

def is_consistent(bit, t_tuple):
    mask, tf = t_tuple
    if (bit & mask) == (tf & mask):
        return True
    else:
        return False

n = int(input())
testimony = [0] * n
for i in range(n):
    mask, tf = 0, 0
    for j in range(int(input())):
        x, y = map(int, input().split())
        mask += 1 << (x - 1)
        tf += y << (x - 1)
    testimony[i] = (mask, tf)

max_honest = 0
for bit in range(1 << n):
    honest = 0
    for shift in range(n):
        if ((bit >> shift) & 1):
            if is_consistent(bit, testimony[shift]):
                honest += 1
            else:
                break
    if max_honest < honest:
        max_honest = honest
        print(bin(bit))
print(max_honest)

def is_consistent(bit, testimony):
    all_consistence = True
    for shift in range(n):
        if (bit >> shift) & 1:
            mask, tf = testimony[shift]
            if (bit & mask) != (tf & mask):
                all_consistence = False
    return all_consistence

n = int(input())
testimony = [0] * n
for i in range(n):
    mask, tf = 0, 0
    for j in range(int(input())):
        x, y = map(int, input().split())
        mask += 1 << (x - 1)
        tf += y << (x - 1)
    testimony[i] = (mask, tf)

max_honest = 0
for bit in range(1 << n):
    if is_consistent(bit, testimony) and (max_honest < bin(bit).count('1')):
        max_honest = bin(bit).count('1')
print(max_honest)

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):
print(15)

import itertools

n=int(input())

lis=[]
for i in range(n):
    ai=int(input())
    lisi=[]
    for _ in range(ai):
        xi,yi=map(int,input().split())
        lisi.append([xi-1,yi])
    lis.append(lisi)

print(lis)

ans=-1
for binary in itertools.product([1,0],repeat=n):
    check=0
    for i in range(n):
        if binary[i]==1:
            for j in range(len(lis[i])):
                if binary[lis[i][j][0]]!=lis[i][j][1]:
                    check+=1
    if check==0:
        ans=max(ans,sum(binary))

print(ans)

print(0)

import itertools

n=int(input())

lis=[]
for i in range(n):
    ai=int(input())
    lisi=[]
    for _ in range(ai):
        xi,yi=map(int,input().split())
        lisi.append([xi-1,yi])
    lis.append(lisi)

ans=0
for binary in itertools.product([1,0],repeat=n):
    check=0
    for i in range(n):
        if binary[i]==1:
            for j in range(len(lis[i])):
                if binary[lis[i][j][0]]!=lis[i][j][1]:
                    check+=1
        else:
            for j in range(len(lis[i])):
                if binary[lis[i][j][0]]==lis[i][j][1]:
                    check+=1
    if check==0:
        print(binary)
        ans=max(ans,sum(binary))

print(ans)

import itertools

n=int(input())

lis=[]
for i in range(n):
    ai=int(input())
    lisi=[]
    for _ in range(ai):
        xi,yi=map(int,input().split())
        lisi.append([xi-1,yi])
    lis.append(lisi)


ans=-1
for binary in itertools.product([1,0],repeat=n):
    check=0
    for i in range(n):
        if binary[i]==1:
            for j in range(len(lis[i])):
                if binary[lis[i][j][0]]!=lis[i][j][1]:
                    check+=1
    if check==0:
        ans=max(ans,sum(binary))

print(ans)
    

Verdicts: Wrong Answer

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

ans = 0

for i in range(2**N):
    bin_i = format(i, '4b')
    flag = True
    for n, c in enumerate(bin_i):
        if c == '1':
            for j in range(N):
                for k in range(A[j]):
                    if xy[j][k][0] == n:
                        if xy[j][k][1] == 0:
                            flag = False
                            break
                if not flag:V
                    break
            if not flag:
                break
    if flag is True:
        honest = bin_i.count('1')
        if honest > ans:
            ans = honest

print(ans)


N = int(input())
xy = []
A = []
for i in range(N):
    Ai = int(input())
    xyi = []
    for j in range(Ai):
        xyi.append(list(map(int, input().split())))
    A.append(Ai)
    xy.append(xyi)

ans = 0

for i in range(2**N):
    bin_i = format(i, '0' + str(N) + 'b')
    flag = True
    for j in range(N):
        for k in range(A[j]):
            if bin_i[j] == '1' and xy[j][k][1] != int(bin_i[xy[j][k][0]-1]):
                flag = False
                break
        if not flag:
            break

    if flag is True:
        honest = bin_i.count('1')
        if honest > ans:
            ans = honest

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 = [0]*n
b=[0]*n
for j in range(n):
  a1 = int(input())
  for i in range(a1):
    c,d = map(int,input().split())
    if d == 0:
      b[c-1] = 1
    else:
      a[c-1] = 1
count = 0
for i in range(n):
  if a[i] != b[i]:
    count += 1
print(count)
    

n = int(input())

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

def count(x,check):
    l = []
    for j in range(n):
        if ((x >> j) & 1):
            l.append(1)
        else:
            l.append(0)
    chec = True
    for i in range(n):
        if l[i] == 1:
            for k in check[i]:
                if k[1] == 1 and l[k[0]-1] == 0:
                    chec = False
                elif k[1] == 0 and l[k[0]-1] == 1:
                    chec = False
    if chec:
        return l.count(1)
    else:
        return 0

ans = 0
for i in range(2**n):
    ans = max(ans,count(i,check))
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,c,e,f=[],[],0,0
for i in range(n):
    a.append(int(input()))
    b=[]
    for i in range(a[-1]):
        b.append(list(map(int,input().split())))
    c.append(b)
for i in range(2**n):
    d=bin(i)[2:-1]+bin(i)[-1]
    d='0'*(n-len(d))+d
    for j in range(n):
        if d[j]==1:
            e+=1
    for j in range(n):
        if d[j]==0:
            continue
        for k in range(a[j]):
            if d[c[j][k][0]]!=c[j][k][1]:
                g=True
                continue
    if g:
        continue
    f=max(e,f)
print(f)

n=int(input())
s=[]
ans=0
for i in range(n):
    a=int(input())
    s.append([list(map(int,input().split())) for _ in range(a)])
for i in range(2**n):
    bit=bin(i)[2:].zfill(n)
    flag=1
    for j in range(n):
        if bit[j]=='0':
            continue
        for sh in s[j]:
            if int(bit[sh[0]-1])!=sh[1]:
                flag=0
    if flag:
        ans=max(ans,bit.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 copy
n=int(input())
xy=[[] for i in range(n)]

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

print(xy)
for i in range(2**n):
    bit=[0]*n
    for j in range(n):
        if ((i >> j) & 1):
            bit[j]=1
    print(bit)
    for j in range(n):
        for z in range(len(xy[j])):
            if bit[j]==0:
                if xy[j][z][1]==1:
                    xy[j][z][1]=0
                else:
                    xy[j][z][1]=1
    
    print(xy)
    print(xyc)
    xy=copy.deepcopy(xyc)

print(xy)



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

for i in range(n):
    a=int(input())
    for j in range(a):
        xy[i].append(list(map(int, input().split())))
#print(xy)
bit=[]
ans=0
def bit_search(bit):
    global ans
    if len(bit)==n:
        for i in range(n):
            jugh=bit[i]
            if jugh==1:
                for j in xy[i]:
                    x,y=j
                    if bit[x-1]==0:
                        if y==1:
                            return 
                    else:
                        if y==0:
                            return 
        ans=max(ans,sum(bit))
    else:
       
        bit_search(bit+[0])
        bit_search(bit+[1])
bit_search(bit)
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())
check_lst = [[None 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())
        check_lst[i][x-1] = y



checker = [None for _ in range(N)]
for i in range(N):
    if checker[i] != None:
        continue
    for j in range(N):

        if check_lst[i][j] != 0 and check_lst[i][j] != 1:
            pass

        else:
            if check_lst[i][j] == 1: 
                if check_lst[i][j] == check_lst[j][i]:
                    pass
                else:
                    checker[i] = False
                    break

            else:
                if checker[j] == True:
                    checker[i] = False
                    break

                else:
                    pass

        
        if j == N-1:
            checker[i] = True
            for j in range(N):
                if j == i:
                    pass
                checker[j] = check_lst[i][j]


        
ans = 0
for e in checker:
    ans += int(True==e)

print(ans)




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

    
def check(i,n):
    flg = True
    for j in range(n):
        if i>>j & 1:
            for x,y in table[j]:
                if (i>>x)&1 != y:
                    flg = False
                    # print(flg)
                    return flg
    # print(flg)
    return flg

# print(table)
ans = 0
for i in reversed(range(2**n)):   
    if check(i,n):
        ans = bin(i).count("1")
        break

print(ans)


n = int(input())
table = []
for _ in range(n):
    a = int(input())
    tmp = []
    for _ in range(a):
        person,assessment = map(int,input().split())
        person -=  1
        tmp.append([person,assessment])
    table.append(tmp)

def check(i,n):
    
    for j in range(n):
        if i >> j & 1:
            for person,assessment in table[j]:
                if (i >> person)&1 !=  assessment:
                    return False
    
    return True

ans = 0
for i in range(2**n):
    if check(i,n):
        ans = max(ans,bin(i).count("1"))

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

ret = 0
for i in range( 2 ** n - 1, 0, -1 ):
  o = [int(i) for i in str( "{:b}".format(i).zfill(n) )]
  is_right = True
  for j in range( n ):
    for m in range( n ):
      if o[j] == 1:
        is_rzight &= ( l[j][m] in [-1, o[m]] )
    if not is_right:
      break
        
  if is_right:
    ret = sum(o)
    break
          
print( ret )


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

ret = 0
for i in range( 2 ** n - 1, 0, -1 ):
  o = [int(i) for i in str( "{:b}".format(i).zfill(n) )]
  is_right = True
  for j in range( n ):
    for m in range( n ):
      if o[j] == 1:
        is_right &= ( l[j][m] in [-1, o[m]] )
    if not is_right:
      break
        
  if is_right:
    ret = sum(o)
    break
          
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):
def main():
    N = int(input())
    d = defaultdict(list)
    for i in range(N):
        n = int(input())
        for _ in range(n):
            d[i].append(list(map(int, input().split())))
    max_trust_num = 0

    # check all possible combinations of Honest or Unkind.
    for i in range(2**N):
        trust = True

        # assign Honest or Unnkind to each person.
        # if person i is Honest, trust_combs[i] = 1
        # else, trust_combs[i] = 0
        trust_combs = []
        for j in range(N):
            if (i >> j) & 1:
                trust_combs.append(1)
            else:
                trust_combs.append(0)
  
        # check if the combination of Honest or
        # Unkind contradicts the given statements.
        for k in range(len(trust_combs)):
            if trust_combs[k] == 1:
                for l in d[k]:
                    if not l[1] == trust_combs[l[0]-1]:
                        trust = False
        if trust:
            max_trust_num = max(max_trust_num, sum(trust_combs))

    print(max_trust_num)


if __name__ == "__main__":
    main()


from collections import defaultdict


def main():
    N = int(input())
    d = defaultdict(list)
    for i in range(N):
        n = int(input())
        for _ in range(n):
            d[i].append(list(map(int, input().split())))
    max_trust_num = 0

    # check all possible combinations of Honest or Unkind.
    for i in range(2**N):
        trust = True

        # assign Honest or Unnkind to each person.
        # if person i is Honest, trust_combs[i] = 1
        # else, trust_combs[i] = 0
        trust_combs = []
        for j in range(N):
            if (i >> j) & 1:
                trust_combs.append(1)
            else:
                trust_combs.append(0)
  
        # check if the combination of Honest or
        # Unkind contradicts the given statements.
        for k in range(len(trust_combs)):
            if trust_combs[k] == 1:
                for l in d[k]:
                    if not l[1] == trust_combs[l[0]-1]:
                        trust = False
        if trust:
            max_trust_num = max(max_trust_num, sum(trust_combs))

    print(max_trust_num)


if __name__ == "__main__":
    main()


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 = []
X = []
Y = []
for _ in range(N):
    a = int(input())
    A.append(a)
    box_x = []
    box_y = []
    for _ in range(a):
        x,y = map(int,input().split())
        box_x.append(x)
        box_y.append(y)
    X.append(box_x)
    Y.append(box_y)
print(A,X,Y)

person = [2]*N

maxim = 0
for i in range(1<<N):
    c_person = person.copy()
    honest = 0
    for j in range(N):
        mask = 1<<j
        if mask&i != 0:
            c_person[j] = 1
        else:
            c_person[j] = 0
    
    for k,l in enumerate(c_person):
        
        if l == 1:
            
            for m,n in zip(X[k],Y[k]):
                
                if c_person[m-1] != n:
                    honest = 0
                    break
            else:
                honest = sum(c_person)
                continue
            break
    maxim = max(maxim,honest)
                
print(maxim)     


N = int(input())
A = []
X = []
Y = []
for _ in range(N):
    a = int(input())
    A.append(a)
    box_x = []
    box_y = []
    for _ in range(a):
        x,y = map(int,input().split())
        box_x.append(x)
        box_y.append(y)
    X.append(box_x)
    Y.append(box_y)

person = [2]*N

maxim = 0
for i in range(1<<N):
    c_person = person.copy()
    honest = 0
    for j in range(N):
        mask = 1<<j
        if mask&i != 0:
            c_person[j] = 1
        else:
            c_person[j] = 0
    
    for k,l in enumerate(c_person):
        
        if l == 1:
            
            for m,n in zip(X[k],Y[k]):
                
                if c_person[m-1] != n:
                    honest = 0
                    break
            else:
                honest = sum(c_person)
                continue
            break
    maxim = max(maxim,honest)
                
print(maxim)     

Verdicts: Wrong Answer

Accepted