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 <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++: // This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;

int main() {
    int n,k;
    cin >> n >> k;
    int max = 0;
    vector<int> a(100005, 0);
    vector<int> s(100005,0);
    while (n != 0 || k != 0) {
        int b;
        s[0] = 0;
        for(int i = 0; i < n; i++) {
            cin >> b;
            s[i+1] = s[i] + b;
        }
        for (int i = 0; i < n-k; i++) {
            if(max < s[i+k] - s[i]) {
                max = s[i+k] - s[i];
            }
        }
        cout << max << endl;
        cin >> n >> k;
    }
}
// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/

C++: #include "bits/stdc++.h"

using namespace std;

const char en = '\n';
using  ll =          long long;
using ull = unsigned long long;

int n,k,ar[100000];
ll result,buf;

int main(){
	ios::sync_with_stdio(false);cin.tie();
	while(true){
		result=0;
		cin>>n>>k;

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

		for(int i=0;i<n;i++) cin>>ar[i];

		for(int i=0;i<k;i++){
			result+=ar[i];
		}
		buf=result;
		for(int i=k;i<n;i++){
			buf+=ar[i];
			buf-=ar[i-k];
			result=max(result,buf);
		}
		cout<<result<<en;
	}
	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(i=s=0;i<n;i++<k&&(M=s+=a[i-1]))std::cin>>a[i];for(i=k;i<n;M<s&&(M=s))s+=a[i]-a[i++-k];}}

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;
		for(int i=0;i<n-k;i++){
			rem = req(rem,i);
			remm = max(remm,rem);
		}
		cout << remm << endl;
	}
	return 0;
}

C++: //07-1 ?????§??????(??¬???)
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main(){
    bool flg = true;
    while(flg){
        int n,k;
        cin >> n >> k;
        if(n==0 && k==0){
            flg = false;
        }
        else{
            int a[100000] = {};
            int max = 0;
            int now = 0;
            for(int i=0; i<n; i++){
                int tmp;
                cin >> tmp;

                a[i] = tmp;

                if(i+1<=k){
                    now += tmp;
                    max += tmp;
                }
                else if(i+1>k){
                    now -= a[i-k];
                    now += tmp;
                    if(now>max) max = now;
                }
            }
            cout << max << endl;
        }
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){

	int n,k,s,data;
	s = 0;
	
	while(cin >> n >> k, n && k){
	vector<int> sum;	

	rep(i,n){
		cin >> data;
		sum.push_back(data);
	}
	
	data = 0;

	rep(i,k){

		data += sum[i];
		
	}

	int res;
	res = data;
	
	rep(i,n - k){
		data -= sum[i];
		data += sum[i+k];
		res = max(res,data);
	}

	cout << res << endl;
	}
	
	return 0;
}

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

int n,k,b[100100]={},sum[100100]={};

int main() {
	while(1){
		cin>>n>>k;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin>>b[i];
		}
		for(int i=0;i<(n-k+1);i++){
			for(int j=0;j<k;j++){
				sum[i]+=b[j+i];
			}
		}
		sort(sum,sum+(n-k+1), greater<int>()); 
		cout<<sum[0]<<endl;
	}
	return 0;
}