qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import math

n=int(input())
f=list()
p=list()
ans=-10**10
for i in range(n):
    f.append(list(map(int,input().split())))
for i in range(n):
    p.append(list(map(int,input().split())))
for i in range(1,1<<10):
    shop=list()
    cnt=[0]*n
    tmp=0
    for j in range(10):
        if i&(1<<j):
            shop.append(j)
    for s in range(n):
        for p in shop:
            if(f[s][p]==1):
                cnt+=1
        tmp+=p[s][cnt[s]]
    ans=max(ans,tmp)
print(ans)

Fixed code:
import math

n=int(input())
f=list()
p=list()
ans=-10**10
for i in range(n):
    f.append(list(map(int,input().split())))
for i in range(n):
    p.append(list(map(int,input().split())))
for i in range(1,1<<10):
    shop=list()
    cnt=[0]*n
    tmp=0
    for j in range(10):
        if i>>j&1:
            shop.append(j)
    for s in range(n):
        for k in shop:
            if(f[s][k]==1):
                cnt[s]+=1
        tmp+=p[s][cnt[s]]
    ans=max(ans,tmp)
print(ans)
Buggy code:
from itertools import product
import numpy as np


def solve(string):
    n, *fp = map(int, string.split())
    # f = np.asarray(fp[:10 * n]).reshape((n, 10))
    f = fp[:10 * n]
    p = fp[10 * n:]
    ans = -n * 10**7
    """
    for o in product([0, 1], repeat=10):
        if sum(o) == 0:
            continue
        # tmp = np.dot(f, np.asanyarray(o).T)
        tmp = [sum([for ]) for _f in f]
        ans = max(ans, sum([p[11 * i + t] for i, t in enumerate(tmp)]))
    return str(ans)
    """
    int_f = [int("".join(map(str, f[10 * i:10 * (i + 1)])), 2) for i in range(n)]
    for o in range(1, 2**10):
        tmp = [sum(map(int, f"{o & _f:b}")) for _f in int_f]
        print(tmp)
        ans = max(ans, sum([p[11 * i + t] for i, t in enumerate(tmp)]))
    return str(ans)


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(2 * n)])))


Fixed code:
from itertools import product
import numpy as np


def solve(string):
    n, *fp = map(int, string.split())
    f = np.asarray(fp[:10 * n]).reshape((n, 10))
    p = fp[10 * n:]
    ans = -n * 10**7
    for o in product([0, 1], repeat=10):
        if sum(o) == 0:
            continue
        tmp = np.dot(f, np.asanyarray(o).T)
        ans = max(ans, sum([p[11 * i + t] for i, t in enumerate(tmp)]))
    return str(ans)


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(2 * n)])))
Buggy code:
N = int(input())
F = [int("".join(input().split()), 1) for i in range(N)]
P = [list(map(int, (input().split()))) for i in range(N)]

ans = float('-inf')
for bit in range(1,1024):
    sum_p = 0
    for shop in range(N):
        time = bin(F[shop] & bit).count('1')
        sum_p += P[shop][time]

    ans = max(sum_p, ans)
print(ans)


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

ans = float('-inf')
for bit in range(1,1024):
    sum_p = 0
    for shop in range(N):
        time = bin(F[shop] & bit).count('1')
        sum_p += P[shop][time]

    ans = max(sum_p, ans)
print(ans)
Buggy code:
n=int(input())
f=[0 for i in range(n)]
for i in range(n):
    fi=int("".join(list(input().split())),2)
    f[i] = fi
print(f)
p=[[] for i in range(n)]
for i in range(n):
    pi=list(map(int,input().split()))
    p[i] = pi
print(p)
ans=-9999999999999
for i in range(1,1024):
    bene=0
    for j in range(n):
        c = str(bin(i & f[j])).count("1")
        bene+=p[j][c]
    if(ans < bene):
        ans = bene
print(ans)

Fixed code:
n=int(input())
f=[0 for i in range(n)]
for i in range(n):
    fi=int("".join(list(input().split())),2)
    f[i] = fi
p=[[] for i in range(n)]
for i in range(n):
    pi=list(map(int,input().split()))
    p[i] = pi
ans=-9999999999999
for i in range(1,1024):
    bene=0
    for j in range(n):
        c = str(bin(i & f[j])).count("1")
        bene+=p[j][c]
    if(ans < bene):
        ans = bene
print(ans)
Buggy code:
N = int(input())
F = [0 for i in range(N)]
P = [0 for i in range(N)]
for i in range(N):
  F[i] = [int(x) for x in input().split()]
