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):
def main():
    N = int(input())
    S = [[] * N for i in range(N)]
    ans = 0

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

    P = [0]*N

    for i in range(2**N):
        for j in range(N):
            if P[j] == 0:
                P[j] = 1
                break
            else:
                P[j] = 0

        if sum(P) <= ans:
            continue
        flag = 0
        for p in range(len(P)):
            if P[p] == 1:
                for s in S[p]:
                    if s[1]!= P[s[0]]:
                        flag = 1
        if flag == 1:
            continue
        else:
            ans = sum(P)

    print(ans)


 
if name == 'main':
    main()


def main():
    N = int(input())
    S = [[] * N for i in range(N)]
    ans = 0

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

    P = [0]*N

    for i in range(2**N):
        for j in range(N):
            if P[j] == 0:
                P[j] = 1
                break
            else:
                P[j] = 0

        if sum(P) <= ans:
            continue
        flag = 0
        for p in range(len(P)):
            if P[p] == 1:
                for s in S[p]:
                    if s[1]!= P[s[0]]:
                        flag = 1
        if flag == 1:
            continue
        else:
            ans = sum(P)

    print(ans)


 
if name == 'main':
    main()

def main():
    N = int(input())
    S = [[] * N for i in range(N)]
    ans = 0

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

    P = [0]*N
    
    for i in range(2**N):
        for j in range(N):
            if P[j] == 0:
                P[j] = 1
                break
            else:
                P[j] = 0
        
        if sum(P) <= ans:
            continue
        flag = 0
        for p in range(len(P)):
            if P[p] == 1:
                for s in S[p]:
                    if s[1]!= P[s[0]]:
                        flag = 1
        if flag == 1:
            continue
        else:
            ans = sum(P)
        
    print(ans)


 
if __name__ == '__main__':
    main()

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())
ListN=[]*
List = []
keepOrder
for i in range(N):
  k = int(input())
  ListN.append(k)
  for j in range(k):
    List.append(list(map(int, input().split())))
