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(){
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];
}
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<algorithm>
using namespace std;
int main(){
	while(1){
	int n,k,x=0,ma=0;
	cin>>n>>k;
		if(n==0 && k==0)
		break;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n-k;i++){
		x=0;
		for(int j=0;j<k;j++){
			x+=a[i+j];
		}
		ma=max(ma,x);
	}
	cout<<ma<<endl;
	}
return 0;
}

C++: #include<iostream>

using namespace std;

int main() {
    int n, m, a, b;
    int nums[5];
    cin >> n >> m;
    while(cin >> a >> b) {
        int i = 0;
        if(a == 0 && b == 0) {
            break;
        }
        nums[i] = a;
        i++;
    }
    int max = 0;
    for(int i = 0; i < m; i++) {
        i += nums[i];
    }
    for(int i = 1; i < n - m + 1; i++) {
        int sum = 0;
        int k = i;
        for(int j = 0; j < m; j++) {
            sum += nums[k + j];
        }
        if(sum > max) {
            max = sum;
        }
    }
    cout << max << endl;
}

C++: #include <cstdio>

#define MAX(x, y) (x < y) ? y : x

int main(void)
{
	int n, k;
	int data[100000] = {0};
	
	while (1){
		scanf("%d %d", &n, &k);
		if (n == 0 && k == 0) break;
		for (int i = 0; i < n; i++){
			scanf("%d", &data[i]);
		}
		
		int max = 0, tmp;
		for (int i = 0; i <= (n - k); i++){
			tmp = 0;
			for (int j = i; j < (i + k); j++){
				tmp += data[j];
			}
			max = MAX(max, tmp);
		}
		
		printf("%d\n", max);
	}
	
	return (0);
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
	vector<int> sum;
	int n,m,x,max;
	while(cin>>n>>m,n||m){
	cin>>x;
	sum.push_back(0);
	sum.push_back(x);
	max=-1000000;
	for(int i=2;i<=n;i++){
		cin>>x;
		sum.push_back(sum[i-1]+x);
	}
	for(int i=0;i<n-m+1;i++){
		if(sum[m+i]-sum[i]>max)
		max=sum[m+i]-sum[i];
	}
	cout<<max<<endl;
		sum.clear();
	}
	return 0;
}

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

using namespace std;

int main() {
    while(true) {
        int n, k;
        cin >> n >> k;
        int sum = 0;
        int ans = 0;
        queue<int> q;
        for(int i = 0; i < n; ++i) {
            int num;
            scanf("%d", &num);

            sum += num;
            if(i == k-1) ans = sum;
            if(i >= k) {
                sum -= q.front();
                q.pop();
                ans = max(ans, sum);
            }
            q.push(num);
        }

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

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

int main(void)
{
  ios::sync_with_stdio(false);
  int n, k;
  int max;
  int sum;
  while (true)
  {
    cin >> 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];
    }

    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;

    delete[] num_sequence;
  }
  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)braek;
         }
         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 <iostream>
using namespace std;

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

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

int main(){

  int n,k;

  while(cin >> n >> k, n, k){

    int a[100000] = {0},z = 0;

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

    for(int i=0;i<k;i++) z += a[i];

    for(int i=k;i<n;i++) z = max(z , z+(a[i]-a[i-k]));

    cout << z << endl; 
  }
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		vector<int>in(n+1);
		rep(i,n)cin>>in[1+i];
		loop(i,1,1+n)in[i]+=in[i-1];
		int ma=-1e9;
		rep(i,n-m+1)ma=max(ma,in[i+m]-in[i]);
		cout<<ma<<endl;
	}
}

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

C++: #include<iostream>
#include<algorithm>
using namespace std;
int n = 0, k = 0;
int a[100001] = {}, b[100001] = {};
int ans;
int main(){
	while (true){
		n = 0; k = 0;
		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[x + 1];
		}
		ans = b[1];
		for (int i = 2; i <= n; i++){
			if ((i+k)==(n+1))	break;
			b[i] = b[i - 1] - a[i - 1] + a[i + k - 1];
			ans = max(b[i], ans);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <algorithm>
#define MAX 100000
using namespace std;

int main(){
	int n, m;
	while(scanf("%d %d", &n, &m)){
		if(n == 0 and m == 0) break;
		int array[MAX];
		fill(array, array + MAX, 0);
		for(int i = 0; i < n; i++) scanf("%d", &array[i]);
		
		int sum = 0, max = 0;
		for(int i = 0; i < n - m; i++){
			sum = 0;
			for(int j = i; j < i + m; j++){
				sum += array[j];
			}
			if(sum > max) max = sum;
		}
		printf("%d\n", max);
	}
	return 0;
}

C++: #include <stdio.h>

int a[100000],e[100000];
int main(){
	int b,c,d,f,g=-100000000;
	while(1){
		scanf("%d %d",&c,&b);
		if(c==0){
			return 0;
		}
		for(d=0;d<c;d++){
			scanf("%d",a[d]);
		}
		for(d=0;d<c-b;d++){
			for(f=0;f<b;f++){
				e[d]+=a[f];
			}
		}
		for(d=0;d<c-b;d++){
			if(g<=e[d]){
				g=e[d];
			}
		}
		printf("%d\n",g);
	}
}

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;
}