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 <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x) {ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);


int main(){
	int n,k;
	while(cin>>n>>k,n|k){
		vi a(n);
		REP(i,n){
			cin>>a[i];
		}

		int sum=0;
		REP(i,k){
			sum+=a[i];
		}

		int ans=sum;
		FOR(i,k,n){
			sum+=a[i];
			sum-=a[i-k];
			ans=max(ans,sum);
		}

		cout<<ans<<endl;
	}
}

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

int main()
{
    int n,m,result;
    int num[100005];
    int memo[100000];
    while(cin >> n >> m, n+m)
    {
        for(int i = 0; i < n; i++)cin >> num[i];
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                memo[i] = num[m-j];
            }
        }
        for(int i = 0; i < n; i++)
        {
            result = max(result,memo[i]);
        }
        cout << result << endl;
    }
    return 0;
}

C++: #include<string>
#include<vector>
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)


int main(){


	while(true){
		int n,k,s;
		cin >> n >> k;
		if(n==0 && k==0) break;

	    vector<int>a;
        int sum=0; int m;
		rep(i,k){
		cin >> s;
		a.push_back(s);
		sum+=a[i];
		}

		m=sum;

		REP(i,k,n-1){
		cin >> s;
		a.push_back(s);
		sum+=a[i]-a[i-k];
		if(m<=sum) m=sum;

		}

		cout << m << endl;

		a.clear();

	}

	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	long long n,k;
	while(1){
		cin>>n>>k;
		if(!n && !k)break;
		vector<long long> sum;
		long long num[n];
		rep(i,n)cin>>num[i];
		rep(i,n-k+1){
			long long alt=0;
			loop(j,i,i+k){
				alt+=num[j];
			}
			sum.push_back(alt);
		}
		sort(sum.begin(),sum.end());
		cout<<sum[sum.size()-1]<<endl;
	}
	return 0;
}

C++: #include<stdio.h>
int n[100000];
int main(){
	int a,b;
	while(1){
		scanf("%d%d",&a,&b);
		if(a==0&&b==0)return 0;
		int temp=0;
		for(int i=0;i<a;i++){
			int val;
			scanf("%d",&val);
			n[i]=(temp+=val);
		}
		int max=-1000000000;
		for(int i=0;i<a-b+1;i++){
			if(max<n[i+b]-n[i])max=n[i+b]-n[i];
		}
		printf("%d\n",max);
	}
}

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

using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))

int main()
{
    int n,k;
    long long temp;
    long long ans;

    vector<long long> num;

    cin >> n >> k;
    while(n!=0 && k!=0) {
        for(int i=0; i<n; ++i) {
            cin >> temp;
            num.push_back(temp);
        }

        ans=0;

        for(int i=0; i<k; ++i) {
            ans+=num[i];
        }

        temp=ans;

        if(k!=n) {
            for(int i=k; i<n; ++i) {
                temp=temp+num[i]-num[i-k];
                ans=MAX(ans,temp);
            }
        }

        cout << ans << endl;
        num.clear();
        cin >> n >> k;
    }
    return 0;
}

C++: #include <algorithm>
#include <cstdio>
typedef long long ll;
ll dp[100000];
int v[100000];
int main()
{
    int n, k;
    while (scanf("%d%d", &n, &k), n|k) {
        for (int i=0; i<n; ++i) scanf("%d", v+i);
        dp[k-1] = 0;
        for (int i=0; i<k; ++i) dp[k-1] += v[i];
        for (int i=k; i<n; ++i) dp[i] = dp[i-1] - v[i-k] + v[i];
        printf("%lld\n", *std::max_element(dp+k-1, dp+n));
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n , k ,ans;
	double a[100001] = {}, b[100001] = {};
	cin >> n >> k;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
	}
	for (int i = 1; i <= n-k+1; i ++){
		b[i] = a[i] + a[i + 1] + a[i + 2];
		if (b[i]>b[i - 1]){
				ans = b[i];
		}
	}
	cout << ans << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef pair<int, int> P_i;
typedef pair<double,double> P_d;
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;int ans=0;
#define answer cout << ans << endl;
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; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed main(){
  int N,k;
  while(cin >> N >> k && (N!=0 || k!=0)){
    int sum[N+1]={};
    int ans=-1*INF;
    for(int i=1;i<=N;i++){
      int a;
      cin >> a;
      sum[i]=sum[i-1]+a;
    }
    rep(i,N-k){
      int res=sum[i+k]-sum[i];
      chmax(ans,res);
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

vector<int> s;
int n, k;

int get_sum(int left, int right)
{
	return s.at(right) - s.at(left);
}

void get_ans(void)
{
	vector<int> a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	s = vector<int>(n + 1, 0);
	for (int i = 0; i < n; i++)s.at(i + 1) = s.at(i) + a.at(i);
	int ans = get_sum(0, k);
	int tmp;
	for (int i = 1; i < n; i++)
	{
		if (k + i == n)break;
		tmp = get_sum(i, k + i);
		if (tmp > ans)ans = tmp;
	}
	cout << ans << endl;
}

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

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

int main(){
	int n,k;
	int num[100005];
	while(cin >> n >> k && n && k){
		for(int i=0;i<n;i++) cin >> num[i];
		int ans = 0;
		for(int i=0;i<n-k+1;i++){
			int sum = 0;
			for(int j=0;j<k;j++){
				sum += num[i+j];
			}
			ans = max(ans,sum);
		}
		cout << ans << endl;
	}
}