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 <climits>

int main() {
    using namespace std;
    
    int n, k;
    while(cin >> n >> k, (n|k)) {
        int arr[n]; cin >> arr[0]; for(int i=1; i<n; i++) { cin >> arr[i]; arr[i] += arr[i-1]; }
    
        int res = INT_MIN/4;

        for(int i=0; i<n-k; i++) {
            res = max(res, arr[i+k]-arr[i]);    
        }
    
        cout << res << endl;
    }
    
    return 0;
}

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

int a[200000];
int n,l,s,maxn;;

int main(){
    while(true){
        cin>>n>>l;
        if(n==0 && l==0){break;}
        for(int i=0;i<n;i++){
            cin>>a[i];
            if(i<l){s+=a[i];}
        }
        maxn=s;
        for(int i=0;i<n-l;i++){
            s-=a[i];
            s+=a[i+l];
            maxn=max(s,maxn);
        }
        cout<<maxn<<endl;
    }
}

C++: #include<iostream>
using namespace std;
int num[100100];
int main(){
int n,m;
int ans=0;
while(1){
         for(int i=0;i<100100;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=num[i]+num[i+1]+num[i+2];
              if(ans<min)ans=min;
         }
         cout<<ans<<endl;
         ans=0;
    }
    return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  while(n!=0|k!=0){
    int max=0,ans,i;
    int a[n];
    for(i = 0;i < n;i++){
      scanf("%d",&a[i]);
      if(i < k){
	max += a[i];
	ans = max;
      }
      else {
	max = max + (a[i] - a[i-k]);
	if(ans < max) ans = max;
      }
    }
    printf("%d\n",ans);
    cin >> n >> k;
  }
  return (0);
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int inp[1000000];
	
int main() {
	int n,m;
	n=in(),m=in();
		int i;
		for(i=0;i<n;i++){
			cin>>inp[i];
		}
		int max=-100000000;
		for(i=0;i<=n-m;i++){
			int sum=0;
			int k;
			for(k=0;k<m;k++){
				sum+=inp[i+k];
				//cout<<sum<<endl;
			}
			if(max<sum)max=sum;
		}
		cout<<max;
	return 0;
}

C++: #include <iostream>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[])
{
    int n,k;
    while (cin >> n >> k) 
    {
        if (n == 0 && k==0) 
        {
            break;
        }
        vector<int> vec(n);
        int sum_max=0;
        int j;
        int sum=0;
        for (int i = 0; i < n; i++) 
        {
            cin >> vec[i];

            if (k  == i + 1) 
            {
                for (j = 0; j < k; j++) 
                {
                    sum += vec[i - j];
                }
                sum_max = max(sum ,sum_max);
                sum -= vec[i-k+1];
            }
            else if (k  < i + 1) 
            {
                sum += vec[i];
                sum_max = max(sum ,sum_max);
                sum -= vec[i-k+1];
            }
        }
        cout << sum_max << endl;
    }
    return 0;
}

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

int main(){
  int i,j,n,k,a[100000],b[100000],s,max;
  while(1){
    cin >> n >> k;
    if(n == 0 && k == 0) break;
    max = 0;
    s = 0;
    for(i=0;i<n;i++){
      cin >> a[i];

      s += a[i];
      b[i] = a[i];
      if(i >= k-1){
	if(max < s) max = s;
	s -= b[i-(k-1)];
      }
    }
    cout << max << endl;
  }
  return 0;
}

C++: 000
0
0
0

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

#define ini 0
using namespace std;

int rlay[100001];

int main (){

while (1){

memset(rlay ,0 ,sizeof(rlay));
int n,k,input,ansmax=0;
cin>>n>>k;
if (n==0 && k==0)break;

rlay[0]=ini;
for (int i=1;i<=n;i++){
        cin>>input;
        rlay[i]=input+rlay[i-1];
}

for (int i=n;i-k>0;i--){
        ansmax = max ( rlay[i]-rlay[i-k] ,ansmax );
}

cout<<ansmax<<endl;
}

return 0;
}

C++: #include<iostream>
using namespace std;
int num[100100];
int main(){
int n,m;
int ans=0;
while(1){
         for(int i=0;i<100100;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<m-n;i++){
              int min=num[i]+num[i+1]+num[i+2];
              if(ans<min)ans=min;
         }
         cout<<ans<<endl;
         ans=0;
    }
    return 0;
}

C++: #include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n, k;
	while (cin >> n >> k) {
		if (n == 0 && k == 0) {
			break;
		}

		vector<ll> a(n);
		for (auto &v : a) {
			cin >> v;
		}

		vector<ll> memo(n + 1);
		for (int i = 1; i <= n; i++) {
			memo[i] = memo[i - 1] + a[i - 1];
		}

		ll ans = INT_MIN;
		for (int i = 0; i < n - k; i++) {
			ll score = memo[i + k] - memo[i];
			ans = max(ans, score);
		}

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