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>                                                                                
using namespace std;                                                                               
                                                                                                   
int N,K,dat[100000];                                                                               
long long r,t;                                                                                     
                                                                                                   
int main(){                                                                                        
    while(scanf("%d%d",&N,&K),N||K){                                                               
        for(int i=0;i<N;i++){                                                                      
            scanf("%d",dat+i);                                                                     
        }                                                                                          
        t=0;                                                                                       
        for(int i=0;i<K;i++){                                                                      
            t+=dat[i];                                                                             
        }                                                                                          
        r=t;                                                                                       
        for(int i=K;i<N;i++){                                                                      
            t=t-dat[i-K]+dat[i];                                                                   
            r=max(r,t);                                                                            
        }
        printf("%lld",r);
    }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long ll;
using namespace std;
#define INF (1 << 30)
#define INFLL (1LL << 60)
#define rep(i, n) for(int i=0; i<(n); ++i)

namespace Sum
{
	int exec(int N, int K)
	{
		vector<int> sum(N + 1, 0);
		rep(i, N) {
			int s; cin >> s;
			sum[i + 1] = sum[i] + s;
		}
		int mx = 0 - INF;
		rep(i, N - K + 1) mx = max(mx, sum[i + K] - sum[i]);
		return mx;
	}
}

int main()
{
	vector<int> anss;
	for (;;) {
		int N, K; cin >> N >> K;
		if (N == 0 || K == 0) break;
		int rz = Sum::exec(N, K);
		anss.push_back(rz);
	}
	rep(i, anss.size()) {
		cout << anss[i] << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    vector<int> ans(0);x
    while(1){
        cin>>n>>k;
        if(n==0&&k==0){
            break;
        }
        vector<int> vec(n);
        for(int i=0;i<n;i++){
            cin>>vec.at(i);
        }
        vector<int> rsw(n+1);
        rsw.at(0)=0;
        for(int i=1;i<n+1;i++){
            rsw.at(i) = rsw.at(i-1) + vec.at(i-1);
        }
        ans.push_back(0);
        for(int i=k;i<n+1;i++){
            if(ans.at(ans.size()) < rsw.at(i) - rsw.at(i-k)){
                ans.at(ans.size()) = rsw.at(i) - rsw.at(i-k);
            }
        }
        cout << ans.at(ans.size()) << endl;
    }
    
}

C++: #include <iostream>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <algorithm>

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);
        int sum_max=0;
        for (int i = 0; i < n; i++) 
        {
            int sum=0;
            cin >> vec[i];
            if (k  <= i + 1) 
            {
                for (int j = 0; j < k; j++) 
                {
                    sum += vec[i - j];
                }
                sum_max = max(sum ,sum_max);
            }
        }
        cout << sum_max << endl;
    }
    return 0;
}

C++: // ruiseki-wa
#include <algorithm>
#include <cstdio>
using namespace std;

int sum[100010];
int main(void)
{
    int n, k;
    while(1) {
        scanf("%d %d", &n, &k);
        if(n==0 && k==0) break;

        int a[n];
        for(int i=0; i<n; i++) scanf("%d", &a[i]);
        for(int i=0; i<n; i++) sum[i+1] = sum[i] + a[i];

        int ans = sum[k] - sum[0];
        for(int i=0; i<n-k+1; i++)
            ans = max(ans, sum[i+1+k] - sum[i+1]);
        printf("%d\n", ans);
    }

    return 0;
}

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

int main(void){
  int n , k;
  cin>>n>>k;
  vector<int> in(n,0);
  vector<int> dp(n,0);
  for(int i = 0 ; i < in.size() ; i ++) 
    cin>>in[i];
  int res = 0;
  for(int i = 0 ; i < in.size() - k ; i ++){
    for(int j = i ; j < i + k ; j ++){
      dp[i] += in[j]; 
    }
    res = max(res,dp[i]);
  }
  
  cout<<res<<endl;
}

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

int main(){
    int n, k;
    while(cin >>n >>k){
        if(n == 0 && k == 0) break;
        vector<int> vec;
        int max = 0, now = 0;
        for(int i = 0; i < k; i++){
            int tmp;
            cin >>tmp;
            max += tmp;
            now += tmp;
            vec.push_back(tmp);
        }
        for(int i = k; i < n; i++){
            int tmp;
            cin >>tmp;
            now += tmp;
            now -= vec[i - k];
            if(max < now) max = now;
        }
        cout <<max <<endl;
    }
    return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll MIN_A = -10000;
const ll MAX_A = -10000;

ll solve(const ll n, const ll k, const vector<ll> as) {
    ll acc = 0;
    for (int i = 0; i < k; i++) {
        acc += as[i];
    }
    ll cand = MIN_A;

    for (int i = k; i < n; i++) {
        acc -= as[i - k];
        acc += as[i];
        chmax(cand, acc);
    }

    return cand;
}

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

        vector<ll> as(n);
        for (int i = 0; i < n; i++) {
            cin >> as[i];
        }
        cout << solve(n, k, as) << endl;
    }
    
    return 0;
}