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())
g = [[-1 for j in range(n)] for i in range(n)]

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

ans = 0
for s in range(2**n):
    ok = True
    for i in range(n):
        if (s>>i&1) == 1:
            for j in range(n):
                if g[i][j] == -1:continue
                if (s>>j&1) != g[i][j]:ok = False
    if ok:
        t = str(bin(x)).count("1")
        ans = max(ans,t)
print(ans)

n = int(input())
g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
    for _ in range(int(input())):
        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):
        if (s>>i&1) == 1:
            for j in range(n):
                if g[i][j] == -1:continue
                if (s>>j&1) != g[i][j]:ok = False
    if ok:
        t = str(bin(x)).count("1")
        ans = max(ans,t)
print(ans)

n = int(input())
g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
    for _ in range(int(input())):
        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):
        if (s>>i&1) == 1:
            for j in range(n):
                if g[i][j] == -1:continue
                if (s>>j&1) != g[i][j]:ok = False
    if ok:
        t = str(bin(s)).count("1")
        ans = max(ans,t)
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())

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):
		if (s>>i&1) == 1:
			for j in range(n):
				if g[i][j] != -1 && (s>>j&1) != g[i][j]:
                  ok = False
	if ok:
		ans = max(ans, bin(s).count("1"))

print(ans)


n = int(input())
g = [[-1] * n] * 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):
		if (s>>i&1) == 1:
			for j in range(n):
				if g[i][j] != -1 and (s>>j&1) != g[i][j]:
                    ok = False
	if ok:
		ans = max(ans, bin(s).count("1"))

print(ans)


n = int(input())

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):
		if (s>>i&1) == 1:
			for j in range(n):
				if g[i][j] != -1 and (s>>j&1) != g[i][j]:
                    ok = False
	if ok:
		ans = max(ans, bin(s).count("1"))

print(ans)


n = int(input())

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):
		if (s>>i&1) == 1:
			for j in range(n):
				if g[i][j] != -1 && (s>>j&1) != g[i][j]:
                    ok = False
	if ok:
		ans = max(ans, bin(s).count("1"))

print(ans)


n = int(input())

g = [[-1]*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):
		if (s>>i&1) == 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, bin(s).count("1"))

print(ans)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
def max_honest(n_ppl, testimonies):
    formating_str = "{0:0" + str(n_ppl) + "b}"
    max = 0
    for i in range(1, 2**n_ppl + 1):
        current_val = formating_str.format(2**n_ppl - i)
        potential = True
        valid_testemonies = []
        for j in range(0, len(current_val)):
            if current_val[j] == "1":
                for k in range(0, len(testimonies[j])):
                    valid_testemonies.append(testimonies[j][k])
        for j in range(0, len(valid_testemonies)):
            if str(valid_testemonies[j][1]) != current_val[valid_testemonies[j][0] - 1]:
                potential = False
                break
        if potential:
            if current_val.count("1") > max:
                max = current_val.count("1")
    return max

testimonies = []
n_ppl = int(input())

for i in range(0, n_ppl):
    tests = []
    n_tests = int(input())
    for j in range(0, n_tests):
        test = input().split(" ")
        test = (int(test[0]), int(test[1]))
        tests.append(test)
    testimonies.append(tests)
    
print("")
print(max_honest(n_ppl, testimonies))
input("Press enter")

def max_honest(n_ppl, testimonies):
    formating_str = "{0:0" + str(n_ppl) + "b}"
    max = 0
    for i in range(1, 2**n_ppl + 1):
        current_val = formating_str.format(2**n_ppl - i)
        potential = True
        valid_testemonies = []
        for j in range(0, len(current_val)):
            if current_val[j] == "1":
                for k in range(0, len(testimonies[j])):
                    valid_testemonies.append(testimonies[j][k])
        for j in range(0, len(valid_testemonies)):
            if str(valid_testemonies[j][1]) != current_val[valid_testemonies[j][0] - 1]:
                potential = False
                break
        if potential:
            if current_val.count("1") > max:
                max = current_val.count("1")
    return max

