qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())

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



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

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

print(ans)

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

N = int(input())

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



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

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

print(ans)
Buggy code:
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)


Fixed code:
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)
Buggy code:
N = int(input())
S = ['']

res = []

for _ in range(N):
    A = int(input())
    s = []
    for _ in range(A):
        s.append(list(map(int, input().split())))
    S.append(s)

allp = 2**N - 1

for i in range(allp, -1, -1):
    pat = bin(i).replace('0b', '')
    pat = pat.zfill(N)
    h_list = []
    l_list = []
    for (i, p) in enumerate(pat):
        t = i + 1
        if p == '1':
            h_list.append(t)
            for s in S[t]:
                if s[1] == 1:
                    if s[0] in l_list:
                        break
                    h_list.append(s[0])
                else:
                    if s[0] in h_list:
                        break
                    l_list.append(s[0])
            else:
                continue
            break
        # else:
        #     l_list.append(t)
        #     for s in S[t]:
        #         if s[1] == 1:
        #             if s[0] in h_list:
        #                 break
        #             l_list.append(s[0])
        #         else:
        #             if s[0] in l_list:
        #                 break
        #             h_list.append(s[0])
        #     else:
        #         continue
        #     break
    else:
        res.append(pat)

maxA = 0
for r in res:
    maxA = max(maxA, r.count('1'))
print(maxA)


Fixed code:
N = int(input())
S = ['']

res = []

for _ in range(N):
    A = int(input())
    s = []
    for _ in range(A):
        s.append(list(map(int, input().split())))
    S.append(s)

allp = 2**N - 1

for i in range(allp, -1, -1):
    pat = bin(i).replace('0b', '')
    pat = pat.zfill(N)
    h_list = []
    l_list = []
    for (i, p) in enumerate(pat):
        t = i + 1
        if p == '1':
            if t in l_list:
                break
            h_list.append(t)
            for s in S[t]:
                if s[1] == 1:
                    if s[0] in l_list:
                        break
                    h_list.append(s[0])
                else:
                    if s[0] in h_list:
                        break
                    l_list.append(s[0])
            else:
                continue
            break
        else:
            if t in h_list:
                break
            l_list.append(t)
            # for s in S[t]:
            #     if s[1] == 1:
            #         if s[0] in h_list:
            #             break
            #         l_list.append(s[0])
            #     else:
            #         if s[0] in l_list:
            #             break
            #         h_list.append(s[0])
            # else:
            #     continue
            # break
    else:
        res.append(pat)

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

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

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

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

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

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

n=int(input())

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

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

print(ans)

Fixed code:
import itertools

n=int(input())

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


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

print(ans)
Buggy code:
n = int(input())
lst = []
for i in range(n):
    a = int(input())
    b = []
    for j in range(a):
        x, y = map(int,input().split())
        x -= 1
        b.append([x, y])
    lst.append(b)
ans = 0

for i in range(2**n):
    honest = []
    honest_F = False

    for j in range(n):
        if i>>j & 1:
            honest.append(j)

    for j in honest:
        honest_F = False
        judge = lst[j]
        for k in judge:
            if k[1] == 1:
                if not k[0] in honest:
                    break
            else:
                if k[0] in honest:
                    break
        else:
            honest_F = True
    if honest_F:
        ans = max(ans, len(honest))

print(ans)

Fixed code:
n = int(input())
lst = []
for i in range(n):
    a = int(input())
    b = []
    for j in range(a):
        x, y = map(int,input().split())
        x -= 1
        b.append([x, y])
    lst.append(b)
ans = 0

for i in range(2**n):
    honest = []
    contradiction_f = False

    for j in range(n):
        if i>>j & 1:
            honest.append(j)

    for j in honest:
        judge = lst[j]
        for k in judge:
            if k[1] == 1:
                if not k[0] in honest:
                    contradiction_f = True
                    break
            else:
                if k[0] in honest:
                    contradiction_f = True
                    break

    if not contradiction_f:
        ans = max(ans, len(honest))

print(ans)
Buggy code:
n=int(input())
w=[[] for i in range(n)]
for i in range(n):
    a=int(input())
    for j in range(a):
        x,y=map(int,input().split())
        w[i].append((x,y))
ans=0
for i in range(1<<n):
    x="0"*15+bin(i)[2:]
    z=[int(i) for i in x[-n:]]
    f=1
    for p,q in enumerate(w):
        if z[p]==1:
            for r in q:
                if (z[r[0]-1]!=r[1]):
                    f=0
    if f:
        ans=max(ans,z.count('1'))
print(ans)

Fixed code:
n=int(input())
w=[[] for i in range(n)]
for i in range(n):
    a=int(input())
    for j in range(a):
        x,y=map(int,input().split())
        w[i].append((x,y))
ans=0
for i in range(1<<n):
    x="0"*15+bin(i)[2:]
    z=[int(i) for i in x[-n:]]
    f=1
    for p,q in enumerate(w):
        if z[p]==1:
            for r in q:
                if (z[r[0]-1]!=r[1]):
                    f=0
    if f:
        ans=max(ans,z.count(1))
print(ans)
Buggy code:
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)

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

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

input = sys.stdin.readline

N = int(input())
A = []
xy = []
ans = []
sm = 0

for _ in range(N):
    temp = int(input())
    A.append([temp, sm])
    sm += temp
    for _ in range(A[-1][0]):
        xy.append(list(map(int, input().split())))

