qyliang/CodeNanoFix huggingface dataset:
Buggy code:
S = input()

N = int(input())
H = list(input())

harshad = 0

for i in H:
    harshad += int(i)

if N % harshad == 0:
    print("Yes")
else:
    print("No")



Fixed code:
S = input()

N = int(S)
H = list(S)

harshad = 0

for i in H:
    harshad += int(i)

if N % harshad == 0:
    print("Yes")
else:
    print("No")
Buggy code:
#ABC080B
n = input()
print("Yes" if sum(map(int,n))%n == 0 else "No")

Fixed code:
#ABC080B
n = input()
print("Yes" if int(n) %sum(map(int,n)) == 0 else "No")
Buggy code:
n = input()
fx = 0
for i in range(len(n)):
  fx += n[i]
if int(n)%fx == 0:
  print('Yes')
else:
  print('No')

Fixed code:
n = input()
fx = 0
for i in range(len(n)):
  fx += int(n[i])
if int(n)%fx == 0:
  print('Yes')
else:
  print('No')
Buggy code:
n =  input()
print('No' int(n) % sum(map(int, n)) else 'Yes')

Fixed code:
n =  input()
print('No' if int(n) % sum(map(int, n)) else 'Yes')
Buggy code:
n = input()
fx = 0
for s in n:
    fx += int(s)
print('Yes' if int(n) % fx else 'No')


Fixed code:
n = input()
fx = 0
for s in n:
    fx += int(s)
print('Yes' if int(n) % fx==0 else 'No')
Buggy code:
def f(x):
    ret = 0
    while x != 0:
        ret += x%10
        x //= 10

n = int(input())
print("Yes" if x % f(x) == 0 else "No")

Fixed code:
def f(x):
    ret = 0
    while x != 0:
        ret += x%10
        x //= 10
    return ret

n = int(input())
print("Yes" if n % f(n) == 0 else "No")
Buggy code:
Num = int(input())
check,check1 = 0,Num

while not 0 < check1 < 1:
    check += Num % 10
    check1 = int(check1 / 10 )

if (Num % check) == 0 :
    print('Yes')
else:
    print('No')

Fixed code:
Num = int(input())
check,check1 = 0,Num

while not 0 <= check1 < 1:
    check += check1 % 10
    check1 = int(check1 / 10 )

if (Num % check) == 0 :
    print('Yes')
else:
    print('No')
Buggy code:
n = input()
n1 = int(n)
n2 = int(sum([int(v) for v in list(n)]))

if n1 % n2 == 0:
  print("YES")
else:
  print("No")

Fixed code:
n = input()
n1 = int(n)
n2 = int(sum([int(v) for v in list(n)]))

if n1 % n2 == 0:
  print("Yes")
else:
  print("No")
Buggy code:
N = input()
n = int(N)
sum = 0
a = list(input())
for i in range(len(a)):
    sum += int(a[i])

if n%sum==0:
    print('Yes')
else:
    print('No')

Fixed code:
N = input()
n = int(N)
sum = 0
a = list(N)
for i in range(len(a)):
    sum += int(a[i])

if n%sum==0:
    print('Yes')
else:
    print('No')
Buggy code:
N = input()

n = int(N)

ans = 0

for i in range(len(N)):
    re = n % 10
    n = int(n / 10)
    ans += re
    print(ans)

x = int(N)    

if x%ans==0:
    print('Yes')
else:
    print('No')



Fixed code:
N = input()

n = int(N)

ans = 0

for i in range(len(N)):
    re = n % 10
    n = int(n / 10)
    ans += re

x = int(N)    

if x%ans==0:
    print('Yes')
else:
    print('No')
Buggy code:
N=int(input())
sum=0
for i in range(len(str(N))) :
  sum+=(N%10)
  N /=10

if (N%sum) == 0:
  print('Yes')
else:
  print('No')
  

Fixed code:
N=int(input())
S=N
n=str(N)
sum=0
  
for i in range(len(n)) :
  sum+=(N%10)
  N =N//10

if S%sum == 0:
  print('Yes')
else:
  print('No')