testimonies = []
n_ppl = int(input())

for i in range(0, n_ppl):
    tests = []
    n_tests = int(input())
    for j in range(0, n_tests):
        test = input().split(" ")
        test = (int(test[0]), int(test[1]))
        tests.append(test)
    testimonies.append(tests)
    
print(max_honest(n_ppl, testimonies))

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

def solve():
    N = int(input())
    graph = {i: [] for i in range(1, N+1)}
    for i in range(N): 
        A = int(input())
        for _ in range(A):
            x,y = map(int, input().split())
            graph[i+1].append((x,y))
            
    def dfs(nodes):
        searched = [-1] * N
        stack = [i+1 for i,node in enumerate(nodes) if node == 1]
        ret_len = len(stack)
        
        while stack:
            node = stack.pop(0)
            for x,y in graph[node]:
                if nodes[x-1] != y: return -1
                if searched[x-1] == -1:
                    searched[x-1] = y
                    if y == 1: stack.append(x)
                        
        # print(nodes, searched)
        return ret_len
                    
        
    ret = 0
    for nodes in product([0,1], repeat=N):
        ret = max(ret, dfs(nodes))
        
    print(ret)

from itertools import product

def solve():
    N = int(input())
    graph = {i: [] for i in range(1, N+1)}
    for i in range(N): 
        A = int(input())
        for _ in range(A):
            x,y = map(int, input().split())
            graph[i+1].append((x,y))
            
    def dfs(nodes):
        searched = [-1] * N
        stack = [i+1 for i,node in enumerate(nodes) if node == 1]
        ret_len = len(stack)
        
        while stack:
            node = stack.pop(0)
            for x,y in graph[node]:
                if nodes[x-1] != y: return -1
                if searched[x-1] == -1:
                    searched[x-1] = y
                    if y == 1: stack.append(x)
                        
        # print(nodes, searched)
        return ret_len
                    
        
    ret = 0
    for nodes in product([0,1], repeat=N):
        ret = max(ret, dfs(nodes))
        
    print(ret)
    
solve()

Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
testimony = [[] for _ in range(n)]

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

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

print(honest)

n = int(input())
testimony = [[] for _ in range(n)]

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

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

print(honest)

n = int(input())
testimony = [[] for _ in range(n)]

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

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

print(honest)

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):
g = [[-1] * 15 for _ in range(15)]
n = int(input())
for i in range(n):
    m = int(input())
    for j in range(m):
        a, x = map(int, input().split())
        a -= 1
        g[i][a] = x
def count_ones_by_minus(num):
    count = 0
    while num:
        num &= num -1
        count += 1
    return count
for i in range(1 << n):
    for j in range(n):
        if i >> j & 1:
            d[j] = 1
    ok = True
    for j in range(n):
        if d[j]:
            for k in range(n):
                if g[j][k] == -1:
                    continue
                if g[j][k] != d[k]:
                    ok = False
        if ok:
            ans = max(ans, count_ones_by_minus(i))
    print(ans)  

g = [[-1] * 15 for _ in range(15)]
n = int(input())
for i in range(n):
    m = int(input())
    for j in range(m):
        a, x = map(int, input().split())
        a -= 1
        g[i][a] = x
def count_ones_by_minus(num):
    count = 0
    while num:
        num &= num -1
        count += 1
    return count
ans = 0
for i in range(1 << n):
    d = [0] * n
    for j in range(n):
        if i >> j & 1:
            d[j] = 1
    ok = True
    for j in range(n):
        if d[j]:
            for k in range(n):
                if g[j][k] == -1:
                    continue
                if g[j][k] != d[k]:
                    ok = False
    if ok:
        ans = max(ans, count_ones_by_minus(i))
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())
lst = [(bin(i)[2:]).zfill(n) for i in range(2**n)]
num_list = []
A_list = []
xy_list = []
for i in range(n):
    a = int(input())
    A_list.append(a)
    for j in range(a):
        x,y = map(int,input().split())
        xy_list.append([x,y])
