You are given two arrays A and B, each of size n. The error, E, between these two arrays is defined $E = \sum_{i = 1}^{n}(a_{i} - b_{i})^{2}$. You have to perform exactly k_1 operations on array A and exactly k_2 operations on array B. In one operation, you have to choose one element of the array and increase or decrease it by 1.

Output the minimum possible value of error after k_1 operations on array A and k_2 operations on array B have been performed.


-----Input-----

The first line contains three space-separated integers n (1 ≤ n ≤ 10^3), k_1 and k_2 (0 ≤ k_1 + k_2 ≤ 10^3, k_1 and k_2 are non-negative) — size of arrays and number of operations to perform on A and B respectively.

Second line contains n space separated integers a_1, a_2, ..., a_{n} ( - 10^6 ≤ a_{i} ≤ 10^6) — array A.

Third line contains n space separated integers b_1, b_2, ..., b_{n} ( - 10^6 ≤ b_{i} ≤ 10^6)— array B.


-----Output-----

Output a single integer — the minimum possible value of $\sum_{i = 1}^{n}(a_{i} - b_{i})^{2}$ after doing exactly k_1 operations on array A and exactly k_2 operations on array B.


-----Examples-----
Input
2 0 0
1 2
2 3

Output
2
Input
2 1 0
1 2
2 2

Output
0
Input
2 5 7
3 4
14 4

Output
1


-----Note-----

In the first sample case, we cannot perform any operations on A or B. Therefore the minimum possible error E = (1 - 2)^2 + (2 - 3)^2 = 2. 

In the second sample case, we are required to perform exactly one operation on A. In order to minimize error, we increment the first element of A by 1. Now, A = [2, 2]. The error is now E = (2 - 2)^2 + (2 - 2)^2 = 0. This is the minimum possible error obtainable.

In the third sample case, we can increase the first element of A to 8, using the all of the 5 moves available to us. Also, the first element of B can be reduced to 8 using the 6 of the 7 available moves. Now A = [8, 4] and B = [8, 4]. The error is now E = (8 - 8)^2 + (4 - 4)^2 = 0, but we are still left with 1 move for array B. Increasing the second element of B to 5 using the left move, we get B = [8, 5] and E = (8 - 8)^2 + (4 - 5)^2 = 1.

Difficulty: competition

Starter code:

Solutions:
n, k1, k2 = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
r = sorted([abs(a[i] - b[i]) for i in range(n)], reverse=True)
for it in range(k1 + k2):
    if r[0] == 0:
        r[0] = 1
    else:
        r[0] -= 1
        for i in range(n - 1):
            if r[i] < r[i + 1]:
                r[i], r[i + 1] = r[i + 1], r[i]
print(sum(x**2 for x in r))


n,k1,k2 = list(map(int,input().split()))
s = []
a = list(map(int,input().split()))
b = list(map(int,input().split()))
for i in range(n):
    s.append(abs(a[i]-b[i]))
for i in range(k1+k2):
    ma = s[0]
    ind = 0
    for j in range(n):
        if s[j] > ma:
            ma = s[j]
            ind = j
    if ma == 0:s[ind] = 1
    else:s[ind] -= 1
t=0
for i in s:t+=i**2
print(t)


n, k1, k2 = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
while k1 + k2 > 0:
    max_dif = -10000000000000
    ind = -1    
    for i in range(n):
        if (a[i] - b[i]) ** 2 > max_dif:
            max_dif = (a[i] - b[i]) ** 2
            ind = i
    if k1 != 0:
        k1 -= 1
        if a[ind] > b[ind]:
            a[ind] -= 1
        else:
            a[ind] += 1
    elif k2 != 0:
        k2 -= 1
        if b[ind] > a[ind]:
            b[ind] -= 1
        else:
            b[ind] += 1
ans = 0
for i in range(n):
    ans += (a[i] - b[i]) ** 2
print(ans)

n,k1,k2=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
d=[abs(a[i]-b[i]) for i in range(n)]
d=sorted(d)[::-1]
k=k1+k2
while k>0:
    if d[0]==0:
        break
    if k>0:
        d[0]-=1
        k-=1
        d=sorted(d)[::-1]
