Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))


def main():
    N, M =two_int()

    key_list=[]
    treasures=[]

    for i in range(M):
        mon,_ =two_int()
        key_list.append(mon)
        temp = map(lambda x: 1<<(x-1), many_int())
        sums = sum(temp)
        treasures.append(sums)

    max_index=2**N
    INF=10**15

    dp=[INF for i in range(max_index)]
    dp_i=[set([j for j in range(M)]) for i in range(max_index)]
    dp[0]=0

    for i in range(max_index-1):
        
        lists = list( dp_i[i])
        min_key=0
        true_new_i=0
        for j in lists:
            new_i = int(bin(treasures[j] | i),2)
            cost = dp[i] + key_list[j]
            if dp[new_i] > cost:
                dp[new_i] = cost 
                min_key = j
                true_new_i=new_i
                
        dp_i[true_new_i] = dp_i[i] - set([min_key])
        
    goal_index=max_index-1
    if dp[goal_index]!=INF:
        print(dp[goal_index])
    else:
        print(-1)

main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))


def main():
    N, M =two_int()

    key_list=[]
    treasures=[]
    check={}

    for i in range(M):
        mon,_ =two_int()
        temp = map(lambda x: 1<<(x-1), many_int())
        sums = sum(temp)
        
        if sums in check:
            if check[sums] > mon:
                check[sums]=mon
        else:
            check[sums]=mon
            
    for k,v in check.items():
        key_list.append(v)
        treasures.append(k)

    max_index=2**N
    INF=10**15

    dp=[INF for i in range(max_index)]
    dp[0]=0
    M=len(key_list)

    for i in range(max_index-1):
        for j in range(M):
            new_i = int(bin(treasures[j] | i),2)
            cost = dp[i] + key_list[j]
            dp[new_i] = min(dp[new_i], cost) 
        
    goal_index=max_index-1
    if dp[goal_index]!=INF:
        print(dp[goal_index])
    else:
        print(-1)

main()
### BUGGY CODE ###

# coding: utf-8

# 標準入力 <int>
N = int(input())

# 標準入力<str>
S = input()

ans = 0

for i in range(N - 2):
  S2 = []
  for j in range(N - i - 2):
    if S[i] == S[i + j + 1]:
      continue
    if i + ((j + 1) * 2) < N:
      S2 = S[i + j + 2:i + (2 * j) + 2] + S[i + (2 * j) + 3:]
    else:
      S2 = S[i + j + 2:]
    S2 = S2.replace(S[i], "")
    S2 = S2.replace(S[i + j + 1], "")
    ans += len(S2)

print(ans)


### FIXED CODE ###

# coding: utf-8

# 標準入力 <int>
N = int(input())

# 標準入力<str>
S = input()

R = S.count("R")
G = S.count("G")
B = S.count("B")

cnt = 0

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    k = i + ((j - i) * 2)
    if k < N:
      if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
        cnt += 1

print(R * G * B - cnt)
### BUGGY CODE ###

n = int(input())
s = [input() for _ in range(n)]
t = []
for i in range(n):
    t.append(s[i] + s[i])
t = t + t
ans = 0
for i in range(n):
    ok = True
    for j in range(n):
        for k in range(n):
            if t[i+j][k] != t[i+k][j]: 
                ok = False
                break
        if not ok: break
    if ok: ans += 1
print(ans * n)

### FIXED CODE ###

n = int(input())
s = [input() for _ in range(n)]
t = []
for i in range(n):
    t.append(s[i] + s[i])
t = t + t
ans = 0
for i in range(n):
    ok = True
    for j in range(n):
        for k in range(n):
            if t[i+j][k] != t[i+k][j]: 
                ok = False
                break
        if not ok: break
    if ok: ans += 1
print(ans * n)
### BUGGY CODE ###

n=int(input())
a=list(map(int, input().split()))
b=[]
for i in range(n):
    b.append(str(a[i]))
    b=b[::-1]
print(' '.join(b))

### FIXED CODE ###

