Your friend Mishka and you attend a calculus lecture. Lecture lasts n minutes. Lecturer tells a_{i} theorems during the i-th minute.

Mishka is really interested in calculus, though it is so hard to stay awake for all the time of lecture. You are given an array t of Mishka's behavior. If Mishka is asleep during the i-th minute of the lecture then t_{i} will be equal to 0, otherwise it will be equal to 1. When Mishka is awake he writes down all the theorems he is being told — a_{i} during the i-th minute. Otherwise he writes nothing.

You know some secret technique to keep Mishka awake for k minutes straight. However you can use it only once. You can start using it at the beginning of any minute between 1 and n - k + 1. If you use it on some minute i then Mishka will be awake during minutes j such that $j \in [ i, i + k - 1 ]$ and will write down all the theorems lecturer tells.

You task is to calculate the maximum number of theorems Mishka will be able to write down if you use your technique only once to wake him up.


-----Input-----

The first line of the input contains two integer numbers n and k (1 ≤ k ≤ n ≤ 10^5) — the duration of the lecture in minutes and the number of minutes you can keep Mishka awake.

The second line of the input contains n integer numbers a_1, a_2, ... a_{n} (1 ≤ a_{i} ≤ 10^4) — the number of theorems lecturer tells during the i-th minute.

The third line of the input contains n integer numbers t_1, t_2, ... t_{n} (0 ≤ t_{i} ≤ 1) — type of Mishka's behavior at the i-th minute of the lecture.


-----Output-----

Print only one integer — the maximum number of theorems Mishka will be able to write down if you use your technique only once to wake him up.


-----Example-----
Input
6 3
1 3 5 2 5 4
1 1 0 1 0 0

Output
16



-----Note-----

In the sample case the better way is to use the secret technique at the beginning of the third minute. Then the number of theorems Mishka will be able to write down will be equal to 16.

Difficulty: interview

Starter code:

Solutions:
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
mask = list(map(int, input().split()))

result = sum(a[i] if mask[i] == 1 else 0 for i in range(n))

h = [a[i] if mask[i] == 0 else 0 for i in range(len(a))]
best_awake = sum(h[:k])
curr = best_awake
for j in range(k, n):
    curr += h[j]
    curr -= h[j - k]
    best_awake = max(best_awake, curr)
print(result + best_awake)




import sys
n,k=list(map(int,input().split()))

l=list(map(int,input().split()))
t=list(map(int,input().split()))
if(k>n):
    print(sum(l))
    return
base=0
for i in range(n):
    if(t[i]==1):
        base+=l[i]
        l[i]=0
max1=0
cur=sum(l[:k])
max1=cur
for i in range(k,n):
    cur-=l[i-k]
    cur+=l[i]
    max1=max(cur,max1)
print(max1+ base)



n, k = map(int, input().split())
a = list(map(int, input().split()))
t = list(map(int, input().split()))
s = [0] * (n-k+1)
res = 0

for i in range(n):
    if t[i]== 1:
        res += a[i]

for i in range(k):
    if t[i]==0:
        s[0] += a[i]

for i in range(1, n-k+1):
    w = 0
    if (t[i - 1] == 0): 
        w -= a[i - 1]
    if (t[i + k - 1] == 0):
        w += a[i + k - 1]
    s[i] = s[i - 1] + w

print(res + max(s))

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

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

the = 0

for i in range(n):
    if T[i]:
        the += A[i]
        A[i] = 0

s = sum(A[:k])
boost = s
for i in range(k,n):
    s = s - A[i-k] + A[i]
    boost = max(s,boost)

print(the+boost)


import atexit
import io
import sys

# Buffering IO
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
    

