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 <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
#define debug(x) cout << #x << " = " << x << endl;
#define sq(x) ((x)*(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

int main(){
	int n, k;
	cin >> n >> k;
	queue<int> q;
	int sum = 0;
	int ans = 0;
	rep(i, n){
		int a;
		cin >> a;
		sum += a;
		q.push(a);
		if(q.size() > k){
			sum -= q.front();
			q.pop();
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

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

int main() {
    while (true) {
        int n, k;
        cin >> n >> k;
        if ((n | k) == 0) {
            break;
        }
        int* a = new int [n];
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        int maxS = 0;
        for (int i = 0; i < k; i++) {
            maxS += a[i];
        }
        for (int i = 1; i <= n - k; i++) {
            int s = 0;
            for (int j = i; j < i + k; j++) {
                s += a[j];
            }
            if (maxS < s) {
                maxS = s;
            }
        }
        cout << maxS << endl;
        delete[] a;
    }
}

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

int main() {
	while(1){
	int a[100000];int n,m;int b[100000];int p=0;
	cin >> n >> m;
	if(n ==0&&m == 0){break;}
	for(int i = 0;i<n;i++){
		cin >> a[i];
	}
	for(int i = 0;i<100000;i++){
		b[i]=0;
	}
	for(int i = 0;i<n-m;i++){
		if(a[i]>a[i+m]){
			for(int k = i;k<i+m;k++){
				b[p]+=a[k];
			}
			p++;
		}
	}
	for(int k = n-m;k<n;k++){
				b[p]+=a[k];
	}
	for(int i = 1;i<100000;i++){
		if(b[0]<b[i]){b[0]=b[i];}
	}
	cout << b[0]<<endl;
}
	return 0;
}

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

int main(){
  int n,k;

  while(cin >> n >> k ,n | k){
    int sum = 0;
    int array[n];

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

    int res = sum;
    for(int i = k ; i < n ; i++){
      sum += array[i];
      sum -= array[i-k];
      res = max(res,sum);
    }
    cout << res << endl;
  }

  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)








int main() {
    int a,b;
    int data[100000];
    scanf("%d",&a);
    scanf("%d",&b);
    while(a != 0 || b != 0){
        for(int i=0;i<a;i++){
            scanf("%d",&data[i]);
        }
        int max=-10000000;
        int s=0;
        for(int i=0;i<a-b+1;i++){
            s=0;
            for(int j=i;j<b+i;j++){
                s+=data[j];
            }
            if(s>=max){
                max=s;
            }
        }
        printf("%d\n",max);
        scanf("%d",&a);
        scanf("%d",&b);
    }
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

C++: #include<iostream>
#include<string.h>
using namespace std;
long long sin[100001];
int main(){
	while(1){
	memset(sin,0,sizeof(sin));
	int n,k;
	int i,j,max=0,x;
	cin>>n>>k;
		if(n==0&&k==0)break;
	for(i=0;i<n;i++){
		cin>>sin[i];
	}
	for(i=0;i<n-k+1;i++){
		x=0;
		for(j=0;j<k;j++){
			x+=sin[i+j];
		}
		if(max<x)max=x;
	}
	cout<<max<<endl;
	}
}

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

using namespace std;

int main()
{
	int n, k, num, ans, sam;
	
	while(cin >> n >> k)
	{
		queue<int> que;
		ans = 0;
		sam = 0;
		for(int i = 0; i < n; i++)
		{
			cin >> num;
			que.push(num);
			sam += num;
			if(que.size() == 3 )
			{
				if(ans < sam)
				{
					ans = sam;
				}
				sam -= que.front();
				que.pop();
			}
		}
		cout << ans << endl;
	}
}

C++: // ?´???????
#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]; // sum[i] := a[0]??????a[i-1]?????§??????(sum[0]=0)

        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;
  while(cin>>n>>k,n||k){
    int ans = -10001;
    vector<int> a(n);
    int sum=0;
    for(int i=0;i<n;++i)cin>>a[i];
    for(int i=0;i<k;++i)sum+=a[i];
    for(int i=0;i<n-k;++i){
      if(sum>ans)ans=sum;
      sum-=a[i];
      sum+=a[i+k];
    }
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int a[100010],n,k;
    while(cin>>n>>k,n||k){
        for(int i=0;i<n;i++)cin>>a[i];
        int mx=-1;
        int sum=0;
        for(int i=0;i<k;i++)sum+=a[i];
        mx=sum;
        for(int i=k;i<n;i++){
            sum-=a[i-k];
            sum+=a[i];
            mx=max(mx,sum);
            cout<<sum<<endl;
        }
        cout<<mx<<endl;
    }
}

C++: #include <iostream>
using namespace std;
int main(void){
	for (;;){
		int a,b,c,d,max=0,m;
		cin>>a>>b;
		int e[a]={0};
		if (a==0&&b==0) break;
		for (c=0;c<a;c++){
			cin>>e[c];
		}
		m=a-b;
		for (c=0;c<a-m;c++){
			for (int y=1;y<b;y++) e[c]=e[c]+e[c+y];
			if (max<e[c]) max=e[c];
	}
		cout<<max<<endl;
	}
	return 0;
}

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

int main(){
  int numn,lisn,num;
  vector<int> outp;
  int outn = 1;
  for(int l = 0;;l++){
    cin >> numn >> lisn;
    if(numn == 0 && lisn == 0){
      break;
    }
    outp.push_back(0);
    vector<int> lists(numn,0);
    for(int n = 0;n<numn;n++){
      cin >> lists[n];
    }
    for(int k = 0;k<numn-lisn+1;k++){
      outn = 0;
      for(int c = 0;c<lisn;c++){
        outn += lists[c+k];
      }
      if(outp[l] < outn){
        outp[l] = outn;
      }
    }
  }
  for(int q = 0;q<outp.size();q++){
    cout << outp[q] << endl;
  }
}