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<stdio.h>
#include<iostream>
using namespace std;
int n,a[100001],k,sum,p;
int main(){
int i,j,h;
cin>>n>>k;
for(i=1;i<=n;i++){
a[i]=0;
}
cin>>a[1];
for(i=2;i<=n;i++){
cin>>a[i];
a[i]+=a[i-1];
}
for(i=1;i<=n;i++){
	for(j=i;i<=i+k;j++){
		p=a[i+k]-a[j];
		if(p>=sum){
			sum=p;
		}
	}
}
cout<<sum<<endl;

return 0;
}

C++: #include<iostream>
using namespace std;
int n=0, k=0;
double a[100001] = {}, b[100001] = {}, ans=0;
int main(){
while (cin>>n>>k){
n=0; k=0;
a[100001] = {}; b[100001] = {}; ans=0;
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];
}
ans=b[1];
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];
}
}
cout << ans << endl;
}
return 0;
}

C++: #include<iostream>
#include<string.h>
using namespace std;
int main(){
	int i,i2,n,k,a[5001],max=0,sum;
	cin>>n>>k;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n-k+1;i++){
		sum=0;
		for(i2=i;i2<i+k;i2++)sum+=a[i2];
		if(sum>max){
			max=sum;
		}
	}
	cout<<max<<endl;
}

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

int main(void)
{
  int n, k;
  int max;
  int sum;
  while (true)
  {
    //cin >> n >> k;
    scanf("%d %d", &n, &k);
    if ( n == 0 && k == 0 ) break;

    int* num_sequence = new int[n];
    for (int i = 0; i < n; i++)
    {
      //cin >> num_sequence[i];
      scanf("%d", &num_sequence[i]);
    }

    max = -999999;
    for (int j = 0; j < n-k+1; j++)
    {
      sum = 0;
      for (int i = 0; i < k; i++)
      {
        sum += num_sequence[i+j];
      }
      if ( sum > max ) max = sum;
    }

    //cout << max << endl;
    printf("%d\n", max);

    //delete[] num_sequence;
  }
  return 0;
}

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

using namespace std;

int main(){
  while(true){
    int a[100000] = {0};
    int n, k;
    cin >> n >> k;
    if(!n)
      break;
    for(int i = 0; i < n; i++){
      cin >> a[i];
    }
    int aa = 0;
    for(int i = 0; i < k; i++){
      aa += a[i];
    }
    //cout << "f:" << aa << endl;
    for(int i = k; i < n; i++){
      int aaa = aa - a[i - k] + a[i];
      aa = aaa > aa ? aaa : aa;
      //cout << "f:" << aa << " n:" << aaa << endl;
    }
    cout << aa << endl;
  }
  return 0;
}

C++: #include <cstdio>

using namespace std;

int n,k,s,smax;
int a[100000];
int s1,s2;

int main(){
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int j=0;j<k;j++) smax+=a[j];
	for(int l=0;l<n;l++){
		s2=s1-a[l]+a[n-l];
		if(s1>smax) smax=s1;
		s1=s2;
	}
		printf("%d",smax);
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
    int a[5];
    int t = 0;
    while(1){
        int n,k;
        cin >> n >> k;
        if(n == 0 && k == 0)break;
        vector<int>l(n);
        for(int i = 0;i < n;i++){
            cin >> l[i];
        }
        int s = 0;
        int max = 0;
        for(int i = 0;i < k;i++){
            s += l[i];
        }
        max = s;
        for(int i = k;i < n;i++){
            s += l[i];
            s -= l[i - k];
            if(s > max){
                max = s;
            }
        }
        a[t] = max;
        t++;

    }
    for(int i = 0;i < t;i++){
        cout << a[i] << endl;
    }
    return 0;
}

C++: #include<stdio.h>
int a[100001];
int main(void)
{
	int n,k,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<stdio.h>
#include<iostream>
using namespace std;
int n,a[100001],k,sum,p;
int main(){
int i,j,h;
cin>>n>>k;
for(i=1;i<=n;i++){
a[i]=0;
}
while(1){
cin>>a[1];
for(i=2;i<=n;i++){
cin>>a[i];
a[i]+=a[i-1];
}
for(i=1;i<=n;i++){
	for(j=i;i<=i+k;j++){
		p=a[i+k]-a[j];
		if(p>=sum){
			sum=p;
		}
	}
}
cout<<sum<<endl;
cin>>n>>k;
if(n==0&&k==0)break;
for(i=1;i<=n;i++){
a[i]=0;
}
cin>>a[1];
}
return 0;
}

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

int main() {
  int n, k;
  while(cin >> n >> k, n+k) {
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    long long ans = -10000000000;
    for(int i = 0; i < n-k; i++) {
      long long sum = 0;
      for(int j = 0; j < k; j++) {
	sum += a[i+j];
      }
      if(ans < sum) ans = sum;
    }
    cout << ans << endl;
  }
}

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

C++: #include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;//仮想的な無限大の値

int main() {
   int n,k;
   while(cin >> n >> k){
       if(n==0) break;
       vector<int> a(n);//普通の数字
       for(int i=0;i<n;i++){
           cin >> a[i];
       }
       vector<int> s(n+1,0);//n+1個の配列を全て0で初期化
       for(int j=0;j<n;j++){
           s[j+1] = s[j] + a[j];
       }
       int ans = -INF;
       for(int p=1;p<n-k+1;p++){
           int max1 = s[p+k] - s[p];
           ans = max(max1,ans); 
       }
       cout << ans << endl;
   }
}

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

int main() {
	while (1){
		int n, k;
		cin >> n >> k;

		if (n == 0 && k == 0){ break; }
		else{
			int i, inp;
			int *a;
			a = new int[n];

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

			int sum1 = 0, sum2 = 0, max = 0;

			for (i = 0; i<k; i++){ sum1 += a[i]; }
			max = sum1;

			for (i = k; i<n; i++){
				sum2 = sum1 + a[i] - a[i - k];
				if (sum2>max){ max=sum2; }
				sum2 = sum1;
			}

			cout << max << endl;

			delete[] a;
		}
	}
	return 0;
}

C++: aaaaaaaaa

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

int main(){
	int n, k;
	while( scanf("%d %d", &n, &k), n!=0 && k ){
		vector<int> data(n);
		for( int i=0; i<n; i++ ){
			scanf("%d", &data[i]);
		}
		int ans = 0;
		for( int i=0; i<n-k; i++ ){
			int sum = 0;
			for( int j=0; j<k; j++ ) sum += data[i+j];
			ans = max(ans, sum);
		}
		printf("%d\n", ans);
	}
}

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