for bits in range(2**N):
  keepOrder = list(bin(bits))
  flag= True
  print(bits,keepOrder)
  for j in range(N):
    if((bits>>j) & 1): 
      for k in range(ListN[j]):
        if keepOrder[List[k][0]-1]!=List[k][1]:
          flag = False
    else:
        if keepOrder[List[k][0]-1]==List[k][1]:
          flag = False
  if flag:
    res = max(res,keepOrder.count("1")
print(res)

N = int(input())
ListN=[0]
List = []
res =0
flag = True
mid =0
n =0
for i in range(N):
  k = int(input())
  n += k
  ListN.append(n)
  for j in range(k):
    List.append(list(map(int, input().split())))
#print(List)
for bits in range(2**N):
  mid=0
  flag= True
  for j in range(N):
    #print(bits,j,((bits>>j) & 1))
    if((bits>>j) & 1): 
      mid+= 1
      #print(ListN[j],ListN[j+1])
      for k in range(ListN[j],ListN[j+1]):
        mynum = bits
        #print(bits,List[k][0],(mynum>>List[k][0])&1, List[k][1])
        if ((mynum>>List[k][0]-1)&1) != List[k][1]:
          flag = False
          break
  #print(bits,flag,mid)
  if flag:
    res = max(res,mid)
print(res)

Verdicts: Runtime Error

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

Submission attempts (in order):
N = int(input())
L = []
for i in range(N):
  A = int(input())
  LA = []
  for j in range(A):
    LA.append(list(map(int,input().split())))
  L.append(LA)
from itertools import product
LL = list(product(range(2), repeat=N))
cnt = 0
for i in LL:
  flg = True
  print(i)
  for j in range(len(L)):
    
    
    for x,y in L[j]:
      
      
      
      if i[j]==0:
        if y == 0:
          y = 1
        else:
          y = 0
      if i[x-1]!=y:
        flg = False
        break
  if flg:
    cnt = max(cnt,sum(i))
print(cnt)


N = int(input())
L = []
for i in range(N):
  A = int(input())
  LA = []
  for j in range(A):
    LA.append(list(map(int,input().split())))
  L.append(LA)
cnt = 0

for i in range(2**N):
  flg = True
  for j in range(len(L)):
    
    
    for x,y in L[j]:
      
      
      
      if (i >> j) & 1 == 1:
        if i>>(x-1) & 1 !=y:
          flg = False
          break
  if flg:
    cnt = max(cnt,bin(i).count('1'))
print(cnt)

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

times = n
table = []
for _ in range(times):
    a = int(input())
    temp = []
    for _ in range(a):
        temp.append(list(map(int,input().split())))
    table.append(temp)  
    
def check(i,n):
    honestOrUnkind = [None]*n
    honestOrUnkind[i] = 1
    for item in table[i]:
        membernum = item[0]-1
        honestOrUnkind[membernum] = item[1]
    for idx,hOrU in enumerate(honestOrUnkind):
        if hOrU == 1:
            for item in table[idx]:
                membernum = item[0]-1
                if honestOrUnkind[membernum] != item[1]:
                    return False,honestOrUnkind
                else:
                    honestOrUnkind[membernum] = item[1]
        else:
            continue    
    return True,honestOrUnkind

member = [None]*n
ans = 0
for i in range(n):
    flg , memberlist = check(i,n)
    if flg:
        member[i] = 1
        ans = max(memberlist.count(1),ans)
    else:
        member[i] = 0
    
ans = max(member.count(1),ans)

print(ans)


n = int(input())

times = n
table = []
for _ in range(times):
    a = int(input())
    temp = []
    for _ in range(a):
        x , y = map(int,input().split())
        temp.append([x-1,y])
    table.append(temp)  
    
def check(i,n):
    flg = True
    for j in range(n):
        if i>>j & 1:
            for x,y in table[j]:
                if (i>>x)%2 != y:
                    flg = False
                    # print(flg)
                    return flg
    # print(flg)
    return flg

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

print(ans)


Verdicts: Wrong Answer

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

Submission attempts (in order):

N = int(input())
A = list(map(int, input().split()))


x = [  A[i]^A[j] for i in range(N-1) for j in range(i+1,N) ]
kotae =sum(x) % (10**9 +7)
print(kotae)

from itertools import product

N = int(input())
testimony ={j:[-1 for i in range(N)] for j in range(1,N+1)}
A=[]
for i in range(1,N+1):
    a = int(input())
    A.append(a)
    for j in range(a):
        x,y = list(map(int, input().split()))
        testimony[i][x-1] =y



assumption_correct =[]
for assumption in product([1,0], repeat=N):
    count_2=0
    for i in range(N):      
        if assumption[i] ==1:
            count =0 
            for j in range(N):  
                         
                if testimony[i+1][j] ==assumption[j]:
                    count +=1
            if count == A[i]:
                count_2 +=1
    if count_2 ==sum(assumption):
        assumption_correct.append(sum(assumption))
print(max(assumption_correct))

Verdicts: Runtime Error

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

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

N=2**n
ans=[]
for k in range(N):
    c=format(k,"b")
    cha=c.zfill(n)
    cnt=0
    mis=0
 
    for l in range(n):
        if cha[l]==1 and mis==0:
            for m in range(cnt,cnt+a[l]):
                if y[m]==0:
                  if cha[x[m]-1]!=0:
                    mis+=1
                    cnt+=a[l] 
                    break
                  else:
                      if m==cnt+a[l]-1:
                          cnt+=a[l]      
                else:
                  if cha[x[m]-1]!=1:
                    mis+=1
                    cnt+=a[l] 
                    break
                  else:
                      if m==cnt+a[l]-1:
                          cnt+=a[l]                     
        elif cha[l]==0 and mis==0:
            for m in range(cnt,cnt+a[l]):
                if y[m]==0:
                  if cha[x[m]-1]==0:
                    mis+=1
                    cnt+=a[l] 
                    break
                  else:
                      if m==cnt+a[l]-1:
                          cnt+=a[l] 
                else:
                  if cha[x[m]-1]==1:
                    mis+=1
                    cnt+=a[l] 
                    break
                  else:
                      if m==cnt+a[l]-1:
                          cnt+=a[l]                
        elif mis!=0:
            break        
    if mis==0:
        ans.append(cha.count("1"))
   
    
print(max(ans))        


from itertools import product
n=int(input())
li=[[] for _ in range(n)]
A=[]
for i in range(n):
    a=int(input())
    A.append(a)
    for _ in range(a):
        x,y=map(int,input().split())
        li[i].append([x,y])
ans=0
for p in product([0, 1], repeat = n):
    f = 0
    for i in range(n):
        if f==0:
            for j in range(A[i]):
                if p[i]==1 and li[i][j][1] == 0:
                    if p[li[i][j][0] - 1] == 1:
                        f += 1
                        break
                elif p[i]==1 and li[i][j][1] == 1:
                    if p[li[i][j][0] - 1] == 0:
                        f += 1
                        break
        else:
            break
    if f==0:
        ans=max(ans,p.count(1))
print(ans)







Verdicts: Wrong Answer

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

Submission attempts (in order):
import itertools

n=int(input())
H,L=[[] for _ in range(n)],[[] for _ in range(n)]

for i in range(n):
  m=int(input())
  for j in range(m):
    x,y=map(int,input().split())
    if y==1:
      H[i].append(x-1)
    else:
      L[i].append(x-1)
      
N=set(range(n))
ans=0
item={num:com  for num in range(1,n+1) for com in list(itertools.combinations(range(n),num))}
for k,v in item.items():
    num=k
    h=set(v)
    nh=N-h
    t=sum([H[i] for i in h],[])
    l=sum([L[i] for i in h],[])
    if set(t)<=h and set(l)<=nh:
      ans=max(ans,num)
print(ans)

import itertools
 
n=int(input())
H,L=[[] for _ in range(n)],[[] for _ in range(n)]
 
for i in range(n):
  m=int(input())
  for j in range(m):
    x,y=map(int,input().split())
    if y==1:
      H[i].append(x-1)
    else:
      L[i].append(x-1)
      
N=set(range(n))
ans=0
for num in range(1,n+1):
  pat=set(itertools.combinations(range(n),num))
  for h in pat:
      h=set(h)
      num=len(h)
      nh=N-h
      t=sum([H[i] for i in h],[])
      l=sum([L[i] for i in h],[])
      if set(t)<=h and set(l)<=nh:
        ans=max(ans,num)
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())

