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<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

int n, k;
ll a[111111];

int main()
{
  cin >> n >> k;
  rep(i, n) cin >> a[i];

  rep(i, n - 1) a[i + 1] += a[i];

  ll res = -INF;
  rrep(i, k, n) maxup(res, a[i] - a[i - k]);
  cout << res << endl;

  return 0;
}

C++: #include <iostream>

using namespace std;

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

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

int main(){
	int n, k;
	int a[100000];
	int sum = 0;
	int Max = 0;
	
	while(1){
		cin >> n >> k;
		if(n + k == 0){
			for(int i = 0; i < n; i++){
			cin >> a[i];
			}
		}
	
		for(int i = 0; i < n-k+1; i++){
			sum = 0;
			for(int j = i; j < i+k; j++){
				sum += a[j];
			}
			Max = max(Max, sum);
		}
	
		cout << Max << 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&&(s-=a[i-k-1])&&M<s&&(M=s))std::cin>>a[i];}

C++: #include<iostream>
#include<stdio.h>

using namespace std;

int main(){


    int n,k,ans=0,ans2=0,ans3=0;
    while(1){
    scanf("%d%d",&n,&k);
    if(n==0&&k==0)break;
    int num[n];
    for(int y=0;y<n;y++){
        scanf("%d",&num[y]);
    }
        for(int a=0;a<k;a++){
        ans+=num[a];
        }
        ans3=ans;
    for(int j=0;j<n-k;j++){
        ans2=ans-num[j]+num[j+k];
        if(ans3<ans2){
            ans3=ans2;
        }
    ans=ans2;
    ans2=0;
    }
    printf("%d\n",ans3);
    }

return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

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

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

#define MAX_N 100000

using namespace std;

int n, k;
int a[MAX_N];

int main()
{
	int max_v = 0;
	cin >> n >> k;

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

	for(int i = 0; i + k <= n ; i++)
	{
		int value = 0;

		for(int j = 0; j < k; j++)
		{
			value += a[i + j];
		}

		max_v = max(max_v, value);
	}	

	cout << max_v << endl;

	return 0;
}

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

int main(){

  int n,k,i,j;

  while(1){

  int a[100003]={0};
  int sum[100003]={0};

    scanf("%d %d",&n,&k);

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

    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
    }

    for(i=0;i<k;i++){
      if(i+k<=n){
      for(j=i;j<i+k;j++){
	sum[i]+=a[j];
      }
      }
      }

    sort(sum,sum+k,greater<int>());
  
    printf("%d\n",sum[0]);

  }

  return 0;

}

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

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

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

int solve(const vector<int>& v,int k) {
  int mx = MIN;
  int i = 0;
  auto begin = v.begin();
  while(i++ < v.size() - k) {
    mx = max(mx, accumulate(begin, begin + k, 0));
    begin++;
  }

  return mx;
}

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

    cout << solve(v, k) << 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 <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<iostream>
#include<stdio.h>

using namespace std;


int main(){

while(1){
    int n, k;
    cin>> n>> k;
    if(n==0&&k==0) break;
    int a[n];
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }

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