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>
using namespace std;

int main(){
	int n, k;
	int num[100000];
	int sum = 0;
	int maxsum = 0;
	
	for(;;){
		cin >> n >> k;
		maxsum = sum = 0;
		if(n == 0 && k == 0)	return 0;
			for(int i = 0; i < n; i++){
				cin >> num[i];
			}
		for(int i = 0; i < n-k; i++){
			sum = 0;
			for(int j = i; j < i+k; j++){
				sum += num[j];
			}
			maxsum = max(maxsum, sum);
		}
	
		cout << maxsum << endl;
	}
	
	return 0;
}

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

//{{{
/********************************************************************/
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) elems.push_back(item);
      item.clear();
    }
    else item += ch;
  }
  if (!item.empty()) elems.push_back(item);
  return elems;
}

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

/****************************************************************/
//}}}

signed main()
{
  int n, m;

  while (cin >> n >> m, n + m){
    int a[n];
    long long int maxsum = 0;

    rep(i, n) a[i] = in();
    rep(i, m) maxsum += a[i];
    reps(i, m, n) maxsum = max(maxsum, maxsum - a[i - m] + a[i]);
    print(maxsum);
  }

  return (0);
}

C++: #include<cstdio>
#include<algorithm>
#define INF 1000000000
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

ll a[100001];
ll memo[100001];//i???????????§?¶?????????????????¨?(i???????????????)
int main(){
	int n, k;
	while (scanf("%d%d", &n, &k), n){
		rep(i, n)
			scanf("%lld", &a[i]);
		ll sum = 0;
		rep(i, n){
			memo[i] = sum;
			sum += a[i];
		}
		ll Max = -INF;
		rep(i, n - k + 1){
			sum = memo[i + k] - memo[i];
			Max = max(Max, sum);
		}
		printf("%lld\n", Max);
	}
	return 0;
}

C++: #include<cstdio>
#include<string>
#include<vector>
#include<sstream>
#include<deque>
#include<algorithm>
#include<queue>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,n) for(int i=1;i<=n;i++)

int ini[100001];
int main(){
	while(1){
		int n,m;
		scanf("%d%d",&n,&m);
		if(n==0)break;
		rep(i,n){
			scanf("%d",&ini[i]);
		}
		
		int sum=0;
		rep(i,m){
			sum+=ini[i];
		}
		
		int maxi=sum;
		for(int i=m;i<n;i++){
			sum-=ini[i-m];
			sum+=ini[i];
			maxi=max(maxi,sum);
		}
		
		printf("%d\n",maxi);
	}
}

C++: #include<iostream>
#define MIN -1000000000000000000
using namespace std;

int input[100010];

int main() {
	int N,K;
	long long int sum=0,nummax=MIN;
	cin >> N >> K;

	for(int i=0;i<N;i++){
		cin >> input[i];
		sum+=input[i];
		if(i+1>=K){
			sum-=input[i-K];
			if(nummax<sum)nummax=sum;
			cout<< "   " << sum << "   "<< nummax <<endl;
		}
	}
	cout << nummax <<endl;

	return 0;
}

C++: #include <iostream>
using namespace std;
 
int main() {
	while(1){
		int n, k, ans = -1000000, sum = 0;
		cin >> n >> k;
		if (n == 0 && k == 0){
			return 0;
		}
		int yj[200008] = {};
			for(int i = 0; i < n; i++){
				cin >> yj[i];
			}
		for(int i = 0; i < k; i++){
			sum += yj[i];
		}
		for(int i = 0; i < n - k; i++){
			sum += yj[i+k];
			sum -= yj[i];
			ans = max(sum, ans);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n, k;
	while (scanf("%d%d", &n, &k), n|k)
	{
		int a[100000];
		for (int i = 0; i < n; ++i)
			scanf("%d", a + i);
		int res, sum;
		res = sum = accumulate(a, a+k, 0);
		for (int i = k; i < n; ++i)
		{
			sum += a[i] - a[i-k];
			res = max(res, sum);
		}
		printf("%d\n", res);
	}
}

C++: #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  int gomi;
  cin >> gomi >> gomi;
  int ans = 0;
  for(int i = 0; i < k; i++) {
    ans += a[i];
  }
  int mx = ans;
  for(int i = 0; i < n - k; i++) {
    mx = mx + a[k + i] - a[i];
    ans = max(mx, ans);
  }

  cout << ans << endl;
  return 0;
}

C++: #include <stdio.h>
int main(){
while(1){
int k,n,i,j,x[100000];
long long int sum=0,max;
scanf("%d%d",&n,&k);
if(n==0 && k==0) break;
for(i=0;i<n;i++){
scanf("%d",&x[i]);
}
for(i=0;i<k;i++){
sum+=x[i];
}
max=sum;
for(i=1;i<=n-k;i++){
	sum=0;
for(j=i;j<i+k;j++){
sum+=x[j];
}
if(max<sum) max=sum;
}
printf("%lld\n",max);
}
return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, k;
	while (cin >> n >> k&&n != 0 && k != 0) {
		int a[100000], sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			if (i < k) sum += a[i];
		}
		int s = 1, e = k, f;
		while (e < n) {
			f = sum;
			sum += a[e];
			sum -= a[s - 1];
			sum = max(sum, f);
			s++;
			e++;
		}
		cout << sum << endl;
	}
}

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

int main() {
	while(1){
		int n,k,b[100010]={},sum[100010]={};
		cin>>n>>k;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin>>b[i];
		}
		for(int i=0;i<(n-k+1);i++){
			for(int j=0;j<k;j++){
				sum[i]+=b[j+i];
			}
		}
		sort(sum,sum+(n-k+1), greater<int>()); 
		cout<<sum[0]<<endl;
	}
	return 0;
}