l = []
for i in range(2**n,,-1):
  l += ['{:0=3}'.format(int(str(bin(i))[2:]))]

print(l)

A=[]
for i in range(n:=int(input())):
  for _ in range(int(input())): x,y=map(int,input().split()); A+=[(i,x-1,y)]
print(max(sum(map(int,bin(i)[2:]))*all(i>>j&1<1 or i>>x&1==y for j,x,y in A) for i in range(2**n)))

Verdicts: Runtime Error

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

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

TF = [-1 for i in range(n)]
Fset = []
l = [[-1 for j in range(n)] for i in range(n)]
for i in range(n):
    lena = int(input())
    for j in range(lena):
        x, y = map(int, input().split())
        l[i][x-1] = y

for i in range(n):
    for j in range(n):
        if i != j:
            if l[i][j]+l[j][i] == 1:
                TF[i] = 0
                TF[j] = 0
            if l[i][j]+l[j][i] == 0:
                Fset.append((i, j))
            for k in range(n):
                if l[i][j] >= 0 and l[i][j] != l[i][k]:
                    Fset.append((j,k))


print(Fset)


n = int(input())

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


ans = 0
for i in range(2 ** n):
    bag = 0
    ok = 0
    for j in range(n):
        if (i >> j) & 1:
            bag += 1
            for x,y in deps[j]:
                if (i >> x-1) & 1:
                    if y != 1:
                        ok = -1
                else:
                    if y == 1:
                        ok = -1
    if ok == 0:
        ans = max(ans,bag)

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 = [[] for i in range(n)]
num_of_testimony = []
for i in range(n):
    for a in range(int(input())):
        num_of_testimony.append(a)
        x,y = map(int, input().split())
        testimony[i].append([x,y])
