qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import copy

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

print(X)

def rec(condition, i):
  if i==N:
    return condition.count(1)
  _X = X[i]
  _condition = copy.copy(condition)
  through_condition = copy.copy(condition)
  through_condition[i] = 0
  if condition[i]==0:
    return rec(copy.copy(through_condition), i+1)
  for x in _X:
    if _condition[ x[0]-1 ] == -1:
      _condition[ x[0]-1 ] = x[1]
    elif _condition[ x[0]-1 ] != x[1]:
      return 0 if _condition[i]==1 else rec(copy.copy(through_condition), i+1)
  _condition[i] = 1
  return max(rec(copy.copy(through_condition), i+1), rec(copy.copy(_condition), i+1))

print( rec([-1 for _ in range(N)], 0) )


Fixed code:
import copy

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

def rec(condition, i):
  if i==N:
    return condition.count(1)
  _X = X[i]
  _condition = copy.copy(condition)
  through_condition = copy.copy(condition)
  through_condition[i] = 0
  if condition[i]==0:
    return rec(copy.copy(through_condition), i+1)
  for x in _X:
    if _condition[ x[0]-1 ] == -1:
      _condition[ x[0]-1 ] = x[1]
    elif _condition[ x[0]-1 ] != x[1]:
      return 0 if _condition[i]==1 else rec(copy.copy(through_condition), i+1)
  _condition[i] = 1
  return max(rec(copy.copy(through_condition), i+1), rec(copy.copy(_condition), i+1))

print( rec([-1 for _ in range(N)], 0) )
Buggy code:
n = int(input())
v = [[tuple(map(int, input().split()))for i in range(int(input()))] for i in range(n)]

ans = 0
for i in range(2**n):
    f = [False]*n
    xy = []
    for j in range(n):
        if (i >> j) & 1:
            f[j] = True
            xy.append(v[j])
    flag = True
    for xyi in xy:
        for x,y in xyi:
            if not (f[x-1] and y):
                flag = False
                break
    if flag:
        ans = max(ans,len(xy))
print(ans)

Fixed code:
n = int(input())
v = [[tuple(map(int, input().split()))for i in range(int(input()))]
     for i in range(n)]

ans = 0
for i in range(2**n):
    f = [False] * n
    xy = []
    for j in range(n):
        if (i >> j) & 1:
            f[j] = True
            xy.append(v[j])
    flag = True
    for xyi in xy:
        for x, y in xyi:
            if f[x - 1] is not bool(y):
                flag = False
                break
    if flag:
        ans = max(ans, len(xy))
print(ans)
Buggy code:
from itertools import product

N = int(input())
c = product(range(2), repeat=N)
d = [[] for _ in range(N)]

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


ans = 0
for l in c:
    o = [None]*N
    is_conflict = False
    for i, j in enumerate(l):
        if j==0:continue
        for x, y in d[i]:
            if (o[x-1]!=None and o[x-1]!=y) or l[x-1]!=y:
                is_conflict = True
                break
            o[x-1] = y
        if is_conflict == True:
            break
    else:
        ans = mas(ans, sum(l))

print(ans)

Fixed code:
from itertools import product

N = int(input())
c = product(range(2), repeat=N)
d = [[] for _ in range(N)]

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


ans = 0
for l in c:
    o = [None]*N
    is_conflict = False
    for i, j in enumerate(l):
        if j==0:continue
        for x, y in d[i]:
            if (o[x-1]!=None and o[x-1]!=y) or l[x-1]!=y:
                is_conflict = True
                break
            o[x-1] = y
        if is_conflict == True:
            break
    else:
        ans = max(ans, sum(l))

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

Fixed code:
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)
Buggy code:
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)

Fixed code:
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
    
    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:
        ans = max(ans, sum(h))
 
print(ans)
Buggy code:
n = int(input())
lst = [[-1 for _ in range(n)] for _ in range(n)]
for _ in range(n):
    c = int(input())
    for c1 in range(c):
        x, y = map(int, input().split())
        x -= 1
        lst[_][x] = y

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


Fixed code:
n = int(input())
lst = [[-1 for _ in range(n)] for _ in range(n)]
for _ in range(n):
    c = int(input())
    for c1 in range(c):
        x, y = map(int, input().split())
        x -= 1
        lst[_][x] = y
        