Buggy code:
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

N = iIn()

fN = sum(list(map(int, list(str(N)))))

ans = 'Yes' if N == fN else 'No'

print(ans)

Fixed code:
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

N = iIn()

fN = sum(list(map(int, list(str(N)))))

ans = 'Yes' if N % fN == 0 else 'No'

print(ans)
Buggy code:
n=int(input())
sum_digit=0
while n>0:
  sum_digit+=n%10
  n=n//10
if n//sum_digit==0:
  print("Yes")
else:
  print("No")

Fixed code:
n=int(input())
m=n
sum_digit=0
while n>0:
  sum_digit+=n%10
  n=n//10
if m%sum_digit==0:
  print("Yes")
else:
  print("No")
Buggy code:
n = list(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

fx = sum(n)

if int(n)%fx == 0:
    print("Yes")
else:
    print("No")

Fixed code:

n= input()
x = map(int,list(n))
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))
#print(n)
fx = sum(x)

if int(n)%fx == 0:
    print("Yes")
else:
    print("No")
Buggy code:
n=int(input());print("No"if n%sum(map(int,str(s))) else"Yes")

Fixed code:
n=int(input());print("No"if n%sum(map(int,str(n))) else"Yes")
Buggy code:
n = int(input())
fx = sum([int(i) for i in list(n)])
if n % fx == 0:
  print("Yes")
else:
  print("No")

Fixed code:
n = int(input())
fx = sum([int(i) for i in list(str(n))])
if n % fx == 0:
  print("Yes")
else:
  print("No")
Buggy code:
N=input()
if sum([int(x) for x in N])%int(N)==0:
  print('Yes')
else:
  print('No')

Fixed code:
N=input()
if int(N)%sum([int(x) for x in N])==0:
  print('Yes')
else:
  print('No')
Buggy code:
x = input()
l = len(x)
a = 0
for i in range(l):
  a += int(x[i])
if a%x ==0:
  print('Yes')
else:
  print('No')

Fixed code:
x = input()
l = len(x)
a = 0
for i in range(l):
  a += int(x[i])
#print(a)
if int(x)%a ==0:
  print('Yes')
else:
  print('No')
Buggy code:
N = int(input())

def sum_10(n):
  ans = 0
  while n != 0:
    ans += n % 10
    n //= 10
  return ans

if N / sum_10(N) == 0:
  print('Yes')
else:
  print('No')

Fixed code:
N = int(input())

def sum_10(n):
  ans = 0
  while n != 0:
    ans += n % 10
    n //= 10
  return ans

if N % sum_10(N) == 0:
  print('Yes')
else:
  print('No')
Buggy code:
N = int(input())
fN = 0
while N > 0:
  fN += N % 10
  N //= 10

if N % fN == 0:
  print("Yes")
else:
  print("No")

Fixed code:
N = int(input())
NN = N
fN = 0
while NN > 0:
  fN += NN % 10
  NN //= 10

if N % fN == 0:
  print("Yes")
else:
  print("No")
Buggy code:
n = int(input())
sum = 0
m = n
while n > 0:
    sum = sum + (n % 10)
    n = int(n / 10)
    # print(n)
    print(sum)

    
if m % sum == 0:
    print("Yes")
else:
    print("No")

Fixed code:
n = int(input())
sum = 0
m = n
while n > 0:
    sum = sum + (n % 10)
    n = int(n / 10)
    # print(n)
    # print(sum)

    
if m % sum == 0:
    print("Yes")
else:
    print("No")
Buggy code:
n = input()
N = list(n)
n = int(n)
ans = 0
for i in N:
    ans += int(i)
if ans % n == 0:
    print('Yes')
else:
    print('No')


Fixed code:
n = input()
N = list(n)
n = int(n)
ans = 0
for i in N:
    ans += int(i)
if n % ans == 0:
    print('Yes')
else:
    print('No')
Buggy code:
"""
https://abc080.contest.atcoder.jp/tasks/abc080_b
"""
n=input()
a=0
for i in range(len(n)):
    a=a+int(n[i])
if n%a==0:
    print("Yes")