print(sum([i**2 for i in d])+k%2)



N,K1,K2=map(int,input().split())
A,B=[*map(int,input().split())],[*map(int,input().split())]

for i in range(K1):
 max_pos,max_diff=-1,0
 for j in range(N):
  if abs(A[j]-B[j])>=max_diff:
   max_pos,max_diff=j,abs(A[j]-B[j])
 if A[max_pos]>=B[max_pos]: A[max_pos]-=1
 else: A[max_pos]+=1

for i in range(K2):
 max_pos,max_diff=-1,0
 for j in range(N):
  if abs(A[j]-B[j])>=max_diff:
   max_pos,max_diff=j,abs(A[j]-B[j])
 if B[max_pos]>=A[max_pos]: B[max_pos]-=1
 else: B[max_pos]+=1

ans=0
for i in range(N):
 ans+=(A[i]-B[i])**2
print(ans)

n, k1, k2 = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
d = [abs(a[i] - b[i]) for i in range(n)]
for i in range(k1):
    ind = d.index(max(d))
    d[ind] = abs(d[ind] - 1)
for i in range(k2):
    ind = d.index(max(d))
    d[ind] = abs(d[ind] - 1)
s = 0
for i in range(n):
    s += d[i] ** 2
print(s)

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

arr=[]
for i in range(n):
    arr.append(abs(a[i]-b[i]))

arr=sorted(arr,reverse=True)

for i in range(k1+k2):
    arr[0]=abs(arr[0]-1)
    j=0
    while(j<(n-1) and arr[j]<arr[j+1]):
        arr[j],arr[j+1]=arr[j+1],arr[j]
        j+=1

ans=0
for i in range(n):
    ans=ans+(arr[i]*arr[i])

print(ans)


def decrease_max(C, D):
    mx = (-1, -1)
    for i, e in enumerate(abs(c - d) for c, d in zip(C, D)):
        if e > mx[1]:
            mx = (i, e)
    i = mx[0]
    if C[i] > D[i]:
        C[i] -= 1
    else:
        C[i] += 1

def solution(k1, k2, A, B):
    for _ in range(k1):
        decrease_max(A, B)
    for _ in range(k2):
        decrease_max(B, A)
    return sum((a - b)**2 for a, b in zip(A, B))

n, k1, k2 = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
print(solution(k1, k2, A, B), end="")


R = lambda: list(map(int, input().split()))

n, k1, k2 = R()
k = k1 + k2
A = list(R())
B = tuple(R())
for i in range(n): A[i] = abs(A[i] - B[i])
for _ in range(k):
    idx = A.index(max(A))
    A[idx] = abs(A[idx] - 1)
s = 0
for a in A: s += a*a
print(s)


n, k1, k2 = [int(x) for x in input().split()]
a = input().split()
b = input().split()
d = [abs(int(x) - int(y)) for x, y in zip(a,b)]
for i in range(k1 + k2):
    m = 0
    max_ind = 0
    for j in range(n):
        if d[j] >= m:
            m = d[j]
            max_ind = j
    d[max_ind] = abs(d[max_ind] - 1)
print(sum(x*x for x in d))


n, k1, k2 = input().split()
a = input().split()
b = input().split()
c = [abs(int(a[i])-int(b[i])) for i in range(int(n))]
for i in range(int(k1)+int(k2)):
   c.sort()
   c[int(n)-1] = abs(c[int(n)-1] - 1)
e = 0
for i in range(int(n)):
   e += c[i]**2
print(e)


# -*- coding: UTF-8 -*-

import math

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

x = []
for i in range(n):
    x.append(int(math.fabs(a[i] - b[i])))

k = k1 + k2
while k > 0:
    max_num = 0
    idx = -1
    for i in range(n):
        if x[i] > max_num:
            max_num = x[i]
            idx = i
    if idx == -1:
        break
    x[idx] -= 1
    k -= 1

ret = 0
for i in range(n):
    ret += x[i] * x[i]
if k % 2 == 1:
    ret += 1
print(ret)

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

k = k1 + k2

d = [abs(a[i] - b[i]) for i in range(n)]

