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>                                                                                
using namespace std;                                                                               
                                                                                                   
int N,K,dat[100000];                                                                               
long long r,t;                                                                                     
                                                                                                   
int main(){                                                                                        
    while(scanf("%d%d",&N,&K),N||K){                                                               
        for(int i=0;i<N;i++){                                                                      
            scanf("%d",dat+i);                                                                     
        }                                                                                          
        t=0;                                                                                       
        for(int i=0;i<K;i++){                                                                      
            t+=dat[i];                                                                             
        }                                                                                          
        r=t;                                                                                       
        for(int i=K;i<N;i++){                                                                      
            t=t-dat[i-K]+dat[i];                                                                   
            r=max(r,t);                                                                            
        }
        printf("%lld",r);
    }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long ll;
using namespace std;
#define INF (1 << 30)
#define INFLL (1LL << 60)
#define rep(i, n) for(int i=0; i<(n); ++i)

namespace Sum
{
	int exec(int N, int K)
	{
		vector<int> sum(N + 1, 0);
		rep(i, N) {
			int s; cin >> s;
			sum[i + 1] = sum[i] + s;
		}
		int mx = 0 - INF;
		rep(i, N - K + 1) mx = max(mx, sum[i + K] - sum[i]);
		return mx;
	}
}

int main()
{
	vector<int> anss;
	for (;;) {
		int N, K; cin >> N >> K;
		if (N == 0 || K == 0) break;
		int rz = Sum::exec(N, K);
		anss.push_back(rz);
	}
	rep(i, anss.size()) {
		cout << anss[i] << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    vector<int> ans(0);x
    while(1){
        cin>>n>>k;
        if(n==0&&k==0){
            break;
        }
        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);
        }
        ans.push_back(0);
        for(int i=k;i<n+1;i++){
            if(ans.at(ans.size()) < rsw.at(i) - rsw.at(i-k)){
                ans.at(ans.size()) = rsw.at(i) - rsw.at(i-k);
            }
        }
        cout << ans.at(ans.size()) << endl;
    }
    
}

C++: #include <iostream>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[])
{
    int n,k;
    while (cin >> n >> k) 
    {
        if (n == 0 && k==0) 
        {
            break;
        }
        vector<int> vec(n);
        int sum_max=0;
        for (int i = 0; i < n; i++) 
        {
            int sum=0;
            cin >> vec[i];
            if (k  <= i + 1) 
            {
                for (int j = 0; j < k; j++) 
                {
                    sum += vec[i - j];
                }
                sum_max = max(sum ,sum_max);
            }
        }
        cout << sum_max << endl;
    }
    return 0;
}

C++: // ruiseki-wa
#include <algorithm>
#include <cstdio>
using namespace std;

int sum[100010];
int main(void)
{
    int n, k;
    while(1) {
        scanf("%d %d", &n, &k);
        if(n==0 && k==0) break;

        int a[n];
        for(int i=0; i<n; i++) scanf("%d", &a[i]);
        for(int i=0; i<n; i++) sum[i+1] = sum[i] + a[i];

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

    return 0;
}

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

int main(void){
  int n , k;
  cin>>n>>k;
  vector<int> in(n,0);
  vector<int> dp(n,0);
  for(int i = 0 ; i < in.size() ; i ++) 
    cin>>in[i];
  int res = 0;
  for(int i = 0 ; i < in.size() - k ; i ++){
    for(int j = i ; j < i + k ; j ++){
      dp[i] += in[j]; 
    }
    res = max(res,dp[i]);
  }
  
  cout<<res<<endl;
}

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

int main(){
    int n, k;
    while(cin >>n >>k){
        if(n == 0 && k == 0) break;
        vector<int> vec;
        int max = 0, now = 0;
        for(int i = 0; i < k; i++){
            int tmp;
            cin >>tmp;
            max += tmp;
            now += tmp;
            vec.push_back(tmp);
        }
        for(int i = k; i < n; i++){
            int tmp;
            cin >>tmp;
            now += tmp;
            now -= vec[i - k];
            if(max < now) max = now;
        }
        cout <<max <<endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll MIN_A = -10000;
const ll MAX_A = -10000;

ll solve(const ll n, const ll k, const vector<ll> as) {
    ll acc = 0;
    for (int i = 0; i < k; i++) {
        acc += as[i];
    }
    ll cand = MIN_A;

    for (int i = k; i < n; i++) {
        acc -= as[i - k];
        acc += as[i];
        chmax(cand, acc);
    }

    return cand;
}

int main(void) {
    ll n, k;
    while (1) {
        cin >> n >> k;
        if (n == 0 && k == 0) {
            break;
        }

        vector<ll> as(n);
        for (int i = 0; i < n; i++) {
            cin >> as[i];
        }
        cout << solve(n, k, as) << endl;
    }
    
    return 0;
}

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

int main()
{
	while (1)
	{
		int a = 0, b = 0;
		double c = -1000;
		double as = 0;
		cin >> a;
		cin >> b;
		if (a == 0 && b == 0)
		{
			break;
		}
		vector<double> size;
		for (int i = 0; i < a; i++)
		{
			int w;
			cin >> w;
			size.push_back(w);
		}
		for (int i = 0; i < a - 2; i++)
		{
			
			for (int ii = 0; ii < b; ii++)
			{
				as += size[i + ii];
			}
			size.push_back(as);
		}
		for (int i = 0; i < a - 2; i++)
		{
			if (c < size[i + a])
			{
				c = size[i + a];
			}
		}
		cout << c << endl;
	}
	
	return 0;
}