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

int main()
{
	int n,k;

	int suu[100000 + 100] = { 0 };
	int a;
	int i;
	int mx;

	cin >> n >> k;

	while (n != 0 && k != 0)
	{
		for (i = 1; i <= n; i++)
		{

			cin >> a;

			suu[i] = a + suu[i - 1];

		}

		for (i = k; i <= n; i++)
		{
			if (mx < suu[i] - suu[i - k])
			{
				mx = suu[i] - suu[i - k];
			}

		}

		cout << mx << endl;


		cin >> n >> k;
		mx = 0;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int num[100100];
int main(){
int n,m;
int ans=0;
while(1){
        /* for(int i=0;i<100001;i++){
              num[i]=0;
              if(num[i+1]==0)break;
         }*/
         cin>>n>>m;
         if(n==0&&m==0)break;
         for(int i=0;i<n;i++) cin>>num[i];
         for(int i=0;i<n-m;i++){
              int min=0;
              for(int j=i;j<i+m;j++)min+=num[j];
              if(ans<min)ans=min;
         }
         cout<<ans<<endl;
         ans=0;
    }
    return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#define MAX_n 100000
int main()
{
	int n,k,a[MAX_n],i,put=0,total=0;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i+k<=n;i++)
	{
		for(int j=i;j<i+k;j++)
		{
			total+=a[j];
		}
		if(put<total)
			put=total;
		total=0;
	}
	printf("%d\n",put);
	//Sleep(10000);
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, K;
  while(cin >> N >> K,N){
  VL xs(N);
  REP(i,N) cin >> xs[i];

  LL acc = 0;
  REP(i,K) acc += xs[i];
  LL ans = acc;
  for(int i=K;i<N;++i){
	acc += xs[i] - xs[i-K];
	maxi(ans, acc);
  }
  cout << ans << endl;
  }
  return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int n,a[100001],k,sum,p;
int main(){
int i,j,h;
cin>>n>>k;
for(i=1;i<=n;i++){
a[i]=0;
}
cin>>a[1];
for(i=2;i<=n;i++){
cin>>a[i];
a[i]+=a[i-1];
}
for(i=1;i<=n;i++){
	for(j=i;i<=i+k;j++){
		p=a[i+k]-a[j];
		if(p>=sum){
			sum=p;
		}
	}
}
cout<<sum<<endl;

return 0;
}

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

C++: #include<iostream>
#include<string.h>
using namespace std;
int main(){
	int i,i2,n,k,a[5001],max=0,sum;
	cin>>n>>k;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n-k+1;i++){
		sum=0;
		for(i2=i;i2<i+k;i2++)sum+=a[i2];
		if(sum>max){
			max=sum;
		}
	}
	cout<<max<<endl;
}

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<string>
#include<algorithm>
#include<cstdio>

using namespace std;

int main(){
  while(true){
    int a[100000] = {0};
    int n, k;
    cin >> n >> k;
    if(!n)
      break;
    for(int i = 0; i < n; i++){
      cin >> a[i];
    }
    int aa = 0;
    for(int i = 0; i < k; i++){
      aa += a[i];
    }
    //cout << "f:" << aa << endl;
    for(int i = k; i < n; i++){
      int aaa = aa - a[i - k] + a[i];
      aa = aaa > aa ? aaa : aa;
      //cout << "f:" << aa << " n:" << aaa << endl;
    }
    cout << aa << endl;
  }
  return 0;
}

C++: #include <cstdio>

using namespace std;

int n,k,s,smax;
int a[100000];
int s1,s2;

int main(){
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int j=0;j<k;j++) smax+=a[j];
	for(int l=0;l<n;l++){
		s2=s1-a[l]+a[n-l];
		if(s1>smax) smax=s1;
		s1=s2;
	}
		printf("%d",smax);
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
    int a[5];
    int t = 0;
    while(1){
        int n,k;
        cin >> n >> k;
        if(n == 0 && k == 0)break;
        vector<int>l(n);
        for(int i = 0;i < n;i++){
            cin >> l[i];
        }
        int s = 0;
        int max = 0;
        for(int i = 0;i < k;i++){
            s += l[i];
        }
        max = s;
        for(int i = k;i < n;i++){
            s += l[i];
            s -= l[i - k];
            if(s > max){
                max = s;
            }
        }
        a[t] = max;
        t++;

    }
    for(int i = 0;i < t;i++){
        cout << a[i] << endl;
    }
    return 0;
}

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

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int n,a[100001],k,sum,p;
int main(){
int i,j,h;
cin>>n>>k;
for(i=1;i<=n;i++){
a[i]=0;
}
while(1){
cin>>a[1];
for(i=2;i<=n;i++){
cin>>a[i];
a[i]+=a[i-1];
}
for(i=1;i<=n;i++){
	for(j=i;i<=i+k;j++){
		p=a[i+k]-a[j];
		if(p>=sum){
			sum=p;
		}
	}
}
cout<<sum<<endl;
cin>>n>>k;
if(n==0&&k==0)break;
for(i=1;i<=n;i++){
a[i]=0;
}
cin>>a[1];
}
return 0;
}

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

int main() {
  int n, k;
  while(cin >> n >> k, n+k) {
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    long long ans = -10000000000;
    for(int i = 0; i < n-k; i++) {
      long long sum = 0;
      for(int j = 0; j < k; j++) {
	sum += a[i+j];
      }
      if(ans < sum) ans = sum;
    }
    cout << ans << endl;
  }
}