Problem:
 Score : 300 points    Problem Statement Joisino is planning to open a shop in a shopping street.  Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods.  There are already N stores in the street, numbered 1 through N .  You are given information of the business hours of those shops, F_{i,j,k} . If F_{i,j,k}=1 , Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0 , Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1 , Tuesday: Day 2 , Wednesday: Day 3 , Thursday: Day 4 , Friday: Day 5 . Also, the morning is denoted as Period 1 , and the afternoon is denoted as Period 2 .  Let c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N} .  Find the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.      Constraints  1≤N≤100  0≤F_{i,j,k}≤1  For every integer i such that 1≤i≤N , there exists at least one pair (j,k) such that F_{i,j,k}=1 .  -10^7≤P_{i,j}≤10^7  All input values are integers.         Input Input is given from Standard Input in the following format:  N  F_{1,1,1}  F_{1,1,2}  ...  F_{1,5,1}  F_{1,5,2}  :  F_{N,1,1}  F_{N,1,2}  ...  F_{N,5,1}  F_{N,5,2}  P_{1,0}  ...  P_{1,10}  :  P_{N,0}  ...  P_{N,10}       Output Print the maximum possible profit of Joisino's shop.        Sample Input 1 1
1 1 0 1 0 0 0 1 0 1
3 4 5 6 7 8 9 -2 -3 4 -2      Sample Output 1 8  If her shop is open only during the periods when Shop 1 is opened, the profit will be 8 , which is the maximum possible profit.       Sample Input 2 2
1 1 1 1 1 0 0 0 0 0
0 0 0 0 0 1 1 1 1 1
0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1
0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1      Sample Output 2 -2  Note that a shop must be open during at least one period, and the profit may be negative.       Sample Input 3 3
1 1 1 1 1 1 0 0 1 1
0 1 0 1 1 1 1 0 1 0
1 0 1 1 0 1 0 1 0 1
-8 6 -2 -8 -8 4 8 7 -6 2 2
-9 2 0 1 7 -5 0 -2 -6 5 5
6 -6 7 -9 6 -5 8 0 -9 -7 -7      Sample Output 3 23

Solution (Python):
l = input().split()
N = int(l[0])

F = [[] for i in range(N)]
P = [[] for i in range(N)]

for i in range(N):
    l = input().split()
    F[i] = [int(x) for x in l]

for i in range(N):
    l = input().split()
    P[i] = [int(x) for x in l]



max_p = -10**9
for i in range(1, 1024):
    p = 0
    for n in range(N):
        num_open = 0
        for j in range(10):
            is_open = ((i >> j) & 1) == 1
            if is_open and F[n][j] == 1:
                num_open += 1
        p += P[n][num_open]
    max_p = max(p, max_p)

print(max_p)

Solution (Python):
N = int(input())
F = [[int(i) for i in input().split()] for j in range(N)]
P = [[int(i) for i in input().split()] for k in range(N)]
x = -(10**10)
for i in range(1,2**10):
    L = [int(b) for b in '{:0>10}'.format(str(bin(i))[2:])]
    y = 0
    for n in range(N):
        m = sum([l&f for l, f in zip(L, F[n])])
        y += P[n][m]
    x = max(x, y)
print(x)

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

m=2**10
gain=-10**10
for i in range(1,2**10):
    x=list(map(int,format(i,'b').zfill(10)))
    sumP=0
    for j in range(N):
        total=sum([a*b for a,b in zip(x,F[j])])
        sumP+=P[j][total]
    gain=max(gain,sumP)
print(gain)

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

jo = []
for a1 in range(2):
    for a2 in range(2):
        for a3 in range(2):
            for a4 in range(2):
                for a5 in range(2):
                    for a6 in range(2):
                        for a7 in range(2):
                            for a8 in range(2):
                                for a9 in range(2):
                                    for a10 in range(2):
                                        if a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10 != 0:
                                            jo.append([a1,a2,a3,a4,a5,a6,a7,a8,a9,a10])

a = []

