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())
testimo_ls = [ [] for i in range(N) ]
rst = 0
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split(' '))
        testimo_ls[i].append([x - 1, y])
for i in range(1 << N):
    honest_ls = []
    for j in range(N):
        if i >> j & 1:
            honest_ls.append(j)
    is_ok = True
    for s in honest_ls:
        for t in testimo_ls[s]:
            if t[0] not in honest_ls and t[1] == 1:
                is_ok = False
                break
            if t[0] in honest_ls and t[1] == 1:
                is_ok = False
                break
    if is_ok:
        rst = max(rst, len(honest_ls))
print(rst)

N = int(input())
testimo_ls = [ [] for i in range(N) ]
rst = 0
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split(' '))
        testimo_ls[i].append([x - 1, y])
for i in range(1 << N):
    honest_ls = []
    for j in range(N):
        if i >> j & 1:
            honest_ls.append(j)
    is_ok = True
    for s in honest_ls:
        for t in testimo_ls[s]:
            if t[0] in honest_ls and t[1] == 0:
                is_ok = False
                break
            if t[0] not in honest_ls and t[1] == 1:
                is_ok = False
                break
    if is_ok:
        rst = max(rst, len(honest_ls))
print(rst)

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

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


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

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

print(ans)


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

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

print(ans)


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

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

print(ans)


Verdicts: Runtime Error

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]*15]*15
for i in range(N):
    a = int(input())
    for _ in range(a):
        x,y = map(int,input().split())
        g[i].append([x,y])

ans = 0
for i in range(1<<N):
  d = [0]*N
  for j in range(N):
    if (i>>j&1):
      d[j] = 1
  flag = True
  for j in range(N):
    if d[j] == 1:
      for k in range(N):
        if g[j][k] == -1:
          continue
        if g[j][k] != d[k]:
          flag = False
    ans = max(ans,sum(d))
print(ans)

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

for i in range(1<<N):
  d = [0]*N
  for j in range(N):
    if (i>>j&1):
      d[j] = 1
  flag = True
  for j in range(N):
    if d[j]:
      for k,l in A[j]:
        if d[k] == l:
          continue
        if d[k] != l:
          flag = False
      if not flag:
        break
  if flag:
    ans = max(ans,sum(d))
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):
    A = int(input())
    xy.append([])
    
    for j in range(A):
        xy[i].append(tuple(map(int, input().split())))
 
ans = 0
 
for i in range(2 ** N):
    h = [0] * N
    
 
    for j in range(N):
        if (i >> j) & 1:
            h[j] = 1
    print(h)
    flag = False
    for i in range(N):
        if h[i] == 1:
            for x, y in xy[i]:
                if h[x-1] != y:
                    flag = True
                    break
            if flag:
                break
    
    if not flag:
        print(sum(h))
        ans = max(ans, sum(h))
 
print(ans)

import itertools
 
N = int(input())
 
evidence_dit = {}
 
for i in range(N):
    A = int(input())
    x_y = []
    if A == 0:
        evidence_dit[i] = []
    for j in range(A):
        x_y.append(list(map(int,input().split())))
        
        evidence_dit[i] = x_y 

attribute = [0,1]
ans = 0
 
for i in itertools.product(attribute,repeat=N):
    flag = False
    
    for j in range(N):
       
        if i[j] == 1:
            for k in evidence_dit[j]:
                
                
                if i[k[0]-1] != k[1]:
                    flag = True
                    break
            if flag:
                break
 
    if flag == False:
        
        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())
words = []
for i in range(n):
	a = int(input())
	w = []
	for _ in range(a):
		x, y = map(int, input().split())
		w.append([x-1, y])
	words.append(w)


ans = 0
for bit in range(1<<n):　
	ok = True
	is_honest = [(bit>>i) & 1 for i in range(n)]
	
	for i in range(n):
		if not is_honest[i]:
			continue
		for x, y in words[i]:
			if is_honest[x] != y:
				ok = False
	if ok:
		ans = max(ans, sum(is_honest))
print(ans)


import sys
def input():
	return sys.stdin.readline()[:-1]
n = int(input())
words = []
for i in range(n):
	a = int(input())
	w = []
	for _ in range(a):
		x, y = map(int, input().split())
		w.append([x-1, y])
	words.append(w)


