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: #!/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)):
        ans = max(ans, tmp + a[i] - a[i - k])
    print(ans)


if __name__ == "__main__":
    main()

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

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

    ans = -10*18
    for i in range(n-k+1):
        if s[i+k] - s[i] > ans:
            ans = s[i+k] - s[i]

    print(ans)

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

    cs = [0]*(n+1)
    for i in range(n):
        cs[i+1] = cs[i] + a[i]

    ans = -10**16
    for i in range(n-k+1):
        ans = max(ans, cs[i+k]-cs[i])

    print(ans)

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

print(max(c))

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: max = -10**9
for i in range(5):
  n,k = map(int,input().split())
  if n==0 and k == 0:
    break
  else:
    b = []*n
    sum = 0
    max = -10**9
    for i in range(n):
      a = int(input())
      b.append(sum+a)
      sum += a
    for j in range(len(b)-k):
      if max<b[j+k]-b[j]:
        max = b[j+k]-b[j]
    print(max)

Python: def main():
	while True:
		a = []
		n, k = [int(x) for x in input().split()]
		if n == 0 and k == 0: break
		for i in range(n): a.append(int(input()))
		l = [0]
		for i in range(1, n - k + 2): l.append(a[i + k - 2] - a[i - 1])
		maxsum = 0
		maxi = 0
		s = 0
		for i, x in enumerate(l):
			s += x
			if s >= maxsum:
				maxsum = s
				maxi = i
		print(sum(a[i - 1:i + k - 1]))
main()

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: 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])
    ma=s
    for i in range(k,n):
        s=s+a[i]-a[i-k]
        if s>ma:
            ma=s
    print(ma)

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

Python: n = int(input())
k = int(input())
l = list(map(int, input().split()))

L=[]
for i in range(n):
    if(i == 0):
        L.append(0)
        L.append(l[i])
    else:
        L.append(L[i]+l[i])

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

print(ans)

Python: import sys
input=sys.stdin.readline

def shak(n,k):

	a=[int(input()) for _ in range(n)]


	l,r=0,k
	res=0
	cnt=sum(a[l:r])
	while r<n:
		res=max(res,cnt)

		cnt=cnt+a[r]-a[l]
		r+=1
		l+=1
	print(res)

for i in range(5):
	n,k=map(int,input().split())
	if n==k==0:exit()
	shak(n,k)

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

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: 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: n,k=map(int,input().split())
a=[int(input()) for _ in range(k)]
m=sum(a)
for i in range(n-k):
    a.append(int(input()))
    m=max(m,sum(a[-k:]))
print(m)

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: import queue
while 1:
    n,k=map(int,input().split())
    if n == 0:break
    r=queue.deque(int(input()) for _ in range(k))
    s=t=sum(r)
    for i in range(n-k):
        u=r.popleft()
        v=int(input())
        r.append(v)
        t+=v-u
        s=max(t,s)
    print(s)

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

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