for j in jo:
    ans = 0
    for i in range(n):
        li = []
        for k in range(10):
            li.append(f[i][k]+j[k])
        ans += p[i][li.count(2)]
    a.append(ans)

print(max(a))

Solution (Python):
N = int(input())
st_con = [[i for i in map(int,input().split())] for j in range(N)]
rieki = [[i for i in map(int,input().split())] for j in range(N)]

ans = -10**9
for i in range(1,2**10):
    a = 0
    for j in range(N):
        count = 0 
        for h in range(10):
            if (i>>h) & st_con[j][h] and (i>>h) & 1:
                count += 1
        a += rieki[j][count]
    
    if ans < a : ans = a 
print("{}".format(ans))

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

ans = []

for i in range(1, 2**10):
    C = [0] * N
    for j in range(10):
        if (i >> j) & 1 == 1:
            for k, f in enumerate(F):
                if f[j] == 1:
                    C[k] += 1
    pro = 0
    for c, p in zip(C, P):
        pro += p[c]
    ans.append(pro)

print(max(ans))

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

for _ in range(n):
    p.append(list(map(int, input().split())))

result = -float('inf')
for i in range(1,1024):
    working = [0 for _ in range(n)]
    for j in range(10):
        if i>>j&1:
            for shop in range(n):
                if f[shop][j]:
                    working[shop] += 1
    benefit = 0
    for shop in range(n):
        benefit += p[shop][working[shop]]

    result = max([result, benefit])

print(result)

Solution (Python):
N = int(input())
F = []
for _ in range(N):
    lst = input().split()
    F.append(''.join(lst))
P = []
for _ in range(N):
    P.append(tuple(map(int, input().split())))
ans = -10**12
for bit in range(1, 1 << 10):
    temp = 0
    for i, f in enumerate(F):
        f_dec = int(f, 2)
        both_open = f_dec & bit
        c = format(both_open, 'b').count('1')
        temp += P[i][c]
    ans = max(ans, temp)
print(ans)

Solution (Python):
N = int(input())

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



ans = -10 ** 9
for i in range(1, 2**10):
    tmp = 0
    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
    for l in range(N):
        tmp += P[l][c[l]]
    ans = max(tmp, ans)

print (ans)

Solution (Python):
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)]


solver = []
for i in range(1 << 10): 
    if i == 0:
      continue
    C = [0]*N
    for j in range(10):  
        if ((i >> j) & 1) == 1: 
            for k in range(N):
                C[k] += F[k][j] 
    profit = sum([P[k][C[k]] for k in range(N)])
    solver.append(profit)

print(max(solver))

Solution (Python):



def main():
    num = int(input())
    open_data = [list(map(int, input().split())) for i in range(num)]
    value_data = [list(map(int, input().split())) for i in range(num)]

    ans = -1 * 10 ** 10

    for i in range(1, 1024):
        open_list = list(map(int, list(bin(i)[2:].zfill(10))))
        kari = 0
        for j in range(num):
            onaji = 0
            for k in range(10):
                if open_list[k] and open_data[j][k]:
                    onaji += 1
            kari += value_data[j][onaji]

        if kari > ans:
            ans = kari

    print(ans)



if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
open_other=[]
for i in range(n):
    open_other.append(list(map(int,input().split())))
benefit_other=[]
for i in range(n):
    benefit_other.append(list(map(int,input().split())))

max_benefit=-10**10
def convert(num):
    res=[]
    for i in range(10):
        res.append(num%2)
        num=num//2
    return res

for opennum in range(1,2**10):
    opentime=convert(opennum)
    benefit=0
    for i in range(n):
        count=0
        for j in range(10):
            if open_other[i][j]==1 and opentime[j]==1:
                count+=1
        benefit+= benefit_other[i][count]
    max_benefit=max(max_benefit,benefit)
print(max_benefit)

Solution (Python):


n = int(input())
lst_F = [list(map(int, input().split())) for _ in range(n)]
lst_P = [list(map(int, input().split())) for _ in range(n)]