if sum(d) > k:
    for i in range(k):
        m = max(d)
        d.remove(m)
        d.append(m - 1)

    ans = sum(x ** 2 for x in d)
    print(ans)

else:
    print((k - sum(d)) % 2)


n,k1,k2=[int(x)for x in input().split()[:3]]
ks1=[int(x) for x in input().split()[:n]]
ks2=[int(x) for x in input().split()[:n]]
err=[abs(ks1[i]-ks2[i]) for i in range(n)]
num=k1+k2
rest1=False
if num%2 != sum(err)%2:
    rest1=True

def kill():
    nonlocal num
    maxx=max(err)
    if maxx==0 or num==0:
        return False
    for i in range(len(err)):
        if err[i] == maxx:
            err[i]-=1
            num-=1
            if num==0:
                return False
    return True
while kill():
    pass
summ=sum([x**2 for x in err])
if summ==0 and rest1:
    print(1)
else:
    print(summ)

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

d = [abs(x - y) for x, y in zip(a, b)]

moves = k + l

d.sort()
d.reverse()

while moves > 0:
    if d[0] == 0:
        print(moves%2)
        break

    d[0] -= 1

    c = 0

    while c < n - 1 and d[c] < d[c + 1]:
        d[c], d[c + 1] = d[c + 1], d[c]
        c += 1

    moves -= 1
else:
    print(sum([x**2 for x in d]))

n,k1,k2 = list(map(int,input().split()))
ai = list(map(int,input().split()))
bi = list(map(int,input().split()))
ci = [0]*n
k = k1 + k2
for i in range(n):
    ci[i] = abs(ai[i]-bi[i])
ci.sort()
ci2 = [0]*n
ci3 = [0]*n
ci2[0] = ci[0]
ci3[0] = 1
j = 0
for i in range(1,n):
    if ci[i] == ci[i-1]:
        ci3[j] += 1
    else:
        j += 1
        ci2[j] = ci[i]
        ci3[j] = 1
temp2 = -1
temp3 = 0
for i in range(j,0,-1):
    if k  >= ci3[i] * (ci2[i]-ci2[i-1]):
        k -= ci3[i] * (ci2[i]-ci2[i-1])
        ci3[i-1] += ci3[i]  
        ci3[i] = 0
    else:
        temp = k // ci3[i]
        temp2 = k % ci3[i]
        temp3 = i
        ci2[i] -= temp
        break
if temp2 != -1:
    ans = 0
    for i in range(temp3):
        ans += ci3[i]*(ci2[i]**2)
    print(ans+(ci3[temp3]-temp2)*(ci2[temp3]**2) + temp2*((ci2[temp3]-1))**2)
else:
    if k >= ci3[0] * ci2[0]:
        k -= ci3[0] * ci2[0]
        print(k%2)
    else:
        temp = k // ci3[0]
        temp2 = k % ci3[0]
        print((ci3[0]-temp2)*((ci2[0]-temp)**2) + temp2*((ci2[0]-temp-1))**2)
    


import heapq

n, k1, k2 = list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))

err = [abs(x-y) for x,y in zip(a,b)]

if k1+k2 >= sum(err):
    print((k1+k2-sum(err))%2)

else:

    moves = k1+k2
    err = [-a for a in err]
    heapq.heapify(err)

    while moves:
        x = heapq.heappop(err)
        x += 1
        heapq.heappush(err, x)
        moves -= 1

    print(sum([x**2 for x in err]))


import operator

n,k1,k2 = list(map(int,input().split(" ")))
arrayA = list(map(int,input().split(" ")))
arrayB = list(map(int,input().split(" ")))

arraydiff = list(map(operator.sub,arrayA,arrayB))
arraydiff = list(map(abs,arraydiff))

for i in range(k1+k2):
	index = arraydiff.index(max(arraydiff))
	if arraydiff[index] == 0:
		arraydiff[index] += 1
	else:
		arraydiff[index] -= 1
print(sum([x*x for x in arraydiff]))




from collections import defaultdict as dd, deque

n,k1,k2 = list(map(int,input().split()))
k = k1+k2

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

D = dd(int)

