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 <bits/stdc++.h>
using namespace std;
int num[100005],ans,n,k,sum;
int main(){

    while(1){
    cin >> n >> k;
    if(n==0&&k==0)break;
    for(int i=0;i<n;i++){
            cin >> num[i];
            if(k>i)sum+=num[i];
    }


    for(int i=k;i<n;i++){
        ans=max(ans,sum);
        //cout << "#" << sum << endl;
        sum-=num[i-k];
        sum+=num[i];
    }

    cout << ans << endl;
    ans=0;
    sum=0;
    }

return 0;
}

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

using namespace std;

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

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

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

using namespace std;

int main() {
    int n,k,max=-1e9,sum=0;
    cin >> n >> k;
    int ar[n];
    for(int i = 0;i<n;i++){
        int a;
        cin >> a;
        ar[i]=a;
    }
    
    for(int i=0;i<n-k+1;i++){
        for(int j=0;j<k;j++){
            sum += ar[i+j];
        }
        if(sum>max){
            max=sum;
        }
        sum=0;
    }
    cout << max <<endl;
    
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
	for (;;)
	{
		int a,b,c,d,max=0;
		cin>>a>>b;
		int e[a];
		if (a==0&&b==0) break;
		for (c=0;c<a;c++){
			cin>>e[c];
		}
		for (c=0;c<=a-b;c++){
			for (d=1;d<b;d++){
				e[c]=e[c]+e[c+d];
			}
			if (e[c]>=max) max=e[c];
		}
		cout<<max<<endl;
	}
	return 0;
}

C++: #include <stdio.h>
int main(){
    long long int n,k,a[1000000],top;
    while(1){
        scanf("%lld%lld",&n,&k);
        if(n==0)return 0;
        scanf("%lld",&a[0]);
        for(int i=1;i<k;i++){
            scanf("%lld",&a[i]);
            a[i]+=a[i-1];
        }
        top=a[k-1];
        for(int i=k;i<n;i++){
            scanf("%lld",&a[i]);
            a[i]+=a[i-1];
            a[i]-=a[i-k];
            if(i!=k)a[i]+=a[i-k-1];
            if(a[i]>top)top=a[i];
        }
        printf("%lld\n",top);
    }
}

C++: #include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
static const int MAX = 100001;
int arr[MAX];

int main() {

    int N, k;
    long long global_max, current_max;
    for (; ;) {
        scanf("%d %d", &N, &k);
        if (N == 0 && k == 0) break;
        current_max = 0;
        for (int i = 0; i < k; i++) {
            scanf("%d", &arr[i]);
            current_max += arr[i];
        }
        global_max = current_max;
        for (int i = k; i < N; i++) {
            std::scanf("%d", &arr[i]);
            current_max += arr[i] - arr[i-k];
            global_max = max(global_max, current_max);
        }
        std::cout << global_max << std::endl;
    }
    return 0;
}

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

using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))

int main()
{
    int n,k;
    int temp;
    int ans;
    vector<int> num;

    cin >> n >> k;
    while(n!=0 && k!=0) {
        for(int i=0; i<n; ++i) {
            cin >> temp;
            num.push_back(temp);
        }


        ans=0;

        for(int i=0; i<k; ++i) {
            ans+=num[i];
        }

        if(k!=n) {
            for(int i=k; i<n; ++i) {
                ans=MAX(ans,ans+num[i]-num[i-k]);
            }
        }

        cout << ans << endl;
        num.clear();
        cin >> n >> k;
    }
    return 0;
}

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

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef vector<int> vi;

int main(){
    int n, k;
    while(cin >> n >> k, n || k){
	vi nums(n);
	int sum = 0;
	rep(i,k){
	    cin >> nums[i];
	    sum += nums[i];
	}
	int ans = sum;
	repi(i,k,n){
	    cin >> nums[i];
	    sum -= nums[i-k];
	    sum += nums[i];
	    if(sum > ans){
		ans = sum;
	    }
	}
	cout << ans << endl;
    }
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int n, k;
	while (cin >> n >> k, n || k) {
		vector<int>v(n + 1, 0);
		rep(i, 1, n + 1)cin >> v[i];
		rep(i, 1, n + 1)v[i] += v[i - 1];
		int ans(-INF);
		for (int i = k; i < v.size(); i++) {
			ans = max(ans, v[i] - v[i - k]);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    while(n!=0||k!=0){
       vector<int> a(n);
        cin >> a;
        S[0]=0;
        for(int i=1;i==n;i++){
            S[i]=S[i-1]+a.at(i-1);
        }
        int x=S[k];
        for(int l=1;l==n-k;l++){
            if(x<S[k+l]-S[l]){
                x==S[k+l]-S[l];
            }
        }
            cout << x << endl;
            cin >> n >> k;
        }

    }

}

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=-2000000000;
		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>
using namespace std;

int main(){
  int n,k,ans;
  int sum,kazu[111111];
  while(1){
    cin >> n >> k;
    if(n == 0 && k == 0) break;
    for(int i=0;i<n;i++){
      cin >> kazu[i];
    }
    sum = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<k;j++){
	if(i+j >= n){
	  sum = 0;
	  break;
	}
	sum += kazu[i+j];
      }
      if(ans < sum){
	ans = sum;
      }
      sum = 0;
    }
    cout << ans << endl;
  }
}

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

int main() {
  while(1) {
    int n, k, max=-100000000, a[1000000],sum=0,z=0;
    cin >> n >> k;
    if(n==0 && k==0) break;

    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) {
      if(z<k-1) {
	sum+=a[i];
	z++;
      } else {
	sum-=a[i-k];
	sum+=a[i];
	if(max<sum) max=sum;
      }
    }
    cout << max << endl;
  }
  return 0;
}