def main():
    n, k = [int(x) for x in input().split()]
    a = [int(x) for x in input().split()]
    t = [int(x) for x in input().split()]
    
    mx = 0
    for i in range(n):
        if i < k:
            mx += a[i]
        else:
            mx += a[i] * t[i]
    
    xx = mx
    for i in range(n):
        if i + k >= n:
            break
        xx -= a[i]
        xx += a[i]*t[i]
        xx += a[i+k]
        xx -= a[i+k]*t[i+k]
        mx =max(xx,mx)
        
    print(mx)
    
    

    
def __starting_point():
    main()

__starting_point()

n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
c = list(map(int,input().split()))
s = 0
ss = 0
for i in range(n):
    if c[i] == 1:ss += a[i]
for i in range(k):
    if c[i] == 0:
        s += a[i]
m = s
#print(s)
for i in range(n-k):
    if c[i] == 0:
        s -= a[i]
    if c[i+k] == 0:
        s += a[i+k]
    m = max(m,s)
    #print(s)
print(ss+m)



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

s = [0]*n
if b[0]==0:
	s[0] = a[0]
su = 0
for i in range(n):
	if b[i]==1:
		su+=a[i]
for i in range(1,n):
	if b[i]==0:
		s[i] = a[i]
max_init_sum = init_sum = sum(s[:m])
k = m
for i in range(k, n):
	init_sum = init_sum - s[i-k] + s[i]
	#print (init_sum, s[i-k], s[k])
	max_init_sum = max(max_init_sum, init_sum)
print(max_init_sum+su)


n, k = map(int, input().split())
A = list(map(int, input().split()))
T = list(map(int, input().split()))

gain = [0] * (n-k+1)
for i in range(k):
    if T[i] == 0:
        gain[0] += A[i]

for i in range(1, n-k+1):
    gain[i] = gain[i-1]
    if T[i-1] == 0:
        gain[i] -= A[i-1]
    if T[i+k-1] == 0:
        gain[i] += A[i+k-1]

sum = 0
for i in range(n):
    if T[i] == 1:
        sum += A[i]

print(sum + max(gain))

from collections import Counter

def main():
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    t = list(map(int, input().split()))
    print(solve(n, k, a, t))

def solve(n, k, a, t):
    minsum = sum(ai for ai, ti in zip(a,t) if ti == 1)
    inc = sum(ai for ai, ti in zip(a[:k], t[:k]) if ti == 0)
    best_inc = inc
    for i in range(1, n - k + 1):
        if t[i - 1] == 0:
            inc -= a[i - 1]
        if t[i + k - 1] == 0:
            inc += a[i + k - 1]
        if inc > best_inc:
            best_inc = inc
    return minsum + best_inc

main()


R = lambda: list(map(int, input().split()))
n, k = R()
a = R()
t = R()

g = 0
for i in range(n):
	if t[i]:
		g += a[i]

l = 0
for i in range(0, k):
	if t[i] == 0:
		l += a[i]

max_l = l
for i in range(k, n):
	a_new = a_old = 0
	if t[i-k] == 0:
		a_old = a[i-k]
	if t[i] == 0:
		a_new = a[i]
	l += a_new - a_old
	max_l = max(max_l, l)
		
print(g + max_l)

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

ans = sum([a[i] for i in range(n) if t[i] == 1])

z = [i for i in range(n) if t[i] == 0]
ln = len(z)

d = 0
now = 0
left, right = 0, -1
for i in range(2 * ln):
    if right + 1 < ln and z[right + 1] - z[left] < k:
        right += 1

        now += a[z[right]]
        d = max(d, now)

    else:
        now -= a[z[left]]

        left += 1

print(ans + d)


t = input().split(' ')
n = int(t[0])
k = int(t[1])
A = input().split(' ')
B = input().split(' ')
for i in range(len(A)):
    A[i] = int(A[i])
    B[i] = int(B[i])
sm = 0
for i in range(len(B)):
    if B[i] == 1:
        sm += A[i]
mx = 0
for i in range(k):
    if B[i] == 0:
        mx += A[i]