ans = -float("INF")
for b in range(1, 2**10):
    tmp = 0
    for i in range(n):
        c = 0
        for k in range(10):
            if b&(1<<k) and lst_F[i][k]:
                c += 1
        tmp += lst_P[i][c]
    ans = max(tmp, ans)


print(ans)

Solution (Python):


n = int(input())
lst_F = [list(map(int, input().split())) for _ in range(n)]
lst_P = [list(map(int, input().split())) for _ in range(n)]


ans = -float("INF")
for b in range(1, 2**10):
    tmp = 0
    for i in range(n):
        c = 0
        for k in range(10):
            if b&(1<<k) and lst_F[i][k]:
                c += 1
        tmp += lst_P[i][c]
    ans = max(tmp, ans)


print(ans)

Solution (Python):
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):
  tmp = 0
  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
  for l in range(N):
    tmp += P[l][c[l]] 
  ans = max(tmp, ans)
print(ans)

Solution (Python):
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=float("-inf")
for i in range(1,2**10):
    i=list(map(int,list(bin(i)[2:].zfill(10))))
    x,y=0,0
    for j in range(n):
        y=0
        for k in range(10):
            if i[k]==f[j][k]==1:y+=1
        x+=p[j][y]
    ans=max(ans,x)
print(ans)

Solution (Python):
n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]
ans = -10**9
for bit in range(1,2**10):
  t = [0]*10
  for k in range(10):
    if bit&(2**k):
      t[k] = 1
  pat = [0]*n
  for a in range(10):
    for b in range(n):
      if f[b][a]&t[a]:
        pat[b] += 1
  ben = 0 
  for x in range(n):
    ben += p[x][pat[x]]
  if ans < ben:
    ans = ben
print(ans)

Solution (Python):
import itertools
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=-1000000000
for x in itertools.product([0,1],repeat=10):
    if all(i==0 for i in x):
        continue
    cnt=[0]*n
    tmp=0
    for i in range(n):
        for t in range(10):
            if x[t]==0:continue
            cnt[i]+=f[i][t]
        tmp+=p[i][cnt[i]]
    ans=max(ans,tmp)
print(ans)

Solution (Python):

import sys
INF = float("inf")


def solve(N, F, P):
    
    bmax = -INF
    bmax_arg = -1
    for n in range(1, 2**10):
        bene = 0
        
        for j in range(N):
            c = bin(int(F[j], 2) & n).count("1")
            bene += P[j][c]
        if bmax < bene:
            bmax = bene
            bmax_arg = n
    print(bmax)


def main():
    N = int(input())
    F = []
    for i in range(N):
        F.append("".join(input().split()))
    P = []
    for i in range(N):
        P.append(list(map(int, input().split())))
    solve(N, F, P)
    pass


if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
F=[]
for i in range(N):
    f=list(map(int,input().split()))
    F.append(f)
P=[]
for i in range(N):
    p=list(map(int,input().split()))
    P.append(p)
ans=-10**12
for i in range(1,2**10):
    i=bin(i)[2:].zfill(10)
    res=0
    for n in range(N):
        tmp=0
        for j in range(10):
            if i[j]=="1" and F[n][j]==1:
                tmp+=1
        res+=P[n][tmp]
    ans=max(ans,res)
print(ans)

Solution (Python):
N = int(input())

F = []
for _ in range(N):
    F.append(list(map(int, input().split())))
    
P = []
for _ in range(N):
    P.append(list(map(int, input().split())))
    
from itertools import product
joisino_store_product = list(product([0, 1], repeat=10))[1:]

def binary_compare(A, B):
    C = []
    for i, j in zip(A, B):
        if i == 1 and  j == 1:
            C.append(1)
        else:
            C.append(0)
    return C
  
sum_list = []

for joisino_store in joisino_store_product:
    C = []
    priceSum = 0
    
    for F_store in F:
        C.append(sum(binary_compare(joisino_store, F_store)))
    
    for C_num, P_list in zip(C, P):
        priceSum += P_list[C_num]
        
    sum_list.append(priceSum)
    
print(max(sum_list))

