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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
typedef long long ll;
int n,k,a[100002];
ll sum[100002];
const int INF = 1<<28;

void solve() {
  rep(i,n) cin>>a[i];
  sum[0]=0;
  rep(i,n) sum[i+1]=sum[i]+a[i];
  ll ans = -INF;
  //rep(i,n+1) cout<<sum[i]<<endl;
  for(int i=0; i+k<=n; ++i) {
    ans = max(ans, sum[i+k]-sum[i]);
  }
  cout<<ans<<endl;
}
int main() {
  while(cin>>n>>k,n) solve();
  return 0;
}

C++: #include<string>
#include<vector>
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)


int main(){

	int n,k,s;
	vector<int>a;

	while(true){

		cin >> n >> k;
		if(n==0 && k==0) break;

		rep(i,n){
		cin >> s;
		a.push_back(s);
		}

		int m=0; int sum=0;
		REP(j,0,n-k){
		REP(i,j,k+j-1)
			sum+=a[i];

		if(m<=sum) m=sum;
		sum=0;

		}

		cout << m << endl;

		a.clear();

	}

	return 0;
}

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

#define MAX 1000000000
#define MIN -10000000000

#define ll long long

using namespace std;
int main() {

        ll n,k,i,j,temp,last,maxx;
        do {
            cin >> n >> k;
            if(k==0&&n==0)break;
            vector<ll> a(n);
            vector<ll> s(n + 1);
            for (i = 0; i < n; i++) {
                cin >> a[i];
            }
            //cin >> temp >> temp;
            s[0] = 0;
            for (i = 0; i < n; i++) {
                s[i + 1] = s[i] + a[i];
            }
            maxx = a[k - 1] + a[0];
            for (i = 0; i < n - k + 1; i++) {
                //   cout << s[i+k]-s[i] << endl;
                maxx = max(s[i + k] - s[i], maxx);
            }
            cout << maxx << endl;
        }while(k!=0&&n!=0);

//cout << "aaa" << endl;

    return 0;
}

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

int main()
{
	int n, k, i, j, inp, max=0;
	int *a;
	cin >> n >> k;
	a = new int[n];
	
	for (i = 0; i < n; i++){
		cin >> inp;
		a[i] = inp;
	}
	
	int o1, o2;
	cin >> o1 >> o2;

	for (i = 0; i < n - k + 1; i++){
		int sum = 0;

		for (j = 0; j < k; j++){
			sum += a[i + j];
		}

		if (sum > max){ max = sum; }
	}

	cout << max << endl;

	delete[] a; 
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

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

int N,K;
int a[100010];

int main(){
  int i;

  while(1){
    scanf("%d %d",&N,&K);
    if(N == 0 && K == 0) break;

    REP(i,N) scanf("%d",&a[i]);

    int sum = 0, res = 0;
    REP(i,K){ sum += a[i]; res += a[i]; }
    while(i < N){
      sum += a[i];
      sum -= a[i-K];
      res = max(res,sum);
      i++;
    }

    printf("%d\n",res);
  }

  return 0;
}

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

int main(){
  int n,k;
  while( cin >> n >> k,n+k){
    
    int a[n];
    for(int i = 0;i < n;i++){
      cin >> a[i];
    }
    int sum = -500000;
    for(int i = 0;i < n-k+1;i++){
      //cout << i << endl;
      int s = 0;
      for(int j = i;j < i+k;j++){
	s += a[j];
      }
      sum = max(s,sum);
    }
    cout << sum <<  endl;
    
  }
  
}

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

int main() {
  //cout << "aaa" << endl;
  while (true) {
    ll n, k;
    cin >> n >> k;
    if (n == 0 && k == 0) break;
    vector<ll> A(n);
    for (ll i = 0; i < n; i++) {
      cin >> A[i];
    }

    vector<ll> s(n);
    for (ll i = 0; i < n; i++) {
      s[i + 1] = s[i] + A[i];
    }
    ll mx = (1LL << 60) * -1;

    for (ll i = 0; i < n - k; i++) {
      mx = max(mx, s[i + k] - s[i]);
    }
    cout << mx << endl;
  }
}

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

int main() {
	int n, k;
	while (cin >> n >> k, n, k) {

		int a[10005];
		for (int i = 0;i < n;i++) {
			cin >> a[i];
		}

		int ans = 0;
		for (int i = 0;i <= n - k;i++) {
			int s = 0;
			for (int j = 0;j < k;j++) {
				s += a[i + j];
			}
			if (s > ans)ans = s;
		}
		cout << ans << endl;
	}
	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<100100;i++)num[i]=0;
         cin>>n>>m;
         if(n==0&&m==0)break;
         for(int i=0;i<n;i++) cin>>num[i];
         for(int i=0;i<m-n;i++){
              int min=num[i]+num[i+1]+num[i+2];
              if(ans<min)ans=0;
         }
         cout<<ans<<endl;
         ans=0;
    }
    return 0;
}

C++: #include <cstdio>
 
int main(void)
{
  int n, k;
  int max;
  int sum;
  while (true)
  {
    scanf("%d %d", &n, &k);
    if ( n == 0 && k == 0 ) break;
 
    int* num_sequence = new int[n];
    for (int i = 0; i < n; ++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;
    }
    printf("%d\n", max);
  }
  return 0;
}

C++: //Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
int main()
{
while(1)
{
	int n,k;
	scanf("%d %d",&n,&k);
	if(!n) return 0;
	int ret=-INF;
	int res=0;
	queue<int>que;
	for(int i=0;i<k;i++)
	{
		int s; scanf("%d",&s);
		res+=s;
		que.push(s);
	}
	ret=max(ret,res);
	for(int i=k;i<=n;i++)
	{
		int s; scanf("%d",&s);
		res+=s;
		res-=(que.front());
		ret=max(ret,res);
		que.pop();
		que.push(s);
	}
	printf("%d\n",ret);
}
}

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

int main(){

  int n, k;
  while( cin >> n >> k, n+k ) {
    int max_sum, sum = 0, data[100000];
    
    for(int i=0; i<k; i++) {
      cin >> data[i];
      sum += data[i];
    }
    max_sum =sum;

    for(int i=k; i<n; i++) {
      cin >> data[i];
      sum -= data[i-k];
      sum += data[i];
      max_sum = max(max_sum, sum);
    }

    cout << max_sum << endl;
  }
}