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 <cstdio>
#include <utility>
#include <vector>
#include <climits>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int n, k; n = in(), k = in(), k || n;) {
		int r = INT_MIN;
		vector<int> s(n + 1);
		for (int i = 1; i <= n; i++) {
			s[i] = s[i - 1] + in();
			if (i >= k)
				r = max(r, s[i] - s[i - k]);
		}
		outl(r);
	}
}

C++: #include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main(){
	while(1){
	int k,n,s=0,cn=0;
	cin>>k>>n;
	if(k==0 && n==0){
		break;
	}
	int dat[n+10];
	for(int i=0;i<k;i++){
		cin>>dat[i];
	}
	for(int j=0;j<k-n+1;j++){
		cn=0;
		for(int k=0;k<n;k++){
			cn+=dat[j+k];
		}
		s=max(s,cn);
	}
	cout<<s<<endl;
	}
	return 0;
}

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

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

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main()
{
    int n,m,a[100000];
for(;;){
cin >> n >> m;
if(n==0&&m==0)return 0;
for(int i=0;i<n;i++)cin >> a[i];
int ans=0;
int x=0;
for(int i=0;i<m;i++)x+=a[i];
ans=max(ans,x);
for(int i=0;i<n-m;i++){
x+=a[i+m];
x-=a[i];
ans=max(ans,x);
}
printf("%d\n",ans);
}
}

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

//{{{
/********************************************************************/
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) elems.push_back(item);
      item.clear();
    }
    else item += ch;
  }
  if (!item.empty()) elems.push_back(item);
  return elems;
}

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

/****************************************************************/
//}}}

signed main()
{
  int n, m;

  while (cin >> n >> m, n + m){
    int a[n], maxsum = 0;

    rep(i, n) a[i] = in();
    rep(i, m) maxsum += a[i];
    reps(i, m, n) maxsum = max(maxsum, maxsum - a[i - m] + a[i]);
    print(maxsum);
  }

  return (0);
}

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



int main(){
        int n, k;
        vector<double> v;
        cin >> n>>k;

        int num=0;
        for(int i=0; i<n; i++) {  //ベクターに格納
                cin>>num; //入力をnumに代入
                v.push_back(num); //ベクターvにプッシュ
        }


        int max=0;
        int temp=0;
        for(int i=0; (i+k)<=n; i++) {
                for(int j=0; j<k; j++) {
                        temp+=v[i+j]; //tempにvのiからi+k番目までの総和を代入
                }
                //cout<<temp<<endl;
                if(temp>max) max=temp;  //tempが最も大きい数値ならmaxを更新
                temp=0; //tempの初帰化
        }
        cout<<max<<endl;
}

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<iostream>
using namespace std;

int main(){
  int n,k,tmp,max;
  int a[111111];
  while(1){
    cin >> n >> k;
    if(n == 0 && k == 0) break;
    max = 0;
    tmp = 0;
    for(int i=0;i<n;i++){
      cin >> a[i];
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<k;j++){
	if(i+k > n){
	  tmp = 0;
	}
	else tmp += a[i+j];
	if(j == k-1){
	  if(tmp > max){
	    max = tmp;
	    tmp = 0;
	  }
	  else tmp = 0;
	}
      }
    }
    cout << max << endl;
  }
}

C++: #include <stdio.h>

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