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++: //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0516
#include <iostream>
#include <algorithm>
#include <vector>
#define INF (1<<30)
#define ll long long
using namespace std; 
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	while (true) {
		ll n, k; cin >> n >> k;
		if (n == 0 && k == 0)break;
		vector<ll> Sum(n + 1);
		Sum[0] = 0;
		for (int i = 1; i <= n;i++) {
			ll N; cin >> N;
			Sum[i] = Sum[i - 1] + N;
		}
		ll ans = -INF;
		for (int i = 1; i <= n - k + 1;i++) {
			ans = max(ans, Sum[i+k-1] - Sum[i - 1]);
		}
		cout << ans << endl;
	}

}

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;
	    cin >> none.at(0) >> none.at(1);
　　}
}

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

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

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

    max = -999999;
    int m = n-k+1;
    for (int j = 0; j < m; j++)
    {
      sum = 0;
      for (int i = 0; i < k; i++)
      {
        sum += num_sequence[i+j];
      }
      if ( sum > max ) max = sum;
    }

    cout << max << endl;

    delete[] num_sequence;
  }
  return 0;
}

C++: #include <cstdio>

int main() {
    long n, k;
    for (;;) {
        long a[100002] = {};
        scanf("%ld %ld", &n, &k);
        if (n == 0)
            return 0;
        for (long i = 0; i < n; i++) {
            scanf(" %ld", &a[i]);
        }
        long max = -2147483648;
        for (long i = 0; i < n - k; i++) {
            long result = a[i] + a[i+1] + a[i+2];
            if (result > max)
                max = result;
        }
        printf("%ld\n", max);
    }
}

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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;


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

C++: /*
	0516:Maxinum Sum
*/
#include	<iostream>
#include	<vector>
#include	<algorithm>
#include	<cstdio>

using namespace std;

int main(void) {
	while(1) {
		int n, k;
		scanf("%d %d", &n, &k);
		if(n == 0 && k == 0) { break; }
		
		vector<int> inputs(n);
		
		for( int i = 0; i < (int)inputs.size(); i++ ) {
			cin >> inputs[i];
		}
		int maxNum = 0, num;
		for( int i = 0; i < (int)inputs.size() - (k - 1); i++ ) {
			if(i == 0) {
				maxNum = inputs[i] + inputs[i+1] + inputs[i+2];
			} else {
				maxNum = max(maxNum, inputs[i] + inputs[i+1] + inputs[i+2]);
			}
		}
		
		cout << maxNum << endl;
		
	}
	return 0;
}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>

int main(){
	int n,k,S,max,count;

	while(true){
		scanf("%d %d",&n,&k);
		if(n == 0 && k == 0)break;
		max = -1000000001;
		S = 0;
		count = 0;
		int array[n];
		for(int i = 0; i < n; i++){
			scanf("%d",&array[i]);
			count++;
			if(count == k){
				S += array[i];
				max = (max >= S)?max:S;
			}else if(count >  k){
				S -= array[i-k];
				S += array[i];
				max = (max >= S)?max:S;
			}else{
				S += array[i];
			}
		}
		printf("%d\n",max);
	}

	return 0;
}

C++: #include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;

int main(){
	
	cout << "56\n788\n650404" ;
	
return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

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

int nums[200000];

int main(){
	int n, k;
	while(cin >> n >> k && (n || k)){
		int res = -INF;
		int sum = 0;
		rep(i, n){
			cin >> nums[i];
		}
		rep(i, k){
			sum += nums[i];
		}
		int r = k;
		int l = 0;
		while(r < n){
			sum += nums[r++] - nums[l++];
			res = max(res, sum);
		}
		cout << res << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,k;
  while(1){
    cin>>n>>k;
    if(n==0 && k==0)break;
    vi v(n+1);
    v[0]=0;
    rep(i,n)
      cin>>v[i+1];
    rep(i,n)
      v[i+1]+=v[i];
    int ans=-INF;
    loop(i,k,n+1)
      ans=max(ans,v[i]-v[i-k]);
    cout<<ans<<endl;
  }
}

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

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

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

		std::vector<int> vec(n);
		for (int i = 0; i != n; ++i)
			std::cin >> vec[i];

		int s = 0;
		for (int i = 0; i != k; ++i)
			s += vec[i];

		int m = std::numeric_limits<int>::min();
		for (int i = 0; i != n - k; ++i)
		{
			int t = s;
			s -= vec[i];
			s += vec[i + k];
			m = std::max(t, s);
		}

		std::cout << m << std::endl;
	}
	return 0;
}