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<stdio.h>

using namespace std;


int main(){

while(1){
    int n, k;
    cin>> n>> k;
    if(n==0&&k==0) break;
    int a[n];
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }

    long long sum=0, ans=0;
    for(int i=0; i<k; i++){
        sum+=a[i];
        ans=max(ans, sum);
    }
    for(int i=0; k<n; i++, k++){
        ans=max(ans, sum);
        sum-=a[i];
        sum+=a[k];
    }

    cout<< ans<< endl;
}
    return 0;
}

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

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

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    for(int count = 0;  count < 5; count++){
	    int none(2);
	    int N, k;
	    cin >> N >> k;
	    vector<int> a(N);
	    for(int i = 0; i < N; i++){
		cin >> a.at(i);
	    }
	    int ans = 0;
	    int total = 0;
	    for(int i = 0; i < N; i++){
	    	if(i < k) total += a[i];
		else total = total + a[i] - a[i-k];
		if(ans < total) ans = total;
	    }
	    cout << ans << endl;
	    for(int i = 0; i < 2; i++){
    	    cin >> none.at(i);
	    }
　　}
}

C++: #include <stdlib.h>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	vector<int> results;

	while (true) {
		int n, k;
		cin >> n >> k;
		if (n == 0 && k == 0) break;

		int* a = new int[n];
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}

		int max = 0;
		for (int i = 0; (i + k - 1) <= n; i++) {
			int s = 0;
			for (int j = i; j < (i + k); j++)
				s += a[j];

			if (max < s) max = s;
		}

		results.push_back(max);
	}

	for (int i = 0; i < results.size(); i++)
		cout << results[i] << endl;

	return 0;
}

C++: #include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define INF (1<<29)
using namespace std;
typedef long long ll;
int main(){
      int n,k;
      int a[100000];
      while(cin>>n>>k&&n&&k){
            REP(i,n)cin>>a[i];
            int sum=0;
            REP(i,k)sum+=a[i];
            int ans=sum;
            REP(i,n-k){
                  sum=sum+a[i+k]-a[i];
                  ans=max(ans,sum);
            }
            cout<<ans<<endl;
      }
}

C++: #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int N, K;
int64 a[100000];

int main() {
    while (true) {
        cin >> N >> K;
        if (N == 0 && K == 0) break;
        for (int j = 0; j < N; ++j) {
            cin >> a[j];
        }
        for (int j = 0; j < N-1; ++j) {
            a[j+1] += a[j];
        }

        int64 ans = a[K-1];
        for (int j = K; j < N; ++j) {
            ans = max(ans, a[j] - a[j-K]);
        }
        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,t;

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);
    }

    for(int q =	0;q<n;++q){
      if(q<k){
        ans_t += a_n[q];
        ans = ans_t;
      }
      else{
        m = ans_t	+ a_n[q] - a_n[q-k];
        if(m > ans){
          ans = m;
	}
        ans_t =	m;
      }
    }

    cout<<ans<<endl;
  }

  return 0;
}

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

int main() {
    int n, k;
    while(cin >> n >> k, n) {
        vector<int> a(n);
        for(int i=0; i<n; ++i) {
            cin >> a[i];
        }
        int sum = 0;
        for(int i=0; i<k; ++i) {
            sum += a[i];
        }
        int res = sum;
        for(int i=k; i<n; ++i) {
            sum = sum - a[i-k] + a[i];
            res = max(res, sum);
        }
        cout << res << endl;
    }
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;

using namespace std;

int solve(int n,int k){
    int a[100000];
    ll sum=0,ans=0;
    
    
    
    for(int i=0;i<k;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    
    ans=sum;
    
    for(int i=k;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i]-a[i-k];
        ans=max(ans,sum);
    }
    
    printf("%lld\n",ans);
    
    return 0;
}

int main(){
    int n,k;
    
    while(1){
        scanf("%d%d",&n,&k);
        if(n+k==0)
            break;
        solve(n,k);
    }
    
    return 0;
}

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

int main(){

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

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

unsigned long long int n, k, i, j, a[MAX_N], max = 0, f;

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

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

C++: #include<iostream>
using namespace std;
int a[1000000]
int main(){
	int i,i2,n,k,a[5001],max=-100000000,sum;
	cin>>n>>k;
	while(n!=0){
		for(i=1;i<=n;i++)cin>>a[i];
		for(i=1;i<=n-k+1;i++){
			sum=0;
			for(i2=i;i2<i+k;i2++)sum+=a[i2];
			if(sum>max){
				max=sum;
			}
		}
		cout<<max<<endl;
		cin>>n>>k;
	}
}
/*#include <stdio.h>
 
int a[100000];
 
int main() {
  int i, j, n, m, k, t;
  while (1) {
    scanf("%d%d", &n, &k);
    if (!n && !k) break;
    for (i = 0; i < n; i++) ~scanf("%d",a+i);
    for (i = m = 0; i < n - k; i++) {
      for (j = t = 0; j < k; j++) t += a[i+j];
      if (t > m) m = t;
    }
    printf("%d\n", m);
  }
  return 0;
}*/