CodeEff/ECCO huggingface dataset:
# Original solution
N = int(eval(input()))
fs = [list(map(int,input().split())) for i in range(N)]
ps = [list(map(int,input().split())) for i in range(N)]

INF = float('inf')
ans = -INF
for b in range(1,2**10):
    tmp = 0
    for f,p in zip(fs,ps):
        c = 0
        for k in range(10):
            if b&(1<<k)==0: continue
            if f[k]: c += 1
        tmp += p[c]
    ans = max(ans, tmp)
print(ans)

# Optimized solution
N = int(eval(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 k in range(1,1<<10):
    tmp = 0
    for fs,ps in zip(F,P):
        cnt = 0
        for b in range(10):
            if (k>>b)&1 and fs[b]:
                cnt += 1
        tmp += ps[cnt]
    ans = max(ans, tmp)
print(ans)
# Original solution
N = int(eval(input()))

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

ans = - 10 ** 16
for i in range(1 << 10):
    output = [0] * 10
    for j in range(10):
        if (i>>j) & 1:
            output[j] = 1
    if output.count(0) == 10:
        continue
    tmp_sum = 0
    for n in range(N):
        cnt = 0
        for m in range(10):
            if F[n][m] == output[m] == 1:
                cnt += 1
        tmp_sum += P[n][cnt]
    ans = max(ans, tmp_sum)
print(ans)

# Optimized solution
def main():
    N = int(eval(input()))
    F = [list(map(int, input().split())) for _ in range(N)]
    P = [list(map(int, input().split())) for _ in range(N)]
    ans = -(10**15)
    for i in range(2**10):
        tmp = []
        for j in range(10):
            if ((i >> j) & 1):
                tmp.append(j)
        if not tmp:
            continue
        score = 0
        for k in range(N):
            cnt = 0
            for l in range(10):
                if F[k][l] == 1 and l in tmp:
                    cnt += 1
            score += P[k][cnt]

        ans = max(ans, score)

    print(ans)
if __name__ == "__main__":
    main()
# Original solution
n = int(eval(input()))
flst = []
for _ in range(n):
  flst.append([int(i) for i in input().split()])
plst = []
for _ in range(n):
  plst.append([int(i) for i in input().split()])
m = - 1 << 30
for i in range(1, 1 << 10):
  r = 0
  for j in range(n):
    c = 0
    for k in range(10):
      if (i >> k & 1) & flst[j][k]:
        c += 1
    r += plst[j][c]
  m = max(m, r)
print(m)


# Optimized solution
n = int(eval(input()))
flst = []
for _ in range(n):
  flst.append(int(''.join(input().split()), 2))
plst = []
for _ in range(n):
  plst.append([int(i) for i in input().split()])
m = - 1 << 30
for i in range(1, 1 << 10):
  r = 0
  for j in range(n):
    s = i & flst[j]
    c = 0
    while s:
        s &= s - 1
        c += 1
    r += plst[j][c]
  m = max(m, r)
print(m)
# Original solution
n = int(eval(input()))
f = [input().replace(" ", '') for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

outcome_list = []
for i in range(1, 1 << 10):
    outcome = 0
    for j, x in enumerate(f):
        both = "{:010b}".format(i & int(x, 2))
        n_store = sum(map(int, list(both)))
        outcome += p[j][n_store]
    outcome_list.append(outcome)
print((max(outcome_list)))

# Optimized solution
N = int(eval(input()))
F = [int(input().replace(" ", ''), 2) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

outcome_list = []
for i in range(1, 1 << 10):
    outcome = 0
    for f, p in zip(F, P):
        n_store = "{:010b}".format(i & f).count("1")
        outcome += p[n_store]
    outcome_list.append(outcome)
print((max(outcome_list)))
# Original solution
from sys import stdin

input = stdin.readline

MAX_TIME = 10

N = int(eval(input()))

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

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


def main():
    ans = -11000000001

    # 営業時間帯 最低でも ひとつの時間帯
    # 選択パターン
    for i in range(1, 2 ** MAX_TIME):
        tmp = 0

        # 他の店
        for j in range(N):
            # 各時間帯
            cnt = sum([F[j][k] for k in range(MAX_TIME) if i >> k & 1])
            tmp += P[j][cnt]

        ans = max(ans, tmp)

    print(ans)
    return


main()


# Optimized solution
MAX_TIME = 10

N = int(eval(input()))

F = [int(input().replace(" ", ""), 2) for i in range(N)]

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


def main():
    # 1 から 2 ** MAX_TIME - 1
    # 営業時間帯 最低でも ひとつの時間帯
    # 選択する時間帯を2進法で表現したもの

    # F[店のインデックス]
    # 他の店
    # 選択する時間帯を2進法で表現したもの

    # P[店のインデックス][合致した時間帯の数]
    # 利益
    print((max(sum(
        [p[bin(f & i).count("1")] for f, p in zip(F, P)])
        for i in range(1, 2 ** MAX_TIME))))

    return


main()
# Original solution
n = int(eval(input()))
shops = [list(input().split()) for i in range(n)]
profits = [list(input().split()) for i in range(n)]

l = []
ans = -10000000000000000000000000000
def f(now, i):
  if i >= 10:
    l.append(list(now))
    return
  
  f(now+"1", i+1)
  f(now+"0", i+1)
f("", 0)

for i in range(len(l)-1):
  temp = 0
  for j in range(len(shops)):
    count = 0
    for k in range(10):
      if shops[j][k] == "1" and l[i][k] == "1":
        count += 1
    temp += int(profits[j][count])
  if temp > ans:
    ans = temp

print(ans)

# Optimized solution
import itertools
n = int(eval(input()))
F = [list(map(int, input().split())) for i in range(n)]
P = [list(map(int, input().split())) for i in range(n)]
combos = sorted(list(itertools.product([0, 1], repeat=10)))
ans = -float('inf')

for combo in combos[1:]:
  total = 0

  for i in range(len(F)):
    count = 0      
    for a, b in zip(combo, F[i]):
      if a == 1 and b == 1:
        count += 1
    total += P[i][count]
  
  ans = max(ans, total)

print(ans)
# Original solution
N=int(eval(input()))
F=[tuple(map(int,input().split())) for _ in range(N)]
P=[tuple(map(int,input().split())) for _ in range(N)]

ans=-(10**7*N)
#営業パターンを10bitの整数であらわす(0はない)
for o in range(1,1<<10):
    #同時に営業する時間帯数のリスト
    C=[0]*N
    for t in range(10):
        #時間帯tに営業するか
        if o&1:
            for i in range(N):
                if F[i][t]==1:
                    C[i]+=1
        o>>=1
    #利益を計算
    p=0
    for i in range(N):
        p+=P[i][C[i]]
    ans=max(ans,p)

print(ans)

# Optimized solution
N=int(eval(input()))
F=[int(input().replace(' ',''),2) for _ in range(N)]
P=[tuple(map(int,input().split())) for _ in range(N)]

ans=-(10**7*N)
for o in range(1,1<<10):
    p=0
    for i in range(N):
        p+=P[i][bin(F[i]&o).count('1')]
    ans=max(ans,p)
print(ans)
# Original solution
N = int(eval(input()))
Flists = [list(map(int, input().split())) for _ in range(N)]
Plists = [list(map(int, input().split())) for _ in range(N)]

ans = -10**9
for i in range(1, 2**10):
    open = []
    for j in range(10):
        if ((i>>j) & 1):
            open.append(1)
        else:
            open.append(0)
    money = 0
    for num in range(N):
        Flist = Flists[num]
        same = sum([int(open[_] and Flist[_]) for _ in range(10)])
        money += Plists[num][same]
    ans = max(ans, money)

print(ans)


# Optimized solution
N = int(eval(input()))
F = [int("".join(input().split()), 2) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

# for i in range(N):
#     print(bin(F[i]))

ans = -10**9
for bit in range(1, 1<<10):
    money = 0
    for i in range(N):
        cnt = format(bit&F[i], 'b').count('1')
        money += P[i][cnt]
    ans = max(money, ans)
 
print(ans)
# Original solution
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)

    from collections import Counter
    from collections import deque

    #dxy = [[0,1],[0,-1],[1,0],[-1,0]]
    #dxy = [[0,1],[0,-1],[1,0],[-1,0],[1,1],[1,-1],[-1,1],[-1,-1]]
    #mod = 1000000007

    n = int(eval(input()))
    F = [input().split() for _ in range(n)]
    P = [list(map(int, input().split())) for _ in range(n)]
    ans = -10**10
    for i in range(1, 1033):
        a = list(str(format(i, '010b')))
        total = 0
        for j in range(n):
            cnt = 0
            for k in range(10):
                if F[j][k]=='1' and a[k]=='1':
                    cnt += 1
            total += P[j][cnt]
        if total>ans:
            ans = total
    print(ans)




if __name__ == '__main__':
    main()

# Optimized solution
N=int(eval(input()))
SO=[int(input().replace(' ',''), 2) for i in range(N)]
PT=[list(map(int,input().split())) for i in range(N)]
ret=-10**7*N
for sp in range(1,2**10):
  r=0
  for i in range(N):
    r+=PT[i][bin(SO[i] & sp).count('1')]
  ret=max(ret,r)
print(ret)
# Original solution
N=int(eval(input()))
SO=[int(input().replace(' ',''), 2) for i in range(N)]
PT=[list(map(int,input().split())) for i in range(N)]
ret=-10**7*N
for sp in range(1,2**10):
  r=0
  for i in range(N):
    r+=PT[i][bin(SO[i] & sp).count('1')]
  ret=max(ret,r)
print(ret)

# Optimized solution
n = int(eval(input()))
F = [int(input().replace(' ',''), 2) for _ in range(n)]
P = [list(map(int, input().split())) for _ in range(n)]
ans=-10**7*n
for sp in range(1, 2**10):
  total = 0
  for i in range(n):
    total += P[i][bin(F[i] & sp).count('1')]
  ans = max(ans, total)
print(ans)
# Original solution
n = int(eval(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, 2 ** 10):
    i_bin = "{:010b}".format(i)
    sm = 0
    for shop_i in range(n):
        cnt = 0
        for j, dig in enumerate(i_bin):
            if f[shop_i][j] * int(dig):# == 1
                cnt += 1
        sm += p[shop_i][cnt]
    ans = max(ans, sm)
        
print(ans)


# Optimized solution
from itertools import combinations

n = int(eval(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, 11):
    for pat in combinations(list(range(10)), i):
        cnt = [0] * n
        for e in pat:
            for j in range(n):
                cnt[j] += f[j][e]

        score = 0
        for i, e in enumerate(cnt):
            score += p[i][e]

        ans = max(ans, score)

print(ans)
# Original solution
n=int(eval(input()))
f=[0]*n
for i in range(n):
  x=list(map(int,input().split()))
  for j in range(len(x)):
    if x[j]==1:
      f[i]+=1<<j
  
p=[[0 for j in range(10)] for i in range(n)]

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

ans=10**9*(-1)-1
for i in range(1,2**10):
  pro=0
  for j in range(len(f)):
    open=0
    for k in range(10):
      if (i>>k)&1==1 and (f[j]>>k)&1==1:
        open+=1
    pro+=p[j][open]
  if ans<pro:
    ans=pro
print(ans)


# Optimized solution
# 曜日と時間帯の組み合わせを1111111111の10ビットで全探索

import sys
readline = sys.stdin.readline

N = int(readline())
F = [None] * N
for i in range(N):
  F[i] = int(readline().rstrip().replace(" ",""),2)
    
P = [None] * N
for i in range(N):
  P[i] = list(map(int,readline().split()))
  
ans = -(10 ** 10)
for i in range(1, 2 ** 10):
  # joisinoが営業する時間帯の文字列11011101
  # 各店について、店jとANDを取って、1ビットの数を数えるとCが分かる
  point = 0
  for j in range(N):
    # 店j
    debug = False
    c = bin(i & F[j])[2:].count("1")
    point += P[j][c]
  if ans < point:
    ans = point
  
print(ans)
# Original solution
ans = -10 ** 9
A = [0] * 10


def func():
    if sum(A) == 0:
        return
    score = 0
    for i in range(N):
        days = sum([a * f for a, f in zip(A, F[i])])
        score += P[i][days]
    global ans
    ans = max(ans, score)


def dfs(pos):
    if pos == 10:
        func()
        return
    A[pos] = 0
    dfs(pos + 1)
    A[pos] = 1
    dfs(pos + 1)


N = int(eval(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())))

dfs(0)
print(ans)


# Optimized solution
def calc(days):
    if sum(days) == 0:
        return
    profit = 0
    for i in range(N):
        both = 0
        for f, d in zip(F[i], days):
            if f == d == 1:
                both += 1
        profit += P[i][both]
    global ans
    ans = max(ans, profit)


def dfs(days):
    if len(days) == 10:
        calc(days)
        return
    dfs(days + [0])
    dfs(days + [1])


ans = 10 ** 9 * (-1)
N = int(eval(input()))
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

dfs([])
print(ans)
# Original solution
import itertools
N = int(eval(input()))
F = [list(map(int,input().split())) for i in range(N)]
P = [list(map(int,input().split())) for i in range(N)]
b = [0,1]
ans = -float('inf')
for e in itertools.product(b,repeat=10):
    e = list(e)
    if e == [0]*10:
        continue
    res = 0
    for i in range(N):
        cnt = 0
        for j in range(10):
            if e[j] == 1 and F[i][j] == 1:
                cnt += 1
        res += P[i][cnt]
    if res > ans:
        ans = res
print(ans)

# Optimized solution
import itertools
inf = float('inf')

N = int(eval(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)
# Original solution
n = int(eval(input()))
v = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

max_v_minus_c = 0

for i in range(2**n):
    flugs = bin(i)[2:].zfill(n)
    sum_v = 0
    sum_c = 0
    j = 0
    for flug in str(flugs):
        if flug == '1':
            sum_v += v[j]
            sum_c += c[j]
        j += 1

    if (max_v_minus_c < sum_v - sum_c):
        max_v_minus_c = sum_v - sum_c

print(max_v_minus_c)


# Optimized solution
n = int(eval(input()))
v_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]

b_list = [v - c for (v, c) in zip(v_list, c_list)]
print((sum([b for b in b_list if b > 0])))
# Original solution
n = int(eval(input()))
v = list(map(int,input().split()))
c = list(map(int,input().split()))
xy = [x-y for (x,y) in zip(v,c)]
sm = 0
for x in xy:
    if x>0:
        sm += x
print(sm)

# Optimized solution
n = int(eval(input()))
v = list(map(int,input().split()))
c = list(map(int,input().split()))
xy = [x-y for (x,y) in zip(v,c)]
sm = 0
for x in xy:
    sm = sm+x if x>0 else sm+0
print(sm)
# Original solution
N = int(eval(input()))
V = [int(n) for n in input().split()]
C = [int(n) for n in input().split()]

take = [0 for _ in range(N)]
ans = 0

def up(i):
    if i == N:
        return False
    take[i] += 1
    if take[i] == 2:
        take[i] = 0
        return up(i + 1)
    return True

while True:
    sum = 0
    for i in range(N):
        if take[i] == 1:
            sum += V[i] - C[i]
    if sum > ans:
        ans = sum
    if not up(0):
        break

print(ans)


# Optimized solution
N = int(eval(input()))
V = [int(n) for n in input().split()]
C = [int(n) for n in input().split()]

ans = 0
for i in range(N):
    ans = max([ans, ans + V[i] - C[i]])

print(ans)
# Original solution
N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))

maxV = 0
for i in range(2**N):
    bit = i
    X = Y = 0
    for j in range(N):
        mod = bit%2
        bit = bit//2
        if(mod==1):
            X += V[j]
            Y += C[j]
    maxV = max(maxV, X-Y)

print(maxV)


# Optimized solution
N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))

X = [max(0, V[i]-C[i]) for i in range(N)]
print((sum(X)))
# Original solution
def main():
    g = []
    n = int(eval(input()))
    v = list(map(int,input().split()))
    c = list(map(int,input().split()))
    for i in range(n):
        gain = v[i] -c[i]
        if gain > 0 :
            g.append(gain)
    print((sum(g)))


if __name__ == '__main__':
    main()

# Optimized solution
def main():
    g = 0
    n = int(eval(input()))
    v = list(map(int,input().split()))
    c = list(map(int,input().split()))
    for i in range(n):
        gain = v[i] -c[i]
        if gain > 0 :
            g += gain
    print(g)


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))