#print(testimony)
honest = 0
for i in range(2**n):
    Flag = True
    for j in range(n):
        if (i>>j)&1:
            for x,y in testimony[j]:
                if (i>>x)&1 != y:
                    flag = False
                    break
    if Flag:
        honest = max(honest, bin(i)[2:].count('1'))
print(honest)

n = int(input())
testimony = [[] for _ 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))
honest = 0
for i in range(2**n):
    flag = True
    for j in range(n):
        if (i>>j)&1:
            for x,y in testimony[j]:
                if (i>>(x-1))&1 != y:
                    flag = False
                    break
    if flag:
        honest = max(honest, bin(i)[2:].count('1'))
print(honest)


Verdicts: Wrong Answer

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

Submission attempts (in order):
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-


def main():
    N = int(input())
    XY = [[] for _ in range(N)]
    for i in range(N):
        A = int(input())
        XY[i] = [list(map(int, input().split())) for _ in range(A)]

    max_H = 0
    for i in range(2**N):
        bin = format(i, '015b')[::-1]
        ok = True

        for j in range(N):
            for x, y in XY[j]:
                if bin[j] == '1' and y != int(bin[x - 1]):
                    ok = False
                    break
                else:
                    continue
                break
        if ok:
            H = sum(int(x) for x in bin)
            max_H = max(max_H, H)
        print(max_H)


if __name__ == "__main__":
    main()


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


def main():
    N = int(input())
    XY = [[] for _ in range(N)]
    for i in range(N):
        A = int(input())
        XY[i] = [list(map(int, input().split())) for _ in range(A)]

    max_H = 0
    for i in range(2**N):
        bin = format(i, '015b')[::-1]
        ok = True

        for j in range(N):
            for x, y in XY[j]:
                if bin[j] == '1' and y != int(bin[x - 1]):
                    ok = False
                    break
                else:
                    continue
                break
        if ok:
            H = sum(int(x) for x in bin)
            max_H = max(max_H, H)
    print(max_H)


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):
# -*- coding: utf-8 -*-
"""
Created on Sun Dec  8 21:12:35 2019

@author: over-
"""

N=int(input())
A=dict()
x=dict()
y=dict()
for i in range(1,N+1):
    A[i]=int(input())
    x[i]=dict()
    y[i]=dict()
    for j in range(A[i]):
        a1,a2=map(int,input().split())
        x[i][j+1]=a1
        y[i][j+1]=a2

C=2**N
ans=0
for c in range(C):
    honest=[]
    unkind=[]
    B='{:0b}'.format(c)
    B='0'*(N-len(B))+B
    bool=True
    for i in range(N):
        if B[i]==0:
            honest.append(i+1)
        else:   
            unkind.append(i+1)
        
    for k in range(1,N+1):
        if k in honest:
            for j in range(A[k]):
                if y[k][j+1]==1:
                    if x[k][j+1] in unkind:
                        bool=False
                else:
                    if x[k][j+1] in honest:
                        bool=False
    if bool: 
        count=0
        for i in range(N):
            count+=int(B[i])
        if count > ans:
            ans= count
                        
print(count)        
                        


# -*- coding: utf-8 -*-
"""
Created on Sun Dec  8 21:12:35 2019

@author: over-
"""

N=int(input())
A=dict()
x=dict()
y=dict()
for i in range(1,N+1):
    A[i]=int(input())
    x[i]=dict()
    y[i]=dict()
    for j in range(A[i]):
        a1,a2=map(int,input().split())
        x[i][j+1]=a1
        y[i][j+1]=a2

