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

n,x,y = map(int,input().split())
x,y = x-1,y-1
dist_list = []
for i in range(n-1):
    for j in range(i+1,n):
        dist1 = j-i
        dist2 = abs(i-x) +1 + abs(j-y)
        dist = min(dist1,dist2)
        dist_list.append(dist)

S = set(dist_list)
D = {}
for i in range(n):
    D[str(i+1)]=0
for i in range(len(dist_list)):
    D[str(dist_list[i])]=D[str(dist_list[i])]+1
    
for i in range(1,n):
    print(D[str(i)])

### FIXED CODE ###

n,x,y = map(int,input().split())
x,y = x-1,y-1

D = [0 for _ in range(n+1)]
    
for i in range(n-1):
    for j in range(i+1,n):
        dist1 = j-i
        dist2 = abs(i-x) +1 + abs(j-y)
        dist = min(dist1,dist2)
        D[dist] = D[dist]+1


    
for i in range(1,n):
    print(D[i])
### BUGGY CODE ###

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

A=list(map(int,input().split()))
F=list(map(int,input().split()))

A.sort()
F.sort(reverse=True)

H=10**12
L=0

while abs(H-L)>4:
    Mid=(H+L)//2
    #print(H,Mid,L)
    cnt=0
    for i in range(N):
        f=0
        if A[i]*F[i]>Mid:
            cnt+=(A[i]-int(Mid/F[i]))
            if cnt>K:
                f=1
                break
    if f==1:
        L=Mid
    else:
        H=Mid
for j in range(5):
    M=H-j
    cnt=0
    for i in range(N):
        if A[i]*F[i]>M:
            cnt+=(A[i]-int(M/F[i]))
            if cnt>K:
                print(M+1)
                exit()
print(0)

### FIXED CODE ###

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

A=list(map(int,input().split()))
F=list(map(int,input().split()))

A.sort()
F.sort(reverse=True)

H=10**12
L=0

while abs(H-L)>4:
    Mid=(H+L)//2
    #print(H,Mid,L)
    cnt=0
    for i in range(N):
        f=0
        if A[i]*F[i]>Mid:
            cnt+=(A[i]-int(Mid/F[i]))
            if cnt>K:
                f=1
                break
    if f==1:
        L=Mid
    else:
        H=Mid
for j in range(5):
    M=H-j
    cnt=0
    for i in range(N):
        if A[i]*F[i]>M:
            cnt+=(A[i]-int(M/F[i]))
            if cnt>K:
                print(M+1)
                exit()
print(0)
### BUGGY CODE ###

import numpy as np

N = int(input())
X = str(input())
num_one = X.count("1")
def func(x):
    if a[x] != -1:
        return a[x]
    else:
        counter = 0
        x_tmp = x
        while x > 0:
            if x % 2 == 1:
                counter += 1
            x = x >> 1
        a[x_tmp] = func(x_tmp % counter) + 1
        return func(x_tmp % counter) + 1

    

a = [-1] * (2 * 10 ** 5)
a[0] = 0
num_one = X.count("1")
zero_ver = np.array([pow(2,  i, num_one + 1) for i in range(N)])
one_ver = np.array([-1])
if num_one != 1:
    one_ver = np.array([pow(2,  i, num_one - 1) for i in range(N)])
bool_arr = np.array([True if X[N-i-1] == "1" else False for i in range(N)])
for i in range(1,N+1):
    tmp_bool = bool_arr.copy()
    start = 0
    if tmp_bool[N-i] == False:
        tmp_bool[N-i] = True
        start = sum(zero_ver[tmp_bool]) % (num_one + 1)
        print(func(start)+1)
    else:
        if sum(one_ver) == -1:
            print(0)
        else:
            tmp_bool[N-i] = False
            start = sum(one_ver[tmp_bool]) %  (num_one - 1)
            print(func(start)+1)

### FIXED CODE ###

import numpy as np

N = int(input())
X = str(input())
num_one = X.count("1")

dp = [-1] * N
dp[0] = 0
def dfs(n):
    if dp[n] == -1:
        dp[n] = 1 + dfs(n % bin(n).count('1'))
    return dp[n]

