Go: package main

import "fmt"

func main() {

	for true {
		var n, k int
		fmt.Scan(&n, &k)

		if n == 0 && k == 0 {
			return
		}
		
		a := make([]int, n)
		ans := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
			if i == 0 {
				ans[i] = a[i]
			} else {
				ans[i] = ans[i-1] + a[i]
			}
		}
		max := 0
		for i := k; i < n; i++ {
			t := ans[i] - ans[i-k]
			if max < t {
				max = t
			}
		}
		fmt.Println(max)
	}
}

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