Solution (Python):
N = int(input())
F = [''.join(input().split()) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

x = [int(v, 2) for v in F]
rev = []
for i in range(1, 2 ** 10):
    cnt = [list(bin(i & v)[2:]).count('1') for v in x]
    rev.append(sum([P[j][cnt[j]] for j in range(N)]))
print(max(rev))

Solution (Python):
N = int(input())
F = [int(input().replace(' ', ''), 2) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]



ans = -(10**9+7)
for i in range(1, 2**10):
  tmp = 0
  for f, p in zip(F, P):
    tmp += p[bin(f&i).count('1')]
    
  ans = max(ans, tmp)
print(ans)

Solution (Python):
N = int(input())
F = []
P = []
for _ in range(N):
    F.append(list(map(int, input().split())))
for _ in range(N):
    P.append(list(map(int, input().split())))
a = [0] * 20


def dfs(pos):
    if pos == 10:
        if a.count(0) == 20:
            return -1000000000
        score = 0
        for f, p in zip(F, P):
            c = 0
            for aa, ff in zip(a, f):
                if aa == ff == 1:
                    c += 1
            score += p[c]
        return score
    a[pos] = 0
    x = dfs(pos + 1)
    a[pos] = 1
    y = dfs(pos + 1)
    return max(x, y)


def main():
    print(dfs(0))


main()

Solution (Python):
def main():
    N = int(input())
    F = [int(input().replace(' ', ''), 2) for _ in range(N)]
    P = [list(map(int, input().split())) for _ in range(N)]

    ans = -10 ** 10
    for i in range(1, 2 ** 10):
        c = 0
        for f, p in zip(F, P):
            c += p[bin(f & i).count('1')]
        ans = max(ans, c)
    print(ans)


main()

Solution (Python):
N = int(input())
F = [int(input().replace(' ',''), 2) for _ in range(N)]
P = [[int(i) for i in input().split()] for _ in range(N)]

ma = -1e20
for i in range(1, 2 ** 10):
    count = 0
    for f, p in zip(F, P):
        count += p[bin(f & i).count("1")]
    ma = max(ma, count)
print(ma)

Solution (Python):
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)]
benefit = -10**9
for i in range(1, 2 ** 10):
    b = 0
    for f, p in zip(F, P):
        count = 0
        for j in range(10):
            if (i & f) >> j & 1:
                count += 1
        b += p[count]
    benefit = max(benefit, b)
print(benefit)

Solution (Python):
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(ans, sum_p)

print(ans)

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    

    
    

    
    
    
    
    
    
    
    
    
    INF = float("inf")

    
    MOD = 10**9+7
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N = int(input())
    F = []
    P = []
    for i in range(N):
        F.append(list(int(_) for _ in input().split()))
    for i in range(N):
        P.append(list(int(_) for _ in input().split()))
        
    ans = -1 * INF
    for i in range(1,2**10):
        tmp_ans =0
        for j in range(N):
            cnt = 0
            for k in range(len(F[j])):
                if ( i & (1 << k) )and(F[j][k] == 1):
                    cnt +=1
            tmp_ans += P[j][cnt]
        ans = max(ans,tmp_ans)
    print(ans)
    
if __name__ == '__main__':
    main()

Solution (Python):
import sys
import itertools
import numpy as np

input = sys.stdin.readline

n = int(input())
F = [[int(i) for i in input().split()] for _ in range(n)]
P = [[int(i) for i in input().split()] for _ in range(n)]

scores = []
for a in itertools.product(
  *[[0, 1] for _ in range(10)]):
    
    if np.sum(a)==0:
        continue
    
    score = 0
    
    for f, p in zip(F, P):
        m = np.sum([
            int(x==1 and y==1) for x, y 
          in zip(a, f)])
        score += p[m]
    
    scores.append(score)
    
print(np.max(scores))

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
score = -10 ** 18

for i in range(1 << 10):
    t = []
    
    for j in range(10):
        if (i >> j) & 1:
            t.append(j)
            
    if t == []:
        continue
        
    s = [0] * N
    for j in range(N):
        p = F[j]
        c = 0
        for tt in t:
            if p[tt] == 1:
                c += 1
        s[j] = P[j][c]
    
    score = max(score, sum(s))
    