num_one = X.count("1")
bool_arr = np.array([True if X[N-i-1] == "1" else False for i in range(N)])
zero_ver = np.array([pow(2,  i, num_one + 1) for i in range(N)])
zero_ver_sum = sum(zero_ver[bool_arr])

one_ver = -1
one_ver_sum = 0
flag = False
if num_one != 1:
    one_ver = np.array([pow(2,  i, num_one - 1) for i in range(N)])
    one_ver_sum = sum(one_ver[bool_arr])
else:
    flag = True
for i in range(1,N+1):
    start = 0
    if bool_arr[N-i] == False:
        start = (zero_ver_sum + pow(2, N - i, num_one + 1)) % (num_one + 1)
        print(dfs(start)+1)
    else:
        if flag:
            print(0)
        else:
            start = (one_ver_sum - pow(2, N - i, num_one - 1))  %  (num_one - 1)
            print(dfs(start)+1)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
def saiki(num,lis):
    if num==H:
        cand.append(lis)
    else:
        saiki(num+1,lis+[lis[-1]])
        saiki(num+1,lis+[num])
#全探索
H,W,K=map(int,input().split())

S=[]
for h in range(H):
    s=list(input())
    S.append(list(map(int,s)))
        
cand=[]

saiki(1,[0])

ans=[]
for item in cand:
    temp=len(list(set(item)))-1
    wa=[[0]*W for i in range(H)]
    for i in range(H):
        for j in range(W):
            wa[item[i]][j]+=S[i][j]
    #クラスタを作っていきたい
    sam=[0]*H
    count=0
    for w in range(W):
        judge=False
        for h in range(H):
            if wa[h][w]>K:
                judge=True
            sam[h]+=wa[h][w]
            if w!=W-1:
                if sam[h]+wa[h][w+1]>K:
                    count+=1
                    for i in range(H):
                        
                        sam[i]=0
                    break
        if judge:
            count=10**9
            break
    """
    print("------------------")
    print(item)
    print(sam)
    """
    ans.append(temp+count)
    #print(wa)
print(min(ans))
#print(cand)
#print(S)

### FIXED CODE ###

# coding: utf-8
# Your code here!
def saiki(num,lis):
    if num==H:
        cand.append(lis)
    else:
        saiki(num+1,lis+[lis[-1]])
        saiki(num+1,lis+[num])
#全探索
H,W,K=map(int,input().split())

S=[]
for h in range(H):
    s=list(input())
    S.append(list(map(int,s)))
        
cand=[]

saiki(1,[0])

ans=[]
for item in cand:
    temp=len(list(set(item)))-1
    wa=[[0]*W for i in range(H)]
    for i in range(H):
        for j in range(W):
            wa[item[i]][j]+=S[i][j]
    #クラスタを作っていきたい
    sam=[0]*H
    count=0
    for w in range(W):
        judge=False
        for h in range(H):
            if wa[h][w]>K:
                judge=True
            sam[h]+=wa[h][w]
            if w!=W-1:
                if sam[h]+wa[h][w+1]>K:
                    count+=1
                    for i in range(H):
                        
                        sam[i]=0
                    break
        if judge:
            count=10**9
            break
    """
    print("------------------")
    print(item)
    print(sam)
    """
    ans.append(temp+count)
    #print(wa)
print(min(ans))
#print(cand)
#print(S)
### BUGGY CODE ###

N,K = map(int,input().split())
L=list(map(int,input().split()))
A=[0]*N

s=0

for i in range(N):
    t=(L[i]+1)*L[i]/2*(1/L[i])
    A[i]=t

for i in range(N-K+1):
    #print(A[i:i+K])
    s=max(s,sum(A[i:i+K]))

print(s)    


### FIXED CODE ###

N,K = map(int,input().split())
L=list(map(int,input().split()))
A=[0]*N


for i in range(N):
    t=(L[i]+1)*L[i]/2*(1/L[i])
    A[i]=t