else:
    print("No")

Fixed code:
"""
https://abc080.contest.atcoder.jp/tasks/abc080_b
"""
n=input()
a=0
for i in range(len(n)):
    a=a+int(n[i])
if int(n)%a==0:
    print("Yes")
else:
    print("No")
Buggy code:
N = str(input())
ans = 0
for i in N:
    ans += int(i)
if (N % ans == 0):
    print('Yes')
else:
    print('No')


Fixed code:
N = str(input())
ans = 0
for i in N:
    ans += int(i)
if (int(N) % ans == 0):
    print('Yes')
else:
    print('No')
Buggy code:
# -*- coding: utf-8 -*-
N = int, input()
print(N)
num = str(N[1])
char_list = list(num)
sum = 0
for i in range(len(char_list)):
    sum += int(char_list[i])

if N[1] % sum == 0:
    print("Yes")
else:
    print("No")


Fixed code:
# -*- coding: utf-8 -*-
N = int, input()
num = str(N[1])
char_list = list(num)
sum = 0
for i in range(len(char_list)):
    sum += int(char_list[i])

if int(N[1]) % sum == 0:
    print("Yes")
else:
    print("No")
Buggy code:
N = int(input())
 
F = []
 
for _ in range(N):
    f = list(input().strip().split())
    F.append(int("".join(f), 2))
 
P = [list(map(int, input().split())) for _ in range(N)]

ans = -10**9+7

for i in range(1,2**10+1):
    candi = 0
    for j in range(N):
        tmp = i & F[j]
        p = format(tmp, 'b').count("1")
        candi += P[j][p]
    ans = max(ans,candi) 
    
print(ans)

Fixed code:
N = int(input())
 
F = []
 
for _ in range(N):
    f = list(input().strip().split())
    F.append(int("".join(f), 2))

P = [list(map(int, input().split())) for _ in range(N)]

ans = -10**10-7

for i in range(1,2**10):
    candi = 0
    for j in range(N):
        tmp = i & F[j]
        p = format(tmp, 'b').count("1")
        candi += P[j][p]
    ans = max(ans,candi) 
    
print(ans)
Buggy code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
F = [l() for _ in range(N)]
P = [l() for _ in range(N)]
ans = 0
for bit in range(1<<10):
    nans = 0
    B = [(bit>>i)&1 for i in range(10)]
    for i in range(N):
        cnt = 0
        for j in range(10):
            if B[j] == 1 and F[i][j] == 1:
                cnt += 1
        nans += P[i][cnt]
    ans = max(ans,nans)
print(ans)

Fixed code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
F = [l() for _ in range(N)]
P = [l() for _ in range(N)]
ans = INF*-1
for bit in range(1,1<<10):
    nans = 0
    B = [(bit>>i)&1 for i in range(10)]
    for i in range(N):
        cnt = 0
        for j in range(10):
            if B[j] == 1 and F[i][j] == 1:
                cnt += 1
        nans += P[i][cnt]
    ans = max(ans,nans)
print(ans)
Buggy code:
n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]
benefits = []

for t in range(1,1024):
  bits = list(bin(t))
  a = [0 for _ in range(n)]
  jk = 0
  while jk < 10:
    b = bits.pop()
    if b == "b":
      break
    elif b == "0":
      jk += 1
      continue
    else:
      for i in range(n):
        if f[i][jk]:
          a[i] += 1
  
  s = 0
  for i in range(n):
    s += p[i][a[i]]
  else:
    benefits.append(s)
else:
  print(max(benefits))

Fixed code:
n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

benefits = -1000000000

for t in range(1,1024):
  bits = list(bin(t))
  a = [0 for _ in range(n)]
  jk = 0
  while jk < 10:
    b = bits.pop()
    if b == "b":
      break
    elif b == "0":
      jk += 1
      continue
    else:
      for i in range(n):
        if f[i][jk]:
          a[i] += 1
      jk += 1
  
  s = 0
  for i in range(n):
    s += p[i][a[i]]
  else:
    benefits = max(s,benefits)
else:
  print(benefits)
