Go: package main

import "fmt"

func main() {

	for true {
		var n, k int
		fmt.Scan(&n, &k)

		if n == 0 && k == 0 {
			return
		}
		
		a := make([]int, n)
		ans := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
			if i == 0 {
				ans[i] = a[i]
			} else {
				ans[i] = ans[i-1] + a[i]
			}
		}
		max := 0
		for i := k; i < n; i++ {
			t := ans[i] - ans[i-k]
			if max < t {
				max = t
			}
		}
		fmt.Println(max)
	}
}

Python: while True:
    n,k = map(int,input().split())
    if n==k==0:
        break
    a =[]
    for i in range(n):
        a.append(int(input()))
    ans = sum(a[0:k:])
    tmp = ans
    for i in range(n-k):
        tmp += a[k+i]
        tmp -= a[i]
        if ans < tmp:
            ans = tmp
    print(ans)

Python: #!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")

# https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/all/DSL_1_B
import sys
sys.setrecursionlimit(1000000)
INF = float("inf")

while True:
    N,K = map(int,sys.stdin.readline().split())
    if N==0 and K==0:
        exit()
    a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param

    com = [0]*(N+1)
    for i in range(N):
        com[i+1]=com[i]+a[i]

    ret = -INF
    for i in range(N-K):
        ret = max(ret,com[i+K]-com[i])
    print(ret)

Python: while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    
    a=[int(input()) for i in range(n)]
    b=sum(a[0:k])
    c=[b]
    for j in range(k,n):
        b=b+a[j]-a[j-k]
        c.append(b)
    print(max(c))

Python: while 1:
    n,m=map(int,input().split())
    if n==m==0:break
    li=[]
    for i in range(n):
        li.append(int(input()))
    s_li=[li[0]]
    for i in range(1,n):
        s_li.append(s_li[-1]+li[i])
    c_li=[s_li[m-1]]
    for i in range(n-m):
        c_li.append(s_li[i+m]-s_li[i])
    print(max(c_li))

Python: def main():
    while 1:
        maximum = 0
        n,k = map(int,input().split())
        if not n and not k: break
        N = [int(input())for _ in range(n)]
        for i in range(n-k+1):
            maximum = max(maximum,sum(N[i:i+k]))
        print(maximum)
if __name__ == "__main__":
    main()

Python: while 1:
    n,m=map(int,input().split())
    if n==m==0:break
    li=[]
    for i in range(n):
        li.append(int(input()))
    s_li=[li[0]]
    for i in range(1,n):
        s_li.append(s_li[-1]+li[i])
    c_li=[s_li[m-1]]
    for i in range(n-m):
        c_li.append(s_li[i+m]-s_li[i])
    print(max(c_li))

Python: def main():
    from itertools import accumulate
    N, K = (int(i) for i in input().split())
    while N != 0 or K != 0:
        A = [int(input()) for i in range(N)]
        S = list(accumulate([0] + A))
        ans = 0
        for i in range(N-K+1):
            cur = S[i+K] - S[i]
            ans = max(ans, cur)
        print(ans)
        N, K = (int(i) for i in input().split())


if __name__ == '__main__':
    main()

Python: while True:
    
    n,k = map(int,input().split())
    if n == k == 0:
        break
    N_lis = []
    for i in range(n):
        N_lis.append(int(input()))
    N_max = 0
    N_sum = 0
    for j in range(k):
        N_sum += N_lis[j]
    for l in range(n - k):
        if N_sum - N_lis[l] + N_lis[l + k] > N_sum:
            N_max = N_sum - N_lis[l] + N_lis[l + k]
        N_sum = N_sum - N_lis[l] + N_lis[l + k]
    print(N_max)

