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 F(i,s,e) for(int i=s;i<e;++i)

int main(){
    long n,k;
    while(cin >> n >> k && (n!=0 && k!=0)){
        long a[n],s[n];
        F(i,0,n){
            cin >> a[i];
        }
        s[0]=a[0];
        F(i,1,n){
            s[i]=s[i-1]+a[i];
        }
        long ans=0;
        F(i,0,n-k){
            ans=max(ans,s[i+k]-s[i]);
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
int n,m;
while(true){
cin>>n>>m;
if(n==0&&m==0){break;}
int ans=-2147483646;
int sum[100001];
for(int i=0;i<n;i++)
{
cin>>sum[i];
if(i!=0){sum[i]+=sum[i-1];}
if(i==m-1){ans=max(ans,sum[i]);}
else if(i>m-1){ans=max(ans,sum[i]-sum[i-m]);}
}
cout<<ans<<endl;
/////////////
}
///////////
    return 0;
}

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

int main(void)
{
  int n, k;
  int max;
  int sum;
  while (true)
  {
    //cin >> n >> k;
    scanf("%d %d", &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];
      scanf("%d", &num_sequence[i]);
    }

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

    //cout << max << endl;
    printf("%d\n", max);

    delete[] num_sequence;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <numeric>
using namespace std;
int main(){
  int n, k, l;
  int N[100001], ans, sum, tmp;
  while(cin >> n >> k, n && k){
    ans = 0, sum = 0;
    for(int i = 0 ; i < n ; i++){
      cin >> N[i];
    }

    for(l = 0 ; l < k ; l++){
      sum += N[l];
    }
    ans = max(ans, sum);
    tmp = sum;
    for(int i = l ; i < n ; i++){
      tmp = sum;
      sum += N[i];
      sum -= N[i-k];
      tmp = sum;
      ans = max(ans, sum);
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;



const int mod = 100000;
struct Mod {
public:
	int num;
	Mod() : Mod(0) { ; }
	Mod(long long int n) : num((n % mod + mod) % mod) {
		static_assert(mod<INT_MAX / 2, "mod is too big, please make num 'long long int' from 'int'");
	}
	Mod(int n) : Mod(static_cast<long long int>(n)) { ; }
	operator int() { return num; }
};

Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int  b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) { return Mod((mod + a.num - b.num) % mod); }
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) { return Mod(((long long)a.num * b.num) % mod); }
Mod operator*(const long long int a, const Mod b) { return Mod(a)*b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b)*a; }
Mod operator*(const Mod a, const int b) { return Mod(b)*a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod& a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
	if (n == 0) return Mod(1);
	Mod res = (a * a) ^ (n / 2);
	if (n % 2) res = res * a;
	return res;
}
Mod mod_pow(const Mod a, const long long  int n) {
	if (n == 0) return Mod(1);
	Mod res = mod_pow((a * a), (n / 2));
	if (n % 2) res = res * a;
	return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
	assert(b.num != 0);
	return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) {
	return Mod(a) / b;
}
Mod operator/=(Mod &a, const Mod b) {
	return a = a / b;
}

#define MAX_MOD_N 1024000

Mod fact[MAX_MOD_N], factinv[MAX_MOD_N];
void init(const int amax = MAX_MOD_N) {
	fact[0] = Mod(1); factinv[0] = 1;
	for (int i = 0; i < amax - 1; ++i) {
		fact[i + 1] = fact[i] * Mod(i + 1);
		factinv[i + 1] = factinv[i] / Mod(i + 1);
	}
}
Mod comb(const int a, const int b) {
	return fact[a] * factinv[b] * factinv[a - b];
}

int main() {
	while (1) {
		int N, K; cin >> N >> K;
		vector<int>as(N);
		for (int i = 0; i < N; ++i) {
			cin >> as[i];
		}
		long long int sum = 0;
		for (int i = 0; i < K; ++i) {
			sum += as[i];
		}
		long long int ans = sum;
		for (int i = K; i < N; ++i) {
			sum += as[i] - as[i - K];
			ans = max(ans, sum);
		}
		cout << ans << endl;
	}

	return 0;
}

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

int main(){
	int n, k, x, maxnum = 0;
	cin >> n >> k;
	int wa[100000];
	for(int i=0;i<100000;i++) wa[i] = 0;
	for(int i=0;i<n;i++){
		cin >> x;
		for(int j=0;j<k;j++){
			wa[i+j] += x;
		}
	}
	cin >> x >> x;
	for(int i=k-1;i<n;i++){
		if(maxnum < wa[i]) maxnum = wa[i];
	}
	cout << maxnum << endl;
}

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

using namespace std;

int main(){
	deque<int> deq;
	int n,k,max=0,buf;
	
	cin >> n >> k;
	
	deq.push_front(0);
	for(int i = 0; i < k-1; i++){
		cin >> buf;
		deq.push_front(buf);
		n--;
	}
	
	for(; n > 0; n--){
		cin >> buf;
		deq.push_front(buf);
		deq.pop_back();
		
		buf = 0;
		
		for(int i = 0; i < k; i++){
			buf += deq.at(i);
		}
		
		if(max < buf){
			max = buf;
		}
	}
	
	cout << max << endl;
	
	return 0;
	
}

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

using namespace std;
int main(){
  int n,k;
  int max;
  cin >> n >> k;
  while(n != 0 || k != 0){
    vector <int> a(n);
    cin >> a[0];
    for(int i =  1 ; i < k ; i++){
      cin >> a[i];
      a[i] += a[i-1];
    }
    max = a[k-1];

    for(int i = k; i < n ; i++){
      cin >> a[i];
      a[i] += a[i-1];
      if(max < (a[i] - a[i-k])){
        max = a[i] - a[i-k];
      }
    }
    cout << max << endl;
    cin >> n >> k;
  }
}