C=2**N
ans=0
for c in range(C):
    honest=[]
    unkind=[]
    B='{:0b}'.format(c)
    B='0'*(N-len(B))+B
    bool=True
    for i in range(N):
        if int(B[i])==0:
            honest.append(i+1)
        else:   
            unkind.append(i+1)
        
    for k in range(1,N+1):
        if k in honest:
            for j in range(A[k]):
                if y[k][j+1]==1:
                    if x[k][j+1] in unkind:
                        bool=False
                else:
                    if x[k][j+1] in honest:
                        bool=False
    if bool: 
        if len(honest) > ans:
            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):
N = int(input())
A = []
XY = []
honest_count = []

for i in range(N):
    a = int(input())
    A.append(a)
    inter = []
    for x in range(a):
        xy = list(map(int,input().split()))
        inter.append(xy)
    XY.append(inter)
    print(XY)

for i in range(2**N):
    pt = [0]*N
    ck = 1
    for j in range(N):
        if (i>>j)&1:
            pt[N-j-1]=1
    for k in range(N):
        if pt[k] ==1:
            for l in range(A[k]):
                if XY[k][l][1] != pt[XY[k][l][0] -1]: 
                    ck = 0
    if ck == 1:
        honest_count.append(sum(pt))
print(max(honest_count))


N = int(input())
A = []
XY = []
honest_count = []

for i in range(N):
    a = int(input())
    A.append(a)
    inter = []
    for x in range(a):
        xy = list(map(int,input().split()))
        inter.append(xy)
    XY.append(inter)
    

for i in range(2**N):
    pt = [0]*N
    ck = 1
    for j in range(N):
        if (i>>j)&1:
            pt[N-j-1]=1
    for k in range(N):
        if pt[k] ==1:
            for l in range(A[k]):
                if XY[k][l][1] != pt[XY[k][l][0] -1]: 
                    ck = 0
    if ck == 1:
        honest_count.append(sum(pt))
print(max(honest_count))


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():
    z = [-1] * 10
    xy = []
    n = int(input())
    for _ in range(n):
        a = int(input())
        xy.append([list(map(int, input().split())) for _ in range(a)])
    ans = 0
    
    for a in range(2**n):
        c = []
        for b in range(n):
            c.append(a >> b & 1)
       
        flag = True
                        
        if flag:
            ans = max(ans, sum(c))
    
    print(ans)
        
    
if __name__ == '__main__':
    main()


def main():
    z = [-1] * 10
    xy = []
    n = int(input())
    for _ in range(n):
        a = int(input())
        xy.append([list(map(int, input().split())) for _ in range(a)])
    
    print(0)
        
    
if __name__ == '__main__':
    main()

@patch('builtins.input', test.test_input)
def main():
    z = [-1] * 10
    xy = []
    n = int(input())
    for _ in range(n):
        a = int(input())
        xy.append([list(map(int, input().split())) for _ in range(a)])
    ans = 0
    print(0)
        
    
if __name__ == '__main__':
    main()

def main():
    xy = []
    n = int(input())
    for _ in range(n):
        a = int(input())
        xy.append([list(map(int, input().split())) for _ in range(a)])
    ans = 0
    
    for a in range(2**n):
        c = []
        for b in range(n):
            c.append(a >> b & 1)
       
        flag = True
        for i in range(n):
            if c[i] == 1:
                for x, y in xy[i]:
                    if c[x - 1] != y:
                        flag = False
                        
        if flag:
            ans = max(ans, sum(c))
    
    print(ans)
        
    
if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

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())
syo=[]
mx=0
for i in range(n):
  a=int(input())
  gen=[]
  for j in range(a):
    x,y=map(int,input().split())
    gen.append([x-1,bool(y)])
  syo.append(gen)
brk=False
for i in range(2**n):
  table=[False]*n
  for j in range(n):
    if((i>>j)&1):
      table[j]=True
  for j in range(n):
    if table[j]==False:
      brk=True
      break
    brk=False
    for syogen in syo[j]:
      if table[syogen[0]]!=syogen[1]:
        brk=True
        break
    if brk:
      break
  if brk:
    continue
  cnt=table.count(True)
  if cnt>mx:
    mx=cnt