ans = 0
for bit in range(2**n):
    flg = True
    for a in range(n):
        if (bit >> a) & 1:
            for x in range(n):
                if lst[a][x] != -1:
                    if ((bit >> x) & 1) != lst[a][x]:
                        flg = False
                        break
    if flg:
        ans = max(ans, bin(bit).count('1'))
print(ans)
Buggy code:
import math
import itertools

# -1 no ans
# 1 syoziki
# 0 hu sinsetu

N = int(input())
ans = [[-1] * N for i in range(N)]


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


def is_ok(num):
    # -1 not decided
    # 1 syoziki
    # 0 husinsetu
    people = [-1] * N
    for i in range(N):
        # i is syoziki
        if((num >> i) & 1):
            if(people[i] == 0):
                return False
            people[i] = 1
            for j in range(N):
                if(ans[i][j] == 1):
                    if(people[j] == 0):
                        return False
                    people[j] = 1
                if(ans[i][j] == 0):
                    if(people[j] == 1):
                        return False
                    people[j] = 0
        else:
            if(people[i] == 1):
                return False
            people[i] = 0

    return True


def countBit(num):
    ori = num
    count = 0
    while(num > 0):
        if(num & 1):
            count += 1
        num = num >> 1
    return count


out = 0

for i in range(1 << N):
    if(is_ok(i)):
        out = max(out, countBit(i))

print(out)


Fixed code:
import math
import itertools

# -1 no ans
# 1 syoziki
# 0 hu sinsetu

N = int(input())
ans = [[-1] * N for i in range(N)]


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


def is_ok(num):
    # -1 not decided
    # 1 syoziki
    # 0 husinsetu
    people = [-1] * N
    for i in range(N):
        # i is syoziki
        if((num >> i) & 1):
            if(people[i] == 0):
                return False
            people[i] = 1
            for j in range(N):
                if(ans[i][j] == 1):
                    if(people[j] == 0):
                        return False
                    people[j] = 1
                if(ans[i][j] == 0):
                    if(people[j] == 1):
                        return False
                    people[j] = 0
        else:
            if(people[i] == 1):
                return False
            people[i] = 0

    return True


def countBit(num):
    ori = num
    count = 0
    while(num > 0):
        if(num & 1):
            count += 1
        num = num >> 1
    return count


out = 0

for i in range(1 << N):
    if(is_ok(i)):
        out = max(out, countBit(i))

print(out)
Buggy code:
#python3 
g = [[-1 for _ in range(15)] for _ in range(15)]

n = int(input())
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 for _ in range(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)

Fixed code:
#python3 
g = [[-1 for _ in range(15)] for _ in range(15)]

n = int(input())
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 for _ in range(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, bin(i).count('1'))

print(ans)
Buggy code:
def main():
    n = int(input())
    ans = []
    for _ in range(n):
        a_num = int(input())
        t = []
        for _ in range(a_num):
            t.append(tuple(map(int, input().split())))
        t = tuple(t)
        ans.append(t)
   
    r = 0
    for bit in range(1 << n):
        honest = []
        for i1 in range(n):
            mask = 1<<i1
            if bit & mask:
                honest.append(i1)

        flag = 1
        if not honest:
            flag = 0
        for eh in honest:
            say = ans[eh]
            for esay in say:
                if esay[0] - 1 in honest:
                    if esay[1] == 0:
                        flag = 0
                else:
                    if esay[1]:
                        flag = 0
        if flag:
            r = max(r, len(honest))
    print(r)

