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 <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;

int main(){
	int a[100000],n,k,s[100000];
	while(1){
	cin >> n >> k ;
		if((n==0)&&(k==0)){
			return 0;
		}
	for(int i=0;i<n;i++){
		cin >> a[i] ;
		s[i]=0;
	}
	
	for(int i=0;i<n-k;i++){
		for(int j=i;j<i+k;j++){
			s[i]+=a[j];
		}
	}
	
	for(int i=1;i<n;i++){
		for(int j=1;j<n-i;j++){
			if(s[j-1]<s[j]){
				k=s[j-1];s[j-1]=s[j];s[j]=k;
			}
		}
	}
	
	cout << s[0] <<"\n";
	}
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    for(int count = 0;  count < 5; count++){
	    vector<int> none(2);
	    int N, k;
	    cin >> N >> k;
	    vector<int> a(N);
	    for(int i = 0; i < N; i++){
		cin >> a.at(i);
	    }
	    int ans = 0;
	    int total = 0;
	    for(int i = 0; i < N; i++){
	    	if(i < k) total += a[i];
		else total = total + a[i] - a[i-k];
		if(ans < total) ans = total;
	    }
	    cout << ans << endl;
	    for(int i = 0; i < 2; i++){
    	    cin >> none.at(i);
	    }
　　}
}

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

int main()
{
    int n,k;
    for(;;){
        cin >> n >> k;
        if(n==0&&k==0) break;
        int s=0;
        int a[n];
        for(int i=0;i<n;i++)
            cin >> a[i];
        int m=0;
            for(int j=0;j<k;j++)
                m+=a[j];
            s=m;
        for(int q=0;q<n-k;q++){
            m-=a[q];
            m+=a[q+k];
            s=max(s,m);
        }
        cout << s << endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
  while (1) {
    int k, n;
    cin >> n >> k;
    if ((k <= n) && (n == 0)) {
      return 0;
    }

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

    int s = 0;
    for (int i = 0; i < k; i++) {
      s += a[i];
    }
    for (int i = 0; i + k < n; i++) {
      int t = s + a[k + i] - a[i];
      if (t >= s) {
        s = t;
      }
    }
    cout << s << endl;
  }
  return 0;
}

C++: #include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;

int main(void){
	int n, k, t, m;
	while(true){
		scanf("%d %d", &n, &k);

		if(n == 0 && k == 0) return 0;

		vector<int> a;

		for(int i = 0;i < n;++i){
			scanf("%d", &t);
			a.push_back(t);
		}

		m = 0;
		for(int i = 0;i < n-k;++i){
			t = 0;
			for(int j = 0;j < k;++j){
				t += a[i+j];
			}
			m = max(m, t);
		}

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

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

int main(){
  int numn,lisn,num;
  vector<int> outp;
  int outn = 1;
  for(int l = 0;;l++){
    cin >> numn >> lisn;
    if(numn == 0 && lisn == 0)break;
    outp.resize(l+1,0);
    vector<int> lists(numn,0);
    for(int n = 0;n<numn;n++){
      cin >> num;
      lists[n] = num;
    }
    for(int k = 0;k<numn-2;k++){
      outn = lists[k] + lists[k + 1] + lists[k + 2];
      if(outp[l] < outn){
        outp[l] = outn;
      }
    }
  }
  for(int q = 0;q<outp.size();q++){
    cout << outp[q] << " ";
  }
}

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

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

		if (n==0&&k==0){ break; }
		else{
			int i, j, inp, max = 0;
			int *a;
			
			a = new int[n];

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

			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 <stdio.h>
#include <stdlib.h>

int main(void){
	int n=0, k=0;
	int *a;
	long sum  = 0;
	long msum = 0;
	while(true){
		sum = 0;
		scanf("%d %d", &n, &k);
		if(n==0){break;}
		a = (int*)malloc(sizeof(int) * n);
		for(int i=0; i<n; ++i){
			scanf("%d", a+i);
		}

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

		for(int i=0; k<n; ++i,++k){
			sum = sum - a[i] + a[k];
			if(sum > msum){
				msum = sum;
			}
		}
		printf("%d\n", msum);
		free(a);
	}
	return 0;
}

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

int main()
{   
    while(true){
    
    int i, n, k;
    cin >> n >> k;
    if((n==0)&(k==0))break;
    int a[n];
    for(i=0; i<n ;i++){
        cin >> a[i];
    }

    int max_val;
    int S;
    //--init--
    S = 0;
    for(i=0; i<k; i++){
        S += a[i];
    }
    max_val = S;
    for(i=0; i<n-k; i++){
        S += a[i+k];
        S -= a[i];
        if(max_val < S){
            max_val = S;
        }
    }
    std::cout << max_val << std::endl;
    }
    return 0;
}

C++: #include <stdio.h>
int main(){
while(1){
int k,n,i,j,x[100000];
long long int max=0,sum=0;
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];
}
for(i=1;i<=n-k;i++){
	if(x[i-1]<x[i+k-1]){
	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>
using namespace std;
int main(){
	while (true){
		int n=0, k=0;
		double 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];
		}
		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];
			}
		}
		if (ans == 0){
			cout << b[1] << endl;
		}
		else{
			cout << ans << endl;
		}
	}
	return 0;
}

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

using namespace std;

int main(){
	int n,k,sum=0,max;
	int a[100001];
	while(scanf("%d %d",&n,&k)){
		if(n==0&&k==0)
		break;
		for(int i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		for(int i=0;i<n;i++){
			if(i<k)
			sum+=a[i];
			else if(i>=k){
				sum+=a[i];
				sum-=a[i-k];
			}
			if(i==k-1)
			max=sum;
			else if(i>k-1){
				max=(max<sum ? sum:max);
			}
		}
		printf("%d\n",max);
	}
}

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

int main(){
	int n,k;
	queue<int> q;
	while(cin>>n>>k,n||k){
		while(!q.empty())q.pop();
		int t,sum=0,ans= -10000*100000;
		for(int i=0;i<k;i++){
			cin>>t;
			sum += t;
			q.push(t);
		}
		ans=max(ans,sum);
		for(int i=0;i<n-k;i++){
			t=q.front();
			q.pop();
			sum -= t;
			cin>>t;
			sum += t;
			ans=max(ans,sum);
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

constexpr int MAX_N= 100000;

int n,k;
int sums[MAX_N];

int main(){
	std::cin>>n>>k;
	for(int i=0;i<n;++i)
		std::cin>>sums[i];

	for(int i=1;i<n;++i)
		sums[i]+=sums[i-1];

	int ans=sums[k-1];

	for(int i=0;i<n-k+1;++i){
		ans=std::max(ans,sums[i+k]-sums[i]);
    }
	std::cout<<ans<<std::endl;

	return 0;
}

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

#define INT_MIN -2147483648
#define MAX_N 100010
int N, K;
int S[MAX_N];

int main() {
  while (true) {
  cin >> N >> K;
  if (N == 0 && K == 0) break;
  int ans = INT_MIN;
  for (int i=0; i<N; i++) cin >> S[i];

  for (int i=0; i<=N-K; i++) {
    int t = 0;
    for (int j=0; j<K; j++) t += S[i+j];
    ans = max(ans, t);
  }
  cout << ans << "\n";
  }
  return 0;
}