ans = 0
for bit in range(1<<n):　
	ok = True
	is_honest = [(bit>>i) & 1 for i in range(n)]
	
	for i in range(n):
		if not is_honest[i]:
			continue
		for x, y in words[i]:
			if is_honest[x] != y:
				ok = False
	if ok:
		ans = max(ans, sum(is_honest))
print(ans)


n = int(input())
words = []
ans = 0
for i in range(n):
	a = int(input())
	w = []
	for _ in range(a):
		x, y = map(int, input().split())
		w.append([x-1, y])
	words.append(w)
for bit in range(n):
	ok = True
	is_honest = [(bit>>i) & 1 for i in range(n)] 
    
	for i in range(n):
		if not is_honest[i]:
			continue
		for x, y in words[i]:
			if is_honest[x] != y:
				ok = False
	if ok:
		ans = max(ans, sum(is_honest))
print(ans)

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


ans = 0
for bit in range(1<<n):
  
	ok = True
	is_honest = [(bit>>i) & 1 for i in range(n)]
	
	for i in range(n):
		if not is_honest[i]:
			continue
		for x, y in words[i]:
			if is_honest[x] != y:
				ok = False
	if ok:
		ans = max(ans, sum(is_honest))
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):
def f():
    N = int(input())
    A = []
    
    for n in range(N):
        templist = []
        for a in range(int(input())):
            templist.extend(list(map(int, input().split())))
        A.append(templist)
    
    print(A)
    
    maxlen = len(str(bin(2**len(A)-1).replace('0b','')))
    for j in reversed((range(2**len(A)))):
        tempb = str(bin(j).replace('0b',''))
        for i in range(maxlen - len(tempb)):
            tempb = '0'+tempb
        
        tempj = list(map(int, list(tempb)))
        counter = 0
        for jj in range(len(tempj)):
            if tempj[jj] == 1: 
                if tempj[A[jj][0]-1] != A[jj][1]:
                    break
                else:
                    counter += 1
            else:
                if tempj[A[jj][0]-1] == A[jj][1]:
                    break
                else:
                    counter += 1
        if counter == len(A):
            return print(tempj.count(1))
            
    return print(tempj.count(1))
    
f()

def f():
    N = int(input())
    A = []
    
    for n in range(N):
        templist = []
        for a in range(int(input())):
            templist.append(list(map(int, input().split())))
        A.append(templist)
    
    # print(A)
    J = [0]
    maxlen = len(str(bin(2**len(A)-1).replace('0b','')))
    for j in reversed((range(2**len(A)))):
        tempb = str(bin(j).replace('0b',''))
        for i in range(maxlen - len(tempb)):
            tempb = '0'+tempb
        
        tempj = list(map(int, list(tempb)))
        counter = 0
        for jj in range(len(tempj)):
            if tempj[jj] == 1: 
                
                shocounter = 0
                for s in range(len(A[jj])):
                    if tempj[A[jj][s][0]-1] != A[jj][s][1]:
                        break
                    else:
                        shocounter += 1
                if shocounter == len(A[jj]):
                    counter += 1
            else:
                
                shocounter = 0
                for s in range(len(A[jj])):
                    if tempj[A[jj][s][0]-1] == A[jj][s][1]:
                        continue
                    else:
                        shocounter += 1
                if shocounter > 0:
                    counter += 1
        if counter == len(A):
            J.append(tempj.count(1))
    
    list.sort(J, reverse=True)        
    return print(J[0])
    
f()

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())
word = []
for i in range(n):
  a = int(input())
  l = [list(map(int,input().split())) for _ in range(a)]
  word.append(l)
print(word)

ans = 0
for i in range(2**n):
  flag = 0
  count = 0
  for j in range(n):
    if ((i>>j)&1)==1 and flag==0:
      for k,l in word[j]:
        if ((i>>(k-1))&1) != l:
          flag = 1 ## tell a lie
          break
  if flag==0:
    count = bin(i).count('1')
    ans = max(ans,count)
print(ans)


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