print(score)

Solution (Python):

def bi(i):
    o = [0]*10
    c = 0
    while i > 0:
        o[c] = i % 2
        i //= 2
        c += 1
    return o

v = []
N = int(input())
F = [0]*N
C = [0]*N
for i in range(N):
    F[i] = list(map(int,input().split(" ")))

for i in range(N):
    C[i] = list(map(int,input().split(" ")))

i = 1
while i < 1024:
    o = bi(i)
    i += 1
    a = 0
    j = 0
    while j < N:
        f = F[j]
        c = C[j]
        a += c[sum([o[x]*f[x] for x in range(10)])]
        j += 1
    v.append(a)

print(max(v))

Solution (Python):
n = int(input())
f = [list(input().split()) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]
print(max(sum(p[j][sum(f[j][x] == "1" and format(i, "010b")[x] == "1" for x in range(10))] for j in range(n)) for i in range(1, 2 ** 10)))

Solution (Python):
def mkstring(s):
  if len(s)<10:
    return '0'*(10-len(s))+s
  else:
    return s

n=int(input())
arr1=[''.join(map(str,input().split())) for _ in range(n)]
arr2=[list(map(int,input().split())) for _ in range(n)]
ans=-10**10
for i in range(1,2**10+1):
  s=mkstring(format(i,'b'))
  tmp=0
  for j in range(n):
    cnt=0
    for k in range(10):
      if s[k]=='1' and arr1[j][k]=='1':
        cnt+=1
    tmp+=arr2[j][cnt]
  if ans<tmp:
    ans=tmp
print(ans)

Solution (Python):
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):
    profit = 0
    for j in range(N):
        sim = 0
        for s in range(10):
            if i & (1 << s) and F[j][s]:
                sim += 1
        profit += P[j][sim]
    ans = max(ans, profit)

print(ans)

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

values_all = []
for a in range(2 ** 10):
    a2 = bin(a)[2:].zfill(10)
    values = 0
    for i in range(n):
        ci = 0
        for j in range(10):
            if f[i][j] == 1 and a2[j] == '1':
                ci += 1
        pici = p[i][ci]
        values += pici
    values_all.append(values)

print(max(values_all[1:]))

Solution (Python):
import itertools
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 = -float("inf")
for i in itertools.product((0,1), repeat=10):
  if list(i) == [0] * 10:
    continue
  a = 0
  for j in range(n):
    c = 0
    for k in range(10):
      if i[k] == f[j][k] == 1:
        c += 1
    a += p[j][c]
  ans = max(ans, a)
  
print(ans)

Solution (Python):
N=int(input())
F=[int(input().replace(" ", ""), 2) for _ in range(N)]
P=[[int(x) for x in input().split()] for _ in range(N)]
C=[sum(map(int, format(i, "b"))) for i in range(2**10)]
print(max([sum([p[C[f&i]] for f,p in zip(F, P)]) for i in range(1, 2**10)]))

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    fa = [ f() for i in range(n)]
    
    pa = [ f() for i in range(n)]

    mxa = int(-1e9)
    for i in range(1,2**10):
        ans = 0
        for j in range(n):
            cnt = 0
            for k in range(10):
                if i&(1<<k) and fa[j][k]:
                    cnt += 1
            ans += pa[j][cnt]
        mxa = max(mxa, ans)

    print(mxa)
            

solve()

Solution (Python):

def read_input():
    n = int(input())

    flist = []
    for i in range(n):
        flist.append(list(map(int, input().split())))

    plist = []
    for j in range(n):
        plist.append(list(map(int, input().split())))

    return n, flist, plist



def check_open(a, b):
    c = 0
    for i,j in zip(a, b):
        if i == j == 1:
            c += 1

    return c


def get_pattern(p):
    binary_p = bin(p)[2:]
    list_p = [int(c) for c in binary_p]
    list_p = [0]*(10 - len(list_p)) + list_p
    return list_p


