Go: package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	parseProblem(os.Stdin)
}

func parseProblem(r io.Reader) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	for true {
		n, k := scanInt(sc), scanInt(sc)
		if n == 0 && k == 0 {
			break
		}
		sum := make([]int, n+2)
		for i := 2; i <= n+1; i++ {
			sum[i] = sum[i-1] + scanInt(sc)
		}
		max := math.MinInt32
		for i := 1; i+k <= n+1; i++ {
			if v := sum[i+k] - sum[i]; max < v {
				max = v
			}
		}
		fmt.Println(max)
	}
	return
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

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 x = 0; x<k; x++){
			b[1] += a[1 + x];
		}
		for (int i = 2; i <= n; i++){
			if (a[i + k - 1] == 0)	break;
			b[i] = b[i - 1] - a[i - 1] + a[i + k - 1];
			if (b[i]>b[i - 1]){
				ans = b[i];
			}
		}
		if (ans == 0){
			cout << b[1] << endl;
		}
		cout << ans << 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);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  int gomi;
  cin >> gomi >> gomi;
  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<bits/stdc++.h>
using namespace std;

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

int main(){
    long long int ans=-1000000000;
    cin >> n >> k;

    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;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
	int n,k;
	while(1){
		cin>>n>>k;
		if(n==0)	return 0;
		int a[n];
		for(int i=0;i<n;i++)	cin>>a[i];
		ll bgs=0;
		for(int i=0;i<=n-k;i++){
			ll temp=0;
			for(int j=0;j<k;j++)	temp+=a[i+j];
			bgs=max(bgs,temp);
		}
		cout<<bgs<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	int n, k;
	int a[100000];
	for(;;){
		cin >> n >> k;
		if(n == 0 && k == 0) break;
		for(int i = 0; i < n; i++) scanf("%d", &a[i]);
		ll ans = 0;
		for(int i = 0; i < k; i++){
			ans += a[i];
		}
		ll sum = ans;
		for(int i = k; i < n; i++){
			sum -= a[i - k];
			sum += a[i];
			if(sum > ans) ans = sum;
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	while(1){
        int n,k;
        int ans[10010] = {0};
        cin >> n >> k;
        if(n + k == 0) break;
        for(int i = 0; i < n; i++){
            cin >> ans[i];
        }
        int mx = 0,sum = 0;
        for(int i = 0; i < k; i++){
            sum += ans[i];
        }
        mx = sum;
        for(int i = k; i < n; i++){
            sum += ans[i];
            sum -= ans[i-k];
            mx = max(mx,sum);
        }
        cout << mx << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
using namespace std;
#define MAX_N 10000

int n, k, i, j, a[MAX_N], max = 0, f;

int sort(const void *a, const void *b){
  return *(int*)b - *(int*)a;
}

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

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

int main() {

  while(1) {
  int n,k;
  cin >> n >> k;
  if(n==0 && k==0) break;

  int a[100001] = {};

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

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

  sum = maxsum;
  for(int i=k;i<n;i++) {
    sum =sum + a[i] - a[i-k];
      if(sum > maxsum) maxsum = sum;
  }

  cout << maxsum <<endl;
  }

  return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
  while (1) {
    int k, n;
    cin >> n >> k;
    if ((k <= n) && (n == 0)) {
      return 0;
    }

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

    int s = 0;
    for (int i = 0; i < k; i++) {
      s += a[i];
    }
    for (int i = 0; i + k < n; i++) {
      int t = s + a[k + i] - a[i];
      if (t >= s) {
        s = t;
      }
    }
    cout << s << 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; s = 0; if (n == 0)break; for (int i = 1; i <= n; i++) { scanf("%lld", &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<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)*a[i++ -k],k<i&&M<s&(M=s))std::cin>>a[i];
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,m;
	int box[100001];
	int sum;
	int MAX;
	int i;
	while(1){
		cin>>n>>m;
		if(n==0&&m==0)	break;
		sum=0;	
		for(i=0;i<n;i++)	cin>>box[i];
		for(i=0;i<m;i++)	sum+=box[i];
		MAX=sum;
		for(i=m-1;i<n-1;i++){
			// cout<<sum<<" "<<box[i+1]<<" "<<box[i-2]<<endl;
			sum=sum+box[i+1]-box[i-(m-1)];
			// cout<<sum<<endl;
			MAX=max(MAX,sum);
		}
		cout<<MAX<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int n, k;
	int n2[5001];
	int cnt = 0, cnt_max = -10001;
	while (1) {
		cin >> n >> k;
		if (n == 0 && k == 0)return 0;
		for (int i = 1; i <= n; i++) {
			cin >> n2[i];
		}
		for (int i = 1; i <= n - k + 1; i++) {
			cnt = n2[i];
			for (int j = 1; j < k; j++) {
				cnt += n2[i + j];
			}
			if (cnt_max < cnt) {
				cnt_max = cnt;
			}
		}
		cout << cnt_max << endl;
		cnt_max = 0;
	}
}

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

constexpr int MAX_N= 100000;

int n,k,sum;
int a[MAX_N];
int ans;

int main(){
    while(1){
    	std::cin>>n>>k;
    	if(n+k==0)
    		break;
    	sum=0;
    	ans=0;
    	for(int i=0;i<n;++i)
    		std::cin>>a[i];

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

    	for(int i=0;i<n-k;++i){
    		ans=std::max(ans,sum-a[i]+a[i+k]);
    	}

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

C++: #include <iostream>
using namespace std;
int main(void){
	for (;;){
		int a,b,c,d,max=0,m;
		cin>>a>>b;
		int e[a]={0};
		if (a==0&&b==0) break;
		for (c=0;c<a;c++){
			cin>>e[c];
		}
		m=a-b;
		for (c=0;c<a-m;c++){
			for (int y=1;y<b;y++) e[c]=e[c]+e[c+y];
			if (max<e[c]) max=e[c];
	}
		cout<<max<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    for(int count = 0;  count < 5; count++){
	    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;
	    cin >> none[0] >> none[1];
　　}
}