cur = mx
for j in range(n-k):
    if B[j] == 0:
        cur -= A[j]
    if B[j+k] == 0:
        cur += A[j+k]
    if cur > mx:
        mx = cur
print(mx + sm)


def read_data():
    n, m = map(int, list(input().strip().split()))
    a = list(map(int, list(input().strip().split())))
    b = list(map(int, list(input().strip().split())))
    return n, m, a, b

def solve():
    val = 0
    for i in range(n):
        if b[i] == 1:
            val += a[i]
    for i in range(k):
        if b[i] == 0:
            val += a[i]
    i = k
    max = val
    while i < n:
        if b[i-k] == 0:
            val -= a[i-k]
        if b[i] == 0:
            val += a[i]
        if val > max:
            max = val
        i += 1
    return max

n, k, a, b = read_data()
print(solve())

def potential(a):
    return a[0] if a[1] == 0 else 0

def theorems(a):
    return a[0] if a[1] == 1 else 0

n, k = list(map(int, input().split()))
A = list(zip(
    list(map(int, input().split())),
    list(map(int, input().split())))
)

awake = 0
for a in A[:k]:
    awake += potential(a)

best = awake
for i, a in enumerate(A[k:]):
    awake += potential(a)
    awake -= potential(A[i])
    if awake > best:
        best = awake

already = sum(
    theorems(a)
    for a in A
)

print(already + best)


n,k=list(map(int,input().split()))
L=list(map(int,input().split()))
T=list(map(int,input().split()))
out=0
for i in range(n):
    if T[i]==1:
        out+=L[i]
        L[i]=0

ps=[0]*(n+1)
for i in range(1,n+1):
    ps[i]=ps[i-1]+L[i-1]
x=0
for i in range(n-k+1):
    x=max(x,ps[i+k]-ps[i])
print(x+out)


n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * n
num1 = 0
for i in range(n):
    if b[i] == 0:
        c[i] = a[i]
    else:
        num1 += a[i]

num2 = 0
s = sum(c[:k])
for i in range(n - k + 1):
    num2 = max(num2, num1 + s)
    if i != n - k:
        s = s - c[i] + c[i + k]

print(num2)

n,k=[int(x) for x in input().split()[:2]]
an=[int(x) for x in input().split()[:n]]
tn=[int(x) for x in input().split()[:n]]

first=0
for i in range(k):
    first+=an[i]
for i in range(k,n):
    first+=an[i]*tn[i]
ans=first
for i in range(1,n-k+1):
    new=i+k-1
    last=i-1
    if tn[last]==0:
        first-=an[last]
    if tn[new]==0:
        first+=an[new]
    ans=max(first,ans)
print(ans)

n, k =[int(x) for x in input().split()]
a =[int(x) for x in input().split()] 
bodr = [int(x) for x in input().split()] 
su = 0
for i in range(n):
    if bodr[i]:
        su += a[i]
        a[i] = 0
summa = sum(a[:k])
head = 0
maxi = summa
for i in range(k, n):
    summa -= a[head]
    head += 1
    summa += a[i]
    maxi = max(summa, maxi)
print(su + maxi)

L = input().split();
n,m = list(map(int,L));
L = input().split();
a = list(map(int,L));
L = input().split();
t = list(map(int,L));
ttot = [0]*(n+5);
ttot[0] = 0;
ta = [0]*(n+5);
ta[0] = 0;
for i in range(n):
    ttot[i+1] = ttot[i] + a[i];
    ta[i+1] = ta[i] + a[i]*t[i];
Max = 0;
for i in range(n-m+1):
    tmp = ta[i];
    tmp = tmp + ttot[i+m]-ttot[i];
    tmp = tmp + (ta[n]-ta[i+m]);
    if (tmp>Max):
        Max = tmp;
        pos = i+1;
#print(ttot, ta);
print(Max);


import sys;

