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 <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;


int main() {
    while(true){
        int N,K;
        cin >> N >> K;
        if(N == 0 && K == 0)break;
        vector<int> a(N);
        vector<int> wa(N+1);
        wa.at(0) = 0;
        for(int i = 0; i < N; i++){
            cin >> a.at(i);
            wa.at(i+1) = a.at(i) + wa.at(i);
        }
        int ANS = -INF;
        for(int i = 0; i < N - K +1; i++){
            int ans = wa.at(i+K) - wa.at(i);
            ANS = max(ANS, ans);
        }
        cout << ANS << endl;
    }
    
    
    
    
}

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

int max(int a, int b){
	if(a > b) return a;
	else return b;
}

int main(){
	const int MAX_N = 100000;
	int n, a[MAX_N], k, S, S1, S2;
	int p;
	
	while(true){
		scanf("%d%d", &n, &k);
		if(n == 0 && k == 0) break;
		for(int i = 0; i < n; i++) scanf("%d", &a[i]);
		
		S = 0;
		for(p = 0; p < k; p++){
			S += a[p];
		}
		S1 = S;
		
		while(p < n){
			S2 = S1 + a[p] + a[p - k];
			
			S = max(S, S2);
			
			S1 = S2;
			
			p++;
		}
		
		printf("%d\n", S);
	}
	
	return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	while(1){
	int k,n,s=0,cn=0;
	cin>>k>>n;
	if(k==0 && n==0){
		break;
	}
	int dat[1000];
	for(int i=0;i<k;i++){
		cin>>dat[i];
	}
	for(int j=0;j<k-n+1;j++){
		cn=0;
		for(int k=0;k<n;k++){
			cn+=dat[j+k];
		}
		s=max(s,cn);
	}
	cout<<s<<endl;
	}
	return 0;
}

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

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

	for (i = 0; i < n - 2; i++){
		sum = a[i] + a[i + 1] + a[i + 2];
		if (sum > max){ max = sum; }
	}

	cout << max << endl;

	delete[] a; 
	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>
using namespace std;
int main(){
	while (true){
		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 <stdio.h>

int main()
{
	int max,a[100000],sum,k,n;

	
	while(scanf("%d %d",&n,&k) && n || k ){
	
		for(int i = 0; i < n; i++){
			scanf("%d",&a[i]);
		}
	
		sum = 0;
		for(int i = 0; i < k; i++){
			sum += a[i];
		}
	
		max = sum;
		for(int i = k; i < n; i++){
			sum += a[i]-a[i-k];
			if(sum > max){
				max = sum;
			}
		}

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

	return 0;
}

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

int main(){
  int n,k,a[100000],sum,maxv;
  
  while(cin >> n >> k,n||k){
    sum = 0;
    for(int i=0;i<k;i++){
      cin >> a[i]; sum += a[i];
    }
    
    maxv = sum;
    for(int i=k;i<n;i++){
      cin >> a[i]; sum += a[i] - a[i-k];
      maxv = std::max(maxv,sum);
    }
    cout << maxv << endl;
  }
}

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

int main(){
	int n, k;
	int input[100000];
	int sun;
	while(cin >> n >> k, n || k){
		int ans = 0;
		for(int i=0; i < n; i++) cin >> input[i];

		for(int i=0; i < n-k; i++){
			sun = 0;
			for(int j=i; j < i+k; j++){
				sun += input[j];
			}
			ans = max(ans, sun);
		}
		cout << ans << endl;
	}
}

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

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

int s[100000 + 1];

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

		for (int i = 0; i < n-2; i++) {
			ans = max(ans, s[i] + s[i + 1]+ s[i + 2]);
		}
		cout << ans << endl;
	}
	return 0;
}

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]);
		}
		
		for (int i = 0; i < n - 1; i++){
			data[i + 1] += data[i];
		}
		int max = 0;
		for (int i = 0; i <= (n - k); i++){
			int tmp = data[i + k] - data[i];
			for (int j = i; j < (i + k); j++){
				if (data[j] < 0) tmp += data[j];
			}
			max = MAX(max, tmp);
		}
		
		/*
		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 <algorithm>
#include <vector>
using namespace std;

int main() {
	int n, k, tmp;
	while (cin >> n >> k, n||k) {
		vector<int> dt, ans;
		for (int i=0; i<n; i++) {
			cin >> tmp;
			dt.push_back(tmp);
			if (i > 1) {
				int sum = 0;
				for(int j=k; j>0; j--)
					sum += dt[i-j+1];
				ans.push_back(sum);
			}
		}
		sort(ans.rbegin(), ans.rend());
		cout << ans[0] << endl;
	}

	return 0;
}

C++: #include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int n,k,a,max;
  int set[100001];
  while(1){
    scanf("%d %d",&n,&k);
  if(n==0 && k==0)break;
  max=0;
  for(int i=0;i<n;i++){
    scanf("%d",&set[i]);
  }

  for(int i=0,sum=0;i<n-k;i++,sum=0){
    for(int j=i;j<i+k;j++){
      sum += set[j];
    }
    if(max<sum || i==1){
      max=sum;
    }
  }
  printf("%d\n",max);
  }
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){

	int n,k,s,data;
	s = 0;
	
	while(cin >> n,n){
	cin >> k;
	vector<int> sum;	

	rep(i,n){
		cin >> data;
		sum.push_back(data);
	}

	rep(i,k){
		if( s < sum[i] + sum[i+1] + sum[i+2]) s = sum[i] + sum[i+1] + sum[i+2];
	}

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