ans = 0
for i in range(2**n):
  flag = 0
  count = 0
  for j in range(n):
    if ((i>>j)&1)==1 and flag==0:
      for k,l in word[j]:
        if ((i>>(k-1))&1) != l:
          flag = 1 ## tell a lie
          break
  if flag==0:
    count = bin(i).count('1')
    ans = max(ans,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())
llie=[[] for i in range(N)]
for i in range(N):
    a=int(input())
    for j in range(a):
        x,y=map(int,input().split())
        if y==0:
            llie[i].append(x)
print(llie)
ans=0
for i in range(2**N):
    print("i",i)
    dlie={}
    dtrue={}
    tmpsum=0
    f=0
    for j in range(N):
        if i&1:
            if j+1 in dlie:
                f=1
                break
            else:
                for x in llie[j]:
                    if x in dtrue:
                        f=1
                        break
                    #dlie[j+1]=1
                    dlie[x]=1
                if f==0:
                    tmpsum+=1
                    dtrue[j+1]=1
                    #i>>=1
                    #continue
                else:
                    f==1
                    break
            #tmpsum+=1
        else:
            if j+1 in dtrue:
                f==1
                break
        i>>=1

    #else:
    if f==1:
        ans=max(ans,tmpsum)
        #ans=max(ans,N-len(dlie))
        #print("j",j)
    print("ans",ans)
#print(dtrue)
print(ans)


N=int(input())
llie=[[] for i in range(N)]
ltrue=[[] for i in range(N)]
for i in range(N):
    a=int(input())
    for j in range(a):
        x,y=map(int,input().split())
        if y==0:
            llie[i].append(x)
        else:
            ltrue[i].append(x)
ans=0
for i in range(2**N):
    dlie={}
    dtrue={}
    tmpsum=0
    f=0
    for j in range(N):
        if i&1:
            if j+1 in dlie:
                f=1
                break
            else:
                for x in llie[j]:
                    if x in dtrue:
                        f=1
                        break
                    dlie[x]=1
                for x in ltrue[j]:
                    if x in dlie:
                        f=1
                        break
                    dtrue[x]=1
                if f==0:
                    tmpsum+=1
                    dtrue[j+1]=1
                else:
                    break
        else:
            if j+1 in dtrue:
                f=1
                break
            dlie[j+1]=1
        i>>=1
    if f==0:
        ans=max(ans,tmpsum)
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):
def main():
    N = int(input())
    testimony = [[] for i in range(N)]
    for i in range(N):
        for j in range(int(input())):
            x,y = map(int,input().split())
            testimony[i].append([x,y])
    
    ans = 0
    for i in range(2**N):
        for j in range(N):
            flag = True
            if (i>>j)&1:
                for x,y in testimony[j]:
                    if ((i>>x)&1) != y:
                        flag = False
                        break
                if not flag:
                    break        
        if flag:
            tmp = list(bin(i))
            ans = max(ans,tmp[2:].count("1"))

    print(ans)

if __name__ == "__main__":
    main()

def main():
    N = int(input())
    testimony = [[] for i in range(N)]
    for i in range(N):
        for j in range(int(input())):
            x,y = map(int,input().split())
            testimony[i].append([x-1,y])
    
    ans = 0
    for i in range(2**N):
        for j in range(N):
            flag = True
            if (i>>j)&1:
                for x,y in testimony[j]:
                    if ((i>>x)&1) != y:
                        flag = False
                        break
                if not flag:
                    break        
        if flag:
            tmp = list(bin(i))
            ans = max(ans,tmp[2:].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):
from itertools import product

N = int(input())
xy = [[] for in range(N)]

for i in range(N):
    for j i range(int(input())):
        xy[i].append(list(map(int, input().split())))
        
ans = 0
for bit in product([0,1], repeat=N):
    f = 0
    for i, j in enumerate(bit):
        if j == 1:
            for x, y in xy[i]:
                if bit[x-1] != y:
                    f = 1
                    break
    if f == 0:
        ans = max(ans, sum(bit))
print(ans)

from itertools import product

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

for i in range(N):
    for j i range(int(input())):
        xy[i].append(list(map(int, input().split())))
        