for i in range(N):
  P[i] = [int(x) for x in input().split()]
ans = 0
for c in range(1, 2 ** 10):
  pat = ('0' * 9 + bin(c)[2:])[-10:]
  ans = max(sum([P[i][sum([F[i][j] * int(pat[j]) for j in range(10)])] for i in range(N)]), ans)
print(ans)

Fixed code:
N = int(input())
F = [0 for i in range(N)]
P = [0 for i in range(N)]
for i in range(N):
  F[i] = [int(x) for x in input().split()]
for i in range(N):
  P[i] = [int(x) for x in input().split()]
ans = -10 * 10 ** 9
for c in range(1, 2 ** 10):
  pat = ('0' * 9 + bin(c)[2:])[-10:]
  ans = max(sum([P[i][sum([F[i][j] * int(pat[j]) for j in range(10)])] for i in range(N)]), ans)
print(ans)
Buggy code:
ls = []
def onoff(n):
    global ls
    if len(n) == 10:
        ls.append(n)
    else:
        onoff(n + '0')
        onoff(n + '1')
onoff('1')
onoff('0')
n = int(input())
f = [list(map(str,input().split())) for x in range(n)]
p = [list(map(int,input().split())) for x in range(n)]
ans = -99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
for i in range(1024):
    check = 0
    for j in range(n):
        count = 0
        for k in range(10):
            if ls[i][k] == f[j][k] and ls[i][k] == '1':
                count += 1
        check += p[j][count]
    ans = max(ans,check)
print(ans)

Fixed code:
ls = []
def onoff(n):
    global ls
    if len(n) == 10:
        ls.append(n)
    else:
        onoff(n + '0')
        onoff(n + '1')
onoff('0')
onoff('1')
del ls[0]
n = int(input())
f = [list(map(str,input().split())) for x in range(n)]
p = [list(map(int,input().split())) for x in range(n)]
ans = -99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
for i in range(1023):
    check = 0
    for j in range(n):
        count = 0
        for k in range(10):
            if ls[i][k] == f[j][k] and ls[i][k] == '1':
                count += 1
        check += p[j][count]
    ans = max(ans,check)
print(ans)
Buggy code:
N = int(input())

F,P,b,T = [],[],1,-9999999999

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

while b < 1 << 10:
    bs = "{0:10b}".format(b)
    bsi = 0
    S = [0]*N
    for c in bs:
        if c == "1":
            for i in range(N):
                S[i] += F[i][bsi]
        bsi += 1
    t = 0
    for i in range(N):
        t += P[i][S[i]]
    if T < t:
        print("T",T,"t",t)
        T = t
    b += 1
print(T)



Fixed code:
N = int(input())

F,P,b,T = [],[],1,-9999999999

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

while b < 1 << 10:
    bs = "{0:10b}".format(b)
    bsi = 0
    S = [0]*N
    for c in bs:
        if c == "1":
            for i in range(N):
                S[i] += F[i][bsi]
        bsi += 1
    t = 0
    for i in range(N):
        t += P[i][S[i]]
    if T < t:
        T = t
    b += 1
print(T)
Buggy code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    F = []
    for _ in range(N):
        f = list(map(int, input().split()))
        F.append(f)
    P = []
    for _ in range(N):
        p = list(map(int, input().split()))
        P.append(p)

    ans = -1000000000
    for am in range(2 ** 5):
        for pm in range(2 ** 5):
            closed = False
            opens = [0 for _ in range(10)]
            for i in range(5):
                if not (((am >> i) & 1) or ((pm >> i) & 1)):
                    closed = True
                    break
                if ((am >> i) & 1):
                    opens[2 * i] = 1
                if ((pm >> i) & 1):
                    opens[2 * i + 1] = 1
            if closed:
                continue
            res = 0
            for i, fs in enumerate(F):
                cnt = 0
                for f, o in zip(fs, opens):
                    if f == 1 and o == 1:
                        cnt += 1
                res += P[i][cnt]
            ans = max(ans, res)

    print(ans)


if __name__ == '__main__':
    main()


Fixed code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    F = []
    for _ in range(N):
        f = list(map(int, input().split()))
        F.append(f)
    P = []
    for _ in range(N):
        p = list(map(int, input().split()))
        P.append(p)

    ans = -1000000000
    for am in range(2 ** 5):
        for pm in range(2 ** 5):
            opens = [0 for _ in range(10)]
            for i in range(5):
                if ((am >> i) & 1):
                    opens[2 * i] = 1
                if ((pm >> i) & 1):
                    opens[2 * i + 1] = 1
            if sum(opens) == 0:
                continue
            res = 0
            for i, fs in enumerate(F):
                cnt = 0
                for f, o in zip(fs, opens):
                    if f == 1 and o == 1:
                        cnt += 1
                res += P[i][cnt]
            ans = max(ans, res)

    print(ans)


