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;
  
// #define int long long
#define pb push_back
#define print(Target) cout << Target << '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

signed main()
{
  ios::sync_with_stdio(false);
  int n, k;
  
  while (cin >> n >> k, n || k){
    vi a(n);
    REP(i, n) cin >> a[i];
    int m = 0;
    REP(i, n - k + 1){
      int sum = 0;
      for (int j = 0; j < k; j++){
        sum += a[i + j];
      }
      m = max(m, sum);
    }
    print(m);
  }
  return (0);
}

C++: #include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;

int main(){
	int a[100000],n,k,s[100000];
	while(1){
	cin >> n >> k ;
		if((n==0)&&(k==0)){
			return 0;
		}
	for(int i=0;i<n;i++){
		cin >> a[i] ;
		s[i]=0;
	}
	
	for(int i=0;i<n-k;i++){
		for(int j=i;j<i+k;j++){
			s[i]+=a[j];
		}
	}
	
	for(int i=1;i<n;i++){
		for(int j=1;j<n-i;j++){
			if(s[j-1]<s[j]){
				k=s[j-1];s[j-1]=s[j];s[j]=k;
			}
		}
	}
	
	cout << s[0] <<"\n";
	}
return 0;
}

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

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

int main()
{
    int n,k;
    for(;;){
        cin >> n >> k;
        if(n==0&&k==0) break;
        int s=0;
        int a[n];
        for(int i=0;i<n;i++)
            cin >> a[i];
        int m=0;
            for(int j=0;j<k;j++)
                m+=a[j];
            s=m;
        for(int q=0;q<n-k;q++){
            m-=a[q];
            m+=a[q+k];
            s=max(s,m);
        }
        cout << s << 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;
    }

    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 <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;

int main(void){
	int n, k, t, m;
	while(true){
		scanf("%d %d", &n, &k);

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

		vector<int> a;

		for(int i = 0;i < n;++i){
			scanf("%d", &t);
			a.push_back(t);
		}

		m = 0;
		for(int i = 0;i < n-k;++i){
			t = 0;
			for(int j = 0;j < k;++j){
				t += a[i+j];
			}
			m = max(m, t);
		}

		printf("%d\n", m);
	}
}

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

int main(){
  int numn,lisn,num;
  vector<int> outp;
  int outn = 1;
  for(int l = 0;;l++){
    cin >> numn >> lisn;
    if(numn == 0 && lisn == 0)break;
    outp.resize(l+1,0);
    vector<int> lists(numn,0);
    for(int n = 0;n<numn;n++){
      cin >> num;
      lists[n] = num;
    }
    for(int k = 0;k<numn-2;k++){
      outn = lists[k] + lists[k + 1] + lists[k + 2];
      if(outp[l] < outn){
        outp[l] = outn;
      }
    }
  }
  for(int q = 0;q<outp.size();q++){
    cout << outp[q] << " ";
  }
}

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, j, inp, max = 0;
			int *a;
			
			a = new int[n];

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

			for (i = 0; i < n - k + 1; i++){
				int sum = 0;

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

				if (sum > max){ max = sum; }
			}

			cout << max << endl;

			delete[] a;
		}
	}

	return 0;
}

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

int main(void){
	int n=0, k=0;
	int *a;
	long sum  = 0;
	long msum = 0;
	while(true){
		sum = 0;
		scanf("%d %d", &n, &k);
		if(n==0){break;}
		a = (int*)malloc(sizeof(int) * n);
		for(int i=0; i<n; ++i){
			scanf("%d", a+i);
		}

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

		for(int i=0; k<n; ++i,++k){
			sum = sum - a[i] + a[k];
			if(sum > msum){
				msum = sum;
			}
		}
		printf("%d\n", msum);
		free(a);
	}
	return 0;
}

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

int main()
{   
    while(true){
    
    int i, n, k;
    cin >> n >> k;
    if((n==0)&(k==0))break;
    int a[n];
    for(i=0; i<n ;i++){
        cin >> a[i];
    }

    int max_val;
    int S;
    //--init--
    S = 0;
    for(i=0; i<k; i++){
        S += a[i];
    }
    max_val = S;
    for(i=0; i<n-k; i++){
        S += a[i+k];
        S -= a[i];
        if(max_val < S){
            max_val = S;
        }
    }
    std::cout << max_val << std::endl;
    }
    return 0;
}

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

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

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

using namespace std;

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