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

int n, k;
int a[100000];
int ra[100001];	//ra[i] = a[0] + ??? + a[i-1]

int main() {
	while (cin >> n >> k) {
		for(int ii = 0; ii < n; ii++) cin >> a[ii];
		if (!n) { break; }
		ra[0] = 0;
		for (int i = 0; i < n; i++) {
			ra[i+1] = ra[i] + a[i];
		}

		int ans = -1000000001;
		for (int i = k; i <= n; i++) {
			ans = max(ans, ra[i] - ra[i-k]);
		}

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

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

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);
        vector<int> sum(n -k +1);
        int input;
        for (int i = 0; i < n; i++) 
        {
            cin >> vec[i];//input;
            //vec.push_back(input);
        }
        for (int i = 0; i < n - k + 1; i++) 
        {
            sum[i]=0;
            for (int j = 0; j < k; j++) 
            {
                sum[i] += vec[i + j];
                //cout << " " << vec[i+j] << endl;
            }
            //cout << "sum="<< sum[i] << endl;
        }
        //for (int i = 0; i < n-k+1; i++) 
        //{
        //    cout << vec[i]<<endl;
        //}
        //sort(vec.begin(), vec.end() , greater<int>() );
        //for (int i = 0; i < n-k+1; i++) 
        //{
        //    cout << vec[i]<<endl;
        //}
        cout << sum[0];
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

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

        vector<int> s(n+1,0);
        rep(i,n) s[i+1] = s[i] + v[i];

        ll ans = -INF;
        for(int i = 0; i <= n-k; i++){
            ll val = s[k+i] - s[i];
            ans = max(ans,val);
        }
        cout << ans << endl;
    }

    return 0;
}

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

int main(){
    while(1){
    int n=0,k=0,num[100010]={0},ans=0,sum=0;
    cin>>n>>k;
    if(n==0 && k==0)break;
    for(int i=0;i<n;i++){
            cin>>num[i];
            if(i<k){
            sum+=num[i];
            }
        }
    for(int i=1;i<n-2;i++){
        int s;
        s=sum-num[i-1]+num[i+k-1];
        sum=s;
        if(sum>ans)ans=sum;
        }
    cout<<ans<<endl;
    }
    return 0;
}

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

int main() {
  cout << "aaa" << endl;
  ll n, k;
  cin >> n >> k;
  vector<ll> A(n);
  for (ll i = 0; i < n; i++) {
    cin >> A[i];
  }
  int tmp;
  cin >> tmp >> tmp;

  vector<ll> s(n);
  for (ll i = 0; i < n; i++) {
    s[i + 1] = s[i] + A[i];
  }
  ll mx = (1LL << 60) * -1;

  for (ll i = 0; i < n - k; i++) {
    mx = max(mx, s[i + k] - s[i]);
  }
  cout << mx << endl;
}

C++: #include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値

int main() {
    // 入力
    int N, K;
    while (cin >> N >> K) {
        if (N == 0) break;
        vector<long long> a(N);
        for (int i = 0; i < N; ++i) cin >> a[i];

        // 累積和を前計算
        vector<int> s(N+1, 0);
        for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

        // 答えを求める
        long long res = -INF; // 最初は無限小の値に初期化しておく
        for (int i = 0; i <= N-K; ++i) {
            long long val = s[K+i] - s[i];
            if (res < val) res = val;
        }
        cout << res << endl;
    }
}

C++: #include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int n,k,a,max;
  int set[100001];
  while(1){
    scanf("%d %d",&n,&k);
  if(n==0 && k==0)break;
  max=0;
  for(int i=0;i<n;i++){
    scanf("%d",&set[i]);
  }

  for(int i=0,sum=0;i<n-k+1;i++,sum=0){
    for(int j=i,l=i+k-1;;j++,l--){
      sum += set[j]+set[l];
      printf("%d %d\n",j,l);
      if(l==j+1){
	break;
      }else if(l==j){
	sum-=set[j];
	break;
      }
    }
    if(max<sum || i==1){
      max=sum;
    }
  }
  printf("%d\n",max);
  }
}

C++: #include <cstdio>

int main(){
	int n, k;
	int a[100000];
	int sum;
	int max;
	
	for(;;){
		max = -99999999;
		scanf("%d %d", &n, &k);
		if(n == 0 && k == 0) break;
		
		for(int i = 0; i < n; i++){
			scanf("%d", &a[i]);
		}
	
		for(int i = 0; i < n - k; i++){
			sum = 0;
			for(int j = i; j < i + k; j++){
				sum += a[j];
			}
			if(max < sum) max = sum;
		}
	
		printf("%d\n", max);
	}
	
	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define ll long long int

using namespace std;

int main(void) {
    int n,k;
    while(cin>>n>>k && n>0){
        vector<ll> a(n);
        REP(i,n){
            cin >> a[i];
        }
        ll s=0;
        REP(i,k){
            s+=a[i];
        }
        ll ans=s;
        FOR(i,k,n-1){
            s+=a[i];
            s-=a[i-k];
            ans=max(ans,s);
        }
        cout << ans << endl;
    }
    
    return 0;
}