for i in range(n):
    D[abs(A[i]-B[i])] += 1

x = sorted([[k,v] for k,v in list(D.items())], reverse=True)

ops = 0
i = 0
while x[i][0]>0:
    if i<len(x)-1:
        if x[i][0]==x[i+1][0]:
            x[i+1][1] += x[i][1]
            x[i][1] = 0 # oops
            i += 1
    diff,cnt = x[i]
    if k - ops >= cnt:
        x[i][0] -= 1
        ops += cnt
    else:
        x.append((diff-1,k-ops))
        x[i][1] -= k-ops
        ops += k-ops
        break

if ops!=k:
    print(1 if (k-ops)%2 else 0)
else:
    ans = 0
    for diff,cnt in x:
        ans += cnt*(diff)**2
    print(ans)


a,b,c=map(int,input().split())
k=b+c
x=list(map(int,input().split()))
y=list(map(int,input().split()))
i=0
z=[]
while i<len(x):
    z=z+[max(x[i],y[i])-min(x[i],y[i])]
    i=i+1
z.sort()
i=0
while i<k:
    if z[len(z)-1]!=0:
        z[len(z)-1]=z[len(z)-1]-1
    else:
        if (k-i)%2==1:
            z=[1]
        break
    z.sort()
    i=i+1
s=0
for elem in z:
    s=s+elem**2
print (s)

n,k1,k2 = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = sorted([abs(a[i] - b[i]) for i in range(n)])[::-1]
k = k1+k2
cur = 0
for i in range(k):
    if c[0] == 0:break
    cur+=1
    c[0]-=1
    j=0
    while j+1 < n and c[j] < c[j+1]:
        c[j],c[j+1] = c[j+1],c[j]
        j+=1
k-=cur
if k > 0:
    print(k%2)
else:
    ans = 0
    for i in c:
        ans += i**2
    print(ans)

n, k1, k2 = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = [abs(a[i]-b[i]) for i in range(n)]
k = k1 + k2
for _ in range(k):
    mx = max(d)
    id = d.index(mx)
    if mx == 0:
        d[id] += 1
    else:
        d[id] -= 1
print(sum([x ** 2 for x in d]))


n, k1, k2 = map(int, input().split())

A = map(int, input().split())
B = map(int, input().split())

C = [x - y for x, y in zip(B, A)]

k = k1 + k2
for i in range(k):
    if min(C) >= 0:
        C[C.index(max(C))] -= 1
    elif abs(max(C)) <= abs(min(C)):
        C[C.index(min(C))] += 1
    else:
        C[C.index(max(C))] -= 1
ans = 0
for i in C:
    ans += i**2

print(ans)

def main():
    n, k1, k2 = map(int, input().split())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]
    c = [(abs(a[i] - b[i])) for i in range(n)]
    s = sum(c)
    if s >= (k1 + k2):
        op = (k1 + k2)
        while op > 0:
            c = sorted(c)
            c[-1] -= 1
            op -= 1
        ans = sum([x**2 for x in c])
    else:
        after = (k1 + k2) - s
        if after % 2 == 0:
            ans = 0
        else:
            ans = 1
    print(ans)


def __starting_point():
    main()
__starting_point()

#!/usr/bin/env python3

import sys

[n, k1, k2] = list(map(int, sys.stdin.readline().strip().split()))
ais = list(map(int, sys.stdin.readline().strip().split()))
bis = list(map(int, sys.stdin.readline().strip().split()))

k = k1 + k2
cis = [abs(ai - bi) for ai, bi in zip(ais, bis)]
cis.sort(reverse=True)
cis.append(0)

s = 0
i = 1
done = False
while i < n + 1:  # 0 at the end appended
	s += i * (cis[i - 1] - cis[i])
	if s >= k:
		done = True
		break
	i += 1

if not done:
	if (k - s) % 2 == 0:
		print(0)
	else:
		print(1)
else:
	d = s - k
	h = d // i
	n1 = d % i
	n0 = i - n1
	print(sum(ci**2 for ci in cis[i:]) + n0 * (cis[i] + h)**2 + n1 * (cis[i] + h + 1)**2)