Go: package main

import "fmt"

func main() {

	for true {
		var n, k int
		fmt.Scan(&n, &k)

		if n == 0 && k == 0 {
			return
		}
		
		a := make([]int, n)
		ans := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
			if i == 0 {
				ans[i] = a[i]
			} else {
				ans[i] = ans[i-1] + a[i]
			}
		}
		max := 0
		for i := k; i < n; i++ {
			t := ans[i] - ans[i-k]
			if max < t {
				max = t
			}
		}
		fmt.Println(max)
	}
}

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;
}

C++: #include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

int n, k;
ll a[111111];

int main()
{
  cin >> n >> k;
  rep(i, n) cin >> a[i];

  rep(i, n - 1) a[i + 1] += a[i];

  ll res = -INF;
  rrep(i, k, n) maxup(res, a[i] - a[i - k]);
  cout << res << endl;

  return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
  while (1) {
    int k, n;
    cin >> n >> k;
    if ((k == 0 && n == 0)) {
      return 0;
    }

    int a[100000];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }

    int s = 0;
    for (int i = 0; i < k; i++) {
      s += a[i];
    }
    for (int i = 0; i + k < n; i++) {
      int t = s + a[k + i] - a[i];
      if (t > s) {
        s = t;
      }
    }
    cout << s << endl;
  }
  return 0;
}

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

int main(){
	int n, k;
	int a[100000];
	int sum = 0;
	int Max = 0;
	
	while(1){
		cin >> n >> k;
		if(n + k == 0){
			for(int i = 0; i < n; i++){
			cin >> a[i];
			}
		}
	
		for(int i = 0; i < n-k+1; i++){
			sum = 0;
			for(int j = i; j < i+k; j++){
				sum += a[j];
			}
			Max = max(Max, sum);
		}
	
		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(M=1<<31,i=s=0;i<n;s+=a[i],k<++i&&(s-=a[i-k-1])&&M<s&&(M=s))std::cin>>a[i];}

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

using namespace std;

int main(){


    int n,k,ans=0,ans2=0,ans3=0;
    while(1){
    scanf("%d%d",&n,&k);
    if(n==0&&k==0)break;
    int num[n];
    for(int y=0;y<n;y++){
        scanf("%d",&num[y]);
    }
        for(int a=0;a<k;a++){
        ans+=num[a];
        }
        ans3=ans;
    for(int j=0;j<n-k;j++){
        ans2=ans-num[j]+num[j+k];
        if(ans3<ans2){
            ans3=ans2;
        }
    ans=ans2;
    ans2=0;
    }
    printf("%d\n",ans3);
    }

return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

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