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 "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	while(N){
	    vector<int>v(N + 1);
	int ans = -MOD;
	for (int i = 1; i <= N; i++) {
		cin >> v[i];
		v[i] += v[i - 1];
		if (i >= K) {
			ans = max(ans, v[i] - v[i - K]);
		}
	}
	cin>>N>>K;
	cout << ans << endl;
	}
}

C++: //https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Final/0516?year=2007

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, k;

    while (cin >> n >> k, n | k) {
        vector<int> a((unsigned) n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }

        int s = accumulate(a.begin(), a.begin() + k, 0);
        int ans = s;
        for (int i = k; i < n; ++i) {
            s += a[i] - a[i - k];
            ans = max(ans, s);
        }

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

/*
 *
 */

C++: #include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;


int main() {
    int N,K;
    cin >> N >> K;
    vector<int> a(N);
    vector<int> wa(N+1);
    wa.at(0) = 0;
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
        wa.at(i+1) = a.at(i) + wa.at(i);
    }
    int ANS = -INF;
    for(int i = 0; i < N - K +1; i++){
        int ans = wa.at(i+K) - wa.at(i);
        ANS = max(ANS, ans);
    }
    cout << ANS << endl;
}

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

using namespace std;

int main(void)
{
int n,k,s,b;
while(1)
{
cin >> n >>k;
if(n==0 && k==0)
break;
int m[100001]={0};
int a[100001];

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

m[0]=0;
for(int i=0;i<n;i++)
m[i+1]=m[i]+a[i];

s=0;

for(int i=1;i+k<=n;i++)
{
b=m[i+k]-m[i];
if(s<b)
s=b;
}
}
cout << s << endl;
return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){

	int n,k,s,data;
	s = 0;
	
	while(cin >> n >> k, n && k){
	vector<int> sum;	

	rep(i,n){
		cin >> data;
		sum.push_back(data);
	}
	
	data = 0;

	rep(i,k){

		data += sum[i];
		
	}

	int res;
	res = data;
	
	rep(i,n - k){
		data -= sum[i];
		data += sum[i+k];
		res = max(res,data);
	}

	cout << res << endl;
	}
	
	return 0;
}

C++: #include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;

ll sum[100010];
ll a[100010];

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

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

		sum[1] = a[1];
		for (int i = 2; i <= n; i++) {
			sum[i] = sum[i - 1] + a[i];
		}

		ll mx = 0;
		ll ans = 0;
		for (int i = k; i <= n; i++) {
			mx = sum[i] - sum[i - k];
			ans = max(mx, ans);
		}
		cout << ans << 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<100001;i++){
              num[i]=0;
              if(num[i+1]==0)break;
         }
         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 <iostream>
#include <vector>
using namespace std;



int main(){
        int n, k,max,temp,num,total;
        while(true) {  //ベクターに格納
                cin >> n>>k;
                if(n==k!=0){
                  break;
                }
                vector<double> v;
                total=0;
                v.push_back(total);
                for(int i=0;i<n;i++){
                  cin>>num; //入力をnumに代入
                  total+=num;
                  v.push_back(total); //ベクターvにプッシュ
                }

                max=0;
                temp=0;
                for(int i=0; i+k<=n; i++) {
                        temp=v[i+k]-v[i];
                        if(temp>max) max=temp; //tempが最も大きい数値ならmaxを更新
                        temp=0; //tempの初帰化
                }
                cout<<max<<endl;
        }
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

        vector<ll> cum(n + 1, 0);
        rep(i, n)
        {
            cum[i + 1] += cum[i] + s[i];
        }
        ll ans = 0;
        rep(i, n + 1 - k)
        {
            ans = max(ans, cum[k + i] - cum[i]);
        }
        cout << ans << endl;
    }

    return 0;
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
    while(1){
        int num[100000] = {0};
        int sum = 0;
        int ma = -100000;
        int n,k;
        scanf("%d%d",&n,&k);
        if(n == 0 && k == 0) break;

        for(int i = 0;i < n;i++){
            scanf("%d",&num[i]);
            if(i < k) sum += num[i];
        }
        ma = max(sum,ma);
        for(int i = 0;i < n-k;i++){
            sum += num[k+i] -num[i];
            ma = max(sum,ma);
        }
        printf("%d\n",ma);
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;

int main(){
	int n, k;
	vector< int > a;
	vector< int > r;
	
	while(cin >> n >> k, n){
		a.CLR();
		r.CLR();
		
		a.RS(n);
		r.RS(n - k + 1);
		
		REP(i, n) cin >> a[i];
		
		REP(i, k) r[0] +=  a[i];
		
		FOR(i, k, n){
			r[i-k+1] = r[i-k] + a[i] - a[i-k];
		}
		
		REP(i, n - k + 1){
			cout << r[i] << endl;
		}
		
		//cout << *max_element(ALL(r)) << 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;
        }

    }

}