if __name__ == '__main__':
    main()
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)]

tmp = 0
ans = 0
for i in range(1, 2**10+1):
    tmp = 0
    for j in range(N):
        cnt = 0
        for k in range(10):
            if((i>> k)%2 == 1 and F[j][k] == 1):
                cnt += 1
        tmp += P[j][cnt+1]
    ans = max(ans, tmp)

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 = -10000000000
for mask in range(1, 2**10):
    tmp = 0
    for j in range(N):
        cnt = 0
        for k in range(10):
            if((mask>>k)%2 == 1 and F[j][k] == 1):
                cnt += 1
        tmp += P[j][cnt]
    ans = max(ans, tmp)

print(ans)
Buggy code:
#from collections import Counter
N=int(input())
F=list(list(map(int,input().split())) for i in range(N))
P=list(list(map(int,input().split())) for i in range(N))
ans=-(1<<30)
for bit in range(1<<10):
    tmp = 0
    for i in range(N):
        c=0
        for j in range(10):
            if bit&(1<<j) and F[i][j]:
                c+=1
        tmp+=P[i][c]
    ans = max(ans,tmp)
print(ans)

Fixed code:
#from collections import Counter
N=int(input())
F=list(list(map(int,input().split())) for i in range(N))
P=list(list(map(int,input().split())) for i in range(N))
ans=-(1<<40)
for bit in range(1,1<<10):
    tmp = 0
    for i in range(N):
        c=0
        for j in range(10):
            if bit&(1<<j) and F[i][j]:
                c+=1
        tmp+=P[i][c]
    ans = max(ans,tmp)
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)]

s = [list(map(int,bin(x)[2:].zfill(10))) for x in range(2**10)]
s.pop(0)
c = 0
ans = 0
max = -10000000
for k in range(2**10-1):
    for i in range(n):
        for j in range(10):
            c += f[i][j]*s[k][j]
        ans += p[i][c+1]
        c=0
    if ans > max:
        max = ans
    ans = 0
print(max)


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

s = [list(map(int,bin(x)[2:].zfill(10))) for x in range(1,2**10)]
c = 0
ans = 0
max = -1000000000
for k in range(2**10-1):
    for i in range(n):
        for j in range(10):
            c += f[i][j]*s[k][j]
        ans += p[i][c]
        c=0
    if ans > max:
        max = ans
    ans = 0
print(max)
Buggy code:
import itertools
N = int(input())
F = [list(map(int,input().split())) for _ in range(N)]
F.insert(0,[0])
P = [list(map(int,input().split())) for _ in range(N)]
P.insert(0,[0])
cmax = 0
for x in itertools.product((0,1),repeat=10):
    cnt = 0
    for i in range(1,N+1):
        c = 0
        for j in range(10):
            if x[j]==1 and F[i][j]==1:
                c += 1
        cnt += P[i][c]
    cmax = max(cmax,cnt)
print(cmax)

Fixed code:
import itertools
N = int(input())
F = [list(map(int,input().split())) for _ in range(N)]
F.insert(0,[0])
P = [list(map(int,input().split())) for _ in range(N)]
P.insert(0,[0])
cmax = -10**10
for x in itertools.product((0,1),repeat=10):
    if sum(x)>0:
        cnt = 0
        for i in range(1,N+1):
            c = 0
            for j in range(10):
                if x[j]==1 and F[i][j]==1:
                    c += 1
            cnt += P[i][c]
        cmax = max(cmax,cnt)
print(cmax)
Buggy code:
N = int(input())
opens = [list(map(int, input().split())) for _ in range(N)]
values = [list(map(int, input().split())) for _ in range(N)]

ans = -(10**9)
for time in range(2**N+1):
  sum_v = 0
  for idx, open in enumerate(opens):
    open_str = ''.join(open)
    bin_str = format(time, '010b')
    both_open = bin_str&bin(open_str)
    cnt = 0
    for char in str(both_open):
      if char == '1':
        cnt += 1
    sum_v += values[idx][cnt]
  ans = max(ans, sum_cnt)
      
  

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

