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

int main()
{
	while (1)
	{
		int a = 0, b = 0;
		double c = -1000;
		cin >> a;
		cin >> b;
		if (a == 0 && b == 0)
		{
			break;
		}
		vector<double> size;
		for (int i = 0; i < a; i++)
		{
			int w;
			cin >> w;
			size.push_back(w);
		}
		for (int i = 0; i < a - 2; i++)
		{
			double as = 0;
			for (int ii = 0; ii < b; ii++)
			{
				as += size[i + ii];
			}
			size.push_back(as);
		}
		for (int i = 0; i < a - 2; i++)
		{
			if (c < size[i + a])
			{
				c = size[i + a];
			}
		}
		cout << c << endl;
	}	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int num[1000000];
int main()
{
	int n, k, ans = 0, anss = 0;
	while (1)
	{
		scanf("%d%d", &n, &k);
		if (n == 0 && k == 0)
			break;
		num[0] = 0;
		for (int i = 1; i <= n; i++)
		{
			scanf("%d", &num[i]);
			num[i] = num[i] + num[i - 1];
		}
		for (int i = k; i <=n; i++)
		{
			anss = num[i] - num[i - k];
			if (ans < anss)
				ans = anss;
		}
		printf("%d\n", ans);
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  const lint inf=1LL<<60;
  bool is=true;
  lint n,k;cin>>n>>k;
  int count=0;
  vector<int> r;
  while(is){
    if(n==0&&k==0) break;
    lint a[101000],s[101000];
    rep(i,n){
      cin>>a[i];
    }
    s[0]=0;
    rep(i,n){
      s[i+1]=s[i]+a[i];
    }
    lint result=-inf;
    for(int i=0;i<=n-k;i++){
      lint sum=s[k+i]-s[i];
      if(result<sum) result=sum;
    }
    r.pb(result);
    cin>>n>>k;
  }
  for(int i=0;i<r.size();i++){
    cout<<r[i]<<endl;
  }
  
}

C++: #include <cstdio>

using namespace std;

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

int main(){
	scanf("%d %d\n",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int j=0;j<k;j++) s1+=a[j];
	smax=s1;
	for(int l=0;l<n-k;l++){
		s2=s1-a[l]+a[l+k];//最後の処理をどうするか
		if(s2>smax) smax=s2;
		s1=s2;
	}
		printf("%d",smax);
	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<100100;i++)num[i]=0;
         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=num[i]+num[i+1]+num[i+2];
              if(ans<min)ans=min;
         }
         cout<<ans<<endl;
         ans=0;
    }
    return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int n,a[100000001],k,sum,p;
int main(){
int i,j,h;
cin>>n>>k;
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<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int inp[1000000];
	
int main() {
	int n,m;
	while(n=in(),m=in()){
		int i;
		for(i=0;i<n;i++){
			inp[i]=in();
		}
		Int max=-2000000000;
		for(i=0;i<=n-m;i++){
			Int sum=0;
			int k;
			for(k=0;k<m;k++){
				sum+=inp[i+k];
				//cout<<sum<<endl;
			}
			if(max<sum)max=sum;
		}
		cout<<max;
	}
	return 0;
}

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

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

int main(){
    long long int ans=-10000000000000;
    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 ;

return 0;
}

C++: #include<stdio.h>

//更新書き換え型
int MAX(int *num,int n,int k){
	int i,now,max = 0;
	for(i = 0;i < k;i++){
		max += num[i];
	}
	now = max;
	for(i = 0;i < n-k;i++){
		now += num[i+k]-num[i];
		if(max < now)
			max = now;
	}
	return max;
}
int main(){
	int n,k,max;
	int *num;
	int i;
	scanf("%d%d",&n,&k);
	num = new int[n];
	for(i = 0;i < n;i++){
		scanf("%d",num+i);
	}
	max = MAX(num,n,k);
	printf("%d\n",max);
	delete[] num;
	return 0;
}

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

int main(){
int n,k,s,ans;
int a[100001];
while(cin>>n>>k){
if(n==0&&k==0)break;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n-k+1;i++){
s=0;
for(int j=i;j<i+k;j++)s+=a[j];
if(i==0)ans=s;
if(s>ans)ans=s;}
cout<<ans<<endl;}}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
using namespace std;

int main(){

	for(int se = 0; se<5; se++){

		int n,k,B[100001],t = -999999;
		cin >> n >> k;

		if(n == 0 && k == 0)break;

		B[0] = 0;
		for(int i=0; i<n; i++){
			int a;
			cin >> a;
			B[i+1] = B[i] + a;
		}
		for(int i = 1; i+k-1<n; i++){
			t = max(B[i+k-1]-B[i-1],t);
		}
		cout << t << endl;
	}
	return 0;
}

C++: #include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<set>
#include<string>
using namespace std;
int main(){
    int n,k,ma;
    for(;;){
        int num[100001]={0};
        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++){
            int all=0;
            for(int j=0;j<k;j++){
                all+=num[i+j];
            }
        if(i==0)ma=all;
        ma=max(ma,all);
        }
        cout<<ma<<endl;
    }
}