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 <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = 1e18+7;

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

/* template */

template<class SemiGroup> struct DisjointStarseTable{
    using F= std::function<SemiGroup(SemiGroup,SemiGroup)>;
    F fn;
    std::vector<std::vector<SemiGroup>> data;
    std::vector<int> height;

    DisjointStarseTable(const std::vector<SemiGroup> &init_vec,F fn) : fn(fn) {
        int n = (int)init_vec.size(), h = 1;
        while((1<<h)<n) h++;
        data.assign(h,std::vector<SemiGroup>(n));
        height.assign((1<<h),0);
        for(int i = 2; i< (1<<h); i++) height[i] = height[i>>1]+1;
        for(int i = 0; i< n; i++) data[0][i] = init_vec[i];
        for(int i = 1; i< h; i++){
            int s = (1<<i);
            for(int j = 0; j<n; j += (s<<1)){
                int t = min(j+s,n);
                data[i][t-1] = init_vec[t-1];
                for(int k = t-2; k >= j; k--){
                    data[i][k] = fn(init_vec[k],data[i][k+1]);
                }
                if(n <= t) break;
                data[i][t] = init_vec[t];
                for(int k = t+1; k< min(t+s,n); k++) data[i][k] = fn(data[i][k-1],init_vec[k]);
            }
        }
    }

    SemiGroup query(int l,int r){
        assert(l<r);
        if(l >= --r) return data[0][l];
        return fn(data[height[l^r]][l],data[height[l^r]][r]);
    }
};

int solve(){
    int n,k; cin >> n >> k;
    if(n==0 && k==0) return 0;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    DisjointStarseTable<ll> c(a,[](ll a,ll b){ return a+b;});
    ll ans = -LNF;
    rep(i,0,n-k+1){
        chmax(ans,c.query(i,i+k));
    }
    cout << ans << endl;
    return 1;
    
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int flag = 1;
    while(flag){
        flag = solve();
    }
}

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

int main() {
	while(1){
		int n, k, num[100000];
		cin >> n >> k;
		if(n == 0 && k == 0)break;
		for(int i = 0; i < n; i++)
			cin >> num[i];
	
		int ans = 0;
		for(int i = 0; i < n; i++){
			if(i + k > n)break;
			int row = 0;
			for(int j = 0; j < k; j++){
				row += num[i + j];
			}
			if(ans < row)
				ans = row;
		}
		
		cout << ans << endl;
	}
	return 0;
}

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

/* {{{ */
#define CL(N) cout << N << endl
#define DCT(N) cout << "debug " << N << endl
#define REP(i, N) for (int i = 0; i < N; i++)
/* }}} */

int main()
{
	int n, l;

    while (cin >> n >> l, n || l){
        int a[100000];
        REP(i, n){
            cin >> a[i];
        }

        int sum = 0;
        REP(i, n - (n - l)){
            int si = 0;
            for (int j = 0; j < l; j++){
                si += a[i + j];
            }

            sum = max(sum, si);
        }

        CL(sum);
    }

	return (0);
}

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

int main() {
    int n,k,i,ans=0;
    cin >> n >> k;
    while(n!=0 || k!=0){
        int a,sum[1000000],S;
        sum[0]=0;
    
        for(i=0;i<n;++i){
            cin >> a;
            sum[i+1] = sum[i] + a;
        }
    
        for(i=0;i<n-k;++i){
            S=sum[i+k]-sum[i];
            ans = max(ans,S[i]);
        }
    
        cout << ans << endl;
        cin >> n >> k;
    }
}

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

int main() {
    using namespace std;
    
    int n, k;
    cin >> n >> k;
    int arr[n]; cin >> arr[0]; for(int i=1; i<n; i++) { cin >> arr[i]; arr[i] += arr[i-1]; }
    
    int res = INT_MIN/4;

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

C++: #include<iostream>
using namespace std;
int num[100100];
int main(){
int n,m;
int ans=0;
while(1){
         for(int i=0;i<100100;i++)num[i]=0;
         cin>>n>>m;
         if(n==0&&m==0)break;
         for(int i=0;i<n;i++) cin>>num[i];
         for(int i=0;i<n-m;i++){
              int min=0;
              for(int j=i;j<i+m;j++)min+=num[j];
              if(ans<min)ans=min;
         }
         cout<<ans<<endl;
         ans=0;
    }
    return 0;
}

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[10000];

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

	return 0;
}