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<cmath>
using namespace std;
int main(){
	int *num,siz,time,max,nownum;
	while(cin>>time>>siz&&time!=0){
		num=new int[siz];
		for(int i=0;i<siz;++i){
			num[i]=0;
		}
		nownum=0;
		int dommy;
		max=-2000000000;
		for(int i=0;i<time;++i){
			cin>>dommy;
			nownum-=num[i%siz];
			nownum+=dommy;
			num[i%siz]=dommy;
			if(max<nownum&&i+1>=siz){
				max=nownum;
			}
		}
		cout<<max<<endl;
		delete num;
	}
	return 0;
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n,k;
    while(cin>>n>>k,n+k){
    vl dp(n,0);
    rep(i,n){
        ll ujimatu; cin>>ujimatu;
        if(!i)dp[0]=ujimatu;
        else if(i<k)dp[i]=ujimatu+dp[i-1];
        else dp[i]=dp[i-1]+ujimatu-dp[i-k];
    }
    ll ans=-INF*INF;
    rep(i,n)cmax(ans,dp[i]);
    cout<<ans<<endl;
    }
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,ans = 0,sum = 0;
  while(cin >> n >> k && n && k){
    if(cin.eof()) break;
    ans = 0,sum =0;
    vary(ll,v,n,0);
    vary(ll,imos,n+1,0);
    rep(i,n){
      cin >> v[i];
      sum += v[i];
      imos[i] += sum;
    }
    ans = -inf;
    REP(i,k,n){
      ans = max(ans,imos[i]-imos[i-k]);
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<cstdlib>
using namespace std;
#define MAX_N 10000

int n, k, i, j, af[MAX_N], max = 0, f;

int sort(const void *a, const void *b){
  return *(int*)b - *(int*)a;
}

int main(){
  while(1){
    scanf("%d %d", &n, &k);
    if(n == 0 && k == 0) break;
    max = 0;
    for(i = 0; i < n; i++) scanf("%d", &af[i]);
    for(i = 0; i < n - k; i++){
      f = 0;
      for(j = 0; j < k; j++) f += af[i + j];
      if(f > max) max = f;
    }
    printf("%d\n", max);
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 100000005
#define MAX 100004
using namespace std;

ll a[MAX];
int main(){
	int n, k;
	while(cin >> n >> k, n){
		ll ans = 0;
		a[0] = 0;
		for(int i = 1;i <= n;i++)cin >> a[i];
		for(int i = 2;i <= n;i++)a[i] += a[i-1];
		for(int i = k;i <= n;i++){
			ans = max(ans, a[i]-a[i-k]);
		}
		//for(int i = 1;i <= n;i++)cout << a[i] << " ";
		//cout << endl;
		cout << ans << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>

int main(void){
	int n=0, k=0;
	int *a;
	long sum  = 0;
	long msum = 0;

	scanf("%d %d", &n, &k);
	a = (int*)malloc(sizeof(int) * n);
	for(int i=0; i<n; ++i){
		scanf("%d", a+i);
	}

	for(int i=0; i<k; ++i){
		sum += a[i];
	}
	msum = sum;

	for(int i=0; i<n-k; ++i){
		sum = sum - a[i] + a[i+k];
		if(sum > msum){
			msum = sum;
		}
	}

	printf("%d\n", msum);
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n, k;
	int ans;
	while (true){
		int a[100001] = {}, b[100001] = {};
		n = 0; k = 0;
		ans = 0;
		cin >> n >> k;
		if (n == 0 || k == 0)	break;
		for (int i = 1; i <= n; i++){
			cin >> a[i];
		}
		for (int x = 0; x<k; x++){
			b[1] += a[x + 1];
		}
		ans = b[1];
		for (int i = 2; i <= n; i++){
			if ((i+k)==(n+1))	break;
			b[i] = b[i - 1] - a[i - 1] + a[i + k - 1];
			ans = max(b[i], ans);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <stdio.h>
int RB[100005],ans;
int main() {int N,K,i,j=0;scanf("%d %d",&N,&K);for (i=0,K--;i<K;i++) scanf("%d",&RB[i]),j+=RB[i];ans=j;for (i=K;i<N;i++) scanf("%d",&RB[i]),j+=RB[i],(ans=(ans>j)?ans:j),j-=RB[i-K]; printf("%d\n",ans);return 0;}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int n = 0, k = 0;
int a[10000000] = {}, b[10000000] = {};
int ans;
int main(){
	while (true){
		n = 0; k = 0;
		ans = 0;
		cin >> n >> k;
		if (n == 0 || k == 0)	break;
		for (int i = 1; i <= n; i++){
			cin >> a[i];
		}
		for (int x = 0; x<k; x++){
			b[1] += a[x + 1];
		}
		ans = b[1];
		for (int i = 2; i <= n; i++){
			if (i+k==n+1)	break;
			b[i] = b[i - 1] - a[i - 1] + a[i + k - 1];
			ans = max(b[i], ans);
		}
		cout << ans << endl;
	}
	return 0;
}

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

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

using namespace std;

int main() {
	int n, k;
	vector<int> num;
	int tmp;

	while(cin >> n >> k, n) {
		rep(i, 0, n) {
			cin >> tmp;
			num.push_back(tmp);
		}

		int s = 0;
		rep(i, 1, n-k+1) {
			tmp = 0;
			rep(j, 0, k) {
				tmp += num[i+j-1];
			}

			if(s < tmp) s = tmp;
		}
		
		cout << s << endl;
	}

	return 0;
}