for i in range(len(lst)):
    choose = lst[i]
    one_count = choose.count("1")
    a_count = 0
    print(choose)
    print(one_count)
    flag = True
    for num, j in enumerate(A_list):
        a_count += j
        for k in range(a_count-j, a_count):
            x,y = xy_list[k][0],xy_list[k][1]
            if choose[num] == "1" and choose[x-1] != str(y):
                flag = False
    if flag:
        num_list.append(one_count)
    else:
        num_list.append(0)
print(max(num_list))


n = int(input())
lst = [(bin(i)[2:]).zfill(n) for i in range(2**n)]
ans = 0
A_list = []
xy_list = []
for i in range(n):
    a = int(input())
    A_list.append(a)
    for j in range(a):
        x,y = map(int,input().split())
        xy_list.append([x,y])
for i in range(len(lst)):
    choose = lst[i]
    one_count = choose.count("1")
    a_count = 0
    flag = True
    for num, j in enumerate(A_list):
        a_count += j
        for k in range(a_count-j, a_count):
            x,y = xy_list[k][0],xy_list[k][1]
            if choose[num] == "1" and choose[x-1] != str(y):
                flag = False
                break
    if flag:
        ans = max(ans,one_count)
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())
ls = []
for i in range(n):
    a = int(input())
    p = []
    for i in range(a):
        x,y = map(int,input().split())
        p.append([x-1,y])
    ls.append(p)

ans = 0

for i in range(2**n):
    flag = 0
    for j in range(n):
        if (i >> j) & 1:
            for k in ls[j]:
                if (i >> k[0])&1 != k[1]:
                    flag = 1
                    break
    if flag == 0:
        ans = max(ans, bin(i)[2:].count(1))
print(ans)

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

ans = 0

