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==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)

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0516

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def main(args):
    while True:
        n, k = map(int, input().split())
        if n == 0 and k == 0:
            break

        d = deque([int(input()) for _ in range(k)])
        sum_value = sum(d)
        maximum_sum = sum_value

        for _ in range(n-k):
            v = int(input())
            o = d.popleft()
            sum_value = sum_value - o + v
            if sum_value > maximum_sum:
                maximum_sum = sum_value
            d.append(v)

        print(maximum_sum)


if __name__ == '__main__':
    main(sys.argv[1:])

Python: while True :
    x,y=input().split()
    x=int(x)
    y=int(y)
    if x==y==0 : break
    a=[]
    c=0
    for i in range(x) :
        b=input()
        a.append(int(b))
    for i in range(y) : 
        c=c+a[i]
        ans=c
    for i in range(y,x) :
        c=c+a[i]-a[i-y]
        ans=max(ans,c)
    print(ans)

Python: def func(n,k):
    A = []
    ans = 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: l = []
while True:
    n,k = map(int,input().split())
    if n == 0 and k == 0:
        break
    for i in range(n):
        l.append(int(input()))
    n_sum1 = 0
    n_sum2 = 0
    n_max = 0
    for i in range(k):
        n_sum1 += l[i]
    for i in range(n-k):
        n_sum2 =n_sum1 - l[i] +l[i+k]
        if n_sum2 > n_max:
            n_max = n_sum2
        n_sum1 = n_sum2
    print(n_max)

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

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

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