n=int(input())
a=list(map(int, input().split()))
b=[0 for _ in range(n)]
if n%2!=0:
    for i in range(n):
        if i%2==0:
            b[n//2-i//2]=str(a[i])
        else:
            b[n//2+i//2+1]=str(a[i])
else:
    for i in range(n):
        if i%2==0:
            b[n//2+i//2]=str(a[i])
        else:
            b[n//2-i//2-1]=str(a[i])
print(' '.join(b))
### BUGGY CODE ###

from collections import deque, Counter


def bfs():
    dx = [0, 1, 0, -1]
    dy = [1, 0, -1, 0]

    while que:
        p = que.popleft()
        y = p[0]
        x = p[1]

        for i in range(4):
            ny = y + dy[i]
            nx = x + dx[i]

            if 0 <= ny < H and 0 <= nx < W and dist[ny][nx] == float("inf"):
                dist[ny][nx] = dist[y][x] + 1
                que.append((ny, nx))

    return dist


# Input params and answer
H, W = map(int, input().split())
Map = [list(input()) for i in range(H)]
dist = [[float("inf")] * W for i in range(H)]

# Initial Black Point
que = deque([])
for h in range(H):
    for w in range(W):
        if Map[h][w] == "#":
            que.append((h, w))
            dist[h][w] = 0

# BFS
nd = bfs()

# 1 dim array
c = []
for l in nd:
    c += l

print(max(c))


### FIXED CODE ###

from collections import deque, Counter


def bfs():
    dx = [0, 1, 0, -1]
    dy = [1, 0, -1, 0]

    while que:
        p = que.popleft()
        for i in range(4):
            ny = p[0] + dy[i]
            nx = p[1] + dx[i]

            if 0 <= ny < H and 0 <= nx < W and dist[ny][nx] == -1:
                dist[ny][nx] = dist[p[0]][p[1]] + 1
                que.append((ny, nx))

    return dist


# Input params and answer
H, W = map(int, input().split())
Map = [list(input()) for i in range(H)]
dist = [[-1] * W for i in range(H)]

# Initial Black Point
que = deque([])
for h in range(H):
    for w in range(W):
        if Map[h][w] == "#":
            que.append((h, w))
            dist[h][w] = 0

# BFS
nd = bfs()

ans = 0
for h in range(H):
    for w in range(W):
        if nd[h][w] > ans:
            ans = nd[h][w]

print(ans)
### BUGGY CODE ###

from collections import defaultdict,deque
import math
def main():
    n = input()
    tmp = 0
    for i in range(len(n)):
        tmp += int(n)
        tmp%=9 
    if(tmp%9==0):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import defaultdict,deque
import math
def main():
    n = input()
    tmp = 0
    for i in range(len(n)):
        tmp += int(n[i])
        tmp%=9
    if(tmp%9==0):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()
### BUGGY CODE ###

# -*- coding: utf-8 -*-

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


import itertools
import math
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(math.sqrt(n)) + 1):
       if temp%i == 0:
           cnt=0
           while temp%i == 0:
               temp //= i
               arr.append(i)

    arr.append(temp)

    ret = set()
    for val in itertools.product([0, 1], repeat = len(arr)):
        cal = 1
        for i, v in enumerate(val):
            if v == 1:
                cal *= arr[i]

        ret.add(cal)
    return ret - set([n])


def main():
    n = input_int()
    a_list = input_to_int_tuple()

    a_set = set(a_list)
    cnt = 0

    import collections
    for val, val_cnt in collections.Counter(a_list).items():
        if val_cnt > 1:
            continue

        flg = False
        for i in factorization(val):
            if i in a_set:
                flg = True
                break

        if not flg:
            cnt += 1

    # for i, val in enumerate(a_sorted_list):
    #     flg = True
    #
    #     for devide_val in a_sorted_list[:i]:
    #         if val % devide_val == 0:
    #             flg = False
    #
    #     if flg:
    #         cnt += 1

    return cnt


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


### FIXED CODE ###

# -*- coding: utf-8 -*-

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n = input_int()
    a_list = input_to_int_tuple()

    a_sorted = list(sorted(a_list))

    max_val = a_sorted[-1]
    cands = [0] * max_val

    for num in a_sorted:
        # if cands[num - 1] >= 2:
        #     continue
        for i in range(num, max_val + 1, num):
            cands[i - 1] += 1

    ans = 0
    for num in a_sorted:
        if cands[num - 1] == 1:
            ans += 1

    return ans


if __name__ == "__main__":
    print(main())
### BUGGY CODE ###

MOD = 10**9 + 7
N, M = map(int, input().split())
S = [[N+1]*(N+1) for i in [0,1,2]]
T = [[0]*(N+1) for i in [0,1,2]]

C = [0]*(N+1)
for i in range(M):
    l, r, x = map(int, input().split())
    S[x-1][r] = min(S[x-1][r], l)
    T[x-1][r] = max(T[x-1][r], l)
    C[r] = 1

S0, S1, S2 = S
T0, T1, T2 = T

ok = 1
for i in range(N+1):
    if not T2[i] < S1[i] or not T1[i] < S0[i]:
        ok = 0
        break

if not ok:
    print(0)
    exit(0)


X = {(0, 0): 3}
R = [0]*(N+1); R[0] = 3
G = [0]*(N+1); G[0] = 3
for b in range(1, N):
    t2 = T2[b+1]; s1 = S1[b+1]; t1 = T1[b+1]; s0 = S0[b+1]
    check = lambda r, g: t2 <= r < s1 and t1 <= g < s0

    if C[b+1]:
        Z = [0]*(N+1)
        if t1 <= b < s0:
            for z in range(t2, s1):
                Z[z] = R[z] + G[z]
        for (r, g), v in X.items():
            if not t2 <= r < s1 or not t1 <= g < s0:
                R[r] -= v
                G[g] -= v
        X = {(r, g): v for (r, g), v in X.items() if t2 <= r < s1 and t1 <= g < s0}
    else:
        Z = [R[z] + G[z] for z in range(N+1)]
    for z, v in enumerate(Z):
        if v:
            v %= MOD
            X[z, b] = v
            R[z] += v
            G[b] += v
print(sum(X.values()) % MOD)

### FIXED CODE ###

MOD = 10**9 + 7
N, M = map(int, input().split())
S = [[N]*(N+1) for i in [0,1,2]]
T = [[0]*(N+1) for i in [0,1,2]]

C = [0]*(N+1)
for i in range(M):
    l, r, x = map(int, input().split())
    S[x-1][r] = min(S[x-1][r], l)
    T[x-1][r] = max(T[x-1][r], l)
    C[r] = 1

S0, S1, S2 = S
T0, T1, T2 = T

ok = 1
for i in range(N+1):
    if not T2[i] < S1[i] or not T1[i] < S0[i]:
        ok = 0
        break

if not ok:
    print(0)
    exit(0)


X = {(0, 0): 3}
for b in range(1, N):
    t2 = T2[b+1]; s1 = S1[b+1]; t1 = T1[b+1]; s0 = S0[b+1]
    check = lambda r, g: t2 <= r < s1 and t1 <= g < s0

    Z = [0]*(N+1)
    if C[b+1]:
        if t1 <= b < s0:
            for (r, g), v in X.items():
                if t2 <= g < s1:
                    # r <- b+1
                    Z[g] += v
                if t2 <= r < s1:
                    # g <- b+1
                    Z[r] += v
        X = {(r, g): v for (r, g), v in X.items() if t2 <= r < s1 and t1 <= g < s0}
    else:
        Z = [0]*(N+1)
        for (r, g), v in X.items():
            # r <- b+1
            Z[g] += v
            # g <- b+1
            Z[r] += v;
    for z, v in enumerate(Z):
        if v:
            X[z, b] = v % MOD
print(sum(X.values()) % MOD)
### BUGGY CODE ###

n, k = (int(i) for i in input().split())
P = [int(i) for i in input().split()]

probs = []
for p in P:
    prob = 0
    for i in range(1,p+1):
        prob += i * (1/p)
    probs.append(prob)

ans = 0
for i in range(n-k+1):
    ans = max(ans, sum(probs[i:i+k]))
print(ans)

### FIXED CODE ###

import itertools
n, k = (int(i) for i in input().split())
P = [int(i) for i in input().split()]

probs = list(itertools.accumulate([(1+p)/2 for p in P]))
probs.insert(0,0)

ans = 0

for i in range(n-k+1):
    ans = max(ans, -probs[i]+probs[i+k])

print(ans)
### BUGGY CODE ###

N=int(input())
*A,=map(int,input().split())
t=10**9+7

ans=0
for i in range(N):
    for j in range(i+1,N):
       ans+=A[i]*A[j]%t
print(ans%t)    

### FIXED CODE ###

N=int(input())
*A,=map(int,input().split())
t=10**9+7
S=[a%t for a in A]
g=sum(S)

ans=0
for i in range(N):
       g-=S[i]
       ans+=S[i]*g%t
print(ans%t)
### BUGGY CODE ###

n=int(input())
a=[]
ans=0
for i in range(n):
    x=int(input())
    try:
        del a[a.index(x)]
    except:
        a.append(x)
print(len(a))


### FIXED CODE ###

n=int(input())
d={}
ans=0
for i in range(n):
    a=int(input())
    try:
        if d[a]%2==0:
            ans+=1
            d[a]+=1
        else:
            ans-=1
            d[a]+=1
    except:
        d[a]=1
        ans+=1
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))
if M <= N:
    print(0)
else:
    Y = []
    for i in range(1, len(X)):
        Y.append(X[i] - X[i-1])
    Y = sorted(Y)
    for i in range(N - 1):
        Y = Y[:-1]
    print(sum(Y))


### FIXED CODE ###

N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))
if M <= N:
    print(0)