for i in range(2**n):
    flag = 0
    for j in range(n):
        if (i >> j) & 1:
            for k in ls[j]:
                if (i >> k[0])&1 != k[1]:
                    flag = 1
                    break
    if flag == 0:
        ans = max(ans, bin(i)[2:].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 itertools

n = input()
array = []
for i in range(n):
  t = input()
  array.append(set())
  for j in range(t):
    tmp = list(map(int, input().split(" ")))
    if tmp[1] == 1:
      array[i].add(tmp[0])
      
allcombs = list(itertools.product([0, 1], repeat=n))
max_val = 0
for comb in allcombs:
  
  if sum(comb) <= max_val:
    continue
  
  for i, j in enumerate(comb):
    broke = False
    if j == 1:
      for k in array[i]:
        if comb[k] == 0:
          broke = True
          break
    if broke:
      break
  if not broke:
    max_val = max(max_val, sum(comb))
   
        
        
print(max_val)

import itertools

n = int(input())
array = []
for i in range(n):
    t = int(input())
    array.append([])
    for j in range(t):
        tmp = list(map(int, input().split(" ")))
        array[i].append(tmp)

allcombs = list(itertools.product([0, 1], repeat=n))
max_val = 0
for comb in allcombs:

    if sum(comb) <= max_val:
        continue

    tmp = []
    for i, j in enumerate(comb):
        if j == 1:
            tmp += array[i]
            
    if all([comb[t[0]-1]==t[1] for t in tmp]):
        max_val = max(max_val, sum(comb))

print(max_val)

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 = [[-1 for _ in range(n)] for _ in range(n)]
for _ in range(n):
    c = int(input())
    for c1 in range(c):
        x, y = map(int, input().split())
        x -= 1
        lst[_][x] = y

ans = 0
for bit in range(n**2 - 1):
    flg = True
    for a in range(n):
        if (bit >> a) & 1:
            for x in range(n):
                if lst[a][x] != -1 and ((bit >> x) & 1) != lst[a][x]:
                    flg = False
                    break
if flg:
  ans = max(ans, bin(bit).count('1'))
print(ans)
    


n = int(input())
lst = [[-1 for _ in range(n)] for _ in range(n)]
for _ in range(n):
    c = int(input())
    for c1 in range(c):
        x, y = map(int, input().split())
        x -= 1
        lst[_][x] = y
        
ans = 0
for bit in range(2**n):
    flg = True
    for a in range(n):
        if (bit >> a) & 1:
            for x in range(n):
                if lst[a][x] != -1 and ((bit >> x) & 1) != lst[a][x]:
                  flg = False
                  break
    if flg:
        ans = max(ans, bin(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):
n = int(input())
A = []
ans = 0
for i in range(n):
    x =int(input())
    lists = [list(map(int,input().split())) for j in range(x)]
    A.append(lists)

for i in range(2**n):
    honesty = [0]*n
    for j in range(n):
        if (i>>j) & 1:
            honesty[j] = 1
    true = 1
    for j in range(n):
        if honesty[j] == 1:
            for k in range(len(A[j])):
                x,y = A[j][k]
                
                if  honesty[x] != y :
                    true = 0
                    break
    if true == 1:
        ans = max(ans,sum(honesty))
print(ans)

n = int(input())
A = []
ans = 0
for i in range(n):
    x =int(input())
    lists = [list(map(int,input().split())) for j in range(x)]
    A.append(lists)

for i in range(2**n):
    honesty = [0]*n
    for j in range(n):
        if (i>>j) & 1:
            honesty[j] = 1
    true = 1
    for j in range(n):
        if honesty[j] == 1:
            for k in range(len(A[j])):
                x,y = A[j][k]
                
                if  honesty[x] != y :
                    true = 0
                    break
    if true == 1:
        ans = max(ans,sum(honesty))
print(ans)

n = int(input())
A = []
ans = 0
for i in range(n):
    x =int(input())
    lists = [list(map(int,input().split())) for j in range(x)]
    A.append(lists)

for i in range(2**n):
    honesty = [0]*n
    for j in range(n):
        if (i>>j) & 1:
            honesty[j] = 1
    true = 1
    for j in range(n):
        if honesty[j] == 1:
            for k in range(len(A[j])):
                x,y = A[j][k]
                if not honesty[x-1] == y:
                    true = 0
                    break
    if true == 1:
        ans = max(ans,sum(honesty))
print(ans)
print(A)

n = int(input())
A = []
ans = 0
for i in range(n):
    x =int(input())
    lists = [list(map(int,input().split())) for j in range(x)]
    A.append(lists)

for i in range(2**n):
    honesty = [0]*n
    for j in range(n):
        if (i>>j) & 1:
            honesty[j] = 1
    true = 1
    for j in range(n):
        if honesty[j] == 1:
            for k in range(len(A[j])):
                x,y = A[j][k]
                if not honesty[x-1] == y:
                    true = 0
                    break
    if true == 1:
        ans = max(ans,sum(honesty))
print(ans)

Verdicts: Runtime Error

Runtime Error

Wrong Answer

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

Submission attempts (in order):
N=int(input())
X=[]
Y=[]
for n in range(N):
    A=int(input())
    lx=[]
    ly=[]
    for m in range(A):
        x,y=map(int,input().strip().split())
        lx.append(x)
        ly.append(y)
    X.append(lx)
    Y.append(ly)    

def judge(l,X,Y):
    honest=True
    for n in range(N):
        if l[n]==1:
            for i in range(len(X[n])):
                if l[X[n][i]-1]!=Y[n][i]:
                    honest=False
    return honest

ans=0
def dfs(l,N): 
    if len(l)==N:
        global ans
        if judge(l,X,Y):
            ans=max(ans,sum(l))
            return
    else:
        for n in range(2):
            l.append(n)
            print(l)
            dfs(l,N)
            l.pop()

dfs([],N)
print(ans)  

N=int(input())
X=[]
Y=[]
for n in range(N):
    A=int(input())
    lx=[]
    ly=[]
    for m in range(A):
        x,y=map(int,input().strip().split())
        lx.append(x)
        ly.append(y)
    X.append(lx)
    Y.append(ly)    

def judge(l,X,Y):
    honest=True
    for n in range(N):
        if l[n]==1:
            for i in range(len(X[n])):
                if l[X[n][i]-1]!=Y[n][i]:
                    honest=False
    return honest

ans=0
def dfs(l,N): 
    if len(l)==N:
        global ans
        if judge(l,X,Y):
            ans=max(ans,sum(l))
            return
    else:
        for n in range(2):
            l.append(n)
            dfs(l,N)
            l.pop()

dfs([],N)
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())
testimony = [[-1]*N for i in range(N)]
count = 0
for i in range(N):
  A = int(input())
  for j in range(A):
    x,y = map(int,input().split())
    testimony[i][x-1]=y
fro i in range(2**N):
  honest = [0]*N
  for j in range(N):
    if(i>>j)&1:
      honest[j]=1
  flag=True
  for j in range(N):
    if honest[j]==1:
      for k in range(N):
        if testimony[j][k]==-1:
          continue
        if testimony[j][k]!=honest[k]:
          flag=False
  if flag==True:
    count=max(count,hones.count(1))
print(count)

N = int(input())
testimony = [[-1]*N for i in range(N)]
count = 0
for i in range(N):
  A = int(input())
  for j in range(A):
    x,y = map(int,input().split())
    testimony[i][x-1]=y
for i in range(2**N):
  honest = [0]*N
  for j in range(N):
    if(i>>j)&1:
      honest[j]=1
  flag=True
  for j in range(N):
    if honest[j]==1:
      for k in range(N):
        if testimony[j][k]==-1:
          continue
        if testimony[j][k]!=honest[k]:
          flag=False
  if flag==True:
    count=max(count,honest.count(1))
print(count)

Verdicts: Runtime Error

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

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

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


for i in range(n):
    a.append(int(input()))
    for j in range(a[i]):
        x,y = map(int,input().split())
        xy[i].append([x-1,y])
print(xy)
ans = 0
for i in range(1<<(n)):
    memo = []
    cnt = 0
    for j in range(n):
        if ((i>>j)&1):
            memo.append(1)
            cnt += 1
        else:
            memo.append(0)
    
    cntn = True     
    for j in range(n):
        if memo[j] == 0:
            continue
        for k in range(a[j]):
           prs = xy[j][k][0]

           if memo[prs] != xy[j][k][1]:
               cntn = False
    if not(cntn):
        continue
    ans = max(ans,cnt)

print(ans)




n = int(input())

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


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

ans = 0
for i in range(1<<(n)):
    memo = []
    cnt = 0
    for j in range(n):
        if ((i>>j)&1):
            memo.append(1)
            cnt += 1
        else:
            memo.append(0)
    
    cntn = True     
    for j in range(n):
        if memo[j] == 0:
            continue
        for k in range(a[j]):
           prs = xy[j][k][0]

           if memo[prs] != xy[j][k][1]:
               cntn = False
    if not(cntn):
        continue
    ans = max(ans,cnt)

print(ans)




Verdicts: Wrong Answer

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

Submission attempts (in order):
n=int(input())
xy=[[] for i in range(n)]
ans=0
a=[0]*n
for i in range(n):
  a[i]=int(input())
  for j in range(a[i]):
    x,y=map(int,input().split())
    xy[i].append([x,y])
for i in range(2**n):
  temp=[0]*n
  for j in range(n):
    if ((i >> j) & 1):
      temp[j]=1
  count=True
  for j in range(n):
    for k in range(a[j]):
      if temp[j]==1:
        p=xy[j][k][0]-1
        if temp[p]!=xy[j][k][0]:
          count=False
      else:
        p=xy[j][k][0]-1
        if temp[p]==xy[j][k][0]:
          count=False     
  if count==True:
    ans=max(ans,sum(temp))
print(ans)

n=int(input())
xy=[[] for i in range(n)]
ans=0
a=[0]*n
for i in range(n):
  a[i]=int(input())
  for j in range(a[i]):
    x,y=map(int,input().split())
    xy[i].append([x,y])
for i in range(2**n):
  temp=[0]*n
  for j in range(n):
    if ((i >> j) & 1):
      temp[j]=1
  count=True
  for j in range(n):
    for k in range(a[j]):
      if temp[j]==1:
        p=xy[j][k][0]
        if temp[p]!=xy[j][k][0]:
          count=False
      else:
        p=xy[j][k][0]
        if temp[p]==xy[j][k][0]:
          count=False     
  if count==True:
    ans=max(ans,sum(temp))
print(ans)

n=int(input())
xy=[[] for i in range(n)]
ans=0
a=[0]*n
for i in range(n):
  a[i]=int(input())
  for j in range(a[i]):
    x,y=map(int,input().split())
    xy[i].append([x,y])
for i in range(2**n):
  temp=[0]*n
  for j in range(n):
    if ((i >> j) & 1):
      temp[j]=1
  count=True
  for j in range(n):
    for k in range(a[j]):
      if temp[j]==1:
        p=xy[j][k][0]-1
        if temp[p]!=xy[j][k][1]:
          count=False
          break
  if count==True:
    ans=max(ans,sum(temp))
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):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
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, 1<<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:
                consintent = False
                break
        if not consistent:
            break
    if consistent:
        result = max(result, bin(i)[2:].count('1'))