def submit():
    n, flist, plist = read_input()
    max_pattern = 2048
    max_profit = -float('inf')
    for p in range(1, 2048):
        myshop = get_pattern(p)
        profit = 0
        for i in range(n):
            target_shop = flist[i]
            c = check_open(myshop, target_shop)
            profit += plist[i][c]

        if max_profit < profit:
            max_profit = profit

    print(max_profit)

if __name__ == '__main__':
    submit()

Solution (Python):
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)

Solution (Python):


import sys
import math



def get_c(a, b):
  
  return str(bin(a&b)).count("1")



if __name__ == "__main__":
  
  N = int(input())
  Fn = []
  Pn = []

  for i in range(N):
    f = list(map(int, input().split()))
    ret = 0
    for i in range(10):
      ret *= 2
      ret += f[i]
    Fn.append(ret)

  for i in range(N):
    p = list(map(int, input().split()))
    Pn.append(p)

  
  ret = -1 * 10**10
  for i in range(1,2**10):
    ans = 0
    for j in range(N):
      ans += Pn[j][get_c(Fn[j],i)]
    ret = max(ret, ans)
  print(ret)

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


max_benef =-float("inf")

for d in range(1,2**10):
    op = ["-"] * 10  
    for j in range(10):
        if ((d >> j) & 1):
            op[10 - 1 - j] = "+"  
    
    m =0
    count=[0 for s in range(N)]
    for t in range(10):
        if op[t]=="+":
            for s in range(N):
                if F[s][t]==1:
                    count[s]+=1
    for s in range(N):
        m += P[s][count[s]]
    max_benef = max(m,max_benef)
    
print(max_benef)

Solution (Python):
N = int(input())
F = [list(map(int,input().split())) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]
ans = -(10**9)
for i in range(1,2**10):
    a = [(i>>j)&1 for j in range(10)]
    tmp = 0
    for j in range(N):
        tmp += P[j][sum(a[k]*F[j][k] for k in range(10))]
    ans = max(ans,tmp)
print(ans)

Solution (Python):
n = int(input())         
import numpy as np

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

max_p = -999999999999
                     
for j in range(1,2**10):  
  store = [0,0,0,0,0,0,0,0,0,0] 
  flag = True          
  for k in range(10):  
    if j %2 ==1 : 
      store[k] = 1 
    j = int(j/2)                           

  days = [sum(i) for i in store * open] 
  score = 0                            
  for i in range(n):                   
          score += p[i][days[i]]
  if score > max_p: 
    max_p = score            
print(max_p)

Solution (Python):
import itertools
inf = float('inf')

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

ans = -inf

for shift in itertools.product([0,1],repeat=10):
    if not any(shift): continue
    res = 0
    for i,line in enumerate(F):
        c = 0
        for s, f in zip(shift, line):
            if s and f:
                c += 1
        res += P[i][c]
    if res > ans:
        ans = res

print(ans)

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

ans = - 10**18

for i in range(1, 2**10):
    x = 0
    for n in range(N):
        c = 0
        for j in range(10):
            if (i >> j) & F[n][j]:
                c += 1
        x += P[n][c]
    ans = max(ans, x)

print(ans)

Solution (Python):
I=input;n=int(I());f=eval('int(I()[::2],2),'*n);p=eval('I().split(),'*n);print(max(sum(int(q[bin(i&g).count('1')])for g,q in zip(f,p))for i in range(1,1024)))

Solution (Python):
from numpy import*
n=int(input())
f=array([list(map(int,input().split()))for i in range(n)])
p=array([list(map(int,input().split()))for i in range(n)])
print(max(sum(p[k][v]for k,v in enumerate(sum(f*array([i>>j&1for j in range(10)]),axis=1)))for i in range(1,1024)))

Solution (Python):
N = int(input())
F = [[int(i) for i in input().split()] for j in range(N)]
P = [[int(i) for i in input().split()] for j in range(N)]


def D2NC(D: int, N: int) -> list:
    res = []
    while D > 0:
        res.insert(0, D % N)
        D //= N
    if not res:
        res.append(0)
    return res