print(mx)
        

n=int(input())
syo=[]
mx=0
for i in range(n):
  a=int(input())
  gen=[]
  for j in range(a):
    x,y=map(int,input().split())
    gen.append([x-1,bool(y)])
  syo.append(gen)
brk=False
for i in range(2**n):
  table=[False]*n
  for j in range(n):
    if((i>>j)&1):
      table[j]=True
  for j in range(n):
    if table[j]==False:
      continue
    for syogen in syo[j]:
      if table[syogen[0]]!=syogen[1]:
        brk=True
        break
    if brk:
      break
  if brk:
    continue
  cnt=table.count(True)
  if cnt>mx:
    mx=cnt
print(mx)
        

n=int(input())
syo=[]
mx=0
for i in range(n):
  a=int(input())
  gen=[]
  for j in range(a):
    x,y=map(int,input().split())
    gen.append([x-1,bool(y)])
  syo.append(gen)
for i in range(2**n):
  brk=False
  table=[False]*n
  for j in range(n):
    if((i>>j)&1):
      table[j]=True
  for j in range(n):
    if table[j]==False:
      continue
    for syogen in syo[j]:
      if table[syogen[0]]!=syogen[1]:
        brk=True
        break
    if brk:
      break
  if brk:
    continue
  cnt=table.count(True)
  if cnt>mx:
    mx=cnt
print(mx)
        

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())
ans=0
g[[-1 for i in range(n)] for j in range(n)]
for i in range(n):
  a=int(input())
  for j in range(a):
    x,y=map(int,input().split())
    g[i][x-1]=y
for i in range(2**n):
  ok=True
  for j in range(n):
    if (i>>j)&1:
      for k in range(n):
        if g[j][k]==-1:
          continue
        if (i>>j)&1!=g[j][k]:
          ok=False
  if ok:
    d=str(bin(i))
    t=d.count('1')
    ans=max(t,ans)
print(ans)
    
    
      

n=int(input())
ans=0
g=[[-1 for i in range(n)] for j in range(n)]
for i in range(n):
  a=int(input())
  for j in range(a):
    x,y=map(int,input().split())
    g[i][x-1]=y
for i in range(2**n):
  ok=True
  for j in range(n):
    if (i>>j)&1:
      for k in range(n):
        if g[j][k]==-1:
          continue
        if (i>>k)&1!=g[j][k]:
          ok=False
  if ok:
    d=i
    t=str(bin(d)).count('1')
    ans=max(t,ans)
print(ans)

Verdicts: Runtime Error

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

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

evi=[[] for _ in range(N)]

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

ans=0

for i in range(2**N):
    cnt=0
    f=True
    print(bin(i))
    for j in range(N):
        if (i>>j)&1:
            cnt+=1
            for x,y in evi[j]:
                if (i>>x)&1 and y==0:
                    f=False
                    break
                if (i>>x)&0 and y==1:
                    f=False
                    break
        if not f:
            break
        ans=max(ans,cnt)

print(ans)  


N=int(input())

evi=[[] for _ in range(N)]

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

ans=0

for i in range(2**N):
    cnt=0
    f=True
    for j in range(N):
        if (i>>j)&1:
            cnt+=1
            for x,y in evi[j]:
                if (i>>x)&1 and y==0:
                    f=False
                    break
                elif (not (i>>x)&1) and y==1:
                    f=False
                    break
        if not f:
            break
    if f:
        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())
 
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(0, 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
                    print(flag)
                    break
    if flag == 0: 
        honest = max(honest, bin(i)[0:].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
                    print(flag)
                    break
    if flag == 0: 
        honest = max(honest, bin(i)[2:].count('1')) 
print(honest)


N = int(input())
 
testimony = [[] for _ in range(N)]
 
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])
        
honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1 == 1: 
            for x,y in testimony[j]:
                if (i>>x)&1 != y: 
                    flag = 1
                    break
    if flag == 0: 
        honest = max(honest, bin(i)[2:].count('1')) 
