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;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using P = std::tuple<int,int>;
using ll = long long;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

// I want to delete this stupid solution ;(
#define sandwich(x) [](auto a, auto b){return (x)(a, b);}

template <typename T>
using F2 = std::function<T(T,T)>;

template <typename T, int N, typename F = std::plus<T>>
    struct SegmentTree{
        SegmentTree(T u, F f = F()){
            size = 1;
            while(size < N){
                size <<= 1;
            }

            unit = u;
            func = f;
            
            init();
        }
        void init(){
            for(int i=0;i<size;++i){
                data[i+size] = unit;
            }
            
            for(int i=size-1;i>0;--i){
                data[i] = func(data[i*2], data[i*2+1]);
            }
        }
        void update(int k, int v){
            k += size;
            data[k] = v;
            
            while(k > 1){
                k >>= 1;
                data[k] = func(data[k*2], data[k*2+1]);
            }
        }
        inline T query(int l, int r){
            return _query(l, r, 1, 0, size);
        }
        T _query(int a, int b, int k, int l, int r){
            if(b <= l || r <= a){return unit;}
            if(a <= l && r <= b){return data[k];}
            int mid = (l + r) >> 1;
            return func(_query(a, b,   2*k,   l, mid),
                        _query(a, b, 2*k+1, mid, r  ));
        }
        
        T unit, data[N*4];
        int size;
        F func;
    };

SegmentTree<ll, 100000> segtree(0);

int main(){
    //*
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    /*/
      /*/

    int N, K;
    while(true){
        std::cin >> N >> K;

        if(N == 0 && K == 0){break;}

        segtree.init();
        
        for(int i=0;i<N;++i){
            int a;
            std::cin >> a;

            segtree.update(i, a);
        }

        ll res = -1001001001001001001ll;
        for(int i=0;i+K<=N;i++){
            res = max(res, segtree.query(i, i+K));
        }

        std::cout << res << std::endl;
    }
}

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

int main( void )
{
	int n, k;
	while ( cin >> n >> k && n > 0 && k > 0 )
	{
		vector <int> a( n+1, 0 );
		vector <int> dp( n+1, 0 );

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

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

		int maxv = 0;
		for ( int i = 0; i < n+1-k; i++ )
		{
			maxv = max( maxv, dp[i+k] - dp[i] );
		}

		cout << maxv << endl;

	}
}

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



int main(){
        int n, k,max,temp,num;
        while(true) {  //ベクターに格納
                cin >> n>>k;
                if(n==k!=0) break;
                vector<double> v;
                for(int i=0;i<n;i++){
                  cin>>num; //入力をnumに代入
                  v.push_back(num); //ベクターvにプッシュ
                }

                max=0;
                temp=0;
                for(int i=0; (i+k)<=n; i++) {
                        for(int j=0; j<k; j++) {
                                temp+=v[i+j]; //tempにvのiからi+k番目までの総和を代入
                        }
                        //cout<<temp<<endl;
                        if(temp>max) max=temp; //tempが最も大きい数値ならmaxを更新
                        temp=0; //tempの初帰化
                }
                cout<<max<<endl;
        }
}

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

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

C++: /*
	0516:Maxinum Sum
*/
#include	<iostream>
#include	<vector>
#include	<algorithm>

using namespace std;

int main(void) {
	while(1) {
		int n, k;
		cin >> n >> k;
		if(n == 0 && k == 0) { break; }
		
		vector<int> inputs(n);
		
		for( int i = 0; i < (int)inputs.size(); i++ ) {
			cin >> inputs[i];
		}
		int maxNum = 0, num;
		for( int i = 0; i < (int)inputs.size() - (k - 1); i++ ) {
			if(i == 0) {
				maxNum = inputs[i] + inputs[i+1] + inputs[i+2];
			} else {
				maxNum = max(maxNum, inputs[i] + inputs[i+1] + inputs[i+2]);
			}
		}
		
		cout << maxNum << endl;
		
	}
	return 0;
}

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

int main() {
    while(1){
        int n, k; cin >> n >> k;
        if(n==0) break;
        vector<int> a(n);
        for(int i=0; i<n; i++) cin >> a[i];
        int ans=0;
        for(int i=0; i<k; i++) ans += a[i];
        int mx=ans;
        for(int i=1; i<n-k+1; i++){
            mx=mx+a[k-1+i]-a[i-1];
            ans=max(ans, mx);
        }
        cout << ans << endl;
    }
}

C++: #include<iostream>
main(){for(int n,k,a[100000],s,M,i;std::cin>>n>>k,n;printf("%d\n",M))for(M=1<<31,i=s=0;i<n;s+=a[i]-(k<i)*a[i++-k],k<i&M<s&&(M=s))std::cin>>a[i];}

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

using namespace std;

int main(void){
    int i,n,k,a[100100],ans;
    cin >> n >> k;
    while(n!=0 && k!=0){
        ans = 0;
        a[0] = 0;
        for(i=1; i<=n; i++){
            cin >> a[i];
            a[i] += a[i-1];
        }
        for(i=k; i<=n; i++){
            ans = max(ans,a[i]-a[i-k]);
        }
        cout << ans << endl;
        cin >> n >> k;
    }
    return 0;
}

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

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

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

using namespace std;

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

C++: #include<iostream>
using namespace std;
int main(){
	int cnt,n,m,dat[110000];
	while(1){
	cin>>n>>m;
	if(n==0 && m==0){
		break;
	}
	for(int i=0;i<n;i++){
		cin>>dat[i];
	}
	int ans=0;
	int cnt=0;
	for(int i=0;i<m;i++){
		ans+=dat[i];
	}
	cnt=ans;
	for(int i=m;i<n;i++){
		cnt+=dat[i]-dat[i-m];
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
	}
	return 0;
}