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>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

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

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n,k;
  while(cin >> n >> k,n+k) {
    int a[n];
    REP(i,n) {
      cin >> a[i];
    }
    int s = 0;
    REP(i,k) {
      s += a[i];
    }
    int res = s;
    for(int i=k; i<n; ++i) {
      s -= a[i-k]; s+= a[i];
      res = max(res, s);
    }
    cout <<res << endl;
  }

}

C++: /*
	0516:Maxinum Sum
*/
#include	<iostream>
#include	<vector>
#include	<algorithm>
#include	<cstdio>

using namespace std;

int main(void) {
	while(1) {
		int n, k;
		scanf("%d %d", &n, &k);
		if(n == 0 && k == 0) { break; }
		
		vector<int> inputs(n);
		
		for( int i = 0; i < (int)inputs.size(); i++ ) {
			cin >> inputs[i];
		}
		int maxNum = 0, num = 0;
		for( int i = 0; i < (int)inputs.size() - (k - 1); i++ ) {
			if(i == 0) {
				maxNum = inputs[i] + inputs[i+1] + inputs[i+2];
			} else {
				maxNum = max(maxNum, inputs[i] + inputs[i+1] + inputs[i+2]);
			}
		}
		
		cout << maxNum << endl;
		
	}
	return 0;
}

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

int main(){
    int n, k;
    while(cin >> n >> k){
        if(!n&&!k) break;
        int A[n]={0}, S[n+1]={0};
        for(int i=0;i<n;i++) {
            cin >> A[i];
            S[i+1] = S[i]+A[i];
        }
        int maxValue = -600000000;
        for(int i=0;i+k<=n;i++){
            maxValue = max(maxValue, S[k+i]-S[i]);
        }
        cout << maxValue << endl;
    }
    //cout << "finished" << endl;
    return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(1) {
    int n, k;
    cin >> n >> k;
    if(n == 0 && k == 0) break;

    vector<int> a(n);
    REP(i, n) cin >> a[i];
    
    int ans = 0;
    for(int i = 0; i < k; i++) {
      ans += a[i];
    }
    int mx = ans;
    for(int i = 0; i < n - k; i++) {
      mx = mx + a[k + i] - a[i];
      ans = max(mx, ans);
    }

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

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#define reep(n1,n2,n3) for(int n1=n3;n1<n2;n1++)
#define rep(n1,n2) reep(n1,n2,0)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF 1e9
using namespace std;
typedef long long int lint;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int,int> > vp;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int> > pii;
typedef vector<string> vs;
const double PI  = acos(-1.0);
int num[100000];
int main(){
    int n,k;
    while(cin>>n>>k,n){
        rep(i,n)cin>>num[i];
        int ret=-INF;
        int buf=0;
        rep(i,k){
            buf+=num[i];
        }
        ret=max(buf,ret);
        rep(i,n-k){
            buf-=num[i];
            buf+=num[i+k];
            ret=max(buf,ret);
        }
        cout<<ret<<endl;
    }
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
#define int ll
signed main(){
    int n,m;
    while(cin>>n>>m,n+m){
        vi v(n+1,0);
        vi dp(n+1,0);
        int ans=-INF;
        rep(i,n)cin>>v[i];
        rep(i,n){
            if(i<=2){
                for(int k=m-1; k>=1;k--)dp[i+k]+=v[i];
            }else{
                dp[i]+=v[i];
                ans=max(ans,dp[i]);
                if(i<n-m-1)
                    for(int j=1;j<=m-1;j++)dp[i+j]+=v[i];
            }
        }
        //rep(i,n)cout<<dp[i]<<endl;
        cout<<ans<<endl;
        
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    for(int count = 0;  count < 5; count++){
	    vecotor<int> none(2);
	    int N, k;
	    cin >> N >> k;
	    vector<int> a(N);
	    for(int i = 0; i < N; i++){
		cin >> a.at(i);
	    }
	    int ans = 0;
	    int total = 0;
	    for(int i = 0; i < N; i++){
	    	if(i < k) total += a[i];
		else total = total + a[i] - a[i-k];
		if(ans < total) ans = total;
	    }
	    cout << ans << endl;
	    for(int i = 0; i < 2; i++){
    	    cin >> none.at(i);
	    }
　　}
}

C++: #include <iostream>
using namespace std;
int n,k;
int a[100001];
int maxsum,sum;

int main(){
	while(1){
		cin >> n>>k;
		if(n==0&&k==0)break;
		for(int i=0;i<n;i++){
			cin >>a[i];
		}
		sum=maxsum=0;
		for(int i=0;i<k;i++){
			sum+=a[i];
		}
		maxsum=sum;
		for(int i=0;i<n-k;i++){
			sum=sum+a[i+k]-a[i];
			if(maxsum<sum)maxsum=sum;
		}
		cout <<maxsum <<endl;
	}
	return 0;
}

C++: #include <stdio.h>
int array[10000],n,k,max;

void func(int now){
	int i,j,temp=0;
	
	if(now==n-k)return;
	
	for(i=now;i<now+k;i++){
		temp+=array[i];
	}
	if(temp>max)max=temp;
	func(now+1);
}
		
		


int main(void){
	int i;
	
	while(scanf("%d",&n),n){
		max=0;
		
		scanf("%d",&k);
		for(i=0;i<n;i++){
			scanf("%d",&array[i]);
		}
		func(0);
		
		printf("%d\n",max);
		
	}
	return 0;
}