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: from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    while True:
        n, m = map(int, input().split())
        if [n, m] == [0, 0]:
            break
        else:
            A = [int(input()) for i in range(n)]
            B = [0] + A
            # 累積和を格納したリスト．A[l:r]の総和はB[r] - B[l]
            B = list(accumulate(B))

            val = max([B[i + m] - B[i] for i in range(n - m + 1)])
            print(val)

resolve()

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

Python: #48 最大の和
while True:
        n, k = map(int, input().split())
        if n == k == 0:
                break
        
        a = [int(input()) for i in range(n)]
        s = sum(a[0:k])                         #リストaの0からkまでの和をsとする
        max = s                                 #maxにsを代入する
        for i in range(k,n):                    
                s = s + a[i] - a[i-k]           
                if s > max:                     #sがmaxより大きければmaxにsを代入する
                        max = s
        print(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 True :
    n,k = map(int,input().split())
    if n == 0 and k == 0 :
        break
    a = 0
    x = [ ]
    for i in range (n):
        y = int(input())
        x.append(y)
    b = 0
    for j in range (k):
        b += x[j]
    S = [ ]
    S.append(b)
    for i in range (1,n-k+1):
        b = S[i-1] + x[i+k-1] - x[i-1]
        S.append(b)
    print(max(S))

Python: while True:
    n,k=map(int,input().split())

    if n==k==0:
        break
    x=[int(input())]
    
    for i in range(n-1):
        y=int(input())
        x.append(x[i]+y)
    
    maxx=x[0]
    
    for i in range(n-k):
        maxx=max(maxx,x[i+k]-x[i])
    
    print(maxx)

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

Python: while 1:
	n,m=map(int,input().split())
	if n==n==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: 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 = s[k-1]
	for i in range(k, n):
		if s[i] > ans: ans = s[i]
	print(ans)

Python: #0516
while True:
    x = 0
    a = []
    S = []
    s = 0
    cnt = 0
    n , k = map(int,input().split())
    if n == 0 and k == 0:
        break
    for i in range(n):
        a.append(int(input()))

    S.append(sum(a[0:k]))
    
    for j in range(k,n):
        s = S[cnt] - a[j - k] + a[j]
        S.append(s)
        cnt += 1
    
    print(max(S))

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

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: from itertools import accumulate
while True:
    n, k = [int(x) for x in input().split()]
    if n == 0 and k == 0:
        break
    L = []
    for _ in range(n):
        L.append(int(input()))

    M = list(accumulate(L))
    S = []
    S.append(M[k-1])

    for i in range(k,n):
        S.append(M[i] - M[i-k])
    print(max(S))

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
    for i in range(k, len(a)):
        tmp += a[i] - a[i - k]
        ans = max(ans, tmp)
    print(ans)


if __name__ == "__main__":
    main()

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

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