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 <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, k;
    while(cin >> n >> k, n|k){
        vector<ll> v(n+1, 0);
        for (int i = 0; i < n; ++i) {
            scanf("%lld", &v[i+1]);
        }
        partial_sum(v.begin(), v.end(), v.begin());
        ll ans = -INF<ll>;
        for (int i = 0; i < n-k+1; ++i) {
            ans = max(ans, v[i+k]-v[i]);
        }
        cout << ans << "\n";
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#pragma warning(disable:4996)
long long n, k, a[200000], s, ret;
int main() {
	while (true) {
		cin >> n >> k; if (n == 0)break; for (int i = 1; i <= n; i++) { scanf("%lld", &a[i]); if (i <= k)s += a[i]; }
		ret = s; for (int i = k + 1; i <= n; i++) { s -= a[i - k]; s += a[i]; ret = max(ret, s); }
		cout << ret << endl;
	}
	return 0;
}

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


int main(){
  int n, k;
  cin >> n >> k;
  int a[100100];
  
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  int mx = -100000;
  for(int i=0; i<n-k; i++){
    int s = 0;
    for(int j=0; j<k; j++){
      s += a[i+j];
    }
    if(mx < s) mx = s;
  }
  cout << mx << endl;
  return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,ans = 0,sum = 0;
  cin >> n >> k;
  vary(ll,v,n,0);
  vary(ll,imos,n+1,0);
  rep(i,n){
    cin >> v[i];
    sum += v[i];
    imos[i] += sum;
  }
  ans = -inf;
  REP(i,k,n){
    ans = max(ans,imos[i]-imos[i-k]);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	int a[100000];int n,m;int b[100000];int p=0;
	cin >> n >> m;
	for(int i = 0;i<n;i++){
		cin >> a[i];
	}
	for(int i = 0;i<100000;i++){
		b[i]=0;
	}
	for(int i = 0;i<n-m;i++){
		if(a[i]>a[i+m]){
			for(int k = i;k<i+m;k++){
				b[p]+=a[k];
			}
			p++;
		}
	}
	for(int k = n-m;k<n;k++){
				b[p]+=a[k];
	}
	for(int i = 1;i<100000;i++){
		if(b[0]<b[i]){b[0]=b[i];}
	}
	cout << b[0]<<endl;
	return 0;

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

int main() {
    while (true) {
        int n, k;
        cin >> n >> k;
        if ((n | k) == 0) {
            break;
        }
        int* a = new int [n];
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        int* s = new int [n - k + 1];
        s[0] = 0;
        for (int i = 0; i < k; i++) {
            s[0] += a[i];
        }
        int maxS = s[0];
        for (int i = 1; i <= n - k; i++) {
            s[i] = s[i - 1] - a[i - 1] + a[i + k - 1];
            if (maxS < s[i]) {
                maxS = s[i];
            }
        }
        cout << maxS << endl;
        delete[] a;
        delete[] s;
    }
}