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 <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    int n, k;
    while (cin >> n >> k, n) {
        vector<long long> ac(n+1, 0);
        for (int i=1; i<=n; ++i) {
            cin >> ac[i];
            ac[i] += ac[i-1];
        }
        long long res = -LLONG_MAX;
        for (int i=k; i<=n; ++i) {
            res = max(res, ac[i] - ac[i-k]);
        }
        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 <bits/stdc++.h>
using namespace std;

/* {{{ */
#define CL(N) cout << N << endl
#define DCT(N) cout << "debug " << N << endl
#define REP(i, N) for (int i = 0; i < N; i++)
/* }}} */

int main()
{
	int n, l;

    while (cin >> n >> l, n || l){
        int a[100000];
        REP(i, n){
            cin >> a[i];
        }

        int sum = 0;
        REP(i, l){
            sum = max(sum, a[i] + a[i + 1] + a[i + 2]);
        }

        CL(sum);
    }

	return (0);
}

C++: #include <iostream>
#include<algorithm>

using namespace std;

int rsw[1000002];

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

C++: #include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)

int N, k, i1, i2;
ll a[100010];

int main() {
    while (cin >> N >> k) {
        if (N == 0) break;
        REP(i,N) cin >> a[i];

        ll S[100010];
        S[0] = 0;
        REP(i,N) {
            S[i+1] = S[i] + a[i];
        }

        int ans = 0;
        REP(i,N+1-k) {
            if (S[i+k] - S[i] > ans) ans = S[i+k] - S[i];
        }

        cout << ans << endl;
    }
}

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

int main(){
  int n,k,data[100000],sum,max;
  while(1){
    cin >> n >> k;
    sum = 0;
    max = -10000000;
    if(n == 0&&k == 0)break;
    for(int i = 0; i < n;i++)
      cin >> data[i];
    for(int i = 0;i < k;i++)
      sum += data[i];
    if(sum > max) max = sum;
    for(int i = 0; i < n-k;i++){
      sum = sum-data[i]+data[i+k];

      if(sum > max)
        max = sum;
    }
    cout << max <<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<bits/stdc++.h>
using namespace std;

int N,K;
int a[100001];

void solve(){
    for(int i=0;i<N;i++){
        scanf("%d",&a[i+1]);
        a[i+1]+=a[i];
    }
    int ma=0;
    for(int i=K;i<=N;i++)ma=max(ma,a[i]-a[i-K]);
    printf("%d\n",ma);
}
int main(){
    while(scanf("%d%d",&N,&K),N||K)solve();
}

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

int data[100000]={0};

int main(){
    int n,k;
    int sum = -1;
    int tmp,tmp2;
    while(1){
        cin >> n >> k;
        if(n == 0 && k == 0) break;
        for(int i=0;i<n;i++) cin >> data[i];
        for(int i=0;i<=(n-k)/2;i++){
            tmp = 0;
            tmp2 = 0;
            for(int j=i,g=n-(i+1);j<i+k;j++,g--){
                tmp += data[j];
                tmp2 += data[g];
            }
            if(sum < tmp) sum = tmp;
            else if(sum < tmp2) sum = tmp2;
        }
        cout << sum << endl;
    }
}

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


int main(){
    while (1){
	vector<long long> inp;
	long n, k, input;
	cin >> n >> k;
	if (!(n || k)) break;

	for (long long i = 0; i < n; i++){
	    cin >> input;
	    inp.push_back(input);
	}
	
	int s, sum = 0;
	for (int i = 0; i < k; i++) sum += inp[i];
	s = sum;
	for (int i = 0; k < inp.size(); i++, k++){
	    s -= inp[i];
	    s += inp[k];
	    if (sum < s) sum = s;
	}
	cout << sum << endl;
    }
}

C++: #include<iostream>
using namespace std;
int num[1001000];
int main(){
int n,m;
int ans=0;
while(1){
         for(int i=0;i<1001000;i++)num[i]=0;
         cin>>n>>m;
         if(n==0&&m==0)break;
         for(int i=0;i<n;i++) cin>>num[i];
         for(int i=0;i<n-m;i++){
              int min=0;
              for(int j=i;j<i+m;j++)min+=num[j];
              if(ans<min)ans=min;
         }
         cout<<ans<<endl;
         ans=0;
    }
    return 0;
}

C++: #include<cstdio>
int main ()
{
    int n,k,N[100000],ans,sum;
    while(1){
        scanf("%d%d",&n,&k);
        if(n==0&&k==0)break;
        sum=0;
        for(int i=0;i<n;i++){
            scanf("%d",&N[i]);
            if(i<k) sum+=N[i];
        }
        ans=sum;
        for(int i=k;i<n;i++){
            sum=sum+N[i]-N[i-k];
            if(ans<sum) ans=sum;
        }
        printf("%d\n",ans);
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
 
int main() {
 
  while(1) {
  int n,k;
  cin >> n >> k;
  if(n==0 && k==0) break;
 
  int a[100001] = {};
 
  for(int i=0;i<n;i++) cin >> a[i];
 
  
  int maxsum = 0;
  int sum;
  for(int i=0;i<k;i++) maxsum += a[i];
 
  sum = maxsum;
  for(int i=k;i<n;i++) {
    sum =sum + a[i] - a[i-k];
      if(sum > maxsum) maxsum = sum;
  }
 
  cout << maxsum <<endl;
  }
 
  return 0;
}