ans = -10**9
for i in range(1, 2**10):
    pattern = ''.join([str(j) for j in D2NC(i, 2)]).zfill(10)
    idx = 0
    ct = 0
    count = [0 for i in range(N)]
    for j in pattern:
        if j == '1':
            idx_2 = 0
            for k in F:
                if k[idx] == 1:
                    count[idx_2] += 1
                idx_2 += 1
        idx += 1
    pro = 0
    for j in range(N):
        pro += P[j][count[j]]
    ans = max(ans, pro)

print(ans)

Solution (Python):
def main():
    N = int(input())
    F = [
        [int(x) for x in input().split()]
        for _ in range(N)
    ]
    P = [
        [int(x) for x in input().split()]
        for _ in range(N)
    ]

    ans = f(N, F, P)
    print(ans)


def f(N, F, P):
    """
    N=100=10^2
    曜日*AMPM=10
        Fの組合せ=2^10≒1000=10^3
    10^3*10^2=10^5
    """
    ans = -float("inf")
    for x in range(1, 2 ** 10):
        tmp = 0
        for i in range(N):
            c = 0
            for j in range(10):
                
                if x & (2 ** j) and F[i][j]:
                    c += 1
            tmp += P[i][c]

        ans = max(ans, tmp)

    return ans


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
def MI(): return map(int, input().split())
def II(): return int(input())
def IS(): return input()
def LI(): return list(map(int, input().split()))


n = II()
eigyo_times = [LI() for _ in range(n)]
p = [LI() for _ in range(n)]
bits = []


for i in range(2 ** 10):
    op = [0] * 10
    for j in range(10):
        if ((i >> j) & 1):
            op[10-1-j] = 1
            bits.append(op)

profit = -(10**100)
for i, bit in enumerate(bits):
    if bit == [0,0,0,0,0,0,0,0,0,0]:  
        continue
    tmp_profit = 0
    for j, eigyo_time in enumerate(eigyo_times):
        
        count = len([k for k in range(10) if bit[k] & eigyo_time[k]])
        tmp_profit += p[j][count]
    profit = max(profit, tmp_profit)
print(profit)

Solution (Python):
N = int(input())
shop = []
for i in range(N):
    shop.append(list(map(int, input().split())))
prof = []
for i in range(N):
    prof.append(list(map(int, input().split())))

ans = -10000000000
for i in range(1, 1024):
    anstemp = 0
    open = "{:010b}".format(i)
    for j in range(N):
        count = 0
        for k in range(10):
            if open[k] == "1" and shop[j][k] == 1:
                count += 1
        anstemp += prof[j][count]
    ans = max(ans, anstemp)
print(ans)

Solution (Python):
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=-float("inf")
for j in range(1,2**10):
  A=list(str(bin(j))[2:])
  for i in range(10-len(A)):
    A.insert(0,"0")  
  prof=0
  for i in range(n):
    k=sum(int(p)*q for p,q in zip(A,F[i]))
    prof+=P[i][k]
  ans=max(ans,prof)
print(ans)

Solution (Python):

n = int(input())

F = []
P = []
for i in range(n):
  f = int(input().replace(" ", ""), 2)
  F.append(f)
  
for i in range(n):
  p = list(map(int,input().split()))
  P.append(p)
  
ans = -10 ** (7+2)

for i in range(1, 2**10):
  total_income = 0
  for j, income in enumerate(P):
    num = bin(i & F[j]).count("1")
    total_income += income[num]

  ans = max(ans,total_income)

  
print(ans)

Solution (Python):
import sys
import numpy as np
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())



N = ii()
F = [[0] * 10 for _ in range(N)]
for i in range(N):
    F[i] = lmi()


P = [[-10**9 for _ in range(10)] for _ in range(N)]
for i in range(N):
    P[i] = lmi()


rieki = -10**18
for i in range(1, 2 ** 10):  
    tmprieki = 0
    for num in range(N):
        cnt = 0
        for j in range(10):
            if ((i >> j) & 1) and F[num][j] == 1:
                cnt += 1
        tmprieki += P[num][cnt]
    rieki = max(rieki, tmprieki)

print(rieki)