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 <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n, k;
    while (cin >> n >> k, n) {
        vector<int> a(n);
        for (int &ai: a) cin >> ai;
        int sum = 0;
        for (int i = 0; i < k; i++) sum += a[i];
        int ma = sum;
        for (int i = k; i < n; i++) {
            sum += -a[i - k] + a[i];
            ma = max(ma, sum);
        }
        cout << ma << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#pragma warning(disable:4996)
long long n, k, a[200000], s, ret;
int main() {
	while (true) {
		cin >> n >> k; if (n == 0)break; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); if (i <= k)s += a[i]; }
		ret = s; for (int i = k + 1; i <= n; i++) { s -= a[i - k]; s += a[i]; ret = max(ret, s); }
		cout << ret << endl;
	}
	return 0;
}

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

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

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, k;
        cin >> n >> k;
        if(n == 0)
            return 0;

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

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

        int ret = sum;
        for(int i=0; i<n-k; ++i){
            sum -= a[i];
            sum += a[i+k];
            ret = max(ret, sum);
        }
        cout << ret << endl;
    }
}

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

int n, k;
int t[100002];

int main(){

  while(cin >> n >> k, n || k){
    int sum = 0;

    for(int i = 0; i < n; i++){
      cin >> t[i];
      if(i < k) sum += t[i];
    }

    int ans = sum;

    for(int i = 0; i < n - k; i++){
      sum -= t[i];
      sum += t[i + k];
      ans = max(ans, sum);
    }
    cout << ans << endl;
  }
}

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

int main(){
  int serchn,numn;
  int gh = 0;
  int outp = 0;
  for(int a = 0;;a++){
    cin >> numn >> serchn;
    if(numn == 0 && serchn == 0){
      break;
    }
    outp = 0;
    gh = 0;
    vector<int> num(numn);
    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 = 1,b=serchn;a<numn-serchn;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;

#define loop(i,n) for(int i=1;i<=n;i++)
int a[100002];
int s[100002];

int main(){
  while(1){
    int n,k;
    cin>>n>>k;
    if(n==0)return 0;
    loop(i,n)cin>>a[i];
    s[1]=0;
    loop(j,k){
      s[1]+=a[j];
    }
    int m=s[1];
    loop(i,n-k+1){
      if(i==1)continue;
      s[i]=s[i-1]-a[i-1]+a[i+k-1];
      m=max(m,s[i]);
    }
    cout<<m<<endl;
  }
  return 0;
}

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

#define INF (1e+9)
#define LLINF (1e+18)
#define LL long long


using namespace std;


int array[200000];

int main (void){
	//printf("%lld:::%lld",(LL)INF,(LL)LLINF);

	int n;
	int k;

	LL sum;
	LL maxNum;

	while(true){
		sum = 0;
		maxNum = -1*(LL)LLINF;
		scanf("%d",&n);
		scanf("%d",&k);
		if((n==0)||(k==0))break;
		for(int i=0;i<n;i++){
			scanf("%d",array+i);
		}
		for(int i=0;i<k;i++){
			sum += array[i];
		}
		maxNum = max(maxNum,sum);
		for(int i=0;i<n-k;i++){
			maxNum = max(maxNum,sum = (sum-array[i]+array[i+k]));
		}
		printf("%lld\n",maxNum);
	}

	return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }

  vector<int> s(n);
  s.at(0) = 0;
  for(int i=1;i<n;i++){
    s.at(i) = s.at(i-1)+a.at(i-1);
  }

  int ans=0;
  for(int i=0;i<n-k;i++){
    ans = max(s.at(i+k)-s.at(i),ans);
  }

  cout << ans << endl;
}

C++: #include <iostream>
#include <algorithm>
#define int long long
using namespace std;

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

signed main() {
	while (cin >> n >> k) {
		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>
#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];
        }
        cout<<sum<<endl;
        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>
#include <algorithm>
#include <string.h>

using namespace std;

int a[100000 + 1];
int s[100000 + 1];

int main() {

	int n, k;
	int i, j, l;
	int sum = 0, asus = 0;

	while (true) {

		memset(s, 0, sizeof(s));
		memset(a, 0, sizeof(a));

		cin >> n >> k;
		if (n == 0 && k == 0) return 0;

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

		for (i = 0; i < n-k; ++i) {
			for (j = 0; j < k; ++j) {

				sum += a[i + j];
			}
			asus = max(asus, sum);
			sum = 0;
		}

		cout << asus << endl;
	}
}

C++: #include <cstdio>

int n,k,ans,tmp;
int a[100000];

int main(){
	while(scanf("%d%d", &n, &k)){
		if(n == 0 && k == 0) break;
		ans = 0;
		for(int i = 0; i < n; i++) scanf("%d", &a[i]);
		for(int i = 0; i < k; i++) ans += a[i];
		tmp = ans;
		for(int i = 0; i < n-k; i++){
			tmp += a[k+i]-a[i];
			if(ans < tmp) ans = tmp;
		}
		printf("%d\n", ans);
	}
}

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

int main() {
	int n, k, a[100000], i, S[100000], m=0;
	cin >> n >> k;
	for (i = 0; i<n; i++) {
		cin >> a[i];
	}
	S[0] = 0;
	for (i = 0; i < k; i++) {
		S[0] += a[i];
	}
	for (i = 1; i<n - k + 1; i++) {
		S[i] = S[i - 1] - a[i - 1] + a[i + k-1];
		m = max(m, S[i]);
		cout << S[i] << endl;
	}
	cout << m << endl;
}