V = list(map(int,input().split()))
C = list(map(int,input().split()))

x = 0
y = 0
mx = 0
for i in range(2**N):
    x = 0
    y = 0
    for j in range(N):
        if (i >> j) & 1 == 1:
            x += V[j]
            y += C[j]
        mx = max(x-y,mx)
print(mx)

# Optimized solution
N = int(eval(input()))

V = list(map(int,input().split()))
C = list(map(int,input().split()))

x = 0
y = 0
mx = 0
l = [V[i]-C[i] for i in range(N)]
print((sum([ i for i in l if i>0 ])))
# Original solution
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
x = 0
y = 0
for i in range(n):
    if v[i] - c[i] > 0:
        x += v[i]
        y += c[i]
print((x-y))


# Optimized solution
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
x = 0
y = 0
# 価値とコストが0以上である宝石を選ぶ。
for i in range(n):
    if v[i] - c[i] > 0:
        x += v[i]
        y += c[i]
# 選択した宝石の価値とコストの総和差の計算。
print((x-y))
# Original solution
N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(1<<N):
    val = 0
    for j in range(N):
        if i >> j & 1:
            val+=V[j]
            val-=C[j]
    ans = max(ans, val)
print(ans)


# Optimized solution
N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    val = 0
    for j in range(N):
        if (i >> j) & 1:
            val+=V[j]
            val-=C[j]
    ans = max(ans, val)