ans = 0
for bit in product([0,1], repeat=N):
    f = 0
    for i, j in enumerate(bit):
        if j == 1:
            for x, y in xy[i]:
                if bit[x-1] != y:
                    f = 1
                    break
    if f == 0:
        ans = max(ans, sum(bit))
print(ans)

from itertools import product

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

for i in range(N):
    for j in range(int(input())):
        xy[i].append(list(map(int, input().split())))
        
ans = 0
for bit in product([0,1], repeat=N):
    f = 0
    for i, j in enumerate(bit):
        if j == 1:
            for x, y in xy[i]:
                if bit[x-1] != y:
                    f = 1
                    break
    if f == 0:
        ans = max(ans, sum(bit))
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):
2
1
2 0
1
1 n = int(input())

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

ans = 0
def judge(f):
    for i in range(n):
        if flag[i] == 1:
            for j in xy[i]:
                if f[j[0] - 1] != j[1]:
                    return False
        
    return True

for i in range(2 ** n):
    flag = [0] * n
    for j in range(n):
        if i >> j & 1:
            flag[j] = 1
    if judge(flag):
        ans = max(ans, sum(flag))
print(ans)

n = int(input())

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

ans = 0
def judge(f):
    for i in range(n):
        print(xy[i], flag)
        for j in range(len(xy[i])):
            if f[xy[i][j][0] - 1] != xy[i][j][1] ^ (f[i] ^ 1):
                return False
    return True

for i in range(2 ** n):
    flag = [0] * n
    for j in range(n):
        if i >> j & 1:
            flag[j] = 1
    print()
    if judge(flag):
        ans = max(ans, sum(flag))
print(ans)

n = int(input())

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

ans = 0
def judge(f):
    for i in range(n):
        if flag[i] == 1:
            for j in xy[i]:
                if f[j[0] - 1] != j[1]:
                    return False
        
    return True

for i in range(2 ** n):
    flag = [0] * n
    for j in range(n):
        if i >> j & 1:
            flag[j] = 1
    if judge(flag):
        ans = max(ans, sum(flag))
print(ans)

Verdicts: Runtime Error

Wrong Answer

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

Submission attempts (in order):
import math

if __name__ == '__main__':
    n = int(input())
    ans = 0
    is_honest = [-1] * n
    evidence = []
    for i in range(n):
        a = int(input())
        tmp = []
        for j in range(a):
            x, y = map(int, input().split())
            tmp.append((x - 1, y))
        evidence.append(tmp)

    
    for i in range(2 ** n):
        flag = True
        for j in range(n):
            # j is Liar
            if not (i & (1 << j)):
                continue
            for x, y in evidence[j]:
                if y == 1 and not (i & (1 << x)):
                    flag = False
                elif y == 0 and (i & (1 << x)):
                    flag = False
        if flag:
            print(bin(i))
            count = 0
            for k in range(n):
                if i & (1 << k):
                    count += 1
            ans = max(ans, count)

    print(ans)


import math

if __name__ == '__main__':
    n = int(input())
    ans = 0
    is_honest = [-1] * n
    evidence = []
    for i in range(n):
        a = int(input())
        tmp = []
        for j in range(a):
            x, y = map(int, input().split())
            tmp.append((x - 1, y))
        evidence.append(tmp)

    
    for i in range(2 ** n):
        flag = True
        for j in range(n):
            # j is Liar
            if not (i & (1 << j)):
                continue
            for x, y in evidence[j]:
                if y == 1 and not (i & (1 << x)):
                    flag = False
                elif y == 0 and (i & (1 << x)):
                    flag = False
        if flag:
            count = 0
            for k in range(n):
                if i & (1 << k):
                    count += 1
            ans = max(ans, 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):
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
N=II()
Shogens=[[] for i in range(N)]
for i in range(N):
  A=II()
  for j in range(A):
    x,y=MI()
    x-=1
    Shogens[i].append((x,y))


def is_honest(i,j):
  return (i>>j)%2==1
def honest_cnt(i):
  ans=0
  for j in range(N):
    ans+=is_honest(i,j)
    return ans
ans=0
for i in range(1<<N):
  ok=True
  for j in range(N):
    if not is_honest(i,j):
      continue
    for x,y in Shogens[j]:
      if y==0 and is_honest(i,x):
        ok=False
      if y==1 and not is_honest(i,x):
        ok=False
  if ok:
    ans=max(ans,honest_cnt(i))
