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++: #include <bits/stdc++.h>
using namespace std;

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    loop {
        int N = next<int>(), K = next<int>();
        if(!N && !K) break;
        auto A = next<vector<int>>(N);
        int ans, now = 0;
        times(K, i) {
            now += A[i];
        }
        ans = now;
        times(N - K, i) {
            now += A[K + i] - A[i];
            ans = max(ans, now);
        }
        cout << ans ln;
    }

    return 0;
}

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

using namespace std;

int n, k, r, i = 0, a[100000];
pair<pair<int,int>,long long int> b[100000];
long long int sorter[1000000];
long long int result[100];

int main()
{
	for (;; i++)
	{
		r = 0;
		cin >> n >> k;
		if (n == 0)
		{
			break;
		}

		for (int p = 0; p < n; p++)
		{
			cin >> a[p];
			b[p].first.first = p;
			b[p].first.second = p;
			b[p].second = a[p];
		}

		for (int p = 0; p < k-1; p++)//?¶?????????°
		{
			for (int q = 0; q < n + r; q++)
			{
				if (b[q].first.first == b[q + 1].first.first && b[q].first.second == b[q + 1].first.second)
				{
					b[q].first.first = 100001;
					r--;
					q--;
					sort(b, b + n);
					goto qwop;
				}
				else
				{
					if (b[q].first.first == 0)
					{
						b[q].second += a[b[q].first.second + 1];
						b[q].first.second++;
					}
					else if (b[q].first.second == n - 1)
					{
						b[q].second += a[b[q].first.first - 1];
						b[q].first.first--;
					}
					else if (a[b[q].first.second + 1] == a[b[q].first.first - 1])
					{
						b[k] == b[q];
						b[q].second += a[b[q].first.first - 1];
						b[q].first.first--;
						b[k].second += a[b[k].first.second + 1];
						b[k].first.second++;
						r++;
					}
					else if (a[b[q].first.second + 1] > a[b[q].first.first - 1])
					{
						b[q].second += a[b[q].first.second + 1];
						b[q].first.second++;
					}
					else if (a[b[q].first.second + 1] < a[b[q].first.first - 1])
					{
						b[q].second += a[b[q].first.first - 1];
						b[q].first.first--;
					}
				}
				qwop:;
			}
			sort(b, b + n);
		}

		for(int p = 0;p<n;p++)
		{
			sorter[p] = b[p].second;
		}

		sort(sorter,sorter+n+r,greater<int>());

		result[i] = sorter[0];
	}
	for (int p = 0; p < i; p++)
	{
		cout << result[p] << endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
	int n,k;

	while (1) {
		cin >> n >> k;

		if (n == 0 && k == 0 ){
			break;
		} // end if

		vector <int> a (n + 1, 0 );
		int res = 0, s = 0;

		for (int i = 1; i <= n; ++i){
			cin >> a[i];
			if (i < k ){
				s += a[i];
			}else if (i == k ){
				s += a[i];
				res = s;
			}else{ // if (i > k ){
				s -= a[i-k];
				s += a[i];
				res = max (res , s );
			} // end if				
		} // end for

		cout << res << endl;
	} // end loop
		
	return 0;
}

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

int main(){
	int n, k;
	while( scanf("%d %d", &n, &k), n && k ){
		vector<int> data(n);
		for( int i=0; i<n; i++ ){
			scanf("%d", &data[i]);
		}
		int ans = 0;
		int sum = 0;
		for( int i=0; i<k; i++ ) sum += data[i];
		for( int i=k; i<n; i++ ){
			sum += data[i] - data[i-k];
			ans = max(ans, sum);
		}
		printf("%d\n", ans);
	}
}

C++: #include<stdio.h>
int P[100001];

int main(){

int n,k;
int x,x1,x2,x3;
while(1){
scanf("%d %d",&n,&k);
if(n==0&&k==0)break;
int s=0,max=0;

for(int i=0;i<n;i++)
{scanf("%d",&P[i]);}


for(int j=0;j<k;j++)
s+=P[j];
max=s;

for(int i=k;i<n;i++)
	{s+=P[i];s-=P[i-k];

if(s>max)max=s;}

printf("%d\n",max);
}
return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;

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

void solve16(int a, int b) {
    vector<int> v;
    REP(i,a) {
        int j;
        cin >> j;
        v.push_back(j);
    }
    vector<long> vl;
    long s = 0;
    REP(i, b) {
        s += v[i];
    }
    vl.push_back(s);
    REP(i,a-b) {
        s -= v[i];
        s += v[b+i];
        vl.push_back(s);
    }
    sort(vl.begin(), vl.end(), greater<long>());
    cout << vl[0] << endl;
}

int main() {
    int a, b;
    while(cin >> a >> b, a+b) {
        solve16(a, b);
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
		int n, k;
		double a[100001] = {}, b[100001] = {}, ans;
		cin >> n >> k;
		if (n == 0 || k == 0)	return 0;
		for (int i = 1; i <= n; i++){
			cin >> a[i];
		}
		for (int i = 1; i <= n; i++){
			for (int x = 0; x<k; x++){
				if (a[i + k] == 0) break;
				b[i] = a[i + x];
			}
			if (b[i]>b[i - 1]){
				ans = b[i];
			}
		}
		cout << ans << endl;
	return 0;
}

C++: #include <stdio.h>
int array[100000],n,k,max;

void func(int now){
	int i,j,temp=0;
	
	if(now==n-k)return;
	
	for(i=now;i<now+k;i++){
		temp+=array[i];
	}
	if(temp>max)max=temp;
	func(now+1);
}
		
		


int main(void){
	int i;
	
	while(scanf("%d",&n),n){
		max=0;
		
		scanf("%d",&k);
		for(i=0;i<n;i++){
			scanf("%d",&array[i]);
		}
		func(0);
		
		printf("%d\n",max);
		
	}
	return 0;
}