s=0
t=sum(A[:K])
s=max(s,t)
for i in range(N-K):
    t+=(A[i+K]-A[i])
    s=max(s,t)

print(s)
### BUGGY CODE ###

import math

n = int(input())

total = 0
for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            total += math.gcd(i, math.gcd(j, k))
print(total)

### FIXED CODE ###

import math

n = int(input())

total1 = 0
for i in range(1, n + 1):
    for j in range(i+1, n + 1):
        for k in range(j+1, n + 1):
            total1 += math.gcd(i, math.gcd(j, k))
total1 = 6*total1

total2 = 0
for i in range(1, n + 1):
    for j in range(i+1, n + 1):
        total2 += math.gcd(i, j)
total2 = 6*total2

total3 = 0
for i in range(1, n + 1):
    total3 += i

print(total1 + total2 + total3)
### BUGGY CODE ###

from collections import Counter 
N,T=map(int, raw_input().split())
A=map(int, raw_input().split())

b=[]
for i in range(N-1):
	max_n=max(A[i+1::])
	b.append(max_n-A[i])

C=Counter(b)
max_key=max(C.keys())

print C[max_key]

### FIXED CODE ###

from collections import Counter
N,T=map(int, raw_input().split())
A=map(int, raw_input().split())

A_r=[None for i in range(N)]
n=0
for i in range(N-1,-1,-1):
	n=max(A[i],n)
	A_r[i]=n

B=[]
for i in range(N-1):
	B.append(A_r[i+1]-A[i])


C=Counter(B)

print C[max(B)]
### BUGGY CODE ###

def main():
    S = input()
    Q = int(input())
    revFlag = False
    for i in range(Q):
        tmp = list(input().split())
        if tmp[0] == "1":
            if revFlag:
                revFlag = False
            else:
                revFlag = True
        else:
            if tmp[1] == "1":
                if revFlag:
                    tl = [S,tmp[2]]
                    S = "".join(tl)
                else:
                    tl = [tmp[2],S]
                    S = "".join(tl)
            else:
                if revFlag:
                    tl = [tmp[2],S]
                    S = "".join(tl)
                else:
                    tl = [S,tmp[2]]
                    S = "".join(tl)
    if revFlag:
        print(S[::-1])
    else:
        print(S)


if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import deque

def main():
    S = deque(input())
    Q = int(input())
    revFlag = False
    for i in range(Q):
        tmp = list(input().split())
        if tmp[0] == "1":
            if revFlag:
                revFlag = False
            else:
                revFlag = True
        else:
            if tmp[1] == "1":
                if revFlag:
                    S.append(tmp[2])
                else:
                    S.appendleft(tmp[2])
            else:
                if revFlag:
                    S.appendleft(tmp[2])
                else:
                    S.append(tmp[2])
    if revFlag:
        S = list(S)
        S.reverse()
        print("".join(S))
    else:
        S = list(S)
        print("".join(S))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n=int(input())
i=0
j=n-1
a,b=input(i),input(j)
while 1:
    k=j//2
    c=input(k)
    if(k-i)%2and a==c:
        j=k
    else:
        i=k

### FIXED CODE ###

n=int(input())
i=0
j=n-1
print(i)
a=input()
print(j)
b=input()
while 1:
    if j-i<2:
        print(i)
        _=input()
        print(j)
        if input()!='Vacant':
            print('助けてくれ～～～')
    k=(j-i)//2+i
    print(k)
    c=input()
    if(k-i)%2and a==c or not(k-i)%2and a!=c:
        j=k
    else:
        a=c
        i=k
### BUGGY CODE ###

