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 <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;

int a[100000] = {};

signed main() {
	int k;
	int n;
	
	cin >> n >> k;
	while (n != 0 && k != 0) {
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}

		int m = -9999999999;
		int tmp = 0;
		int cnt = 0;

		for (int i = 0; i < n; i++) {
			if (i < k) {
				tmp += a[i];
			}
			else {
				tmp -= a[i - k];
				tmp += a[i];
				m = max(m, tmp);
			}
		}

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

C++: #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)

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

    vector<int> s(n + 1, 0);
    rep(i, n){
      cin >> x;
      s[i + 1] = s[i] + x;
    }
    int ma = 0;
    for (int i = 0; i + k < n + 1; i++)ma = max(ma, s[i + k] - s[i]);
    cout << ma << endl;

  }

  return 0;
}

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

using namespace std;

int main(void) {
	while(1) {
		int n, k, best = 0, sum = 0;
		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];
		}
		for(int i = 0; i < k; i++) {
			sum += inputs[i];
		}
		for(int i = 0; k < (int)inputs.size(); i++, k++) {
			sum += inputs[k] - inputs[i];
			if(best < sum) {
				best = sum;
			}
		}
		
		cout << best << endl;
		
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
using namespace std;

int main(void){
    int n,m,nsum,sum;
    while(1) {
        nsum = 0;
        sum = 0;
        cin >> n >> m;
        if(n == 0) break;
        vector<int> num(n,0);
        rep(i,n) {
            cin >> num[i];
        }
        rep(i,m) {
            nsum += num[i];
        }
        rep(i,n-m-1) {
            nsum = nsum - num[i] + num[i+m];
            if(nsum > sum) sum = nsum;
        }
        cout << sum << endl;
    }
}

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

int num[100100];

int main(){
    int n,m;
    int sum=0;
    int ans=0;
    while(1){
        cin>>n>>m;
    if(n==0&&m==0)break;
        for(int i=0;i<100100;i++){
            num[i]=0;
            if(num[i+1]==0)break;
        }
        for(int i=0;i<n;i++){
            cin>>num[i];
            if(i<m)sum+=num[i];
        }
        for(int i=1;i<=n;i++){
            sum=sum-num[i-1]+num[i];
            if(ans<sum)ans=sum;
        }
        cout<<ans<<endl;
        }
    return 0;
}

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

int main(){
	int n,k,max=0,*a,buf;
	
	cin >> n >> k;
	
	a = new int[n];
	
	for(int i = 0; i < n; i++){
		cin >> a[n];
		//cout << a[n] << " Inputed\n";
	}
	
	for(int i = 0; i <= n-k; i++){
		buf = 0;
		
		for(int j = 0; j < k; j++){
			buf += a[i+j];
		//	cout << buf-a[i+j] << "+" << a[i+j] << "=" << buf << " acd:" << i+j << endl;
		}
		
		if(max < buf){
			max = buf;
		}
	}
	
	cout << max << endl;
	
	return 0;
}

C++: #include <cstdio>

using namespace std;

int max1(int a, int b) { return a > b ? a : b; }

int main()
{
	int n, k; scanf("%d %d", &n, &k);

	int N[100001];

	for (int i = 1; i <= n; ++i) scanf("%d", &N[i]);

	int sum = 0;

	for (int i = 1; i <= k; ++i) sum += N[i];

	for (int i = k; i < n; ++i) sum = max1(sum, sum - N[i-k+1] + N[i+1]);

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

C++: #include<stdio.h>
int n[100001];
int main(){
	int a,b;
	while(1){
		scanf("%d%d",&a,&b);
		if(a==0&&b==0)return 0;
		int temp=0;
		for(int i=1;i<a+1;i++){
			int val;
			scanf("%d",&val);
			n[i]=(temp+=val);
			printf("%d\n",n[i]);
		}
		int max=-1000000000;
		for(int i=0;i<a-b+2;i++){
			if(max<n[i+b]-n[i])max=n[i+b]-n[i];
			printf("%d\n",n[i+b]-n[i]);
		}
		printf("%d\n",max);
	}
}

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

int data[100500];

int main(void)
{
	int n, k;
	while (1){
		cin >> n >> k;
		if(n==0&&k==0)break;
		for (int i = 1; i <= n; i++){
			cin >> data[i];
			data[i] += data[i-1];
		}
		
		int res = 0;
		for (int i = k; i <= n; i++){
			res = max(res, data[i] - data[i-k]);
	//		cout <<"*"<< i << " " << i-k << endl;
		}
	//	for (int i = 0; i <= n; i++){
	//		cout << data[i] << " ";
	//	}
	//	puts("");
		cout << res << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 1000000009;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(), (c).end()

struct edge{ int t, d; };

int main()
{
	int n, k;
	while (cin >> n && n)
	{
		cin >> k;
		vector<LL> sums(n);
		rep(i, n)
		{
			cin >> sums[i];
			if (i != 0)
				sums[i] += sums[i - 1];
		}
		LL ans = sums[k - 1];
		for (int i = 0; i + k < n; i++)
		{
			ans = max(ans, sums[i + k - 1] - sums[i - 1]);
		}
		cout << ans << endl;
	}
	return 0;
}