print(ans)
# Original solution
import itertools

N = int(eval(input()))
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

max = 0
pattern = itertools.product(list(range(2)), repeat=N)
for p in pattern:
    sum = 0
    count = 0
    for i in p:
        if i == 1:
            sum += V[count]-C[count]
        else:
            pass
        count +=1
    if sum > max:
        max = sum


print(max)


# Optimized solution
import itertools

N = int(eval(input()))
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

sum = 0
for i in range(N):
    if V[i]-C[i] > 0:
        sum += V[i]-C[i]

print(sum)
# Original solution
# coding: utf-8
import itertools
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
d = sum(v) - sum(c)
maxd = d if d > 0 else 0
for m in range(1, n):
    a0 = [i for i in list(itertools.combinations(list(range(n)), m))]
    for a1 in a0:
        d = sum([v[j] - c[j] for j in a1])
        if maxd < d:
            maxd = d
print(maxd)


# Optimized solution
# coding: utf-8
import itertools
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
d = sum([v[i] - c[i] for i in range(n) if v[i] - c[i] > 0])
print(d)
# Original solution
from itertools import combinations

n = int(eval(input()))
value = list(map(int, input().split()))
cost = list(map(int, input().split()))

idx = list(range(n))
result = [0, sum(value)-sum(cost)]
comb = [com for i in range(1, n) for com in combinations(idx, i)]

