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>
using namespace std;
const int SIZE=100001;
int a[SIZE]={00},b[SIZE]={00},c[SIZE]={00};

int main() {
	while(true){
		int n=0,k=0;
		cin >> n >> k;
		if(n==0) break;
		int max;
		for(int i=0;i<n;i++){
			cin >> a[i+1];
		}
		for(int i=0;i<n-1;i++){
			b[i+1]=b[i]+a[i+1];
		}
		for(int i=0;i<n-1;i++){
			c[i+1]=b[i+k]-b[i];
		}
		max=c[0];
		for(int i=0;i<n;i++){
			if(max<c[i]){
				max=c[i];
			}
		}
		cout << max << endl;
	}
	return 0;
}

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


int main(){
    while (1){
	vector<long long> inp;
	long n, k, input;
	cin >> n >> k;
	if (!(n || k)) break;

	for (long long i = 0; i < n; i++){
	    cin >> input;
	    inp.push_back(input);
	}
	
	long long right = inp.size(), left = 0, sum = 0;
	for (long long i = 0; i < inp.size(); i++) sum += inp[i];
	
	while (right - left >= k){
	    if (inp[right] > inp[left]){
		sum -= inp[left];
		left++;
	    }
	    else {
		sum -= inp[right];
		right--;
	    }
	}
	cout << sum << endl;
    }
}

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

int main(void){
  int n, k;
  long long data[100000];
  long long sum[100000];
  while(cin >> n >> k, n | k){
    for(int i=0; i < n; i++){
      cin >> data[i];
    }
    for(int i=1; i < n; i++){
      data[i] += data[i-1];
    }
    long long ans = 0;
    for(int i=k; i < n; i++){
      ans = max(ans, data[i] - data[i-k]);
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main () {
    int n, k, a[100000], i, S[100000],m;
    cin >> n >> k;
    for(i=0;i<n;i++) {
        cin >> a[i];
    }
    for(i=0;i<n-k+1;i++) {
        S[i]=S[i-1] - a[i-1] + a[i+k];
        m = max(m,S[i]);
    }
    cout << m << endl;
}

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

int main(){
    int n;
    int k;

    while(cin >> n >> k, n != 0 || k != 0){
        vector<int> data;
        int sum = 0;
        for(int i=1; i<=n; i++){
            int tmp;
            cin >> tmp;
            data.push_back(tmp);
        }
        for(int i=0; i<k; i++){
            sum += data[i];
        }
        int max = sum;
        for(int i=k; i<data.size(); i++){
            sum -= data[i-k];
            sum += data[i];
            if(sum > max) max = sum;
        }
        cout << max << endl;
    }
    return 0;
}

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

long long int num[100100];

int main(){
    long long int n,m;
    long long int sum=0;
    long long int ans=0;
    while(1){
        cin>>n>>m;
        if(n==0&&m==0)break;
        for(int i=0;i<100100;i++){
            num[i]=0;
            if(num[i+1]==0)break;
        }
        for(int i=0;i<n;i++){
            cin>>num[i];
            if(i<m)sum+=num[i];
        }
        for(int i=1;i<=n;i++){
            sum=sum-num[i-1]+num[i];
            if(ans<sum)ans=sum;
        }
        cout<<ans<<endl;
        ans=0;
        }
    return 0;
}

C++: //Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	int ret=-INF;
	int res=0;
	queue<int>que;
	for(int i=0;i<k;i++)
	{
		int s; scanf("%d",&s);
		res+=s;
		que.push(s);
	}
	ret=max(ret,res);
	for(int i=k;i<=n;i++)
	{
		int s; scanf("%d",&s);
		res+=s;
		res-=(que.front());
		ret=max(ret,res);
		que.pop();
		que.push(s);
	}
	printf("%d\n",ret);
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define INF 10000000

int a[100003];
int main(){
	int n,k;
	while(cin>>n>>k){
		if(n==0&&k==0)break;
		REP(i,n)cin>>a[i];
		LL sum=0,ans=0;
		REP(i,k)sum+=a[i];
		FOR(i,k,n){
			sum=sum-a[i-k]+a[i];
			ans=max(sum,ans);
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int main(){
  int serchn,numn;
  int gh = 0;
  int outp = 0;
  for(int a = 0;;a++){
    cin >> numn >> serchn;
    if(numn == 0 && serchn == 0){
      break;
    }
    outp = 0;
    gh = 0;
    vector<int> num(numn);
    for(int n = 0;n<numn;n++){
      cin >> num[n];
    }
    for(int n = 0;n<serchn;n++){
      outp += num[n];
    }
    gh = outp;
    for(int a = 1,b=serchn;a<numn-serchn;a++,b++){
      gh += num[b];
      gh -= num[a];
      if(gh > outp)outp = gh;
    }
    cout << outp << endl;
  }
  return 0;
}