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 <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int n, k;
	ll result, tmp;

	while(cin >> n >> k, n) {
		vi nums(n);
		result = -INT_MAX;
		tmp = 0;

		REP(i, n) {
			cin >> nums[i];
		}

		REP(i, n-k) {
			REP(j, k) {
				tmp += nums[i+j];
			}

			if(result < tmp) {
				result = tmp;
			}
		}

		cout << result << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0;i < n;i++)
typedef long long ll;
const long long INF = 1LL<<60; // 仮想的な無限大の値

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

  int n, k;
  while(cin >> n >> k) {
    if (n == 0)
      break;
    vector<int> a(n);
    rep(i, n) 
      cin >> a[i];

    vector<int> s(n+1);
    rep(i, n){
      s[i+1] = s[i] + a[i];
    }

    int ans = 0;
    rep(i, n-k) {
      ans = max(ans, s[i+k] - s[i]);
    }

    cout << ans << endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
int main(){
  int n, k;
  int N[100001], ans, sum;
  while(cin >> n >> k, n && k){
    memset(N, 0, sizeof(N));
    ans = 0;
    for(int i = 0 ; i < n ; i++){
      cin >> N[i];
    }
    for(int i = 0 ; i < n ; i++){
      sum = 0;
      for(int j = i ; j < k + i ; j++){
	sum += N[j];
	if(N[j+k-1] == 0) break;
      }
      ans = max(ans, sum);
      //cout << ans << endl;
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#define LL long long
#define rep(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
static const LL INF = 1LL<<61LL;
static const int MAX_N = 1<<18;
typedef pair<int,int> PII;

LL S[MAX_N+1],n,m;
LL ans;

class BIT{
    public:
        int N;
        void init(int _N){
            N=_N;
            rep(i,N+1)S[i]=0;
        }

        LL getSum(int i){
            LL s=0;
            while(i){
                s+=S[i];
                i-=i&-i;
            }
            return s;
        }

        void add(int i,int x){
            while(i<=N){
                S[i]+=x;
                i+=i&-i;
            }
        }
};

int main(){
    while(1){
        BIT bit;
        int t=0;
        cin>>n>>m;
        if(n==0&&m==0)break;
        bit.init(n);
        FOR(i,1,n){
            int x;
            cin>>x;
            bit.add(i,x);
        }
        FOR(i,m,n){
            LL query=bit.getSum(i)-bit.getSum(t);
            ans=max(query,ans);
            t++;
        }
        cout<<ans<<endl;
        ans=0;
    }
    return 0;
}

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

int data[100500];

int main(void)
{
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++){
		cin >> data[i];
		data[i] += data[i-1];
	}
	
	int res = 0;
	for (int i = k; i <= n; i++){
		res = max(res, data[i] - data[i-k]);
//		cout <<"*"<< i << " " << i-k << endl;
	}
//	for (int i = 0; i <= n; i++){
//		cout << data[i] << " ";
//	}
//	puts("");
	cout << res << endl;
	
	return 0;
}

C++: #include<iostream>
#include<stdlib.h>

using namespace std;

int main(){
  int n,k;
  int sum1=0 , max = 0;
  int now = 0, nextdata, next;
  int* s;
  while(1){
    sum1 = 0;
    max = 0;
    cin >>n >>k;

    if(n == 0) break;

    s = (int*)malloc(sizeof(int) * n);

    int data;
    for(int i = 0; i<k; i++){
      cin >>data;
      s[i] = data;
      sum1 += data;
    }
    max = sum1;
    now = n-1;

    for(int i = 0; i<n-k; i++){
      cin >>data;
      if(now+1 == n) {
	next = 0;
	nextdata = s[0];
      } else{
	next = now + 1;
	nextdata = s[next];
      }

      sum1 = sum1- nextdata + data;
      if( sum1 > max) max = sum1;
      now = next;
    }

    cout << max << endl;
    }
  return 0;
}

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

int main(){
	int n, k, x, maxnum = 0;
	cin >> n >> k;
	int wa[100000];
	for(int i=0;i<100000;i++) wa[i] = 0;
	for(int i=0;i<n;i++){
		cin >> x;
		for(int j=0;j<k;j++){
			wa[i+j] += x;
		}
	}
	cin >> x >> x;
	for(int i=k-1;i<n;i++){
		if(maxnum < wa[i]) maxnum = wa[i];
	}
	cout << maxnum << endl;
	cin >> x;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <numeric>
using namespace std;
int main(){
  int n, k;
  int N[100001], ans, sum;
  while(cin >> n >> k, n && k){
    ans = 0;
    for(int i = 0 ; i < n ; i++){
      cin >> N[i];
    }
    for(int i = 0 ; i < n - k ; i++){
      sum = accumulate(N+i, N+i+k, 0);
      /*for(int j = i ; j < k + i ; j++){
	sum += N[j];
	}*/
      ans = max(ans, sum);
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <queue>
using namespace std;
int main(){
	queue<int> a;
	while(1){
		int n,k,num,max,tmp;
		cin >> n >> k;
		if(!n&&!k) break;
		max=tmp=0;
		for(int i=0;i<k;i++){
			cin >> num;
			a.push(num);
			max+=num;
		}
		n-=k;
		tmp=max;
		while(n--){
			cin >> num;
			a.push(num);
			tmp+=a.back()-a.front();
			a.pop();
			if(max<tmp) max = tmp;
		}
		cout << max << endl;
	}
	return 0;
}

C++: 
#include<iostream>
main(){
  for(int n,k,a[100000],s,M,i;std::cin>>n>>k,n;printf("%d\n",M)){
    for(i=s=0;i<n;i++<k&&(M=s+=a[i-1]))std::cin>>a[i];
    for(i=k;i<n;M<s&&(M=s))s+=a[i]-a[i++-k];
  }
}

C++: #include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int N,K;
vi a, s;

void solve(){
    int ans = 0;
    rep(i,N)
        s[i+1] = s[i]+a[i];
    
    for(int i = 0; i < N+1-K; i++)
        ans = max(ans, s[i+K] - s[i]);
    
    cout << ans << endl;
}

int main(){
    while(cin >> N >> K && K){
        a.resize(N,0);
        s.resize(N+1,0);

        rep(i,N)  cin >> a[i];
        
        solve();
    }
}