print(ans)

def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

N=II()
ans=0
List=[[-1 for _ in range(N)] for _ in range(N)]
for j in range(N):
  A=II()
  for i in range(A):
    x,y=MI()
    x-=1
    List[j][x]=y
for i in range(1<<N):
  honests=[0]*N
  for j in range(N):
    if 1&(i>>j):
      honests[j]=1
  ok=True
  for j in range(N):
    if honests[j]:
      for k in range(N):
        if List[j][k]==-1:
          continue
        if List[j][k]!=honests[k]:
          ok=False
  if ok:
    ans=max(ans,honests.count(1))
print(ans)

Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
tst = [[] for i in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        st[i].append([x,y])
ans = 0
for bit in range(1<<n):
    honest = [0]*n
    check = 1
    for i in range(n):
        if (bit>>i)&1:
            honest[-1-i] = 1
    for i in range(n):
        if not honest[i]:
            continue
        for l in tst[i]:
            if l[1]!=honest[l[0]-1]:
                check = 0
                break
    if check:
        ans = max(ans,sum(honest))
print(ans)

n = int(input())
tst = [[] for i in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        tst[i].append([x,y])
ans = 0
for bit in range(1<<n):
    honest = [0]*n
    check = 1
    for i in range(n):
        if (bit>>i)&1:
            honest[-1-i] = 1
    for i in range(n):
        if not honest[i]:
            continue
        for l in tst[i]:
            if l[1]!=honest[l[0]-1]:
                check = 0
                break
    if check:
        ans = max(ans,sum(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())
XY = []
ans = 0
for i in range(n):
  a = int(input())
  XY.append([])
  for j in range(a):
    XY[i].append(list(map(int,input().split())))
for i in range(2**n):
  i = format(i, 'b')
  i = i.zfill(n)
  temp = i.count("1")
  temp2 = 0
  print(i)
  for j in range(n):
    if i[j] == "1":
      for k in range(len(XY[j])):
        if str(XY[j][k][1]) != i[XY[j][k][0]-1]:
          temp2 = 1
          break
  if temp2 == 0:
    if ans < temp:
      ans = temp
print(ans)

n = int(input())
XY = []
ans = 0
for i in range(n):
  a = int(input())
  XY.append([])
  for j in range(a):
    XY[i].append(list(map(int,input().split())))
for i in range(2**n):
  i = format(i, 'b')
  i = i.zfill(n)
  temp = i.count("1")
  temp2 = 0
  for j in range(n):
    if i[j] == "1":
      for k in range(len(XY[j])):
        if str(XY[j][k][1]) != i[XY[j][k][0]-1]:
          temp2 = 1
          break
  if temp2 == 0:
    if ans < temp:
      ans = temp
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):
if 0:
  print(0)
else:
  print(1)

N = int(input())
ans = 0
XY = [[] for i in range(N)]
for i in range(N):
  A = int(input())
  for j in range(A):
    XY[i].append(input())
for i in range(2**N):
  for j in range(N):
    if (i >> j) & 1:
      for xy in XY[j]:
        x, y = map(int, xy.split())
        x -= 1
        if (i >> x) & 1 != y:
          break
      else:
        continue
      break
  else:
    ans = max(ans, sum((i >> k) & 1 for k in range(N)))
    continue
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 n in range(N)]
for n in range(N):
  a=int(input())
  XY[n]=[list(map(int, input().split())) for _ in range(a)]
print(XY)

maxH=0
for mask_i in range(2<<(N-1)):
  H=[0]*(N+1)
  for n in range(N):
    if mask_i>>n&1:
      H[n+1]=1
  #print(H[1:])
 
  for idx,(xy) in enumerate(XY,start=1):
    for x,y in xy:
      if y==1:
        if H[idx]==1 and H[x]==1:
          continue
        else:
          break
      else:
        if H[idx]==1 and H[x]==1:
          break
    else:
      continue
    break
  else:
    maxH=max(maxH,sum(H))

print(maxH)


N=int(input())
XY=[[[]] for n in range(N)]
for n in range(1,N+1):
  a=int(input())
  XY[n]=[list(map(int, input().split())) for _ in range(a)]

maxH=0
for mask_i in range(1<<N):
  
  H=[0]*(N+1)
  for n in range(N):
    if mask_i>>n&1:
      H[n+1]=1
  #print(H[1:])
  
  for n in range(1,N+1):
    ok=True
    if H[n]==1:
      for x,y in XY[n]:
        if H[x]!=y:
          ok=False
          break
  if ok:
    maxH=max(maxH,sum(H))

print(maxH)


N=int(input())
XY=[[[]] for n in range(N+1)]
for n in range(1,N+1):
  a=int(input())
  XY[n]=[list(map(int, input().split())) for _ in range(a)]

maxH=0
for mask_i in range(1<<N):
  
  H=[0]*(N+1)
  for n in range(N):
    if mask_i>>n&1:
      H[n+1]=1
  #print(H[1:])
  
  ok=True
  for n in range(1,N+1):
    if H[n]==1:
      for x,y in XY[n]:
        if H[x]!=y:
          ok=False
          break
  if ok:
    maxH=max(maxH,sum(H))

print(maxH)


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())
E = []
for n in range(N):
    A = int(input())
    for _ in range(A):
        x, y = list(map(int, input().split()))
        E.append((n, x - 1, y))