ans = -(10**9)
for time in range(1, 2**10):
  sum_v = 0
  for idx, open in enumerate(opens):
    open_str = ''.join(open)
    bin_str = format(time, '010b')
    both_open = int(bin_str, 2)&int(open_str, 2)
    cnt = 0
    for char in format(both_open, '010b'):
      if char == '1':
        cnt += 1
    sum_v += values[idx][cnt]
  ans = max(ans, sum_v)
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
v = [0] * 10

def culc():
    global ans
    score = 0
    index = 0
    if any(v) == False:
        return
    for i in range(N):
        for j in range(10):
            index += F[i][j] * v[j]
        score += P[i][index]
    ans = max(ans, score)
    return

def dfs(pos):
    if pos == 10:
        culc()
        return

    v[pos] = 0
    dfs(pos+1)
    v[pos] = 1
    dfs(pos+1)
    
    return

dfs(0)

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
v = [0] * 10

def culc():
    global ans
    score = 0
    if any(v) == False:
        return
    for i in range(N):
        index = 0
        for j in range(10):
            index += F[i][j] * v[j]
        score += P[i][index]
    ans = max(ans, score)
    return

def dfs(pos):
    if pos == 10:
        culc()
        return

    v[pos] = 0
    dfs(pos+1)
    v[pos] = 1
    dfs(pos+1)

    return

dfs(0)

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)]
result = 0

for i in range(1024):
    array = []
    num = i
    for _ in range(10):
        array.append(num%2)
        num //= 2

    point = 0
    for j in range(N):
        counter = 0
        for k in range(10):
            if array[k] == 1 and F[j][k] == 1:
                counter += 1

        point += P[j][counter]

    result = max(result, point)

print(result)


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)]
result = -(10 ** 7) * 100

for i in range(1, 1024):
    array = []
    num = i
    for _ in range(10):
        array.append(num%2)
        num //= 2

    point = 0
    for j in range(N):
        counter = 0
        for k in range(10):
            if array[k] == 1 and F[j][k] == 1:
                counter += 1

        point += P[j][counter]

    result = max(result, point)

print(result)
Buggy code:
import numpy as np
n = int(input())
f = np.zeros((n, 10))
p = np.zeros((n, 11))
for i in range(n):
    f[i] = np.array(list(map(int, input().split())))

for i in range(n):
    p[i] = np.array(list(map(int, input().split())))

l = 10
f_n = 2**l-1
ans = (-10**7)*10*n
for i in range(2**l-1):
    ff = np.array(list(map(int,list(format(f_n,'b').zfill(l)))))
    print (ff)
    c = np.sum(ff*f, dtype=np.int64, axis=1)
    c = np.eye(11)[c]
    tmp = np.sum(c*p)
    if ans < tmp:
        ans = tmp
    f_n -= 1
    
print (int(ans))


Fixed code:
import numpy as np
n = int(input())
f = np.zeros((n, 10))
p = np.zeros((n, 11))
for i in range(n):
    f[i] = np.array(list(map(int, input().split())))

for i in range(n):
    p[i] = np.array(list(map(int, input().split())))

l = 10
f_n = 2**l-1
ans = (-10**7)*10*n
for i in range(2**l-1):
    ff = np.array(list(map(int,list(format(f_n,'b').zfill(l)))))
    c = np.sum(ff*f, dtype=np.int64, axis=1)
    c = np.eye(11)[c]
    tmp = np.sum(c*p)
    if ans < tmp:
        ans = tmp
    f_n -= 1
    
print (int(ans))
Buggy code:
n = int(input())
f_matrix = [[0]*10]*n
p_matrix = [[0]*11]*n
f_matrix = [[int(i) for i in input().split()] for _ in range(n)]
p_matrix = [[int(i) for i in input().split()] for _ in range(n)]

ans = -10**6
for i in range(1, 2**10):
  
  for j in range(n):
    c = 0
    tmp = 0
    for k in range(10):
      if i>>k & 1 and f_matrix[j][k] is 1:
        c += 1
    tmp += p_matrix[j][c]
  ans = max(ans, tmp)
print(ans)

Fixed code:
n = int(input())
f_matrix = [[0]*10]*n
p_matrix = [[0]*11]*n
f_matrix = [[int(i) for i in input().split()] for _ in range(n)]
p_matrix = [[int(i) for i in input().split()] for _ in range(n)]

ans = -10**20
for i in range(1, 2**10):
  tmp = 0
  for j in range(n):
    c = 0
    for k in range(10):
      if i>>k&1 and f_matrix[j][k] is 1:
        c += 1
    tmp += p_matrix[j][c]
  ans = max(ans, tmp)
