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 n, k;
int a[100000];
int ra[100001];	//ra[i] = a[0] + ??? + a[i-1]

int main() {
	while (cin >> n >> k) {
		if (!n) { break; }
		ra[0] = 0;
		for (int i = 0; i < n; i++) {
			ra[i+1] = ra[i] + a[i];
		}

		int ans = -1000000001;
		for (int i = k; i <= n; i++) {
			ans = max(ans, ra[i] - ra[i-k]);
		}

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

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
    while(1){
    int n,k;
    cin >> n >> k;
    if(n==0 && k==0){
        break;
    }
    vector<int>a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int s=0;
    int m=0;

    while(s+2<n){
        int cm=0;
        for(int j=0; j<k; j++){
            cm+=a[s+j];
        }
    if(cm>m){
        m=cm;
    }
    s++;
    }
    cout << m << endl;
    }
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

int main(){
    int n, k;
    int ans = -50000;
    int sum = 0;
    int lastNum;
    vi series;
    cin >> n >> k;

    for(int i=0; i < n; i++){
        int m;
        cin >> m;
        series.push_back(m);

        if(i < k-1) sum += m;
        else {
            sum += m-series[i-3];
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;

}

C++: #include<iostream>
#include<stdio.h>

using namespace std;


int main(){

while(1){
    int n, k;
    cin>> n>> k;
    if(n==0&&k==0) break;
    int a[n];
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }

    long long sum=0, ans=0;
    for(int i=0; i<k; i++){
        sum+=a[i];
        ans=max(ans, sum);
    }
    for(int i=0; k<n; i++, k++){
        ans=max(ans, sum);
        sum-=a[i];
        sum+=a[k];
    }

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

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

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

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    for(int count = 0;  count < 5; count++){
	    int none(2);
	    int N, k;
	    cin >> N >> k;
	    vector<int> a(N);
	    for(int i = 0; i < N; i++){
		cin >> a.at(i);
	    }
	    int ans = 0;
	    int total = 0;
	    for(int i = 0; i < N; i++){
	    	if(i < k) total += a[i];
		else total = total + a[i] - a[i-k];
		if(ans < total) ans = total;
	    }
	    cout << ans << endl;
	    for(int i = 0; i < 2; i++){
    	    cin >> none.at(i);
	    }
　　}
}

C++: #include <stdlib.h>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	vector<int> results;

	while (true) {
		int n, k;
		cin >> n >> k;
		if (n == 0 && k == 0) break;

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

		int max = 0;
		for (int i = 0; (i + k - 1) <= n; i++) {
			int s = 0;
			for (int j = i; j < (i + k); j++)
				s += a[j];

			if (max < s) max = s;
		}

		results.push_back(max);
	}

	for (int i = 0; i < results.size(); i++)
		cout << results[i] << endl;

	return 0;
}

C++: #include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define INF (1<<29)
using namespace std;
typedef long long ll;
int main(){
      int n,k;
      int a[100000];
      while(cin>>n>>k&&n&&k){
            REP(i,n)cin>>a[i];
            int sum=0;
            REP(i,k)sum+=a[i];
            int ans=sum;
            REP(i,n-k){
                  sum=sum+a[i+k]-a[i];
                  ans=max(ans,sum);
            }
            cout<<ans<<endl;
      }
}

C++: #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int N, K;
int64 a[100000];

int main() {
    while (true) {
        cin >> N >> K;
        if (N == 0 && K == 0) break;
        for (int j = 0; j < N; ++j) {
            cin >> a[j];
        }
        for (int j = 0; j < N-1; ++j) {
            a[j+1] += a[j];
        }

        int64 ans = a[K-1];
        for (int j = K; j < N; ++j) {
            ans = max(ans, a[j] - a[j-K]);
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int n,k,s,ans,term,ans_t;
vector<int> a_n;
int m,t;

int main()
{

  while(1){
    m = 0;
    cin>>n>>k;

    if(n == 0 && k == 0){
      break;
    }

    for(int q = 0;q < n;++q){
      cin>>term;
      a_n.push_back(term);
    }

    for(int q =	0;q<n;++q){
      if(q<k){
        ans_t += a_n[q];
        ans = ans_t;
      }
      else{
        m = ans_t	+ a_n[q] - a_n[q-k];
        if(m > ans){
          ans = m;
	}
        ans_t =	m;
      }
    }

    cout<<ans<<endl;
  }

  return 0;
}

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

int main() {
    int n, k;
    while(cin >> n >> k, n) {
        vector<int> a(n);
        for(int i=0; i<n; ++i) {
            cin >> a[i];
        }
        int sum = 0;
        for(int i=0; i<k; ++i) {
            sum += a[i];
        }
        int res = sum;
        for(int i=k; i<n; ++i) {
            sum = sum - a[i-k] + a[i];
            res = max(res, sum);
        }
        cout << res << endl;
    }
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;

using namespace std;

int solve(int n,int k){
    int a[100000];
    ll sum=0,ans=0;
    
    
    
    for(int i=0;i<k;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    
    ans=sum;
    
    for(int i=k;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i]-a[i-k];
        ans=max(ans,sum);
    }
    
    printf("%lld\n",ans);
    
    return 0;
}

int main(){
    int n,k;
    
    while(1){
        scanf("%d%d",&n,&k);
        if(n+k==0)
            break;
        solve(n,k);
    }
    
    return 0;
}

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

int main(){

  int n, k;
  
  while(cin >> n >> k, n|k){
    
    int ans, = 0, data[111111] = {};
    for(int i=0;i<n;i++) cin >> data[i];
    for(int i=1;i<n;i++) data[i] += data[i-1];
    
    for(int i=0;i<n-k;i++) ans = max(ans, data[i+k] - data[i]);
    
    cout << ans << endl;
  }
  
}