for com in comb:
  tmp = 0
  for c in com:
    tmp += value[c]-cost[c]
  result.append(tmp)
    
print((max(result)))

# Optimized solution
n = int(eval(input()))
value = list(map(int, input().split()))
cost = list(map(int, input().split()))
result = 0
for v, c in zip(value, cost):
  if v > c:
    result += v-c
print(result)
# Original solution
n = int(eval(input()))
v = list(map(int,input().split()))
c = list(map(int,input().split()))
list = [0]
x, y = 0, 0

v_sort = sorted(v,reverse = True)
c_sort = sorted(c,reverse = True)

for i in range(len(v)):
    if v[i] > c[i]:
        x += int(v[i])
        y += int(c[i])
        list.append(x - y)
    else:
        continue

print((max(list)))

# Optimized solution
n = int(eval(input()))
v = list(map(int,input().split()))
c = list(map(int,input().split()))
list = [0]
x, y = 0, 0

for i in range(len(v)):
    if v[i] > c[i]:
        x += int(v[i])
        y += int(c[i])
        list.append(x - y)
    else:
        continue

print((max(list)))
# Original solution
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))

import itertools
bit = list(itertools.product([0,1], repeat=n))

ans = []
for i in range(2 ** n):
    arr = list(bit[i])
    x = 0
    y = 0
    for j in range(len(arr)):
        if arr[j] == 1:
            x += v[j]
            y += c[j]
    ans.append(x-y)