else:
    Y = []
    for i in range(1, len(X)):
        Y.append(X[i] - X[i-1])
    Y = sorted(Y)
    if N == 1:
        print(sum(Y))
    else:
        print(sum(Y[:-(N-1)]))
### BUGGY CODE ###

H = int(input())

ans = 0
l = [H]
while len(l) > 0:
  ans += 1
  if l[0] == 1: del l[0]
  else:
    l = [l[0] // 2] + [l[0] // 2] + l[1:]

print(ans)

### FIXED CODE ###

H = int(input())
 
# 体力がHのモンスター1体に勝つために必要な攻撃回数をf(H)とする
# すると、f(H)は以下の漸化式に従って求まる
# f(H)=2*f(floor(H/2)+1) (H>1)
# f(H)=1 (H=1)
 
def attack_num(x):
  if x == 1: return 1
  else: return 2*attack_num(x // 2) + 1
  
print(attack_num(H))
### BUGGY CODE ###

N, M = map(int, input().split())

H = list(map(int, input().split()))

S = [list(map(int, input().split())) for i in range(M)]

d=list(range(N))

for i in range(M):
    if H[S[i][0]-1]<H[S[i][1]-1] and (S[i][0]-1) in d:
        d.remove(S[i][0]-1)
    elif H[S[i][0]-1]>H[S[i][1]-1] and (S[i][1]-1) in d:
        d.remove(S[i][1]-1)
    elif H[S[i][0]-1]==H[S[i][1]-1]:
        if (S[i][0]-1) in d:
            d.remove(S[i][0] - 1)
        if (S[i][1] - 1) in d:
            d.remove(S[i][1] - 1)

print(len(d))

### FIXED CODE ###


N, M = map(int, input().split())

H = list(map(int, input().split()))

S = [list(map(int, input().split())) for i in range(M)]

d=set(list(range(N)))

v=[]

for i in range(M):
    if H[S[i][0]-1]<H[S[i][1]-1]:
        v.append(S[i][0]-1)
    elif H[S[i][0]-1]>H[S[i][1]-1]:
        v.append(S[i][1]-1)
    elif H[S[i][0]-1]==H[S[i][1]-1]:
        v.append(S[i][0]-1)
        v.append(S[i][1] - 1)

u=set(v)

d=d-u

print(len(d))
### BUGGY CODE ###


from sys import stdin
input = stdin.readline

a,b,n = map(int,input().split())

maxpoint = 0

for i in reversed(range(n+1)):
    tmp = int((a * i) / b)  - a * int(i/b) 
    if b > 1:
        if i % (b-1) == 0 :
            maxpoint = max(tmp,maxpoint)
            print(maxpoint) 
            exit()
    elif b == 1:
        print(0)
        exit()
    maxpoint = max(tmp,maxpoint)
    # print(maxpoint)

print(maxpoint)



### FIXED CODE ###

from sys import stdin
input = stdin.readline
 
a,b,n = map(int,input().split())
maxpoint = 0
 
if b > n  :
    tmp = int((a * n) / b)  - a * int(n/b) 
    maxpoint = max(tmp,maxpoint)
else:
    k = int(n/b)*b -1
    maxpoint =  int((a * k) / b)  - a * int(k/b) 
    if b == 1:
        maxpoint = 0
 
print(maxpoint)
### BUGGY CODE ###

iteration = int(input())
array = []
set_elem = set()
for i in range(iteration):
    e = input()
    array.append(e)
    set_elem.add(e)
ans = [e for e in set_elem if array.count(e) % 2 == 1]
print(len(ans))

### FIXED CODE ###

# Write and Erase
n = int(input())
a = {}
count = 0
for _ in range(n):
    elem = input()
    if elem not in a:
        a[elem] = 1
    else:
        a[elem] += 1
for i in a.values():
    count += i % 2
print(count)
### BUGGY CODE ###

from math import gcd
n=int(input())
INF=10**18
x,y=map(int,input().split())
for _ in range(n-1):
  t,a=map(int,input().split())
  if x*a>y*t:
    i=1
    while t*i<x:
      i+=1
    x=t*i
    y=x*a//t
  else:
    i=1
    while a*i<y:
      i+=1
    y=a*i
    x=y*t//a
print(x+y)

### FIXED CODE ###

n=int(input())
x,y=1,1
for _ in range(n):
  t,a=map(int,input().split())
  m=max((x+t-1)//t,(y+a-1)//a)
  x,y=m*t,m*a
print(x+y)
### BUGGY CODE ###

s=list(input())
q=int(input())
for i in range(q):
    t=list(input().split())
    if t[0]=="1":
        s.reverse()
    else:
        if t[1]=="1":
            s.insert(0,t[2])
        else:
            s.append(t[2])
print("".join(s))



### FIXED CODE ###

from collections import deque
s=deque(list(input()))
q=int(input())
rev=0
for i in range(q):
    t=list(input().split())
    if t[0]=="1":
        rev=rev+1
    else:
        if t[1]=="1":
            if rev%2==0:
                s.appendleft(t[2])
            else:
                s.append(t[2])
        else:
            if rev%2==0:
                s.append(t[2])
            else:
                s.appendleft(t[2])
if rev%2==0:
    print("".join(s))
else:
    s.reverse()
    print("".join(s))
### BUGGY CODE ###

H,W,K = map(int, input().split())
S = [list(map(str,input())) for _ in range(H)]

ans = [[-1]*W for _ in range(H)]

cnt = 1
cnt_max = 0
for i in range(H):
	ichigo = S[i].count("#")
	if ichigo == 0:
		ans[i] = []
		continue
	cnt_max = cnt + ichigo - 1
	for j in range(W):
		if S[i][j] == ".":
			ans[i][j] = min(cnt,cnt_max)
		else:
			ans[i][j] = min(cnt,cnt_max)
			cnt += 1
	cnt = cnt_max+1
cond = 1
while cond:
	cond = 0
	for i in range(H):
		if ans[i] == []:
			cond = 1
			if i == H-1:
				ans[i] = ans[i-1]
			else:
				ans[i] = ans[i+1]

for i in range(H):
	for j in range(W):
		if j == W-1:
			print(ans[i][j])
		else:
			print(ans[i][j], end = " ")

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

H,W,K = map(int, readline().split())
grid = np.frombuffer(read(), 'S1').reshape(H,-1)[:,:W]

X,Y = np.where(grid == b'#')

A = np.zeros((H,W), np.int32)
A[X,Y] = np.arange(1,K+1)

np.maximum.accumulate(A, axis = 1, out = A)

for w in range(W-2, -1, -1):
	A[:,w] += A[:,w+1] * (A[:,w] == 0)

for h in range(1,H):
	if A[h,-1] == 0:
		A[h] += A[h-1]
for h in range(H-1,-1,-1):
	if A[h,-1] == 0:
		A[h] += A[h+1]

print('\n'.join(' '.join(row) for row in A.astype(str)))
### BUGGY CODE ###

import itertools


max_num = 5000
num_list = [i for i in range(-max_num,  max_num+1)]
num_list_5 = [i ** 5 for i in num_list]
num_comb = list(itertools.combinations(num_list, 2))

x = int(input().strip())
for comb in num_comb:
    a = comb[0]
    b = comb[1]
    a5 = num_list_5[a]
    b5 = num_list_5[b]
    if a5 - b5 == x:
        print(num_list[a], num_list[b])
        break

### FIXED CODE ###

import itertools


max_num = 200
num_list = [i for i in range(-max_num,  max_num+1)]
num_comb = list(itertools.permutations(num_list, 2))

x = int(input().strip())
for comb in num_comb:
    a = comb[0]
    b = comb[1]
    # print(a, b)
    a5 = a ** 5
    b5 = b ** 5
    if a5 - b5 == x:
        print(a, b)
        break
### BUGGY CODE ###

from collections import Counter as coun
from itertools import combinations as comb

import sys
input = sys.stdin.readline

N = int(input())
S = input()

C = coun(S)
ans = C["R"] * C["G"] * C["B"]
for i, j in comb(range(N), 2):
  k = 2 * j - i
  if k < N:
    A, B, C = S[i], S[j], S[k]
    if A != B and B != C and C != A: ans -= 1

print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
S = input()

ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N-2):
  for j in range(i+1, N-1):
    k = 2 * j - i
    if k < N:
      A, B, C = S[i], S[j], S[k]
      if A != B and B != C and C != A: ans -= 1

print(ans)
### BUGGY CODE ###

N = int(input())
V = [int(x.strip()) for x in input().split()]
C = [int(x.strip()) for x in input().split()]

X = [0 for i in range(2**N)]
Y = [0 for i in range(2**N)]
Z = [0 for i in range(2**N)]

for i in range(1, 2**N):
    select = []
    temp = i
    for n in reversed(range(1, N+1)):
        if temp - 2**(n-1) >= 0:
            temp = temp - 2**(n-1)
            select.append(n-1)
    for j in select:
        X[i] += V[j]
        Y[i] += C[j]
    Z[i] = X[i] - Y[i]
print(max(Z))

### FIXED CODE ###

N = int(input())
V = [int(x.strip()) for x in input().split()]
C = [int(x.strip()) for x in input().split()]

Z = [V[i] - C[i] for i in range(N)]
print(sum([z for z in Z if z > 0]))
### BUGGY CODE ###

n=int(input())
import math
a=list(map(int,input().split()))
d=dict()
for i in range(n):
    if d.get(a[i],None)==None:
        d[a[i]]=0
    d[a[i]]+=1 
ans=0
s=d.keys()
for i in range(n):
    if d[a[i]]>1:
        continue 
    flag=True
    # print(a[i],end='    s\n')
    for ii in range(1,math.ceil(a[i]**(1/2))+1):
        if (a[i]%ii)==0:
            aa,bb=ii,a[i]//ii
            if aa!=a[i] and aa in s:
                # print(aa)
                # print('aa')
                flag=False
                break
            if bb!=a[i] and bb in s:
                # print('bb')
                # print(bb)
                flag=False
                break
    if(flag):
        # print(a[i])
        ans+=1
print(ans)
        
    

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
m=max(a)
dp=[0 for i in range(m+1)]
ans=0
for i in range(n):
    if dp[a[i]]>=1:
        dp[a[i]]+=1
        continue
    for j in range(2*a[i],m+1,a[i]):
        dp[j]+=1 
    dp[a[i]]=1
for i in range(n):
    if dp[a[i]]==1:
        ans+=1 
print(ans)
### BUGGY CODE ###

import numpy

N = int(input())

S = [[x for x in input()] for _ in range(N)] 

S_mat = numpy.mat(S)

ret = 0
for A in range(N):
    A_change_list = list(range(A, N))
    A_change_list.extend(list(range(A)))
    for B in range(N):
        B_change_list = list(range(B, N))
        B_change_list.extend(list(range(B)))

        moved = S_mat[A_change_list, :][:,B_change_list]
        if numpy.all(moved == moved.T):
            ret +=1
print(ret)



### FIXED CODE ###

import numpy

N = int(input())

S = [[x for x in input()] for _ in range(N)] 

S_mat = numpy.mat(S)

ret = 0
for A in range(N):
    A_change_list = list(range(A, N))
    A_change_list.extend(list(range(A)))
    moved = S_mat[A_change_list, :]
    if numpy.all(moved == moved.T):
        ret +=1
print(N*ret)
### BUGGY CODE ###

def main():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N)]
    r = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(N):
                if k == i or k == j:
                    continue
                if A[i][k] + A[k][j] < A[i][j]:
                    return -1
                if A[i][k] + A[k][j] == A[i][j]:
                    break
            else:
                r += A[i][j]
    return r

print(main())


### FIXED CODE ###

def main():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N)]
    r = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(N):
                if k == i or k == j:
                    continue
                if A[i][k] + A[k][j] < A[i][j]:
                    return -1
                if A[i][k] + A[k][j] == A[i][j]:
                    break
            else:
                r += A[i][j]
    return r

print(main())
### BUGGY CODE ###

k,s = map(int,input().split())
count = 0
for x in range(max(0,s-2*k),k+1):
    for y in range(max(0,s-k-x),k+1):
        for z in range(max(0,s-x-y),k+1):
            if x+y+z == s:
                count+=1
print(count)

### FIXED CODE ###

k,s = map(int,input().split())
count = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if z>=0 and z<=k:
            count+=1
print(count)