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 <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>

using namespace std;

int main(int argc, char const* argv[])
{
    int n,k;
    while (cin >> n >> k) 
    {
        if (n == 0 && k==0) 
        {
            break;
        }
        vector<int> vec(n);
        vector<int> sum(n -k +1);
        int input;
        for (int i = 0; i < n; i++) 
        {
            cin >> vec[i];//input;
            //vec.push_back(input);
        }
        for (int i = 0; i < n - k + 1; i++) 
        {
            sum[i]=0;
            for (int j = 0; j < k; j++) 
            {
                sum[i] += vec[i + j];
                //cout << " " << vec[i+j] << endl;
            }
            //cout << "sum="<< sum[i] << endl;
        }
        //for (int i = 0; i < n-k+1; i++) 
        //{
        //    cout << vec[i]<<endl;
        //}
        sort(sum.begin(), sum.end() , greater<int>() );
        //for (int i = 0; i < n-k+1; i++) 
        //{
        //    cout << vec[i]<<endl;
        //}
        cout << sum[0];
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int k,n;
	int a[100000];
	while (cin>>n>>k,n!=0&&k!=0) {
		long long sum=0,max;
		for (int i=0; i<n; i++) cin>>a[i];
		for (int i=0; i<k; i++) sum+=a[i];
		max=sum;
		for (int i=k; i<n; i++) {
			sum=sum+a[i]-a[i-k];
			if (sum>max) max=sum;
		}
		cout<<max<<endl;
	}
}

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

int main(){
    int n,k;
    while(cin>>n>>k){
        int total[100010]={0},ip[100010]={0};
        if(n==0 && k==0)break;
        for(int i=0;i<n;i++){
            cin>>ip[i];
            if(i==2)total[i]=ip[i-2]+ip[i-1]+ip[i];
            if(i>2){
                total[i]=total[i-1]-ip[i-3]+ip[i];
            }
        }
        sort(total, total+n, greater<int>());
        cout<<total[0]<<endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

	int n, k;
	int a[100000];

	while(cin >> n >> k) {
		if(n==0&&k==0) {
			break;
		}
		for(int i=0; i<n; i++) {
			cin >> a[i];
		}
		int max=a[0];
		int t=0;
		for(int i=0; i<k; i++) {
			t+=a[i];
		}
		if(t>max) {
			max=t;
		}
		for(int i=k; i<n; i++) {
			t+=a[i];
			t-=a[i-k];
			if(t>max) {
				max=t;
			}
		}
		cout << max << endl;
	}

	return 0;

}

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

int main(){
  int n,k,a[MAX];

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

    int MX = 0 , sum;
    for(int i = k-1 ; i < n ; i++){
      sum = 0;
      for(int j = i-k+1 ; j <= i ; j++){
	sum += a[j];
      }
      if(MX < sum) MX = sum;
    }
    cout << MX << 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>
using namespace std;

int seq[100000];
int n,k;

int req(int rem, int i)
{
	rem -= seq[i];
	rem += seq[i+k];
	return rem;
}
int main()
{
	while(cin >> n >> k){
		if(n==0&&k==0)
			break;
		for(int i=0;i<n;i++){
			cin >> seq[i];
		}
		int rem=0;
		for(int i=0;i<k;i++){
			rem+=seq[i];
		}
		int remm = rem;
		cout << rem << endl;
		for(int i=0;i<n-k;i++){
			rem = req(rem,i);
			remm = max(remm,rem);
		}
		cout << rem << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
typedef long long ll;

vector<string> v;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    while (cin >> n >> k, n || k)
    {
        ll arr[n + 1];
        for (int i = 0; i < n; ++i)
            cin >> arr[i];

        for (int i = 0; i < n; ++i)
        {
            arr[i + 1] += arr[i];
        }

        ll maxV = 0;
        for (int i = 0; i < n - k; ++i)
        {
            maxV = max(maxV, arr[i + k] - arr[i]);
        }
        cout << maxV << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    while(n!=0||k!=0){
       vector<int> a(n);
        cin >> a;
        S[0]=0;
        for(int i=1;i<n;i++){
            S[i]=S[i-1]+a.at(i-1);
        }
        int x=S[k];
        for(int l=1;l<n-k;l++){
            if(x<S[k+l]-S[l]){
                x=S[k+l]-S[l];
            }
        }
        cout << x << endl;
        cin >> n >> k;
        

    }

}

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

int main(){
    int n;
    int k;

    while(cin >> n >> k, n != 0 || k != 0){
        vector<int> data;
        int sum = 0;
        for(int i=1; i<=n; i++){
            int tmp;
            cin >> tmp;
            data.push_back(tmp);
        }
        for(int i=0; i<k; i++){
            sum += data[i];
        }
        int max = sum;
        for(int i=3; i<data.size(); i++){
            sum -= data[i-3];
            sum += data[i];
            if(sum > max) max = sum;
        }
        cout << max << endl;
    }
    return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

int main(){
    int n, k;

    while(cin >> n >> k, n+k){
        int ans = -50000;
        int sum = 0;
        vi series;
        for(int i=0; i < n; i++){
            int m;
            cin >> m;
            series.push_back(m);

            if(i < k-1) sum += m;
            else {
                sum += m-series[i-k];
                ans = max(ans, sum);
            }
        }
        cout << ans << endl;
    }
}

C++: #include<iostream>

using namespace std;

int main(){


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

return 0;
}

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

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