Buggy code:
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
l = [format(i, 'b').zfill(10) for i in range(1, 2 ** 10)]
ans = []

for i in l:
    c = [0] * 
    for j in range(10):
        if i[j] == '1':
            for k in range(N):
                if F[k][j] == 1:
                    c[k] += 1
                else:
                    continue
        else:
            continue
    temp = 0
    for j in range(N):
        temp += P[j][c[j]]
    ans.append(temp)

print(max(ans))

Fixed code:
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
l = [format(i, 'b').zfill(10) for i in range(1, 2 ** 10)]
ans = []

for i in l:
    c = [0] * N
    for j in range(10):
        if i[j] == '1':
            for k in range(N):
                if F[k][j] == 1:
                    c[k] += 1
                else:
                    continue
        else:
            continue
    temp = 0
    for j in range(N):
        temp += P[j][c[j]]
    ans.append(temp)

print(max(ans))
Buggy code:
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

ans = -float('inf')
for i in range(1, 1 << 10):
    bit = i
    profit = 0
    for j in range(N):
        cnt = sum(F[j][k] & (bit >> j) for k in range(10))
        profit += P[j][cnt]
    ans = max(ans, profit)

print(ans)


Fixed code:
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

ans = -float('inf')
for i in range(1, 1 << 10):
    bit = [0] * 10
    for d in range(10):
        bit[d] = 1 if (i >> d) & 1 else 0
    profit = 0
    for j in range(N):
        cnt = sum(F[j][k] & bit[k] for k in range(10))
        profit += P[j][cnt]
    ans = max(ans, profit)

print(ans)
Buggy code:
N = int(input())
F = []
P = []
for i in range(N):
    temp = [int(i) for i in input().split()]
    tt = 0b0
    for j in range(len(temp)):
        tt += 2 ** j * temp[j]
    print(bin(tt))
    F.append(tt)
    
for i in range(N):
    temp = [int(i) for i in input().split()]
    P.append(temp)

def bene(bit):
    res = 0
    for i in range(N):
        a = bit & F[i]
        cc = 0
        for j in str(bin(a)):
            if j == "1":
                cc += 1
        res += P[i][cc]
    return res

benes = [bene(i) for i in range(1,1024)]
benes.sort()
print(benes[-1])

Fixed code:
N = int(input())
F = []
P = []
for i in range(N):
    temp = [int(i) for i in input().split()]
    tt = 0b0
    for j in range(len(temp)):
        tt += 2 ** j * temp[j]
    F.append(tt)
    
for i in range(N):
    temp = [int(i) for i in input().split()]
    P.append(temp)

def bene(bit):
    res = 0
    for i in range(N):
        a = bit & F[i]
        cc = 0
        for j in str(bin(a)):
            if j == "1":
                cc += 1
        res += P[i][cc]
    return res

benes = [bene(i) for i in range(1,1024)]
benes.sort()
print(benes[-1])
Buggy code:
from itertools import product
N = int(input())
F = []
for i in range(N):
    F.append([int(i) for i in input().split()])
P = []
for i in range(N):
    P.append([int(i) for i in input().split()])

ans = -float('inf')

def culc(F, P, l):
    ret = 0
    for i in range(N):
        c = sum([j == k == 1 for j, k in zip(F[i], l)])
        ret += P[i][c]
    return ret

for l in product([0,1],repeat=10):
    ans = max(ans, culc(F, P, l))
print(ans)

Fixed code:
from itertools import product
N = int(input())
F = []
for i in range(N):
    F.append([int(i) for i in input().split()])
P = []
for i in range(N):
    P.append([int(i) for i in input().split()])

ans = -float('inf')

def culc(F, P, l):
    ret = 0
    for i in range(N):
        c = sum([j == k == 1 for j, k in zip(F[i], l)])
        ret += P[i][c]
    return ret

for l in product([0,1],repeat=10):
    if sum(l) == 0:
        continue
    ans = max(ans, culc(F, P, l))
