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: #!/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():
    while True:
        n, k = readi(2)
        if n == 0:
            return
        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: from queue import deque

while True:
    n, k = map(int, input().split())
    if not n:
        break
    q = deque(int(input()) for _ in range(k))
    ans = cur = sum(q)
    for _ in range(n - k):
        new = int(input())
        q.append(new)
        old = q.popleft()
        cur += new - old
        ans = ans if ans > cur else cur
    print(ans)

Python: while True:

    n,k = map(int,input().split())
    if n==0 and k==0 :
        break
    x=[int(input()) for _ in range(n)]
    y=sum(x[0:k])
    z=[y]
    for i in range(k,n):
        y=y+x[i]-x[i-k]
        z.append(y)
    print(max(z))

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: 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])
    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

# 区間[N-k, N) の総和の最大値

while True:
  n, k = map(int, input().split())
  if n == 0:
    break
  a_n = [int(input()) for _ in range(n)]
  _ = input()

  a_n = list(accumulate(a_n))
  # print(a_n)

  result = -99999999999999

  for i in range(n-k):
    val = a_n[k+i] - a_n[i]
    if result < val:
      result = val


  print(result)

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

Python: from itertools import accumulate

while True:
  n, k = map(int, input().split())
  if n == 0 and k == 0:
    break
  A = [int(input()) for _ in range(n)]
  
  S =[0] + list(accumulate(A))
  d = [S[i]-S[i-k] for i in range(k, n+1)]
  print(max(d))

Python: import queue
while 1:
    n,k=map(int,input().split())
    if n==0:break
    a=queue.deque(int(input()) for _ in range(k))
    m=sum(a)
    for i in range(n-k):
        a.popleft()
        a.append(int(input()))
        m=max(m,sum(a))
    print(m)

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

Python: while True:
    n,k=map(int,input().split())
    if n==0 & 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: import queue
while 1:
    n,k=map(int,input().split())
    if n==0:break
    a=queue.deque(int(input()) for _ in range(k))
    m=b=sum(a)
    for i in range(n-k):
        c=a.popleft()
        d=int(input())
        a.append(d)
        b+=d-c
        m=max(b,m)        
    print(m)

Python: while True:
    n, k = [int(i) for i in 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: # AOJ 0516: Maximum Sum
# Python3 2018.6.30 bal4u

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: while 1:                                       
    n, k = (int(x) for x in input().split())   
    if n == 0:                                 
        break                                  
    max_num = -30001                           
    queue = list()                             
    for _ in range(n):                         
        queue.append(int(input()))             
        if len(queue) == k:                    
            max_num = max(sum(queue), max_num) 
            queue.pop(0)                       
    print(max_num)

Python: 
for x in range (5):
    a,k = map(int, input().strip().split())
    if a==k==0 : break
    lst=[int(input()) for i in range(a)]
    s = sum(lst[0:k])
    mx = s
    for i in range (k,a):
        s = s + lst[i] -lst[i-k]
        if s > mx :
            mx = s
            
        
    print(mx)

Python: while True:
    a = []
    b = [0]
    c = []
    n, k = map(int, input().split())
    if n == k == 0:
        break

    for i in range(n):
        x = int(input())
        a.append(x)
        b.append(b[i] + x)

    for i in range(n - k + 1):
        c.append(b[k + i] - b[i])

    print(max(c))

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

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