print(result)


N = int(input())
claim = []
MAX = 0

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

for i in range(2 ** N):
    people = [0 for i in range(N)]
    FLAG = True
    for j in range(N):  
        if ((i >> j) & 1):  
            people[j] = 1
    
    for k in range(len(claim)):
        if people[k] == 0:
            continue
        for l in range(len(claim[k])):
            if people[int(claim[k][l][0]) - 1] != int(claim[k][l][1]):
                FLAG = False
                break
    
    if FLAG:
        MAX = max(MAX, sum(people))

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):
from typing import List, Tuple

def io_readline() -> List[List[Tuple[int, ...]]]:
    N = int(input())
    res = []
    for n in range(N):
        a_n = int(input())
        n_testimony = []
        for _ in range(a_n):
            testimony = tuple(map(int, input().split()))
            n_testimony.append(testimony)
        res.append(n_testimony)
    return res


infos = io_readline()
ans = 0
for i in range(2 ** len(infos)):
    cnt = bin(i).count("1")
    if cnt <= ans:
        continue

    for j in range(2 ** len(infos)):
        
        if i & (1 << j):
            print(f'{bin(i)}:  {bin(1 << j)}')
            for x, y in infos[j]:
                if y == 1 and i % (1 << x):
                    continue
                elif y == 0 and i % (1 << x) == 0:
                    continue
                else:
                    break
            else:
                continue
            break
    else:
        ans = cnt

