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>
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 <bits/stdc++.h>
using namespace std;
int main(){
    int n , k;
    cin >> n >> k;
    while(n!=0|| k!=0){
    vector<int>a(n);
    for(int i = 0;i < n;i++){
      cin >> a.at(i);
    }
   vector<int>S(n+1);
   S.at(0) = 0;
   for(int i = 0;i < n;i++){
     S.at(i+1) = S.at(i) + a.at(i);
   }
   int ans = 0;
   for(int i = 0;i+k < n+1;i++){
     if(S.at(i+k)-S.at(i) > ans)
     ans = S.at(i+k) - S.at(i);
   }
   cout << ans << endl;
   cin >> n >> k;
    }
 }

C++: #include<bits/stdc++.h>
#define LL long long
#define rep(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
static const LL INF = 1LL<<61LL;
static const int MAX_N = 1<<18;
typedef pair<int,int> PII;

LL S[MAX_N+1],n,m;
LL ans;

class BIT{
    public:
        int N;
        void init(int _N){
            N=_N;
            rep(i,N+1)S[i]=0;
        }

        LL getSum(int i){
            LL s=0;
            while(i){
                s+=S[i];
                i-=i&-i;
            }
            return s;
        }

        void add(int i,int x){
            while(i<=N){
                S[i]+=x;
                i+=i&-i;
            }
        }
};

int main(){
    while(1){
        BIT bit;
        int t=0;
        cin>>n>>m;
        if(n==0&&m==0)break;
        bit.init(n);
        FOR(i,1,n){
            int x;
            cin>>x;
            bit.add(i,x);
        }
        FOR(i,m,n-m+1){
            LL query=bit.getSum(i)-bit.getSum(t);
            ans=max(query,ans);
            t++;
        }
        cout<<ans<<endl;
        ans=0;
    }
    return 0;
}

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

using namespace std;

int n, k ,i = 0, a[100000];
long long int b[100000];
long long int result[100][2];

int main()
{
	for (;; i++)
	{
		cin >> n >> k;
		if (n == 0)
		{
			break;
		}

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

		for (int p = 0; p < n - k; p++)
		{
			for (int q = 0; q < k; q++)
			{
				result[i][0] += a[p + q];
			}
			result[i][1] = max(result[i][0], result[i][1]);
			result[i][0] = 0;
		}
	}
	for (int p = 0; p < i; p++)
	{
		cout << result[p][1] << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
	vector<int> sum;
	int n,m,x,max;
	cin>>n>>m;
	cin>>x;
	sum.push_back(0);
	sum.push_back(x);
	max=-1000000;
	for(int i=2;i<=n;i++){
		cin>>x;
		sum.push_back(sum[i-1]+x);
	}
	for(int i=0;i<n;i++){
		if(sum[m+i]-sum[i]>max)
		max=sum[m+i]-sum[i];
	}
	cout<<max<<endl;
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,k,a[100000],s[100001];
  long long b=-1000000000,c;
  cin >> n >> k;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n; i++) {
    s[i+1]=s[i]+a[i];
  }
  for(int i=0; i<=n-k; i++) {
    c=s[k+i]-s[i];
    if(b<c) {
      b=c;
    }
  }
  cout << b << endl;
}

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

int main(){
	int n, k, x, maxnum = 0;
	ifstream ifs;
	ifs.open("input.txt");
	ifs >> n >> k;
	int wa[100000];
	for(int i=0;i<100000;i++) wa[i] = 0;
	for(int i=0;i<n;i++){
		ifs >> x;
		for(int j=0;j<k;j++){
			wa[i+j] += x;
		}

	}
	ifs.close();
	ofstream ofs;
	ofs.open( "output.txt" );
	for(int i=0;i<n;i++){
		if(maxnum < wa[i]) maxnum = wa[i];
	}
	ofs << maxnum;
	ofs.close();
}

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

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

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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
ll bit[100010];
int n;
int k;
ll sum(int i){
	ll s = 0;
	while(i > 0){
		s +=bit[i];
		i -=i&-i;
	}
	return s;
}

void add(int i,int x){
	while(i <=n){
		bit[i] +=x;
		i +=i&-i;
	}
}

int main(){
	while(cin>>n>>k,n||k){
		memset(bit,0,sizeof(bit));
		for(int i = 0;i < n;i++){
			int num;
			cin>>num;
			add(i+1,num);
		}
		ll res =numeric_limits<ll>::min();
		for(int i = 1;i+k-1<=n;i++){
			res =max(sum(i+k-1)-sum(i-1),res);
		}
		cout <<res<<endl;
	}
	return 0;
}

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

int main() {
	// your code goes here
	int n,m;
	cin>>n>>m;
	while(n!=0||m!=0){
		int a[100100];
		for(int i=0;i<n;i++){
			int aa;
			cin>>aa;
			a[i]=aa;
		}
		int sum=0;
		int max=0;
		for(int i=0;i<m;i++){
		 sum=sum+a[i];
			
		}
		//cout<<sum<<endl;
		max=sum;
		for(int i=0;i<n-m;i++){
		sum=sum-a[i]+a[m+i]	;
		//cout<<sum<<endl;
		if(sum>max) max=sum;
		//cout<<max<<endl;
		}
		cout<<max<<endl;
		cin>>n>>m;
	}
	return 0;
}

C++: aaaaaaaaa

C++: #include<iostream>
using namespace std;
int main(){
  int n,k;
  while(cin>>n>>k){
    if(n==0&&k==0) break;
    int s[n],ans=0,su=0;
    for(int i=0;i<n;i++) cin >> s[i];
    for(int i=0;i<k;i++) su += s[i];
    ans = su; 
    for(int i=k;i<n;i++){
      su += (s[i] - s[i-k]);
      if(ans<su) ans = su;
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

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

int main(void){
  int n,k;
  while(cin>>n>>k,n+k){
    vector<int> a(n);

    rep(i,n)cin>>a[i];
    int ret = -100000;
    rep(i,n-k+1){
      int sum = 0;
      rep(j,k){
        sum += a[i+j];
      }
      ret = max(ret,sum);
    }
    cout<<ret<<endl;
  }
}

C++: #include <stdio.h>
int main(){
	for(;;){
		int max=0,set[100000],n,m,a,b,c;
		scanf("%d%d",&n,&m);
		if(n==0&&m==0)
		break;
		for(a=0;a<n;a++){
			scanf("%d",&set[a]);
		}
		for(a=0;a<n-m;a++){
			c=0;
			for(b=0;b<m;b++){
				c+=set[a+b];
			}
			if(max<c)
			max=c;
		}
		printf("%d\n",max);
	}
	return 0;
}