print(ans)
Buggy code:
n=int(input())
f=[list(map(int,input().split())) for i in range(n)]
p=[list(map(int,input().split())) for i in range(n)]
ans=-10**9
for i in range(1,2**10):
  a=0
  m=[i%2,i//2%2,i//4%2,i//8%2,i//16%2,i//32%2,i//64%2,i//128%2,i//256%2,i//512%2]
  mm=[0 for i in range(n)]
  for i in range(10):
    for j in range(n):
      if m[i]==f[j][i]:
        mm[j]+=1
  for i in range(n):
    a+=p[i][mm[i]]
  ans=max(ans,a)
print(ans)
  

Fixed code:
n=int(input())
f=[list(map(int,input().split())) for i in range(n)]
p=[list(map(int,input().split())) for i in range(n)]
ans=-10**9
for i in range(1,2**10):
  a=0
  m=[i%2,i//2%2,i//4%2,i//8%2,i//16%2,i//32%2,i//64%2,i//128%2,i//256%2,i//512%2]
  mm=[0 for i in range(n)]
  for i in range(10):
    for j in range(n):
      if m[i]==1 and f[j][i]==1:
        mm[j]+=1
  for i in range(n):
    a+=p[i][mm[i]]
  ans=max(ans,a)
print(ans)
Buggy code:
n=int(input())
f=[list(map(str,input().split()))for i in range(n)]
p=[list(map(int,input().split()))for i in range(n)]
d=[]
for i in range(n):
    c=""
    for j in range(10):
        c+=f[i][j]
    else:
        d.append(int(c,2))
ans=-float("inf")
for i in range(1,1025):
    k=0
    for j in range(n):
        k+=p[j][bin(d[j]&i).count("1")] 
    else:
        ans=max(k,ans)
print(ans)

Fixed code:
n=int(input())
f=[list(map(str,input().split()))for i in range(n)]
p=[list(map(int,input().split()))for i in range(n)]
d=[]
for i in range(n):
    c=""
    for j in range(10):
        c+=f[i][j]
    else:
        d.append(int(c,2))
ans=float("-inf")
for i in range(1,1024):
    k=0
    for j in range(n):
        k+=p[j][bin(d[j]&i).count("1")] 
    else:
        ans=max(k,ans)
print(ans)
Buggy code:
n = int(input())
fs = []
ps = []
for _ in range(n):
    fs.append(list(map(int, input().split())))
for _ in range(n):
    ps.append(list(map(int, input().split())))

from itertools import product
ans = -float('inf')
for jo in product(range(2), repeat=10):
    prof = 0
    for p, f in zip(ps, fs):
        sim = sum(i * j for i, j in zip(jo, f))
        prof += p[sim]
    if prof > ans:
        ans = prof

print(ans)

Fixed code:
n = int(input())
fs = []
ps = []
for _ in range(n):
    fs.append(list(map(int, input().split())))
for _ in range(n):
    ps.append(list(map(int, input().split())))

from itertools import product
ans = -float('inf')
for jo in product(range(2), repeat=10):
    if sum(jo) == 0:
        continue
    prof = 0
    for p, f in zip(ps, fs):
        sim = sum(i * j for i, j in zip(jo, f))
        prof += p[sim]
    if prof > ans:
        ans = prof

print(ans)
Buggy code:
N= int(input())
F = []
for i in range(N):
    F.append(list(map(int,input().split())))
    
P = []

for i in range(N):
    P.append(list(map(int,input().split())))
    
    
def calc_profit(open_list):
    count = [0 for i in range(N)]
    for i in range(10):
        if open_list[i]:
            for j in range(N):
                if F[j][i]==1:
                    count[j]+=1
    profit=0
    for i in range(N):
        profit+=P[i][count[i]]
    return profit


def get_max(l):
    if len(l)==10:
        return calc_profit(l)
    else:
        return max(get_max(l+[True]),get_max(l+[False]))
print(get_max([]))

Fixed code:

N= int(input())
F = []
for i in range(N):
    F.append(list(map(int,input().split())))
    
P = []

for i in range(N):
    P.append(list(map(int,input().split())))
    
    
def calc_profit(open_list):
    if not (True in open_list):
        return -10**27
    count = [0 for i in range(N)]
    for i in range(10):
        if open_list[i]:
            for j in range(N):
                if F[j][i]==1:
                    count[j]+=1
    profit=0
    for i in range(N):
        profit+=P[i][count[i]]
    return profit

def get_max(l):
    if len(l)==10:
        return calc_profit(l)
    else:
        return max(get_max(l+[True]),get_max(l+[False]))

print(get_max([]))
Buggy code:
import sys
input = sys.stdin.readline
n = int(input())
f = []
for i in range(n):
  f.append(list(map(int, input().split())))
p = []
for i in range(n):
  p.append(list(map(int, input().split())))

cand = []
for i in range(1, 2 ** 20):
  for j in range(20):
    cnt = [0] * n
    if i & (1 << j):
      for k in range(n):
        if f[k][j]:
          cnt[k] += 1
    v = 0
    for k in range(n):
      v += p[k][cnt[k]]
    cand.append(v)
    
print(max(cand))
  

Fixed code:
import sys
input = sys.stdin.readline
n = int(input())
f = []
for i in range(n):
  f.append(list(map(int, input().split())))
p = []
for i in range(n):
  p.append(list(map(int, input().split())))

cand = []
for i in range(1, 2 ** 10):
  cnt = [0] * n
  for j in range(10):
    if i & (1 << j):
      for k in range(n):
        if f[k][j]:
          cnt[k] += 1
  v = 0
  for k in range(n):
    v += p[k][cnt[k]]
  cand.append(v)
    
print(max(cand))
Buggy code:
n=int(input())
f=[list(map(int,input().split())) for _ in range(n)]
p=[list(map(int,input().split())) for _ in range(n)]
from itertools import product as pr
x=0
for ch in list(pr([0,1],repeat=10)):
  if 1 not in ch:
    continue
  s=0
  for j in range(n):
    c=0
    t=f[j]
    for k in range(10):
      if ch[k] and t[k]:
        c+=1
    s+=p[j][c]
  x=max(x,s)
print(x)

Fixed code:
n=int(input())
f=[list(map(int,input().split())) for _ in range(n)]
p=[list(map(int,input().split())) for _ in range(n)]
from itertools import product as pr
x=-10**9
for ch in list(pr([0,1],repeat=10)):
  if 1 not in ch:
    continue
  s=0
  for j in range(n):
    c=0
    t=f[j]
    for k in range(10):
      if ch[k] and t[k]:
        c+=1
    s+=p[j][c]
  x=max(x,s)
print(x)
Buggy code:
# -*- coding: utf-8 -*-
"""
Created on Sun Nov  4 17:22:42 2018
ABC080
@author: maezawa
"""
import itertools as itr

n = int(input())
f = []
for i in range(n):
    f.append(list(map(int, input().split())))
p = []
for i in range(n):
    p.append(list(map(int, input().split())))
    
#print(f)
#print(p)
profit = -10**8
for oph in itr.product([0,1], repeat=10):
    if oph == (0,0,0,0,0,0,0,0,0,0):
        continue
    c = [0]*n
    for i in range(n):
        c[i] = sum([f[i][j] for j in range(10) if oph[j]==1])
    pcurrent = sum([p[i][c[i]] for i in range(n+1)])
    if pcurrent > profit:
        profit = pcurrent
        #print(oph)

print(profit)

Fixed code:
# -*- coding: utf-8 -*-
"""
Created on Sun Nov  4 17:22:42 2018
ABC080
@author: maezawa
"""
import itertools as itr

n = int(input())
f = []
for i in range(n):
    f.append(list(map(int, input().split())))
p = []
for i in range(n):
    p.append(list(map(int, input().split())))
    
#print(f)
#print(p)
profit = -10**10
for oph in itr.product([0,1], repeat=10):
    if oph == (0,0,0,0,0,0,0,0,0,0):
        continue
    c = [0]*n
    for i in range(n):
        c[i] = sum([f[i][j]*oph[j] for j in range(10)])
    pcurrent = sum([p[i][c[i]] for i in range(n)])
    if pcurrent > profit:
        profit = pcurrent
        #print(oph)

print(profit)