for i in range(2**N):
    flag = True
    binary = bin(i)[2:]
    if len(binary) < N:
        binary = '0' * (N - len(binary)) + binary
    check = [0]*N
    for j, digit in enumerate(binary):
        if digit == '1':
            check[j] = 1

    for j, value in enumerate(check):
        if value == 1:
            for k in range(A[j][0]):
                x = xy[A[j][1]+k-1][0] - 1
                y = xy[A[j][1]+k-1][1]
                if check[x] != y:
                    flag = False
    if flag:
        ans.append(check.count(1))

print(max(ans))

Fixed code:
import sys

input = sys.stdin.readline

N = int(input())
A = []
xy = []
ans = []
sm = 0

for _ in range(N):
    temp = int(input())
    A.append([temp, sm])
    sm += temp
    for _ in range(A[-1][0]):
        xy.append(list(map(int, input().split())))
for i in range(2**N):
    flag = True
    binary = bin(i)[2:]
    if len(binary) < N:
        binary = '0' * (N - len(binary)) + binary
    check = [0]*N
    for j, digit in enumerate(binary):
        if digit == '1':
            check[j] = 1
    for j, value in enumerate(check):
        if value == 1:
            for k in range(A[j][0]):
                x = xy[A[j][1]+k][0] - 1
                y = xy[A[j][1]+k][1]
                if check[x] != y:
                    flag = False
    if flag:
        ans.append(check.count(1))

print(max(ans))
Buggy code:
n = int(input())

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


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

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

print(ans)




Fixed code:
n = int(input())

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


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

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

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

print(ans)
Buggy code:
import itertools

n=int(input())

lst=[[] for i in range(n)] 

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

ans=0


for xxx in itertools.product(range(2),repeat=n):
    table=[[] for i in range(n)]
    for j in range(n):
        if xxx[j]==1:
            for k in lst[j]:
                table[k[0]].append(k[1])
    
    flag=True

    for j in range(n):
        if xxx[j]==1:
            if 0 in table[j]:
                flag=False
        
        else:
            if 1 in table[j]:
                flag=False
    
    if not flag:
        continue

    ans=max(ans,xxx.count(1))



print(ans)

Fixed code:
import itertools

n=int(input())

lst=[[] for i in range(n)] 

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

ans=0


for xxx in itertools.product(range(2),repeat=n):
    table=[[] for i in range(n)]
    for j in range(n):
        if xxx[j]==1:
            for k in lst[j]:
                table[k[0]].append(k[1])
    
    flag=True

    for j in range(n):
        if xxx[j]==1:
            if table[j].count(0)!=0:
                flag=False
        
        else:
            if table[j].count(1)!=0:
                flag=False
    

    if not flag:
        continue
    

    ans=max(ans,xxx.count(1))



print(ans)
Buggy code:
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)
        

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

Fixed code:
n = int(input())
peaple = []
for i in range(n):
  a = int(input())
  tests = []
  for j in range(a):
    x, y = input().split()
    tests.append((int(x) - 1, y))
  peaple.append(tests)
  
maximum = 0
for h_bit in range(1, 1<<n):
  h_str = format(h_bit, '0{}b'.format(n))
  flag = False
  for i in range(n):
    if h_str[i] == '1':
      for test in peaple[i]:
        if h_str[test[0]] != test[1]:
          flag = True
          break
    if flag:
      break
  if not flag:
    maximum = max(maximum, h_str.count('1'))
print(maximum)
Buggy code:
N=int(input())
shogen=[]
count_ans=[]
for i in range(N):
    A=int(input())
    shogen.append([list(map(int,input().split())) for i in range(A)])
def saiki(A):
    if len(A)==N:
        honest=set()
        honest_kari=set()
        unkind=set()
        count=0
        unkind_kari=set()
        for i in range(N):
            if A[i]==1:
                honest.add(i)
            else:
                unkind.add(i)
        for i in range(N):
            if i in honest:
                for j in range(len(shogen[i])):
                    if shogen[i][j][1]==0:
                        unkind_kari.add(shogen[i][j][0])
                    else:
                        honest_kari.add(shogen[i][j][0])
        for i in honest:
            if i not in unkind_kari:
                if i not in unkind:
                    count+=1
        for i in unkind:
            if i not in honest_kari:
                if i not in honest:
                    count+=1
        if count==len(unkind_kari)+len(honest_kari):
            count_ans.append(len(honest))

        
        return
    for i in range(2):
        A.append(i)
        saiki(A)
        A.pop()
saiki([])
print(max(count_ans))

Fixed code:
N=int(input())
shogen=[]
count_ans=[]
for i in range(N):
    A=int(input())
    shogen.append([list(map(int,input().split())) for i in range(A)])
#print(shogen)
def saiki(A):
    if len(A)==N:
        honest=set()
        honest_kari=set()
        unkind=set()
        count=0
        unkind_kari=set()
        for i in range(N):
            if A[i]==1:
                honest.add(i)
            else:
                unkind.add(i)
        for i in range(N):
            if i in honest:
                for j in range(len(shogen[i])):
                    if shogen[i][j][1]==0:
                        unkind_kari.add(shogen[i][j][0]-1)
                    else:
                        honest_kari.add(shogen[i][j][0]-1)
        #print(honest,honest_kari)
        for i in unkind_kari:
            if i in unkind:
                count+=1
        for i in honest_kari:
            if i in honest:
                count+=1
        if count==len(unkind_kari)+len(honest_kari):
            kari=set(list(honest)+list(honest_kari))
            #print(honest,honest_kari,count)
            count_ans.append(len(kari))

        
        return
    for i in range(2):
        A.append(i)
        saiki(A)
        A.pop()
saiki([])
print(max(count_ans))