Go: package main

import "fmt"

func main() {

	for true {
		var n, k int
		fmt.Scan(&n, &k)

		if n == 0 && k == 0 {
			return
		}
		
		a := make([]int, n)
		ans := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
			if i == 0 {
				ans[i] = a[i]
			} else {
				ans[i] = ans[i-1] + a[i]
			}
		}
		max := 0
		for i := k; i < n; i++ {
			t := ans[i] - ans[i-k]
			if max < t {
				max = t
			}
		}
		fmt.Println(max)
	}
}

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