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

C++: #include<cstdio>                                                                                   
#include<algorithm>                                                                                
using namespace std;                                                                               
                                                                                                   
int N,K,dat[100000];                                                                               
long long r,t;                                                                                     
                                                                                                   
int main(){                                                                                        
    while(scanf("%d%d",&N,&K),N||K){                                                               
        for(int i=0;i<N;i++){                                                                      
            scanf("%d",dat+i);                                                                     
        }                                                                                          
        t=0;                                                                                       
        for(int i=0;i<K;i++){                                                                      
            t+=dat[i];                                                                             
        }                                                                                          
        r=t;                                                                                       
        for(int i=K;i<N;i++){                                                                      
            t=t-dat[i-K]+dat[i];                                                                   
            r=max(r,t);                                                                            
        }                                                                                          
        printf("%lld\n",r);                                                                        
    }                                                                                              
}

C++: #include<stdio.h>

int main(void){
	int i,n,k,sum,max;
	int N[150000];

	while(0==0){
		scanf("%d %d",&n,&k);
		sum=0;
		if(n==0 && k==0) break;

		for(i=0;i<n;i++)
			scanf("%d",&N[i]);

		for(i=0;i<k;i++)
		    sum+=N[i];
		
		max=sum;

		for(i=k;i<n;i++){
			sum+=N[i];
			sum-=N[i-k];
			if(sum>max)max=sum;
		}

		printf("%d\n",max);
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    long n,k;
    while(cin >> n >> k && (n!=0 && k!=0)){
        long a[n],s[n];
        F(i,0,n){
            cin >> a[i];
        }
        s[0]=a[0];
        F(i,1,n){
            s[i]=s[i-1]+a[i];
        }
        long ans=0;
        F(i,0,n-k){
            ans=max(ans,s[i+k]-s[i]);
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
int n,m;
while(true){
cin>>n>>m;
if(n==0&&m==0){break;}
int ans=-2147483646;
int sum[100001];
for(int i=0;i<n;i++)
{
cin>>sum[i];
if(i!=0){sum[i]+=sum[i-1];}
if(i==m-1){ans=max(ans,sum[i]);}
else if(i>m-1){ans=max(ans,sum[i]-sum[i-m]);}
}
cout<<ans<<endl;
/////////////
}
///////////
    return 0;
}

C++: //#include <iostream>
#include <cstdio>
using namespace std;

int main(void)
{
  int n, k;
  int max;
  int sum;
  while (true)
  {
    //cin >> n >> k;
    scanf("%d %d", &n, &k);
    if ( n == 0 && k == 0 ) break;

    int* num_sequence = new int[n];
    for (int i = 0; i < n; i++)
    {
      //cin >> num_sequence[i];
      scanf("%d", &num_sequence[i]);
    }

    max = -999999;
    for (int j = 0; j < n-k+1; j++)
    {
      sum = 0;
      for (int i = 0; i < k; i++)
      {
        sum += num_sequence[i+j];
      }
      if ( sum > max ) max = sum;
    }

    //cout << max << endl;
    printf("%d\n", max);

    delete[] num_sequence;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <numeric>
using namespace std;
int main(){
  int n, k, l;
  int N[100001], ans, sum, tmp;
  while(cin >> n >> k, n && k){
    ans = 0, sum = 0;
    for(int i = 0 ; i < n ; i++){
      cin >> N[i];
    }

    for(l = 0 ; l < k ; l++){
      sum += N[l];
    }
    ans = max(ans, sum);
    tmp = sum;
    for(int i = l ; i < n ; i++){
      tmp = sum;
      sum += N[i];
      sum -= N[i-k];
      tmp = sum;
      ans = max(ans, sum);
    }
    cout << ans << endl;
  }
  return 0;
}