def resolve():
  N = int(input())
  A = [int(x) for x in input().split(" ")]
  if N == 0 and A[0] != 1:
    print(-1)
    return True
  max_node_in_depth = [sum(A[i:]) for i in range(len(A))]

  # 各 depth における最小値
  min_node_in_depth = [0] * (len(A))
  min_node_in_depth[-1] = max_node_in_depth[-1]
  index = -1
  for i in range(1, len(A)):
    min_node_in_depth[index] = -(-min_node_in_depth[index + 1] // 2) + A[index]
    index = index - 1

  result = 1
  recent = 1
  for i in range(1, len(A)):
    num_of_node = (recent - A[i - 1]) * 2
    if num_of_node < min_node_in_depth[i]:
      print(-1)
      return True

    if num_of_node <= max_node_in_depth[i]:
      result += num_of_node
      recent = num_of_node
    else:
      result += max_node_in_depth[i]
      recent = max_node_in_depth[i]

  print(result)


if __name__ == "__main__":
    resolve()

### FIXED CODE ###


def resolve():
  N = int(input())
  A = [int(x) for x in input().split(" ")]
  if N == 0 and A[0] != 1:
    print(-1)
    return True
  min_maxs = {}
  min_maxs[len(A)-1] = [A[-1], A[-1]]

  for index in reversed(range(len(A)-1)):
    min_maxs[index] = [min_maxs[index+1][0] // 2 + A[index], min_maxs[index+1][1] + A[index]]
  # print(min_maxs)
    # min_maxs.insert(0, [min_maxs[0][0] // 2 + a, min_maxs[0][1] + a])
  # print(min_maxs)
  # max_node_in_depth = [sum(A[i:]) for i in range(len(A))]

  # # 各 depth における最小値
  # min_node_in_depth = [0] * (len(A))
  # min_node_in_depth[-1] = max_node_in_depth[-1]
  # index = -1
  # for i in range(1, len(A)):
  #   min_node_in_depth[index] = -(-min_node_in_depth[index + 1] // 2) + A[index]
  #   index = index - 1

  # for min_max in min_maxs:
  #   print(min_max)

  result = 1
  recent = 1
  for index in range(1, len(A)):
    num_of_node = (recent - A[index-1]) * 2
    # print(min_max, num_of_node)
    if num_of_node < min_maxs[index][0]:
      print(-1)
      return True
    
    result += min(num_of_node, min_maxs[index][1])
    recent = min(num_of_node, min_maxs[index][1])

  print(result)

if __name__ == "__main__":
    resolve()
### BUGGY CODE ###

#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect

#N,M = [int(x) for x in input().split()]

N = int(input())
A = [int(x) for x in input().split()]

alives = N
A = sorted(A)

while alives > 1:
    biggest = A.pop(-1)
    second = A[-1]
    times = int(math.floor(biggest / second))
    new_hp = biggest - second * times
    if new_hp <= 0:
        alives -= 1
    bisect.insort_left(A, new_hp)

for a in A:
    if a > 0:
        print (a)
        break


### FIXED CODE ###

#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq

#N,M = [int(x) for x in input().split()]

N = int(input())
A = [-1 * int(x) for x in input().split()]

alives = N
A = sorted(A)

heap = heapq.heapify(A)
heap = A
num = 0
while alives > 1:
    biggest = -1 * heapq.heappop(heap)
    second = -1 * heapq.heappop(heap)
    times = int(math.floor(biggest / second))
    new_hp = biggest - second * times
    if new_hp <= 0:
        alives -= 1
    heapq.heappush(heap, second * -1)
    heapq.heappush(heap,new_hp * -1)
    num += 1

for a in A:
    if a < 0:
        print (a * -1)
        break
### BUGGY CODE ###

n = int(input())
s = input()
r  = s.count("R")
g = s.count("G")
b = s.count("B")

cnt = 0
for i in range(n):
    for j in range(i+1,n):
        if s[i] !=s[j] and ((2*j-i)<n):
            if s[2*j-i] != s[i] and s[2*j-i] != s[j]:
                cnt += 1
print(r*g*b-cnt)

### FIXED CODE ###

n = int(input())
s = input()
r = list(s).count('R')
g = list(s).count('G')
b = list(s).count('B')

ans = r*g*b
for i in range(n):
    for j in range(i+1,n):
        k = j+(j-i)
        if (k<n and s[i] !=s[j] and s[j] !=s[k] and s[k]!=s[i]):
            ans -=1
print(ans)
### BUGGY CODE ###

import math
a, b, n = map(int,input().split())
ans = 0
for i in range(n+1):
    s = math.floor(a * i / b)
    t = math.floor (i/b)
    ans = max(ans,s - a*t)     
print(ans) 

### FIXED CODE ###

a, b, n = map(int,input().split())
ans = 0
x = min(n , b-1)
print(x*a //b)
### BUGGY CODE ###

import sys

import numpy as np

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

# 数と価値で配列を作る
# 値は価値の最大値


def main():
    N, W = map(int, readline().split())
    WV = np.array([[int(x) for x in readline().split()] for _ in range(N)])
    U = np.sum(WV[:, 1])

    dp = np.full([N+1, U+1], U, np.int64)
    dp[0, 0] = 0

    for w, v in WV:
        p_dp = dp.copy()
        np.minimum(dp[1:, v:], p_dp[:-1, :-v] + w, out=dp[1:, v:])

    print(max(list(zip(*np.where(dp <= W))))[1])


main()


### FIXED CODE ###

import sys

import numpy as np

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


def main():
    N, W = map(int, readline().split())
    WV = np.array([[int(x) for x in readline().split()] for _ in range(N)])
    UV = np.sum(WV[:, 1])
    UW = np.sum(WV[:, 0])

    dp = np.full([UV+1], UW*2, np.int64)
    dp[0] = 0

    for w, v in WV:
        p_dp = dp.copy()
        np.minimum(dp[v:], p_dp[:-v] + w, out=dp[v:])

    print(max(list(np.where(dp <= W)[0])))


main()
### BUGGY CODE ###

import sys

input = sys.stdin.readline


def main():
    N, W = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(N)]

    DP = [[0] * (W+1) for _ in range(N+1)]

    for i in range(N):
        for sum_w in range(W+1):

            if sum_w - wv[i][0] >= 0:
                DP[i+1][sum_w] = max(
                    DP[i][sum_w - wv[i][0]] + wv[i][1],
                    DP[i+1][sum_w])

            DP[i+1][sum_w] = max(DP[i][sum_w], DP[i+1][sum_w])

    print(DP[N][W])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

def main():
    _input = sys.stdin.readline

    N, W = map(int, _input().split())
    wv = [list(map(int, _input().split())) for _ in range(N)]

    wv.sort()

    DP = [-1] * (W+1)
    DP[0] = 0

    sum_w = 0
    for w, v in wv:
        sum_w += w
        for j in range(min(W, sum_w), w-1, -1):
            if DP[j-w] == -1:
                continue
            if DP[j] < DP[j-w] + v:
                DP[j] = DP[j-w] + v
    print(max(DP))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

def rren(): return list(map(int, input().split()))
n, m = rren()
x = rren()
y = rren()
ans = 0
for now_x in range(n-1):
    for now_y in range(m-1):
        S = (x[now_x+1]-x[now_x])*(y[now_y+1]-y[now_y])
        count = (now_x+1)*(n-now_x-1)*(now_y+1)*(m-now_y-1)
        ans = (ans + S*count) % 1000000007

print(ans)

### FIXED CODE ###

def rren(): return list(map(int, input().split()))
n, m = rren()
x = rren()
y = rren()
ans = 0
x_sum = 0
y_sum = 0
for now_x in range(n):
    x_sum += x[now_x] * (now_x - (n-1 - now_x))
for now_y in range(m):
    y_sum += y[now_y] * (now_y - (m-1 - now_y))

print(x_sum * y_sum % 1000000007)
### BUGGY CODE ###

N=int(input())
a=4/N
#h_st=int(N*(2/4))
h_st=1
for h in range(h_st,3501):
    H=1/h
    for n in range(h,3501):
        flag=0
        if a-H-1/n-1/n<=0 and a-H-1/n-1/3500>=0:

            st,end=h,3500
            for w in [st,end]:
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    break
            while st!=end:
                #print(h,n,st,end)
                w=int((st+end)/2)
                if end-st==1:
                    end=w
                    st=w
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    break
                elif B>0:
                    end=w
                else:
                    st=w

        if flag:
            break
    if flag:
        break

print(h,n,w)


### FIXED CODE ###

N=int(input())
a=4/N
h_st=max(int(N*(1/4))-1,1)
#h_st=1
for h in range(h_st,3501):
    H=1/h
    for n in range(h,3501):
        flag=0
        if 4*h*n*n-(n*n+h*n+h*n)*N<=0 and 4*h*n*3500-(n*3500+h*3500+h*n)*N>=0:

            st,end=n,3500
            for w in [st,end]:
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    break
            while st!=end:
                #print(h,n,st,end)
                w=int((st+end)/2)
                if end-st==1:
                    end=w
                    st=w
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    break
                elif B>0:
                    end=w
                else:
                    st=w

        if flag:
            break
    if flag:
        break

print(h,n,w)
### BUGGY CODE ###

from itertools import combinations
n = int(input())
l_ls = list(map(int, input().split()))

count = 0
for a,b,c in combinations(l_ls,3):
    if a < b + c and b < a+c and c < a+b:
        count += 1
print(count)

### FIXED CODE ###

n = int(input())
l_ls = list(map(int, input().split()))
l_ls.sort()
stick_count = [0] * (10**3+1)
stick_csum = [0] * (10**3+1)
for i in range(n):
    stick_count[l_ls[i]] += 1
now = 0
for i in range(10**3+1):
    now += stick_count[i]
    stick_csum[i] = now

ans = 0
for first_i in range(n):
    for second_i in range(first_i+1, n):
        #境界は含まない
        greater_than = abs(l_ls[first_i] - l_ls[second_i])
        smaller_than = min(10**3+1,l_ls[first_i] + l_ls[second_i])
        num_canmake = max(0, stick_csum[smaller_than-1] - stick_csum[greater_than])
        if greater_than < l_ls[first_i] < smaller_than:
            num_canmake -= 1
        if greater_than < l_ls[second_i] < smaller_than:
            num_canmake -= 1
        num_canmake = max(0,num_canmake)
        ans += num_canmake
print(ans//3)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
mod = pow(10, 9)+7
count = 0
for i in range(n-1):
    for j in range(i+1, n):
        x = a[i]
        y = a[j]
        seki = (x*y)%mod
        count += seki
        count%=mod
print(count)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
all = sum(a)
mod = pow(10, 9)+7
all %=mod
count = 0
for i in range(n-1):
    all=(all+mod-a[i])%mod
    x = a[i]
    seki = (x*all)%mod
    count += seki
    count%=mod
print(count)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [a[i:]+a[:i] for i in range(n)]
print(*[sum(b[i][::2])-sum(b[i][1::2]) for i in range(n)])

### FIXED CODE ###

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

# m0 + m1 + m2 + m3 + m4 = d0 + d1 + d2 + d3 + d5
# d0 = (m0 + m1)//2
# d1 = (m1 + m2)//2
# d2 = (m2 + m3)//2
# d3 = (m3 + m4)//2
# d4 = (m4 + m0)//2
# m0 =  d0 - d1 + d2 - d3 + d4
# m1 =  d0 + d1 - d2 + d3 - d4
# m2 = -d0 + d1 + d2 - d3 + d4
# m3 =  d0 - d1 + d2 + d3 - d4
# m4 = -d0 + d1 - d2 + d3 + d4   
s = sum(a)
p = [0 for _ in range(n)]
q = [0 for _ in range(n+1)]
for i in range(n) :
    if i>1 :
        p[i] = p[i-2] + a[i-2]
    q[n-i-2] = q[n-i] + a[n-i-1]

print(*[s-2*p[i]-2*q[i] for i in range(n)])
### BUGGY CODE ###

n=int(input())
v=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
b_lst=[]
for i in range(1 << n):
    sum_v=0
    sum_c=0
    for j in range(n):
        if ((i>>j)&1)==1:
            sum_v += v[j]
            sum_c += c[j]
    b_lst.append(sum_v - sum_c)
print(max(b_lst))

### FIXED CODE ###

n=int(input())
v=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
dif=[]
for i in range(n):
  if v[i]>c[i]:
    dif.append(v[i]-c[i])
print(sum(dif))