ans = 0
for k in range((1 << N)):
    status = [(k >> i) & 1 for i in range(N)]
    no_paradox = True
    for Xa, Xb, yb in E:
        if (status[Xa] == 1 and status[Xb] == yb):
            no_paradox = False
            break
    if no_paradox:
        ans = max(ans, sum(l))
print(ans)

N = int(input())

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

    for k in range((1 << N)):
      status = [(k >> i) & 1 for i in range(N)]
      no_paradox = True
      for Xa, Xb, yb in E:
        if (status[Xa] == 1 and status[Xb] == yb):
          no_paradox = False
          break
          if no_paradox:
            ans = max(ans, sum(l))
print(ans)

N = int(input())
E = []
for n in range(N):
    A = int(input())
    for _ in range(A):
        x, y = list(map(int, input().split()))
        E.append((n, x - 1, y))
ans = 0
for k in range((1 << N)):
    status = [(k >> i) & 1 for i in range(N)]
    no_paradox = True
    for Xa, Xb, yb in E:
        if (status[Xa] == 1 and status[Xb] == yb):
            no_paradox = False
            break
    if no_paradox:
        ans = max(ans, sum(l))

N = int(input())
E = []
for n in range(N):
    A = int(input())
    for _ in range(A):
        x, y = list(map(int, input().split()))
        E.append((n, x - 1, y))
ans = 0
for k in range((1 << N) - 1, -1, -1):
    status = [(k >> i) & 1 for i in range(N)]
    no_paradox = True
    for Xa, Xb, yb in E:
        if (status[Xa] == 1 and status[Xb] != yb):
            no_paradox = False
            break
    if no_paradox:
        ans = max(ans, sum(status))
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

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

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

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

honest = []
for i in range(2 ** n):
    flag = 0
    for j in range(n):
        if (i >> j)&1 == 1: 
            for per_sta in xy[j]:
                if (i >> per_sta[0] & 1) != per_sta[1]:
                    flag = 1
                    break
    if flag == 0:
        honest += [bin(i)[2:].count("1")]

print(max(honest))



n = int(input())
a = []
xy = [list() for _ in range(n)]

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


honestnum = []

for i in range(2**n):
    flag = True
    #(if bin(i).count("1") == _:)
    
    for j in range(n):
        if (i>>j)&1 == 1:
            
            for k in range(a[j]):
                if xy[j][k][1] != (i>>(xy[j][k][0]-1)&1):
                    flag = False
                    break
        
    if flag:
        
        honestnum += [bin(i).count("1")]
print(max(honestnum))


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

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

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

N = int(input())

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

ans = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i>>j) & 1 == 1:
            for x, y in proof[j]:
                if (i>>x)&1 != y:
                    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 collections
import itertools

n = int(input())

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