print(ans)


from typing import List


def io_info() -> List[List[int]]:
    N = int(input())
    res = [[-1] * N for _ in range(N)]
    for n in range(N):
        a = int(input())
        for _ in range(a):
            x, y = map(int, input().split())
            res[n][x-1] = y
    return res


def main():
    infos = io_info()
    n = len(infos)
    ans = 0
    for i in range(1 << n):
        d = [0] * n
        for j in range(n):
            
            if (i >> j) & 1:
                d[j] = 1
        ok = True
        for j in range(n):
            if d[j]:
                for k in range(n):
                    if infos[j][k] == -1: continue
                    if infos[j][k] != d[k]: ok = False

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



if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

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

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


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

for i in range(2**N):
  flag=1
  honest=[]
  unkind=[]
  for j in range(N):
    if (i>>j)&1:
      honest.append(j)
    else:
      unkind.append(j)
  for k in range(N):
    if k in honest:
      for l in Ins[k]:
        if l[1]==1 and l[0] in unkind:
          flag=0
          break
        elif l[1]==0 and l[0] in honest:
          flag=0
          break
    if flag==1:
        ans=max(ans,len(honest))
print(ans)

N=int(input())
Ins=[[] for _ in range(N)]
ans=0


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

for i in range(2**N):
  flag=1
  honest=[]
  unkind=[]
  for j in range(N):
    if (i>>j)&1:
      honest.append(j)
    else:
      unkind.append(j)
      
  for k in honest:
    
    for l in Ins[k]:
      if l[1]==1 and l[0] in unkind:
        flag=0
        break
        
        
      elif l[1]==0 and l[0] in honest:
        flag=0
        break
        
        
  if flag==1:
    ans=max(ans,len(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):
import itertools

n = int(input())
saids = {}  
for i in range(n):
    said = {}
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        said[x] = y == 1
    saids[i] = said
ans = 0
for p in range(2**n):
    honest = [i for i in range(n) if p & 2 ** i != 0]
    for x, y in itertools.product(honest, range(n)):
        if y not in saids[x]:
            continue
        if saids[x][y] is False and y in honest:
            break
        if saids[x][y] is True and y not in honest:
            break
    else:
        ans = max(ans, len(honest))
print(ans)


import itertools

n = int(input())
saids = {}  
for i in range(1, n + 1):
    said = {}
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        said[x] = y
    saids[i] = said
ans = 0
for p in range(2**n):
    honest = [i + 1 for i in range(n) if p & 2 ** i != 0]
    for x, y in itertools.product(honest, range(1, n+1)):
        if y not in saids[x]:
            continue
        if saids[x][y] == 0 and y in honest:
            break
        if saids[x][y] == 1 and y not in honest:
            break
    else:
        ans = max(ans, len(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):
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 13 13:52:16 2020

@author: Kanaru Sato
"""

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

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


honest = 0

for state in range(2**n):   
    flag = 0
    for j in range(n):
        if flag == 1:
            break
        if state&(0b1<<j):    
            for k in range(a[j]):
                proofee = proof[j][k][0]-1
                if state&(0b1<<proofee) != proof[j][k][1]:   
                    flag = 1    
                    break
    if flag == 0:
        count = 0
        for i in range(n):
            count += (state>>i)&0b1
        if honest <= count:
            honest = count
print(honest)


# -*- coding: utf-8 -*-
"""
Created on Fri Mar 13 21:55:08 2020

@author: Kanaru Sato
"""

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

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

honest = 0

for state in range(2**n):   
    flag = 0
    for j in range(n):
        if int(bin(state>>j & 0b1),2) == 1:    
            for k in range(a[j]):
                if int(bin((state >> proof[j][k][0]) & 0b1),2) != proof[j][k][1]:   
                    flag = 1    
    if flag == 0:
        count = 0
        for i in range(n):
            count += int(bin((state >> i) & 0b1), 2)
        if honest <= count:
            honest = count

print(honest)

# -*- coding: utf-8 -*-
"""
Created on Fri Mar 13 13:52:16 2020

@author: Kanaru Sato
"""

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

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

honest = 0

for state in range(2**n):   
    flag = 0
    for j in range(n):
        if flag == 1:
            break
        if state&(0b1<<j):    
            for k in range(a[j]):
                proofee = proof[j][k][0]-1
                if bool(state&(0b1<<proofee)) != (proof[j][k][1]):   
                    flag = 1    
                    break
    if flag == 0:
        count = 0
        for i in range(n):
            count += (state>>i)&0b1
        if honest <= count:
            honest = count
print(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):
n = int(input())
peaple = []
for i in range(n):
  a = int(input())
  tests = []
  for j in range(a):
    x, y = input().split()
    tests.append((int(x) - 1, y))
  peaple.append(tests)
  
maximum = 0
for h_bit in range(1, 1<<n):
  h_str = format(h_bit, '0{}b'.format(n))
  flag = False
  for i in range(n):
    if h_str[i] == '1':
      for tests in peaple[i]:
        for test in tests:
          if h_str[test[0]] != test[1]:
            flag = True
            break
        if flag:
          break
    if flag:
      break
  if not flag:
    maximum = max(maximum, h_str.count('1'))
print(maximum)

n = int(input())
peaple = []
for i in range(n):
  a = int(input())
  tests = []
  for j in range(a):
    x, y = input().split()
    tests.append((int(x) - 1, y))
  peaple.append(tests)
  
maximum = 0
for h_bit in range(1, 1<<n):
  h_str = format(h_bit, '0{}b'.format(n))
  flag = False
  for i in range(n):
    if h_str[i] == '1':
      for test in peaple[i]:
        if h_str[test[0]] != test[1]:
          flag = True
          break
    if flag:
      break
  if not flag:
    maximum = max(maximum, h_str.count('1'))
print(maximum)

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):
# -*- coding:utf-8 -*-

def solve():
    
    N = int(input())
    As = []
    for n in range(N):
        A = int(input())
        XYs = []
        for a in range(A):
            x, y = list(map(int, input().split()))
            XYs.append((x-1, y))
        As.append(XYs)

    ans = 0
    for i in range(N):
        is_next = False
        
        honests = [None for _ in range(N)]
        honests[i] = 1

        que = []
        for x, y in As[i]:
            honests[x] = y
            if y == 1:
                que.append(x)

        while len(que) != 0:
            j = que.pop(-1)
            for x, y in As[j]:
                if honests[x] == None:
                    honests[x] = y
                    que.append(x)
                else:
                    
                    if honests[x] != y:
                        is_next = True
                        break
            if is_next:
                break
        if is_next:
            continue

        
        ret = 0
        for j in honests:
            if j == 1:
                ret += 1

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

            is_honest = True
            for x, y in As[j]:
                if honests[y] != x:
                    is_honest = False
            if is_honest:
                ret += 1

        ans = max(ans, ret)

    print(ans)

if __name__ == "__main__":
    solve()


# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    testimonies = []
    for n in range(N):
        A = int(input())
        XYs = []
        for a in range(A):
            x, y = list(map(int, input().split()))
            XYs.append((x-1, y))
        testimonies.append(XYs)

    
    ans = 0
    for bit in range(2**N):
        is_continue = False
        total = 0
        
        for i in range(N):
            if bit>>i&1:
                
                total += 1
                for testimony in testimonies[i]:
                    x, y = testimony
                    if bit>>x&1 != y:
                        
                        is_continue = True
                        break
            if is_continue:
                break
        if is_continue:
            continue
        ans = max(ans, total)

    print(ans)



if __name__ == "__main__":
    solve()


Verdicts: Wrong Answer

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

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

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


best = 0  

print(1 << 1)









for honest in range(1 << n):  
    for i in range(n):  
        if not (honest >> i) & 1:  
            continue 
        for j, t in testimony[i]:  
            if (honest >> j) & 1 != t:  
                break 
        else:
            continue
        break
    else:  
        best = max(best, bin(honest).count('1'))

print(best)

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


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

max_honest = 0  


for i in range(1 << n):
    ishonest = [False] * n
    for j in range(n):
        if ((i >> j) & 1) == 1:
            ishonest[j] = True
    

    ok = True

    for k in range(n):
        
        if ishonest[k] == False:
            continue
        
        
        for l in range(len(testimony[k])):
            person = testimony[k][l][0]
            true_false = testimony[k][l][1]
            
            
            
            if (ishonest[person] == True) and (true_false == 0) or (ishonest[person] == False) and (true_false == 1):
                ok = False

        if ok == False:
            break
        
    if ok == True:

        if ishonest.count(True) > max_honest:
            max_honest = ishonest.count(True)

print(max_honest)

Verdicts: Wrong Answer

Accepted