Go: package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	parseProblem(os.Stdin)
}

func parseProblem(r io.Reader) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	for true {
		n, k := scanInt(sc), scanInt(sc)
		if n == 0 && k == 0 {
			break
		}
		sum := make([]int, n+2)
		for i := 2; i <= n+1; i++ {
			sum[i] = sum[i-1] + scanInt(sc)
		}
		max := math.MinInt32
		for i := 1; i+k <= n+1; i++ {
			if v := sum[i+k] - sum[i]; max < v {
				max = v
			}
		}
		fmt.Println(max)
	}
	return
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

Python: while True :
    n, k = map(int, input().split())
    
    if n == 0 :
        break
    else :
        A = []
        S = []
        s = 0
        cnt = 0
        
        for i in range(n) :
            A.append(int(input()))
            
        for i in range(k) :
            s += A[i]
        S.append(s)
            
        for j in range(k, n) :
            s = S[cnt] - A[j - k] + A[j]
            S.append(s)
            cnt += 1
        
        print(max(S))

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 True:
    n, k = map(int, input().split())
    if n == k == 0:
        break
    a_sum = [0]
    now = 0
    for i in range(n):
        now += int(input())
        a_sum.append(now)
    maximum = a_sum[k]-a_sum[0]
    for i in range(n-k):
        maximum = max(a_sum[k+i]-a_sum[i], maximum)
    print(maximum)

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

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

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: while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    sn=[]
    for i in range(n):
        sn.append(int(input()))
    c=[]
    for j in range(0,n-k+1):
        if j==0:
            fsum = sum(sn[0:k])
        else:
            fsum = fsum + sn[j+k-1] - sn[j-1]
        c.append(fsum)
    print(max(c))

Python: while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    else:
        a=[]
        s=0
        t=[]
        u=0
        for i in range(n):
            a.append(int(input()))
        for j in range(k):
            s+=a[j]
        t.append(s)
        for l in range(k,n):
            s=t[u]-a[l-k]+a[l]
            t.append(s)
            u+=1
        print(max(t))

Python: def func(n,k):
    A = []
    ans = 0
    SUM = 0
    for i in range(n):
        A.append(int(input()))
    for i in range(k-1):
        SUM += A[i]
    for i in range(k,len(a)):
        ans = max(ans,SUM+a[i]-a[i-k])
    print(ans)

for i in range(100):
    n,k = [int(s) for s in input().split()]
    if n == 0 and k ==0:
        break
    else:
        func(n,k)

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 == 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 == 0 and k == 0:
        break
    a = [int(input()) for _ in range(n)]
    s = [0] * (n+1)
    
    for i in range(n):
        s[i+1] = s[i] + a[i]
    
    ans = -float('inf')
    for i in range(n-k+1):
        tmp = s[k+i] - s[i]
        if tmp > ans:
            ans = tmp
    
    print(ans)

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

Python: def func(n,k):
    SUM = 0
    ans = 0
    A = [int(input()) for _ in range(n)]
    for i in range(k-1):
        SUM += A[i]
    for i in range(k,len(A)):
        ans = max(ans,SUM+A[i]-A[i-k])
        SUM = SUM+A[i]-A[i-k]
    print(ans)

for _ in range(10):
    n,k = [int(s) for s in input().split()]
    if n == 0 and k ==0:
        break
    else:
        func(n,k)

Python: from collections import deque
while True:
    n, k = map(int, input().split())
    if n==0:break
    a = deque(int(input()) for _ in range(k))
    ans = sum(a)
    for _ in range(n-k):
        a.popleft()
        a.append(int(input()))
        tmp = sum(a)
        if ans < tmp: ans = tmp
    print(ans)

Python: #!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in read(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[fill_value]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    n, k = readi(2)
    a = readi(n)
    tmp = sum(a[:k])
    ans = tmp
    dbg(tmp=tmp)
    for i in range(k, len(a)):
        tmp += a[i] - a[i - k]
        ans = max(ans, tmp)
        dbg(tmp=tmp)
    print(ans)


if __name__ == "__main__":
    main()

Python: while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    r=[]
    for I in range(n):
        x=int(input())
        r.append(x)
    s=[]
    i=0
    MAX=sum(r[0:k])
    PRE=MAX
    for J in range(n-k):
        a=r[i]
        b=r[i+k]
        PRE=PRE-a+b
        if PRE>MAX:
            MAX=PRE
        else:
            pass
        i+=1
    print(MAX)