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 <stdio.h>
#include <stdlib.h>
#define MAX_n 100000
int main()
{
	int n,k,a[MAX_n],i,put=0,total=0;
	while(scanf("%d%d",&n,&k),n+k!=0)
	{
		for(i=0;i<n;i++)
			scanf("%d",&a[i]);
		for(i=0;i+k<=n;i++)
		{
			for(int j=i;j<i+k;j++)
				total+=a[j];
			if(put<total)
				put=total;
			total=0;
		}
		printf("%d\n",put);
		put=0;
	}
	//Sleep(10000);
}

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

constexpr int MAX_N= 100000;

int n,k;
int sums[MAX_N];

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

C++: #include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(void){
	int a[100001];
	int n,k,sum,t;
	for(;;){
		scanf("%d%d",&n,&k);
		if(n==0&&k==0)return 0;
		sum=t=0;
		for(int i=0;i<n;i++){
			scanf("%d",a+i);
			if(i>=k)t-=a[i-k];
			t+=a[i];
			//printf("t %d\n",t);
			sum=max(sum,t);
		}
		printf("%d\n",sum);
	}
}

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

int main(){

  int n, k;
  while( cin >> n >> k, n+k ) {
    int max_sum, sum, data[100000];
    
    cin >> data[0] >> data[1] >> data[2];
    max_sum = sum = data[0] + data[1] + data[2];
    
    for(int i=3; i<n; i++) {
      cin >> data[i];
      sum -= data[i-k];
      sum += data[i];
      max_sum = max(max_sum, sum);
    }

    cout << max_sum << endl;
  }
}

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

int main() {
	while (1){
		int n, k;
		cin >> n >> k;

		if (n == 0 && k == 0){ break; }
		else{
			int i, inp;
			int *a;
			a = new int[n];

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

			int sum1 = 0, sum2 = 0, max = 0;

			for (i = 0; i<k; i++){ sum1 += a[i]; }
			max = sum1;

			for (i = k; i<n-k; i++){
				sum2 = sum1 + a[i] - a[i - k];
				if (sum2>max){ max=sum2; }
				sum2 = sum1;
			}

			cout << max << endl;

			delete[] a;
		}
	}
	return 0;
}

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

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> A(n);
  for (ll i = 0; i < n; i++) {
    cin >> A[i];
  }
  int tmp;
  cin >> tmp >> tmp;

  vector<ll> s(n);
  for (ll i = 0; i < n; i++) {
    s[i + 1] = s[i] + A[i];
  }
  ll mx = (1LL << 60) * -1;

  for (ll i = 0; i < n - k; i++) {
    mx = max(mx, s[i + k] - s[i]);
  }
  cout << mx << endl;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
typedef long long ll;
int n,k,a[100002];
ll sum[100002];
const int INF = 1<<28;

void solve() {
  rep(i,n) cin>>a[i];
  sum[0]=0;
  rep(i,n) sum[i+1]=sum[i]+a[i];
  ll ans = -INF;
  //rep(i,n+1) cout<<sum[i]<<endl;
  for(int i=0; i+k<=n; ++i) {
    ans = max(ans, sum[i+k]-sum[i]);
  }
  cout<<ans<<endl;
}
int main() {
  while(cin>>n>>k,n) solve();
  return 0;
}

C++: #include<string>
#include<vector>
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)


int main(){

	int n,k,s;
	vector<int>a;

	while(true){

		cin >> n >> k;
		if(n==0 && k==0) break;

		rep(i,n){
		cin >> s;
		a.push_back(s);
		}

		int m=0; int sum=0;
		REP(j,0,n-k){
		REP(i,j,k+j-1)
			sum+=a[i];

		if(m<=sum) m=sum;
		sum=0;

		}

		cout << m << endl;

		a.clear();

	}

	return 0;
}

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

#define MAX 1000000000
#define MIN -10000000000

#define ll long long

using namespace std;
int main() {

        ll n,k,i,j,temp,last,maxx;
        do {
            cin >> n >> k;
            if(k==0&&n==0)break;
            vector<ll> a(n);
            vector<ll> s(n + 1);
            for (i = 0; i < n; i++) {
                cin >> a[i];
            }
            //cin >> temp >> temp;
            s[0] = 0;
            for (i = 0; i < n; i++) {
                s[i + 1] = s[i] + a[i];
            }
            maxx = a[k - 1] + a[0];
            for (i = 0; i < n - k + 1; i++) {
                //   cout << s[i+k]-s[i] << endl;
                maxx = max(s[i + k] - s[i], maxx);
            }
            cout << maxx << endl;
        }while(k!=0&&n!=0);

//cout << "aaa" << endl;

    return 0;
}

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

int main()
{
	int n, k, i, j, inp, max=0;
	int *a;
	cin >> n >> k;
	a = new int[n];
	
	for (i = 0; i < n; i++){
		cin >> inp;
		a[i] = inp;
	}
	
	int o1, o2;
	cin >> o1 >> o2;

	for (i = 0; i < n - k + 1; i++){
		int sum = 0;

		for (j = 0; j < k; j++){
			sum += a[i + j];
		}

		if (sum > max){ max = sum; }
	}

	cout << max << endl;

	delete[] a; 
	return 0;
}

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

using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

int N,K;
int a[100010];

int main(){
  int i;

  while(1){
    scanf("%d %d",&N,&K);
    if(N == 0 && K == 0) break;

    REP(i,N) scanf("%d",&a[i]);

    int sum = 0, res = 0;
    REP(i,K){ sum += a[i]; res += a[i]; }
    while(i < N){
      sum += a[i];
      sum -= a[i-K];
      res = max(res,sum);
      i++;
    }

    printf("%d\n",res);
  }

  return 0;
}

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

int main(){
  int n,k;
  while( cin >> n >> k,n+k){
    
    int a[n];
    for(int i = 0;i < n;i++){
      cin >> a[i];
    }
    int sum = -500000;
    for(int i = 0;i < n-k+1;i++){
      //cout << i << endl;
      int s = 0;
      for(int j = i;j < i+k;j++){
	s += a[j];
      }
      sum = max(s,sum);
    }
    cout << sum <<  endl;
    
  }
  
}

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

int main() {
  //cout << "aaa" << endl;
  while (true) {
    ll n, k;
    cin >> n >> k;
    if (n == 0 && k == 0) break;
    vector<ll> A(n);
    for (ll i = 0; i < n; i++) {
      cin >> A[i];
    }

    vector<ll> s(n);
    for (ll i = 0; i < n; i++) {
      s[i + 1] = s[i] + A[i];
    }
    ll mx = (1LL << 60) * -1;

    for (ll i = 0; i < n - k; i++) {
      mx = max(mx, s[i + k] - s[i]);
    }
    cout << mx << endl;
  }
}