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

int main(){
  int serchn,numn;
  for(int a = 0;;a++){
    cin >> numn >> serchn;
    if(numn == 0 && serchn == 0){
      break;
    }
    int outp = 0;
    int gh = 0;
    vector<int> num(numn,0);
    for(int n = 0;n<numn;n++){
      cin >> num[n];
    }
    for(int n = 0;n<serchn;n++){
      outp += num[n];
    }
    gh = outp;
    for(int a = 0,b=serchn;b<numn;a++,b++){
      gh += num[b];
      gh -= num[a];
      if(gh > outp)outp = gh;
    }
    cout << outp << 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 = a[k - 1];
  rrep(i, k, n) maxup(res, a[i] - a[i - k]);
  cout << res << endl;

  return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n,k,a[5000],sum,max=0,i,j;
	while(1){
		scanf("%d%d",&n,&k);
		if(n=0&&k==0) break;
		for(i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		for(i=1;i<=n-k;i++){
			sum=0;
			if(i+k<=n){
				for(j=i;j<i+k;j++){
					sum+=a[j];
				}
				if(max<sum){
					max=sum;
				}
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	while (true){
		int n, k;
		double a[100001] = {}, b[100001] = {}, ans;
		cin >> n >> k;
		if (n == 0 || k == 0)	break;
		for (int i = 1; i <= n; i++){
			cin >> a[i];
		}
		for (int i = 1; i <= n; i++){
			for (int x = 0; x<k; x++){
				if (a[i + k-1] == 0) break;
				b[i] += a[i + x];
			}
			if (b[i]>b[i - 1]){
				ans = b[i];
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int n,k,box[10000]={0},sum=0,summ;
int main(){
    while(1){
        cin >> n >> k;
        if(n==0&&k==0)break;
        int ans=0;
        for(int i=0;i<k;i++){
            cin >> box[i];
            sum+=box[i];
            }
          for(int i=k;i<n;i++){
                cin >> box[i];
                sum+=box[i]-box[i-k];
                if(sum>ans)ans=sum;
        }
    cout << ans <<endl;

    }
    return 0;
}

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

int main(){
  int n,k,x;
  vector<int> s;
  int start,end,ans=0,sum;
  
  while(1){
    cin>>n>>k;
    if(n==0 && k==0) break;
    for(int i=0;i<n;i++){
      cin>>x;
      s.push_back(x);
    }
  
    start=0;end=k;
    while(end-1<n){
      sum=0;
      for(int i=start;i<end;i++){
        sum+=s[i];
      }
      ans=max(ans,sum);
    
      start++;end++;
    }
  
    printf("%d\n",ans);
    ans=0;
    s.clear();
  }
  return 0;
}

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

/* {{{ */
#define CL(N) cout << N << endl
#define DCT(N) cout << "debug " << N << endl
#define REP(i, N) for (int i = 0; i < N; i++)
/* }}} */

int main()
{
	int n, l;

    while (cin >> n >> l, n || l){
        int a[100000];
        REP(i, n){
            cin >> a[i];
        }

        int sum = 0;
        REP(i, n - l + 1){
            int si = 0;
            REP(j, l){
                si += a[i + j];
            }

            sum = max(sum, si);
        }

        CL(sum);
    }

	return (0);
}

C++: #include<iostream>
#define INF -10000000000000000;
using namespace std;

long long int num[100100];


int main(){
    long long int n,m;
    long long int sum=0;
    long long int ans=INF;
    while(1){
        cin>>n>>m;
        if(n==0&&m==0)break;
        for(int i=0;i<100100;i++){
            num[i]=0;
            if(num[i+1]==0)break;
        }
        for(int i=0;i<n;i++){
            cin>>num[i];
            if(i<m)sum+=num[i];
        }
        for(int i=1;i<n;i++){
            sum=sum-num[i-1]+num[i];
            if(ans<sum)ans=sum;
        }
        cout<<ans<<endl;
        ans=INF;
        sum=0;
        }
    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<stdio.h>

using namespace std;

int main(){


    int n,k,ans=0,ans2;
    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 j=k;j<n;j++){
        for(int a=0;a<k;a++){
        ans+=num[j-k+a];
        }
        if(ans2<ans){
            ans2=ans;
        }
        ans=0;
    }
    printf("%d\n",ans2);
    }

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 <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int n, k;
int ary[100000];

int main() {
	while(1) {
		scanf(" %d %d", &n, &k);
		if(n == 0 && k == 0) break;
		memset(ary, 0, sizeof ary);
		rep(i,n) {
			static int t;
			scanf(" %d", &t);
			ary[i] = t;
		}

		int sum = 0;
		for(int i = 0; i < k; i++) sum += ary[i];

		int maxv = sum;
		for(int i = 1; i < n - k + 1; i++) {
			sum -= ary[i - 1];
			sum += ary[i + k - 1];
			maxv = max<int>(maxv, sum);
		}
		printf("%d\n", maxv);
	}
	return 0;
}

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

long long int sum,k,n,num[200000];

int main(){

    while(1){

    long long int ans=-1000000000000;
    cin >> n >> k;
    if(n==0&&k==0)break;

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

    for(int i=0;i<n-k;i++){
        for(int j=i;j<i+k;j++){
            sum+=num[j];
        }
        if(ans<sum)ans=sum;
        sum=0;

    }

    cout << ans << endl;
    }


return 0;
}