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;

int main(){
  int numn,lisn,num;
  vector<int> outp;
  int outn = 1;
  for(int l = 0;;l++){
    cin >> numn >> lisn;
    if(numn == 0 && lisn == 0){
      break;
    }
    outp.push_back(0);
    vector<int> lists(numn,0);
    for(int n = 0;n<numn;n++){
      cin >> lists[n];
    }
    for(int k = 0;k<numn-lisn+1;k++){
      outn = 0;
      for(int c = 0;c<lisn;c++){
        outn += lists[c+k];
      }
      if(outp[l] < outn){
        outp[l] = outn;
      }
    }
  }
  for(int q = 0;q<outp.size();q++){
    cout << outp[q] << endl;
  }
}

C++: // ruiseki-wa
#include <algorithm>
#include <iostream>
using namespace std;

int sum[100010];
int main(void)
{
    int n, k;
    while(1) {
        cin >> n >> k;
        if(n==0 && k==0) break;

        int a[n];
        for(int i=0; i<n; i++) cin >> a[i];
        for(int i=0; i<n; i++) sum[i+1] = sum[i] + a[i]; // sum[i] := a[0]??????a[i-1]?????§??????(sum[0]=0)

        int ans = sum[k] - sum[0];
        for(int i=0; i<n-k; i++)
            ans = max(ans, sum[i+1+k] - sum[i+1]);
        cout << ans << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int a[100000];
int main(){
	int i,i2,sum,ans,n,k;
	cin>>n>>k;
	while(n!=0){
		ans=0;
		for(i=0;i<n;i++)cin>>a[i];
		for(i=0;i<n-k;i++){
			sum=a[i];
			for(i2=1;i2<k;i2++)sum+=a[i+i2];
			ans=max(ans,sum);
		}
		cout<<ans<<endl;
		cin>>n>>k;
	}
}

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

using namespace std;

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

int main(void){
  int n,k;
  while(cin>>n>>k,n+k){
    vector<int> a(n);

    rep(i,n)cin>>a[i];
    int ret = -100000;
    //cout<<k-1<<" "<<n-k+1<<endl;
    int sum = 0;
    rep(i,k)sum += a[i];
    for(int i = k ; i < n ; i ++){
      //for(int j = i-2; j <= i ; j ++)cout<<a[j]<<" ";cout<<endl;
      sum = sum + a[i] - a[i-3];
      ret = max(ret,sum);
    }
    cout<<ret<<endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
#define debug(x) cout << #x << " = " << x << endl;
#define sq(x) ((x)*(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

int main(){
	int n, k;
	cin >> n >> k;
	queue<int> q;
	int sum = 0;
	int ans = -INT_MAX;
	rep(i, n){
		int a;
		cin >> a;
		sum += a;
		q.push(a);
		if(q.size() >= k){
			ans = max(ans, sum);
			sum -= q.front();
			q.pop();
		}
	}
	cout << ans << endl;
}

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

int main()
{
    int n,m,result;
    int num[100005];
    int memo[100000];
    while(cin >> n >> m, n+m)
    {
        for(int i = 0; i < n; i++)cin >> num[i];
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                memo[i] = num[m-j];
            }
        }
        for(int i = 0; i < n; i++)
        {
            result = max(result,memo[i]);
        }
        cout << result << endl;
    }
    return 0;
}

C++: #include<iostream>
#define INF -10000000
using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m){
    if(n==0&&m==0) break;
    int s[n],ans=INF;
    for(int i=0;i<n;i++) cin >> s[i];
    for(int i=m-1;i<n;i++){
      int su = 0;
      for(int j=i-m+1;j<=i;j++) su += s[j];
      if(ans<su) ans = su;
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

int n,k,s,ans,term,ans_t;
vector<int> a_n;
int m;

int main()
{

  while(1){
    m = 0;
    cin>>n>>k;

    if(n == 0 && k == 0){
      break;
    }

    for(int q = 0;q < n;++q){
      cin>>term;
      a_n.push_back(term);
    }

    while(1){
      s = m;
      ans_t = 0;

      while(1){
        if(s == k){
          break;
        }
        ans_t += a_n[s];
        s++;
      }

      if(m == 0){
        ans = ans_t;
      }
      else{
        if(ans_t > ans){
          ans = ans_t;
        }
      }

      k++;
      m++;

      if(k == n+1){
        break;
      }
    }
    cout<<ans<<endl;
  }

  return 0;
}