print(honest)

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
n = int(input())
l = []
for _ in range(n):
    m = int(input())
    l.append([[int(i) for i in input().split()]for _ in range(m)])
    
ans = [float('inf') for _ in range(n)]

for i in l:
    for j in i:
        print(i,j,ans)
        if ans[j[0]-1] != j[1] and ans[j[0]-1] != float('inf'):
            ans[j[0]-1] = 0
        else:
            ans[j[0]-1] = j[1]
            
if sum(ans) == 0:
    print(1)
else:
    print(n)

n = int(input())
l = [[-1 for _ in range(n)] for _ in range(n)]
for i in range(n):
    m = int(input())
    for j in range(m):
        x,y = [int(i) for i in input().split()]
        l[i][x-1] = y
        
ans = 0
for i in range(1<<n):
    honests = [0 for _ in range(n)]
    for j in range(n):
        if (i >> j) & 1:
            honests[j] = 1
    flg = 1
    for k in range(n):
        if honests[k]:
            for h in range(n):
                if l[k][h] == -1 : continue
                if l[k][h] != honests[h] : flg = 0
    
    if flg:
        ans = max(ans,sum(honests))
        
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 = [0]*n
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        tmp1,tmp2 = list(map(int,input().split()))
        x[i].append(tmp1-1)
        y[i].append(tmp2)

ans = 0
honest = [0]*n
cnt=0
for i in range(2**n): 
    for j in range(n):
        if((i>>j)&1):
            honest[j] = 1
            cnt+=1
        else:
            honest[j] = 0
            
        f = True
        for k in range(n):
            if honest[k]!=1:
                f = False
                break
            for l in range(a[k]):
                if y[k][l]!=honest[x[k][l]]:
                    f = False
                    break
            if f:
                ans = max(ans,cnt)
        cnt=0

print(ans)

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

ans = 0
honest = [0]*n
cnt=0
for i in range(2**n): 
    for j in range(n):
        if((i>>j)&1):
            honest[j] = 1
            cnt+=1
        else:
            honest[j] = 0
            
        f = True
        for k in range(n):
          	if honest[k]!=1:
                f = False
                break
            for l in range(a[k]):
                if( and y[k][l]!=honest[x[k][l]]):
                    f = False
                    break
        	if f:
            	ans = max(ans,cnt)
        cnt=0

print(ans)

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

ans = 0
honest = [0]*n
cnt=0
for i in range(2**n): 
    for j in range(n):
        if((i>>j)&1):
            honest[j] = 1
            cnt+=1
        else:
            honest[j] = 0
            
    f = True
    for k in range(n):
        if honest[k]!=1:
            continue
        for l in range(a[k]):
            if y[k][l]!=honest[x[k][l]]:
                f = False
                break
    if f:
        ans = max(ans,cnt)
    cnt=0

print(ans)

Verdicts: Wrong Answer

Runtime Error

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

Submission attempts (in order):
N = int(input())
x = []
y = []
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())
x = []
y = []
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

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

Submission attempts (in order):
from collections import Counter
N = int(input())
ans = 0
evidence = [[] for n in range(N)]

for n in range(N):
    A = int(input())
    for a in range(A):
        lis = list(map(int, input().split()))
        evidence[n].append(lis)

for n in range(1 << N):
    bits = [(n >> i) & 1 for i in range(N)]
    boolean = True
    for i in range(N):
        if (n >> i) & 1 == 0:
            continue
        for x, y in evidence[i]:
            if bits[x-1] == y:
                continue
            flag = False
    if flag:
        ans = max(ans, sum(bits))
print(ans)

from collections import Counter
N = int(input())
ans = 0
evidence = [[] for n in range(N)]

for n in range(N):
    A = int(input())
    for a in range(A):
        lis = list(map(int, input().split()))
        evidence[n].append(lis)

for n in range(1 << N):
    bits = [(n >> i) & 1 for i in range(N)]
    flag = True
    boolean = True
    for i in range(N):
        if (n >> i) & 1 == 0:
            continue
        for x, y in evidence[i]:
            if bits[x-1] == y:
                continue
            flag = False
    if flag:
        ans = max(ans, sum(bits))