if __name__ == '__main__':
    main(

Fixed code:

def main():
    n = int(input())
    ans = []
    for _ in range(n):
        a_num = int(input())
        t = []
        for _ in range(a_num):
            t.append(tuple(map(int, input().split())))
        t = tuple(t)
        ans.append(t)

    r = 0
    for bit in range(1 << n):
        honest = []
        for i1 in range(n):
            mask = 1<<i1
            if bit & mask:
                honest.append(i1)
        flag = 1       
        for eh in honest:
            say = ans[eh]
            for esay in say:
                if esay[0] - 1 in honest:
                    if esay[1] == 0:
                        flag = 0
                else:
                    if esay[1]:
                        flag = 0
        if flag:
            r = max(r, len(honest))
    print(r)

if __name__ == '__main__':
    main()
Buggy code:
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    A = [[] for _ in range(N)]
    for i in range(N):
        for _ in range(inputInt()):
            A[i].append(inputIntList())
    ret = 0
    for i in range(2 ** N):
        bits = [i >> j & 1 for j in range(N)]
        for i, a in enumerate(A):
            if bits[i] == 0:
                continue
            for x, y in a:
                if bits[x - 1] == y:
                    continue
                break
            else:
                ret = max(ret, sum(bits))
    return ret


if __name__ == "__main__":
    print(main())


Fixed code:
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    A = [[] for _ in range(N)]
    for i in range(N):
        for _ in range(inputInt()):
            A[i].append(inputIntList())
    ret = 0
    for i in range(2 ** N):
        bits = [i >> j & 1 for j in range(N)]
        for i, a in enumerate(A):
            if bits[i] == 0:
                continue
            for x, y in a:
                # print(bits, bits[x - 1], y)
                if bits[x - 1] == y:
                    continue
                break
            else:
                continue
            break
        else:
            ret = max(ret, sum(bits))
    return ret


if __name__ == "__main__":
    print(main())
Buggy code:
from itertools import product
N = int(input())
A = []
shougen = []
for i in range(N):
    a = int(input())
    A.append(a)
    ls = []
    for j in range(a):
        ls.append([int(k) for k in input().split()])
    shougen.append(ls)
truth = [0, 1]
ans = 0
for x in product(truth, repeat=N):
    num = 0
    for i, y in enumerate(x):
        if y == 1:
            for z in shougen[i]:
                if x[z[0]-1] != z[1]:
                    break
                num += 1
    ans = max(ans, num)
print(ans)

Fixed code:
from itertools import product
N = int(input())
A = []
shougen = []
for i in range(N):
    a = int(input())
    A.append(a)
    ls = []
    for j in range(a):
        ls.append([int(k) for k in input().split()])
    shougen.append(ls)
truth = [0, 1]
ans = 0
for x in product(truth, repeat=N):
    num = 0
    for i, y in enumerate(x):
        if y == 1:
            for z in shougen[i]: 
                if x[z[0]-1] != z[1]:
                    num += 1
    if num == 0:
        ans = max(ans, sum(x))
print(ans)
Buggy code:
n = int(input())
A = []
ans = 0
for i in range(n):
    x =int(input())
    lists = [list(map(int,input().split())) for j in range(x)]
    A.append(lists)

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

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

for i in range(2**n):
    honesty = [0]*n
    for j in range(n):
        if (i>>j) & 1:
            honesty[j] = 1
    true = 1
    for j in range(n):
        if honesty[j] == 1:
            for k in range(len(A[j])):
                x,y = A[j][k]
                if not honesty[x-1] == y:
                    true = 0
                    break
    if true == 1:
        ans = max(ans,sum(honesty))
print(ans)
Buggy code:
N = int(input())
testimony = [[-1]*N for i in range(N)]
count = 0
for i in range(N):
  A = int(input())
  for j in range(A):
    x,y = map(int,input().split())
    testimony[i][x-1]=y
fro i in range(2**N):
  honest = [0]*N
  for j in range(N):
    if(i>>j)&1:
      honest[j]=1
  flag=True
  for j in range(N):
    if honest[j]==1:
      for k in range(N):
        if testimony[j][k]==-1:
          continue
        if testimony[j][k]!=honest[k]:
          flag=False
  if flag==True:
    count=max(count,hones.count(1))
print(count)

Fixed code:
N = int(input())
testimony = [[-1]*N for i in range(N)]
count = 0
for i in range(N):
  A = int(input())
  for j in range(A):
    x,y = map(int,input().split())
    testimony[i][x-1]=y
for i in range(2**N):
  honest = [0]*N
  for j in range(N):
    if(i>>j)&1:
      honest[j]=1
  flag=True
  for j in range(N):
    if honest[j]==1:
      for k in range(N):
        if testimony[j][k]==-1:
          continue
        if testimony[j][k]!=honest[k]:
          flag=False
  if flag==True:
    count=max(count,honest.count(1))
print(count)
Buggy code:
import itertools
n=int(input())
la=[]
for _ in range(n):
  d=int(input())
  for dd in d:
    x,y=map(int,input().split())
    la.append([_,x-1,y])
ans=0
for i in itertools.product([0,1],repeat=n):
  s=sum(list(i))
  for l in la:
    if i[l[0]]==1 and i[l[1]]!=l[2]:
      break
  else:
    ans=max(ans,s)
print(ans)

Fixed code:
import itertools
n=int(input())
la=[]
for _ in range(n):
  d=int(input())
  for dd in range(d):
    x,y=map(int,input().split())
    la.append([_,x-1,y])
ans=0
for i in itertools.product([0,1],repeat=n):
  s=sum(list(i))
  for l in la:
    if i[l[0]]==1 and i[l[1]]!=l[2]:
      break
  else:
    ans=max(ans,s)
print(ans)
Buggy code:
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
                break
        if not consistent:
            break
    if consistent:
        result = max(result, bin(i)[2:].count('1'))
print (result)
print(evidences)

Fixed code:
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
                break
        if not consistent:
            break
    if consistent:
        result = max(result, bin(i)[2:].count('1'))
print (result)
Buggy code:
n = int(input())
l = [False]*n
ls = [0]*n
param_list = [0]*2**n
for i in range(2**(n-1)):
    l = [False]*n
    for id_r, row in enumerate(ls):
        if i & id_r >0:
            l[id_r] = True
    param_list[i] = l 
#1print(param_list)
 
for i in range(2**(n-1)):
    l = [True]+[False]*(n-1)
    for id_r, row in enumerate(ls):
        if i & id_r >0:
            l[id_r] = True
    param_list[i+2**(n-1)] = l 
#print()
#print(param_list)
 
for i in range(n):
    A = int(input())
    for k in range(A):
        a,b = map(int, input().split())
        b = (1==b)
        new_param =[]
        for d in param_list:
            if d[i]:
                if d[a-1] == b:
                    new_param.append(d)
                    pass
                else:
                    #print(2)
                    pass
            #else:
                #if d[a-1] is b:
                    #print(3)
                    #pass
                #else:
                    #print(4)
                    #new_param.append(d)
                    #pass
            
        param_list = new_param
        #print(param_list)
            
ans = 0    
for d in param_list:
    ans = max(ans,d.count(True))
print(ans)

Fixed code:
n = int(input())
ls = [0]*n
param_list = [0]*2**n
for i in range(2**n):
    l = [False]*n
    for id_r, row in enumerate(ls):
        if i & (2 ** id_r) >0:
            l[id_r] = True
    param_list[i] = l 


for i in range(n):
    A = int(input())
    for k in range(A):
        a,b = map(int, input().split())
        b = (1==b)
        new_param =[]
        for d in param_list:
            if d[i]:
                if d[a-1] == b:
                    new_param.append(d)
                    pass
                else:
                    #print(2)
                    pass
            else:
                new_param.append(d)
                #if d[a-1] is b:
                    #print(3)
                    #pass
                #else:
                    #print(4)
                    #new_param.append(d)
                    #pass
            
        param_list = new_param
        #print(param_list)
            
ans = 0    
for d in param_list:
    ans = max(ans, d.count(True))
print(ans)
Buggy code:
import sys, math
from pprint import pprint
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
A = []
for i in range(N):
	a = []
	for j in range(ri()):
		x, y = rl()
		a.append((x-1, y))
	A.append(a)

def check(A, b):
	for i, a in enumerate(A):
		for x, y in a:
			if b[i] == 1:
				if b[x] != y:
					return False
	return True

import itertools
ans = 0
for b in itertools.product([0,1], repeat=N):
	if check(A, b):
		print(b)
		ans = max(ans, sum(b))
print(ans)

Fixed code:
import sys, math
from pprint import pprint
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
A = []
for i in range(N):
	a = []
	for j in range(ri()):
		x, y = rl()
		a.append((x-1, y))
	A.append(a)

def check(A, b):
	for i, a in enumerate(A):
		for x, y in a:
			if b[i] == 1:
				if b[x] != y:
					return False
	return True

import itertools
ans = 0
for b in itertools.product([0,1], repeat=N):
	if check(A, b):
		ans = max(ans, sum(b))
print(ans)
Buggy code:
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)

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