print((max(ans)))


# Optimized solution
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))

count = 0
for i in range(n):
    if v[i] >= c[i]:
        count += v[i] - c[i]

print(count)
# Original solution
n=int(eval(input()))
v=list(map(int,input().split()))
c=list(map(int,input().split()))
h=[]
for x,y in zip(v,c):
  h.append(x-y)
ans=0
for i in h:
  if i>=0:
    ans+=i
print(ans)


# Optimized solution
n=eval(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
for i,j in zip(v,c):
  if i-j>0:
    ans+=(i-j)
print(ans)
# Original solution
n=int(eval(input()))
v=[*list(map(int,input().split()))]
c=[*list(map(int,input().split()))]
print((sum(max(x-y,0) for x,y in zip(v,c))))

# Optimized solution
eval(input())
f=lambda:list(map(int,input().split()))
print((sum(max(x-y,0) for x,y in zip(f(),f()))))
# Original solution
n=int(eval(input()))

v=list(map(int,input().split()))
c=list(map(int,input().split()))

x=0
for i in range(2**n):
    cost=0
    value=0
    for j in range(n):
        if i>>j&1:
            cost+=c[j]
            value+=v[j]
    else:
        if value-cost>x:
            x=value-cost
            


print(x)
         

# Optimized solution
n=int(eval(input()))

v=list(map(int,input().split()))
c=list(map(int,input().split()))

ans=0
for i in range(n):
    if v[i]-c[i]>=1:
        ans+=v[i]-c[i]

print(ans)
# Original solution
import itertools
N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))

diff =[V[n] - C[n] for n in range(N)]
XY = 0

for v in itertools.permutations([0, 1] * N, N):
  xy = 0
  for n in range(N):
    xy += diff[n] * v[n]
  if xy > XY:
    XY = xy
print(XY)

# Optimized solution
N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))

diff = [0]
for n in range(N):
  if V[n] - C[n] > 0:
    diff.append(V[n] - C[n])

print((sum(diff)))
# Original solution
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
v = LI()
c = LI()
lst = [v[i]-c[i] for i in range(n)]
ans = 0
for i in range(n):
    if lst[i] >= 0:
        ans += lst[i]
print(ans)

# Optimized solution
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
v = LI()
c = LI()
ans = 0
for i in range(n):
    if v[i] > c[i]:
        ans += v[i] - c[i]
print(ans)