print(ans)

Verdicts: Runtime Error

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

Submission attempts (in order):

if N == 1:
    print(1)
    exit()


l = [0,1]
H = []

for i in range(2**N+1):
    S = str(bin(i)).zfill(N)
    H.append(S[2:].zfill(N))

IXY = []
for i in range(1,N+1):
    t = int(input())
    for j in range(t):
        x,y = map(int,input().split())
        
        IXY.append([i,x,y])

ANS = []
for h in H:
    flg = True
    for ixy in IXY:
        i,x,y = ixy[0]-1,ixy[1]-1,ixy[2]
        if h[i] == "1" and h[x] != str(y):
            flg = False
            break
    if flg:ANS.append(h)

ans = 0
for a in ANS:
    ans = max(a.count("1"),ans)
print(ans)

N = int(input())


if N == 1:
    print(1)
    exit()



H = []
for i in range(2**N):
    S = str(bin(i))
    H.append(S[2:].zfill(N))

IXY = []
for i in range(N):
    t = int(input())
    for j in range(t):
        x,y = map(int,input().split())
        
        IXY.append([i,x,y])

ans = 0
for h in H:
    cnt = h.count("1")
    for ixy in IXY:
        i,x,y = ixy[0],ixy[1]-1,ixy[2]
        if h[i] == "1" and h[x] != str(y):
            cnt = 0
            break
    ans = max(ans,cnt)
print(ans)

Verdicts: Runtime Error

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

Submission attempts (in order):
n = int(input())
HOU = []
for i in range(n):
    tmp = int(input())
    for _ in range(tmp):
        x, y = (map(int, input().split()))
        HOU.append([i, x - 1, bool(y)])

anssum = 0
for i in range(2 ** n):
    flag = True
    #print(bin(i))
    for j in range(len(HOU)):
        print(i >> HOU[j][0] & 1, HOU[j][0])
        if (i >> HOU[j][0]) & 1:
            if HOU[j][2] == i >> HOU[j][1] & 1:
                continue
            else:
                flag = False
                break
        else:
            if HOU[j][2] != i >> HOU[j][1] & 1:
                continue
            else:
                flag = False
                break


    if flag:
        anssum = max(anssum,str(bin(i)).count('1'))

print(anssum)

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

anssum = 0
for i in range(2 ** n):
    flag = True
    for j in range(len(HOU)):
        if (i >> HOU[j][0]) & 1:
            if HOU[j][2] == i >> HOU[j][1] & 1:
                continue
            else:
                flag = False
                break
        else:
            if not (i >> HOU[j][0]) & 1:
                continue
            else:
                flag = False
                break


    if flag:
        anssum = max(anssum,str(bin(i)).count('1'))

print(anssum)

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):
ans=0
shogen=[]
n=int(input())
for _ in range(n):
  t=[]
  a=int(input())
  for __ in range(a):
    h=list(map(int,input().split()))
    t.append(s)
  shogen.append(t)
for i in range(2**n):
  flag=True
  for j in range(n):
    if not flag:
      break
    if ((i>>j) & 1):
      for h in shogen[j]:
        if ((i>>h[0]-1)&1) !=h[1]:
          flag=False
  if flag:
    mnt = bin(i).count("1")
    ans=max(ans,mnt)
print(ans)


ans=0
shogen=[]
n=int(input())
for _ in range(n):
  t=[]
  a=int(input())
  for __ in range(a):
    h=list(map(int,input().split()))
    t.append(h)
  shogen.append(t)
for i in range(2**n):
  flag=True
  for j in range(n):
    if not flag:
      break
    if ((i>>j) & 1):
      for h in shogen[j]:
        if ((i>>h[0]-1)&1) !=h[1]:
          flag=False
  if flag:
    mnt = bin(i).count("1")
    ans=max(ans,mnt)
print(ans)


Verdicts: Runtime Error

Accepted