for i in range(n, -1, -1):
  flag = True
  for honests in itertools.combinations(range(n), i):
    for h in honests:
      for x, y in per_dict[h]:
        if y == 1 and x not in honests:
          flag = False 
        if y == 0 and x in honests:
          flag = False
    if flag == True:
      break
  if flag == True:
    break
print(i)



import collections
import itertools

n = int(input())

per_dict = collections.defaultdict(list)
for i in range(n):
  a = int(input())
  for j in range(a):
    x, y = map(int, input().split())
    per_dict[i + 1].append([x,y]) 

for i in range(n, -1, -1):
  flag = True
  for honests in itertools.combinations(range(1, n + 1), i):
    flag = True
    for h in honests:
      for x, y in per_dict[h]:
        if y == 1 and x not in honests:
          flag = False 
        if y == 0 and x in honests:
          flag = False
    if flag == True:
      break
  if flag == True:
    break
print(i)





Verdicts: Wrong Answer

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

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

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

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

N = int(input())

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

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

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())
A=[[] for i in range(n)]
for i in range(n):
  r=int(input())
  for j in range(r):
    A[i].append(list(map(int,input().split())))
ans=0
L=list(itertools.product([0,1],repeat=n))
for i in L:
  T=[]
  for num,j in enumerate(i):
    if j==1:
      for k in A[num]:
        T.append(k)
if all(i[j[0]-1]==j[1] for j in T):
  ans=max(ans,sum(i))
print(ans)

import itertools
n=int(input())
A=[[] for i in range(n)]
for i in range(n):
  r=int(input())
  for j in range(r):
    A[i].append(list(map(int,input().split())))
ans=0
L=list(itertools.product([0,1],repeat=n))
for i in L:
  T=[]
  for num,j in enumerate(i):
    if j==1:
      for k in A[num]:
        T.append(k)
  if all(i[j[0]-1]==j[1] for j in T):
    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())
a=[]
b=[]

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

for i in range(2**n):
      L=[0]*n
      for j in range(n):
            if ((i>>j)&1):
                  L[j]=1
      cc=0
      if 1 in L:
            flag=1
            for k in range(n):
                  if L[k]==1:
                        for m in range(a[k]):
                              if L[b[k][m][0]-1]!=b[k][m][1]:
                                    flag=0
                                    break
            if flag==1:
                  cc=max(sum(L),cc)
print(cc)
                        


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

for i in range(n):
      aa=int(input())
      a.append(aa)
      d=[]
      for j in range(aa):
            x,y=map(int,input().split())
            d.append((x,y))
      b.append(d)
cc=0
for i in range(2**n):
      L=[0]*n
      for j in range(n):
            if ((i>>j)&1):
                  L[j]=1
      if 1 in L:
            flag=True
            for k in range(n):
                  if L[k]==1:
                        for m in range(a[k]):
                              if L[b[k][m][0]-1]!=b[k][m][1]:
                                    flag=False
                                    break
            if flag:
                  cc=max(sum(L),cc)
print(cc)

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 = []


evidences = []
for i in range(n):
    ls = []
    x = int(input())    
    a.append(x)
    for j in range(x):
        l = [int(_) for _ in input().split(' ')]
        ls.append(l)
    evidences.append(ls)

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

honest = 0
for pattern in patterns:
    contradict = False
    for i in range(n):
        for evidence in evidences[i]:
            if(pattern[i] == 1):
                if (pattern[evidence[0]-1] != evidence[1]):
                    contradict = True
                    break
            else:
                if (pattern[evidence[0]-1] == evidence[1]):
                    contradict = True
                    break
    if (contradict == False):
        honest = max(honest, pattern.count(1))

print(honest)

n = int(input())

a = []

evidences = []
for i in range(n):
    ls = []
    x = int(input())
    a.append(x)
    for j in range(x):
        l = [int(_) for _ in input().split(' ')]
        ls.append(l)
    evidences.append(ls)

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

honest = 0
for pattern in patterns:
    contradict = False
    for i in range(n):
        for evidence in evidences[i]:
            if(pattern[i] == 1):
                if (pattern[evidence[0]-1] != evidence[1]):
                    contradict = True
    if (contradict == False):
        honest = max(honest, pattern.count(1))

print(honest)

Verdicts: Wrong Answer

Accepted