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>
#include <algorithm>
using namespace std;
int main(void)
{
	for (;;)
	{
		int a,b,c,d,max=0,m;
		cin>>a>>b;
		int e[a];
		if (a==0&&b==0) break;
		for (c=0;c<a;c++){
			cin>>e[c];
		}
		m=a-b;
		for (c=0;c<=m;c++){
			for (d=1;d<b;d++){
				e[c]=e[c]+e[c+d];
			}
			if (e[c]>=max) max=e[c];
		}
		cout<<max<<endl;
	}
	return 0;
}

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

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

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,k,sum=0,num,box[10000],ans=0;
    while(1){
    cin>>n>>k;
    if(n==0&&k==0)break;
    for(int i=0;i<n;i++){
        cin>>num;
        for(int j=0;j<k;j++){
            if(i==j){
                sum+=num;
                box[j]=num;
                break;
            }
            else if(i>=k&&j==k-1){
                if(sum-box[0]+num>ans)ans=sum-box[0]+num;
                sum+=num-box[0];
            }
        }
        if(i>=k){
            for(int j=0;j<k;j++){
                if(j==k-1){
                    box[j]=num;
                }
                else box[j]=box[j+1];
            }
        }
    }
    cout<<ans<<endl;
    }
}

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;
        cin>>n>>k;
        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;



    return 0;
}

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

long long int sum,k,n,ans,num[10000050];

int main(){

    cin >> n >> k;

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

    for(int i=0;i<n-k;i++){
        for(int j=i;j<i+k;j++){
            sum+=num[j];
        }
        if(ans<sum)ans=sum;
        sum=0;
    }

    cout << ans << endl;

return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vec> vec2;
typedef map<ll,ll> MPll;
typedef set<ll> setl;

const ll INF = 1ll << 60;
const ld EPS = 1e-10;



signed main(){
    ll n,k;
    bool flag = true;
    while(flag) {
        cin >> n;
        cin >> k;
        if(n == 0 and k == 0){
            return 0;
        }
        vec A(n + 1, 0);
        ll a;
        for (ll i = 1; i < n + 1; i++) {
            cin >> a;
            A[i] = A[i - 1] + a;
        };

        ll max = -9223372036854775808;
        ll temp;
        for (int j = k+1; j < n + 1; ++j) {
            temp = A[j] - A[j - k];
            amax(max, temp);
        }

        cout << max<<endl;
    }

}

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

int main(){
	int n, k;
	//while( scanf("%d %d", &n, &k), n!=0 && k ){
		scanf("%d %d", &n, &k);
		vector<int> data(n);
		for( int i=0; i<n; i++ ){
			scanf("%d", &data[i]);
		}
		int ans = 0;
		for( int i=0; i<n-k; i++ ){
			int sum = 0;
			for( int j=0; j<k; j++ ) sum += data[i+j];
			ans = max(ans, sum);
		}
		printf("%d\n", ans);
	//}
}

C++: #include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, m, a[100009];
int main() {
	while (scanf("%d%d", &n, &m), n) {
		for (int i = 0; i < n; i++) scanf("%d", &a[i]);
		int sum = 0;
		for (int i = 0; i < m; i++) sum += a[i];
		int ret = sum;
		for (int i = m; i < n; i++) {
			sum += a[i] - a[i - m];
			ret = max(ret, sum);
		}
		printf("%d\n", ret);
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int n,k,ans;
int main(){
	while(1){
	cin>>n>>k;
	if(!n)break;
	ans=0;
	int a[n+2];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n-3;i++){
		int cnt=0;
		for(int j=0;j<k;j++){
		cnt=cnt+a[i+j];
		}
		ans=max(cnt,ans);
	}
	cout<<ans<<endl;
	}

	return 0;
	

}

C++: #include <iostream>
using namespace std;
int main(){
        while(true){
                int n,number[1000000],k;
                long long int num=0,max=-1000000000;
                cin >> n >> k;
                if(n+k==0)      break;
                for(int i=0 ; i<n ; i++ )
                        cin >> number[i];
                for(int i=0 ; i<n-k ; i++ ){
                        num=0;
                        for(int j=0 ; j<k ; j++ ){
                                num+=number[i+j];
                        }
                        if(max<num)
                                max=num;
                }
                cout << max << endl;

        }
        return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec.at(i);
    }
    vector<int> rsw(n+1);
    rsw.at(0)=0;
    for(int i=1;i<n+1;i++){
        rsw.at(i) = rsw.at(i-1) + vec.at(i-1);
    }
    int ans =0;
    for(int i =k;i<n+1;i++){
        if(ans < rsw.at(i) - rsw.at(i-k)){
            ans = rsw.at(i) - rsw.at(i-k);
        }
    }
    cout << ans << endl;
}