print(ans)
Buggy code:
n = int(input())

bits = []
for i in range(n):
  bit = int(input().replace(" ", ""), 2)
  bits.append(bit)
p = [[int(item) for item in input().split()] for _ in range(n)]

ans = - 10**9
for i in range(1,2**10):
  val = 0
  for j,mise in enumerate(p):
    val += mise[bin(i & bits[j]).count("1")]
    print(bin(i & bits[j]))
  ans = max(ans, val)
print(ans)

Fixed code:
n = int(input())

bits = []
for i in range(n):
  bit = int(input().replace(" ", ""), 2)
  bits.append(bit)
p = [[int(item) for item in input().split()] for _ in range(n)]

ans = - 10**9
for i in range(1,2**10):
  val = 0
  for j,mise in enumerate(p):
    val += mise[bin(i & bits[j]).count("1")]
  ans = max(ans, val)
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())))
  
ma = 0

for i in range(1, 1024):
  t = i
  x = []
  for j in range(10):
    x.append(t % 2)
    t //= 2
  wa = 0
  for j in range(N):
    cnt = 0
    for k in range(10):
      if x[k] == 0 and F[j][k] == 1:
        cnt += 1
    wa += P[j][cnt]
    
  if ma < wa:
    ma = wa
print(ma)
        

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())))
  
ma = -10e10

for i in range(1, 1024):
  t = i
  x = []
  for j in range(10):
    x.append(t % 2)
    t //= 2
  wa = 0
  for j in range(N):
    cnt = 0
    for k in range(10):
      if x[k] == 1 and F[j][k] == 1:
        cnt += 1
    wa += P[j][cnt]
    
  if ma < wa:
    ma = wa
print(ma)
Buggy code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
f = [int("".join(ls()), 2) for _ in range(n)]      
p = [list(li()) for _ in range(n)]

def dfs(cur:int, depth:int):
    if depth == 10:
        return sum([p[i][bin(cur&fi).count("1")] for i, fi in enumerate(f)])
    
    else:
        return max(dfs(cur+(1<<depth), depth+1),
                   dfs(cur, depth+1))
        
print(dfs(0,0))

Fixed code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
f = [int("".join(ls()), 2) for _ in range(n)]      
p = [list(li()) for _ in range(n)]

def dfs(cur:int, depth:int):
    if depth == 10:
        if cur == 0:
            return -float("inf")
        else:
            return sum([p[i][bin(cur&fi).count("1")] for i, fi in enumerate(f)])
    
    else:
        return max(dfs(cur+(1<<depth), depth+1),
                   dfs(cur, depth+1))
        
print(dfs(0,0))
Buggy code:
N = int(input())
F = []
for _ in range(N):
    F.append(input().split())
P = []
for _ in range(N):
    P.append(list(map(int,input().split())))

def return_C(i, List):
    j = ''.join(List)
    j = int(j, 2)
    AND = i & j
    return bin(AND).count('1')

ans = - 10 ** 10
for i in range(2 ** 10):
    temp = 0
    for j in range(N):
        c = return_C(i, F[j])
        temp += P[j][c]
    ans = max(ans, temp)

print(ans)

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

def return_C(i, List):
    j = ''.join(List)
    j = int(j, 2)
    AND = i & j
    return bin(AND).count('1')

ans = - 10 ** 10
for i in range(1, 2 ** 10):
    temp = 0
    for j in range(N):
        c = return_C(i, F[j])
        temp += P[j][c]
    ans = max(ans, temp)

print(ans)
Buggy code:
from sys import stdin

n = int(stdin.readline().rstrip())
f = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
p = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n+1)]

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

ma = 0
for i in range(1,1024):
    s = Base_10_to_n(i,2).zfill(10)
    total = 0
    for j in range(n):
        point = 0
        for k in range(10):
            if int(s[k]) == 1 and f[j][k] == 1:
                point += 1
        total += p[j][point]
    ma = max(ma,total)
    
print(ma)

Fixed code:
from sys import stdin

n = int(stdin.readline().rstrip())
f = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
p = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n+1)]

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

ma = -1*(10**10)
for i in range(1,1024):
    s = Base_10_to_n(i,2).zfill(10)
    total = 0
    for j in range(n):
        point = 0
        for k in range(10):
            if int(s[k]) == 1 and f[j][k] == 1:
                point += 1
        total += p[j][point]
    ma = max(ma,total)   
print(ma)