Python: a, s = [0]*100003, [0]*100003
while True:
	n, k=map(int, input().split())
	if n==0 :
	    break
	s[0]=a[0]=int(input())
	for i in range(1, n):
		a[i]=int(input())
		s[i]=s[i-1] + a[i]
		if i>=k:
		    s[i] -= a[i-k]
	ans=0
	for i in range(k, n):
		if s[i] > ans:
		    ans = s[i]
	print(ans)

Python: #!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def solve():
    n, k = read_h()
    arr = read_v(n)

    cumul = [sum(arr[:i]) for i in range(len(arr) + 1)]
    #  print(cumul)

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

    print(ans)


def main():
    while True:
        n, k = read_h()
        if (n, k) == (0, 0):
            break

        arr = read_v(n)

        cumul = [0]
        for i in range(n):
            cumul.append(cumul[i] + arr[i])

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

        print(ans)


if __name__ == '__main__':
    main()

Python: while True:
 n,k = map(int,input().split())
 if n==0 and k==0: break
 
 a = [int(input()) for i in range(n)]

 s = sum(a[0:k])
 max = s

 for i in range(k,n):
  s = s+a[i]-a[i-k]
  if s > max: max = s
 
 print(max)

Python: import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    while True:
        n, k = list(map(int, input().strip().split()))
        if n == 0 and k == 0:
            return
        v = [0] * n
        a = [0] * (n+1)
        for i in range(n):
            v[i] = int(input().strip())
        for i in range(n):
            a[i+1] = v[i] + a[i]

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

if __name__ == '__main__':
    main()

Python: while True:
    n,k = map(int,input().split())
    if n == 0 and k == 0:break
    a = [int(input())for _ in range(n)]
    s = sum(a[0:k])
    ss = [s]
    for i in range(k,n):
        s = s+a[i]-a[i-k]
        ss.append(s)
    print(max(ss))

Python: while True:
    n,k = map(int,input().split())
    if n == 0and k == 0:
        break
    a = [int(input()) for _ in range(n)]
    s = sum(a[0:k])
    ss = [s]
    for i in range(k,n):
        s = s + a[i] - a[i-k]
        ss.append(s)
    print(max(ss))

Python: while True:
    n,k=map(int,input().split())
    if (n,k)==(0,0):
        break
    list=[int(input()) for i in range(n)]
    a=[]
    c=0
    for i in range(k):
        c+=list[i]
    a.append(c)
    for j in range(n-k):
        c+=list[k+j]
        c-=list[j]
        a.append(c)
    print(max(a))

Python: from itertools import accumulate

while True:
    N, K = map(int, input().split())
    if N == 0:
        break
    A = [int(input()) for _ in range(N)]

    S = list(accumulate([0] + A))
    ans = max(S[i] - S[i-K] for i in range(K, len(S)))
    print(ans)

Python: while True:
    n,k=[int(s)for s in input().split(" ")]
    if n==k==0:break
    a=[int(input())for a in range(n)]
    s=0
    for i in range(k):s+=a[i]
    maxval=s
    for i in range(n-k):
        s+=a[i+k]-a[i]
        if s>maxval:maxval=s
    print(maxval)

Python: n,k = [int(i) for i in input().split()]
a = [int(input()) for i in range(n)]
b = [0]*len(a)

for i in range(n):
    b[i] = b[i-1] + a[i]
b = b + [0]

c = [b[i + k - 1] - b[i - 1] for i in range(n - k + 1)]

print(max(c))

Python: n,k = map(int,input().split())
a = [int(input()) for i in range(n)]

unko = [0]
for i in range(n):
        unko.append(unko[i]+a[i])
inf = float("inf")*(-1)
mvl = inf
for i in range(n-k+1):
        if unko[i+k]-unko[i] >= mvl:
                mvl = unko[i+k]-unko[i]
print(mvl)

Python: while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    a=[int(input()) for _ in range(n)]
    s=sum(a[0:k])
    ss=[s]
    for i in range(k,n):
        s=s+a[i]-a[i-k]
        ss.append(s)
    print(max(ss))