class MyReader:
#    file = null;
    def __init__(self):
        filename = "file.in";
        if self.isLocal():
            self.file = open(filename);
        self.str = [""];
        self.ind = 1;
            
    def isLocal(self):
        return len(sys.argv) > 1 and sys.argv[1] == "SCHULLZ";

    def nextString(self):
        if self.isLocal():
            return self.file.read();
        else:
            return input();
        
    def nextInt(self):
        return int(self.nextToken());

    def nextToken(self):
        if (self.ind >= len(self.str)):
            self.ind = 0;
            self.str = self.nextString().split();
        self.ind += 1;
        return self.str[self.ind - 1];



rdr = MyReader();

n = rdr.nextInt();
k = rdr.nextInt();

a = [];
isAwake = [];
missed = [];

for i in range (0, n):
    a.append(rdr.nextInt());
    
awaken = 0;

for i in range (0, n):
    isAwake.append(rdr.nextInt());
    missed.append(0);
    if (0 == isAwake[i]):
        missed[i] = a[i];
    else:
        awaken += a[i];
        missed[i] = 0;

tres = 0;
for i in range(0, k):
    tres += missed[i];

res = tres;

for i in range(k, n):
    tres -= missed[i - k];
    tres += missed[i];
    res = max(res, tres);

    
sys.stdout.write(str(res + awaken));

sys.stdout.flush()

n, k = map(int, input().split())
a = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
pref_sum = [0] * n
pref_score = [0] * n
for i in range(n):
    pref_sum[i] = pref_sum[i - 1] + a[i]
    pref_score[i] = pref_score[i - 1] + a[i] * t[i]
ans = pref_sum[k - 1] + pref_score[n - 1] - pref_score[k - 1]
#print(pref_score, pref_sum)
for i in range(k, n):
    ans = max(ans, pref_score[i - k] + pref_score[n - 1] - pref_score[i] + pref_sum[i] - pref_sum[i - k])
print(ans)

def invert(x):
    if x == 1:
        return 0
    else:
        return 1

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

base = sum([a*b for a,b in zip(a,t)])

t = list(map(invert, t))
t = [a*b for a,b in zip(a, t)]
for i in range(1, len(t)):
    t[i] += t[i-1]

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

print(rslt+base)


n,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sumx=0
sum1=0
s=0
for i in range(n):
	if(b[i]==1):
		sum1+=a[i]
for i in range(k):
	if(b[i]==0):
		sumx+=a[i]
s=sumx+sum1
for i in range(k,n):
	if(b[i-k]==0):
		sumx-=a[i-k]
	if(b[i]==0):
		sumx+=a[i]
	if(sumx+sum1>s):
		s=sumx+sum1
print(s)

def calculate_prefix_sum(a, t):
    s = [0]
    for a_, t_ in zip(a, t):
        if not t_:
            s += [s[-1] + a_]
        else:
            s += [s[-1]]
    return s


def calculate_sum_on_range(s, a, b):
    assert a < b
    return s[min(b, len(s)-1)] - s[a]


def calculate_sums(a, t, k):
    psum = calculate_prefix_sum(a, t)
    s = []

    for i in range(len(a)):
        s.append(calculate_sum_on_range(psum, i, i+k))

    return s


def calculate_max(a, t, k):
    s = calculate_sums(a, t, k)
    ms = max(s)
    return ms


def calculate_answer(a, t, k):
    ms = calculate_max(a, t, k)
    s = 0
    for a_, t_ in zip(a, t):
        if t_:
            s += a_
    return ms + s


r=lambda:list(map(int,input().split()))
_,k=r()
print(calculate_answer(r(),r(),k))

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

s = sum([a[i] * t[i] for i in range(n)])
s += sum([a[i] * (1 - t[i]) for i in range(k)])
ans = s
for i in range(n - k):
    s -= a[i] * (1 - t[i])
    s += a[i + k] * (1 - t[i + k])
    ans = max(ans, s)
print(ans)