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(1):
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    else:
        s=[0]*(n+1)
        top=0
        for i in range(1,n+1):
            b=int(input())
            
            s[i]=s[i-1]+b

        for i in range(n-k+1):
            v=s[k+i]-s[i]
            if v>top:
                top=v
        print(top)

Python: while True:
    n,m=map(int,input().split())
    if n==m==0:break
    alist = []
    for i in range (n):
        a=int(input())
        alist.append(a)
    s = sum(alist[0:m])   #a[i:j]→[a[i], a[i+1], a[i+2], ..., a[j-1]]
    max = s
    for i in range(m, n):
        s = s + alist[i] - alist[i - m]
        if s > max:
            max = s
    print(max)

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: while True:
    n,k=map(int,input().split())
    if k==0 and n==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: while 1:
    n , o = map(int, input().split())
    if n == 0 and o == 0:break
    else:
        k = [0]
        for i in range(n):
            k.append(k[-1]+int(input()))
        m = -float("INF")
        for i,l in zip(k,k[o:]):
            m = max(m,l-i)
        print(m)

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

    a = [int(input()) for i in range(n)]
    b = 0
    s = [0]*(n+1)
    
    for i in range(n):
        s[i+1]=s[i]+a[i]
        
    for i in range(n-k+1):
        tmp = s[k+i]-s[i]
        if tmp>b:
            b = tmp

    print(b)

Python: if __name__ == '__main__':
    while True:
        [n, k] = [int(i) for i in input().split()]
        if n == 0 and k == 0:
            break
        a = []
        for i in range(n):
            a.append(int(input()))

        old = sum(a[0:k])
        max = old

        for i in range(1, n-k+1):
            new = old - a[i-1] + a[i+k-1]
            if new > max:
                max = new
            old = new

        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: #!/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)