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 "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;



const int mod = 100000;
struct Mod {
public:
	int num;
	Mod() : Mod(0) { ; }
	Mod(long long int n) : num((n % mod + mod) % mod) {
		static_assert(mod<INT_MAX / 2, "mod is too big, please make num 'long long int' from 'int'");
	}
	Mod(int n) : Mod(static_cast<long long int>(n)) { ; }
	operator int() { return num; }
};

Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int  b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) { return Mod((mod + a.num - b.num) % mod); }
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) { return Mod(((long long)a.num * b.num) % mod); }
Mod operator*(const long long int a, const Mod b) { return Mod(a)*b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b)*a; }
Mod operator*(const Mod a, const int b) { return Mod(b)*a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod& a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
	if (n == 0) return Mod(1);
	Mod res = (a * a) ^ (n / 2);
	if (n % 2) res = res * a;
	return res;
}
Mod mod_pow(const Mod a, const long long  int n) {
	if (n == 0) return Mod(1);
	Mod res = mod_pow((a * a), (n / 2));
	if (n % 2) res = res * a;
	return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
	assert(b.num != 0);
	return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) {
	return Mod(a) / b;
}
Mod operator/=(Mod &a, const Mod b) {
	return a = a / b;
}

#define MAX_MOD_N 1024000

Mod fact[MAX_MOD_N], factinv[MAX_MOD_N];
void init(const int amax = MAX_MOD_N) {
	fact[0] = Mod(1); factinv[0] = 1;
	for (int i = 0; i < amax - 1; ++i) {
		fact[i + 1] = fact[i] * Mod(i + 1);
		factinv[i + 1] = factinv[i] / Mod(i + 1);
	}
}
Mod comb(const int a, const int b) {
	return fact[a] * factinv[b] * factinv[a - b];
}

int main() {
	while (1) {
		int N, K; cin >> N >> K;
		vector<int>as(N);
		for (int i = 0; i < N; ++i) {
			cin >> as[i];
		}
		long long int sum = 0;
		for (int i = 0; i < K; ++i) {
			sum += as[i];
		}
		long long int ans = sum;
		for (int i = K; i < N; ++i) {
			sum += as[i] - as[i - K];
			ans = max(ans, sum);
		}
		cout << ans << endl;
	}

	return 0;
}

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

int main(){
	int n, k, x, maxnum = 0;
	cin >> n >> k;
	int wa[100000];
	for(int i=0;i<100000;i++) wa[i] = 0;
	for(int i=0;i<n;i++){
		cin >> x;
		for(int j=0;j<k;j++){
			wa[i+j] += x;
		}
	}
	cin >> x >> x;
	for(int i=k-1;i<n;i++){
		if(maxnum < wa[i]) maxnum = wa[i];
	}
	cout << maxnum << endl;
}

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

using namespace std;

int main(){
	deque<int> deq;
	int n,k,max=0,buf;
	
	cin >> n >> k;
	
	deq.push_front(0);
	for(int i = 0; i < k-1; i++){
		cin >> buf;
		deq.push_front(buf);
		n--;
	}
	
	for(; n > 0; n--){
		cin >> buf;
		deq.push_front(buf);
		deq.pop_back();
		
		buf = 0;
		
		for(int i = 0; i < k; i++){
			buf += deq.at(i);
		}
		
		if(max < buf){
			max = buf;
		}
	}
	
	cout << max << endl;
	
	return 0;
	
}

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

using namespace std;
int main(){
  int n,k;
  int max;
  cin >> n >> k;
  while(n != 0 || k != 0){
    vector <int> a(n);
    cin >> a[0];
    for(int i =  1 ; i < k ; i++){
      cin >> a[i];
      a[i] += a[i-1];
    }
    max = a[k-1];

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

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

using namespace std;

int main(){
  while(true){
    int a[100000] = {0};
    int n, k;
    cin >> n >> k;
    if(!n)
      break;
    for(int i = 0; i < n; i++){
      cin >> a[i];
    }
    int ans = 0;

    //cout << "f:" << aa << endl;
    for(int i = 0; i < n - k; i++){
      int aa = 0;
      for(int j = 0; j < k; j++){
	aa += a[j + i];
      }
      ans = aa > ans ? aa : ans;
      //cout << aaa << ":" << aa << " - " << a[i - k] << " + " << a[i] << endl;
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <vector>
#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>

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 EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#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)

const double EPS = 1e-10;

int main() {
	int n, k;
	ll result, tmp;

	cin >> n >> k;

	vi nums(n);
	result = -LONG_MAX;

	REP(i, n) {
		cin >> nums[i];
	}

	REP(i, n-k+1) {
		tmp = 0;

		REP(j, k) {
			tmp += nums[i+j];
		}

		if(result < tmp) {
			result = tmp;
		}
	}

	cout << result << endl;

	return 0;
}

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

int main(){
	int n,k,max=0,*a,buf;
	
	cin >> n >> k;
	
	a = new int[n];
	
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	for(int i = 0; i <= n-k; i++){
		buf = 0;
		
		for(int j = 0; j < k; j++){
			buf += a[i+j];
		}
		
		if(max < buf){
			max = buf;
		}
	}
	
	cout << max << endl;
	
	return 0;
}