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 <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>


using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

int main(){

	int n,k;
	int a[100001];


	while(cin >> n >> k && !(n==0&&k==0)){
	for(int i = 0; i < n; i++)
		cin >> a[i];

	int ub,lb;
	ub=lb=0;
	ll cSum=0;
	for(int i = 0; i < k; i++){
		cSum += a[i];
	}
	ll maxSum = cSum;
	for(int i = 1; i <= n - k; i++){
		cSum -= a[i-1];
		cSum += a[i+k-1];
		maxSum = max(maxSum,cSum);
	}

	cout << maxSum << endl;
	}

	return 0;
}

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

using namespace std;

int main() {
    int n, m;
    while(cin >> n >> m) {
        if(n == 0 && m == 0) {
            break;
        }
        int nums[n];
        for(int i = 0; i < n; i++) {
            cin >> nums[i];
            if(i != 0) {
                nums[i] += nums[i - 1];
            }
        }

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

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

using namespace std;

int rsw[1000002];

int main() {
	int n, k;
	while (cin >> n >> k, n + k) {
		rsw[0] = 0;
		for (int i = 0; i < n; i++) {
			int a;
			cin >> a;
			rsw[i + 1] = rsw[i] + a;
		}
		int MAX = rsw[k] - rsw[0];
		for (int i = 0; i < n - k + 1; i++) {
			MAX = max(MAX, rsw[i + k] - rsw[i]);
		}
		cout << MAX << endl;
		for (int i = 0; i < 1000002; i++) {
			rsw[i] = 0;
		}
	}
	return 0;
}

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

int main(){
  int n,k,x;
  vector<int> s;
  int start,end,ans=0,sum;
  
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>x;
    s.push_back(x);
  }
  
  start=0;end=k;
  while(end-1<n){
    sum=0;
    for(int i=start;i<end;i++){
      sum+=s[i];
    }
    ans=max(ans,sum);
    
    start++;end++;
  }
  
  printf("%d\n",ans);
  return 0;
}

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

using namespace std;

int main(void)
{
	int n, k, s, b;
	int a[100001], m[100001];
	while (1)
	{
		cin >> n >> k;
		if (n == 0 && k == 0)
			break;
		for (int i = 0;i < n;i++)
			cin >> a[i];

		m[0] = a[0];
		for (int i = 0;i < n;i++)
			m[i + 1] = m[i] + a[i];

		s = m[k] - m[0];
		for (int i = 0;i < n - k + 1;i++)
		{
			b = m[i + k + 1] - m[i + 1];
			if (s < b) 
				s = b;

		}

	}
	cout << s << endl;
	return 0;
}

C++: #include <iostream>
template <typename T>
class RingBuffer {
	int size;
	int idx;
	T* arr;
	T& at(int i) {
		return arr[i % size];
	}
public:
	RingBuffer(int s) {
		size = s;
		idx = 0;
		arr = new T[s];
	}
	void push(T t) {
		at(idx++) = t;
	}
	const T& peek() {
		return at(idx);
	}
};
int solve(int n, int k) {
	RingBuffer<int> buffer(k);
	int sum = 0;
	int a;
	for (auto i = 0; i < k; ++i) {
		std::cin >> a;
		buffer.push(a);
		sum += a;
	}
	int max = sum;
	for (auto i = k; i < n; ++i) {
		std::cin >> a;
		sum += a - buffer.peek();
		buffer.push(a);
		if (sum > max) max = sum;
	}
	return max;
}
int main() {
	int n, k;
	while (std::cin >> n >> k && n != 0) {
		std::cout << solve(n, k) << '\n';
	}
	return 0;
}

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

int main()
{
    int n,k;
    cin >> n >> k;
    while(n !=0 && k !=0){
        int a;
        int s[100010];
        s[0]=0;
        for(int i=0;i<n;i++){
            cin >> a;
            s[i+1]=s[i]+a;
        }
        int m=0;
        for(int i=0;i<n-k;i++){ 
            if(m < s[i+k]-s[i]){
                m = s[i+k]-s[i];
            }
        }
        cout << m << endl;
        cin >> n >> k;
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int ans=0,n,k,box[10000]={0},sum=0;;
        cin >> n >> k;
        if(n==0&&k==0)break;
        for(int i=0;i<k;i++){
            cin >> box[i];
            sum+=box[i];
            }
            ans=sum;
          for(int i=k;i<n;i++){
                cin >> box[i];
                if(n-k==0)break;
                sum+=box[i]-box[i-k];
                if(sum>ans)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[199999];
	for(int i=0;i<199999;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<vector>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b,a||b){
    vector<int>in(a);
    rep(i,a)cin>>in[i];
    int sum=0;
    rep(i,b)sum+=in[i];
    int ma=sum;
    rep(i,a-b){
      sum-=in[i];
      sum+=in[i+b];
      ma=max(ma,sum);
    }
    cout<<ma<<endl;
  }

}

C++: #include<iostream>

using namespace std;

#define MAX 100000
#define INF (10000*100000+1)
int main(){

	int n,k,a[MAX];
	long long num,max;

	while(1){

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

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

		max=-1*INF;
		for(int i=0;i<=n-k;i++){
			num=0;
			for(int j=0;j<k;j++){
				num+=a[i+j];
			}
			max=(max<num)?num:max;
		}
		cout<<max<<endl;
		
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, k;
ll a[100010], s[100010];
vector<ll> v;

int main() {
    while (cin >> n >> k) {
        if (n == 0) break;
        rep(i, n) cin >> a[i];
        rep(i, n) s[i+1] = s[i] + a[i];

        ll ans = 0;
        for (int i = 0; i + k - 1 < n; i++) {
            ll tmp = s[i+k] - s[i];
            chmax(ans, tmp);
        }
        v.push_back(ans);
    }
    for (ll &x: v) cout << x << endl;
}

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