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 <vector>

using namespace std;

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

int main()
{
    int n,k;
    int temp;
    int ans;
    vector<int> 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];
        }

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

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

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

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef vector<int> vi;

int main(){
    int n, k;
    while(cin >> n >> k, n || k){
	vi nums(n);
	int sum = 0;
	rep(i,k){
	    cin >> nums[i];
	    sum += nums[i];
	}
	int ans = sum;
	repi(i,k,n){
	    cin >> nums[i];
	    sum -= nums[i-k];
	    sum += nums[i];
	    if(sum > ans){
		ans = sum;
	    }
	}
	cout << ans << endl;
    }
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int n, k;
	while (cin >> n >> k, n || k) {
		vector<int>v(n + 1, 0);
		rep(i, 1, n + 1)cin >> v[i];
		rep(i, 1, n + 1)v[i] += v[i - 1];
		int ans(-INF);
		for (int i = k; i < v.size(); i++) {
			ans = max(ans, v[i] - v[i - k]);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    while(n!=0||k!=0){
       vector<int> a(n);
        cin >> a;
        S[0]=0;
        for(int i=1;i==n;i++){
            S[i]=S[i-1]+a.at(i-1);
        }
        int x=S[k];
        for(int l=1;l==n-k;l++){
            if(x<S[k+l]-S[l]){
                x==S[k+l]-S[l];
            }
        }
            cout << x << endl;
            cin >> n >> k;
        }

    }

}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int inp[1000000];
	
int main() {
	int n,m;
	n=in(),m=in();
		int i;
		for(i=0;i<n;i++){
			cin>>inp[i];
		}
		Int max=-2000000000;
		for(i=0;i<=n-m;i++){
			Int sum=0;
			int k;
			for(k=0;k<m;k++){
				sum+=inp[i+k];
				//cout<<sum<<endl;
			}
			if(max<sum)max=sum;
		}
		cout<<max;
	return 0;
}

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

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

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

int main() {
  while(1) {
    int n, k, max=-100000000, a[1000000],sum=0,z=0;
    cin >> n >> k;
    if(n==0 && k==0) break;

    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) {
      if(z<k-1) {
	sum+=a[i];
	z++;
      } else {
	sum-=a[i-k];
	sum+=a[i];
	if(max<sum) max=sum;
      }
    }
    cout << max << endl;
  }
  return 0;
}

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

int main()
{
	int n,k;

	int suu[100000 + 100] = { 0 };
	int a;
	int i;
	int mx;

	cin >> n >> k;

	while (n != 0 && k != 0)
	{
		for (i = 1; i <= n; i++)
		{

			cin >> a;

			suu[i] = a + suu[i - 1];

		}

		for (i = k; i <= n; i++)
		{
			if (mx < suu[i] - suu[i - k])
			{
				mx = suu[i] - suu[i - k];
			}

		}

		cout << mx << endl;


		cin >> n >> k;
		mx = 0;
	}
	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<100001;i++){
              num[i]=0;
              if(num[i+1]==0)break;
         }*/
         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 <stdio.h>
#include <stdlib.h>
#define MAX_n 100000
int main()
{
	int n,k,a[MAX_n],i,put=0,total=0;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i+k<=n;i++)
	{
		for(int j=i;j<i+k;j++)
		{
			total+=a[j];
		}
		if(put<total)
			put=total;
		total=0;
	}
	printf("%d\n",put);
	//Sleep(10000);
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  LL N, K;
  while(cin >> N >> K,N){
  VL xs(N);
  REP(i,N) cin >> xs[i];

  LL acc = 0;
  REP(i,K) acc += xs[i];
  LL ans = acc;
  for(int i=K;i<N;++i){
	acc += xs[i] - xs[i-K];
	maxi(ans, acc);
  }
  cout << ans << endl;
  }
  return 0;
}