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 <iostream>
#include <algorithm>
#define int long long
using namespace std;

int n, k;
int a[100000];
int ra[100001];	//ra[i] = a[0] + ??? + a[i-1]

signed main() {
	while (cin >> n >> k) {
		if (!n) { break; }
		ra[0] = 0;
		for (int i = 0; i < n; i++) {
			ra[i+1] = ra[i] + a[i];
		}

		int ans = -1000000001;
		for (int i = k; i <= n; i++) {
			ans = max(ans, ra[i] - ra[i-k]);
		}

		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#define INF 10000000000000000;
using namespace std;

long long int num[100100];


int main(){
    long long int n,m;
    long long int sum=0;
    long long int ans=INF;
    while(1){
        cin>>n>>m;
        if(n==0&&m==0)break;
        for(int i=0;i<100100;i++){
            num[i]=0;
            if(num[i+1]==0)break;
        }
        for(int i=0;i<n;i++){
            cin>>num[i];
            if(i<m)sum+=num[i];
        }
        cout<<sum<<endl;
        for(int i=1;i<n;i++){
            sum=sum-num[i-1]+num[i];
            if(ans<sum)ans=sum;
        }
        cout<<ans<<endl;
        ans=INF;
        sum=0;
        }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

int a[100000 + 1];
int s[100000 + 1];

int main() {

	int n, k;
	int i, j, l;
	int sum = 0, asus = 0;

	while (true) {

		memset(s, 0, sizeof(s));
		memset(a, 0, sizeof(a));

		cin >> n >> k;
		if (n == 0 && k == 0) return 0;

		for (i = 0; i < n; ++i) cin >> a[i];

		for (i = 0; i < n-k; ++i) {
			for (j = 0; j < k; ++j) {

				sum += a[i + j];
			}
			asus = max(asus, sum);
			sum = 0;
		}

		cout << asus << endl;
	}
}

C++: #include <cstdio>

int n,k,ans,tmp;
int a[100000];

int main(){
	while(scanf("%d%d", &n, &k)){
		if(n == 0 && k == 0) break;
		ans = 0;
		for(int i = 0; i < n; i++) scanf("%d", &a[i]);
		for(int i = 0; i < k; i++) ans += a[i];
		tmp = ans;
		for(int i = 0; i < n-k; i++){
			tmp += a[k+i]-a[i];
			if(ans < tmp) ans = tmp;
		}
		printf("%d\n", ans);
	}
}

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

int main() {
	int n, k, a[100000], i, S[100000], m=0;
	cin >> n >> k;
	for (i = 0; i<n; i++) {
		cin >> a[i];
	}
	S[0] = 0;
	for (i = 0; i < k; i++) {
		S[0] += a[i];
	}
	for (i = 1; i<n - k + 1; i++) {
		S[i] = S[i - 1] - a[i - 1] + a[i + k-1];
		m = max(m, S[i]);
		cout << S[i] << endl;
	}
	cout << m << endl;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int n,k;
	cin >> n >> k;
	if(n == 0 && k == 0) break;
	ll a[10001];
	REP(i,n){
	    cin >> a[i];
	}
	REP(i,n-1){
	    a[i+1] += a[i];
	}
	ll ans = -1000000000000000;
	FOR(i,k,n){
	    ans = max(ans,a[i] - a[i-k]);
	}
	cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n,k;
  while(cin >> n >> k,n+k) {
    int a[n];
    REP(i,n) {
      cin >> a[i];
    }
    int s = 0;
    REP(i,k) {
      s += a[i];
    }
    int res = s;
    for(int i=k; i<n; ++i) {
      s -= a[i-k]; s+= a[i];
      res = max(res, s);
    }
    cout <<res << endl;
  }

}

C++: /*
	0516:Maxinum Sum
*/
#include	<iostream>
#include	<vector>
#include	<algorithm>
#include	<cstdio>

using namespace std;

int main(void) {
	while(1) {
		int n, k;
		scanf("%d %d", &n, &k);
		if(n == 0 && k == 0) { break; }
		
		vector<int> inputs(n);
		
		for( int i = 0; i < (int)inputs.size(); i++ ) {
			cin >> inputs[i];
		}
		int maxNum = 0, num = 0;
		for( int i = 0; i < (int)inputs.size() - (k - 1); i++ ) {
			if(i == 0) {
				maxNum = inputs[i] + inputs[i+1] + inputs[i+2];
			} else {
				maxNum = max(maxNum, inputs[i] + inputs[i+1] + inputs[i+2]);
			}
		}
		
		cout << maxNum << endl;
		
	}
	return 0;
}

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

int main(){
    int n, k;
    while(cin >> n >> k){
        if(!n&&!k) break;
        int A[n]={0}, S[n+1]={0};
        for(int i=0;i<n;i++) {
            cin >> A[i];
            S[i+1] = S[i]+A[i];
        }
        int maxValue = -600000000;
        for(int i=0;i+k<=n;i++){
            maxValue = max(maxValue, S[k+i]-S[i]);
        }
        cout << maxValue << endl;
    }
    //cout << "finished" << endl;
    return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(1) {
    int n, k;
    cin >> n >> k;
    if(n == 0 && k == 0) break;

    vector<int> a(n);
    REP(i, n) cin >> a[i];
    
    int ans = 0;
    for(int i = 0; i < k; i++) {
      ans += a[i];
    }
    int mx = ans;
    for(int i = 0; i < n - k; i++) {
      mx = mx + a[k + i] - a[i];
      ans = max(mx, ans);
    }

    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#define reep(n1,n2,n3) for(int n1=n3;n1<n2;n1++)
#define rep(n1,n2) reep(n1,n2,0)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF 1e9
using namespace std;
typedef long long int lint;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int,int> > vp;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int> > pii;
typedef vector<string> vs;
const double PI  = acos(-1.0);
int num[100000];
int main(){
    int n,k;
    while(cin>>n>>k,n){
        rep(i,n)cin>>num[i];
        int ret=-INF;
        int buf=0;
        rep(i,k){
            buf+=num[i];
        }
        ret=max(buf,ret);
        rep(i,n-k){
            buf-=num[i];
            buf+=num[i+k];
            ret=max(buf,ret);
        }
        cout<<ret<<endl;
    }
}