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 <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int a[100100];
int main()
{
	int n,k;
	while(1)
	{
	cin >> n >> k;
	if(n==0&&k==0)break;
	for(int i=0;i<n;i++)cin >> a[i];
	int ans=-INF;
	int base=0;
	for(int i=0;i<k;i++)base+=a[i];
	ans=base;
	for(int i=k;i<n;i++)
	{
		base-=a[i-k];
		base+=a[i];
		ans=max(ans,base);
	}
	cout << ans << endl;
	}
	return 0;
}

C++: 
#include <stdio.h>
#include <stdlib.h>
#define MAX_n 100000
int main()
{
	int n,k,a[MAX_n],i,put=0,total=0;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i+k<=n;i++)
	{
		for(int j=i;j<i+k;j++)
			total+=a[j];
		if(put<total)
			put=total;
		total=0;
	}
	printf("%d\n",put);
	//Sleep(10000);
}

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

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

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<algorithm>
using namespace std;
int n=0, k=0;
double a[100001] = {}, b[100001] = {};
long long int ans;
int main(){
	while (true){
		n = 0; k = 0;
		ans = 0;
		cin >> n >> k;
		if (n == 0 || k == 0)	break;
		for (int i = 1; i <= n; i++){
			cin >> a[i];
		}
		for (int x = 0; x<k; x++){
			b[1] += a[x+1];
		}
		for (int i = 2; i <= n; i++){
			if (a[i + k - 1] == 0)	break;
			b[i] = b[i - 1] - a[i - 1] + a[i + k - 1];
				ans = max(b[i],b[i-1]);
			}
		cout << ans << endl;
		}	
	return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<math.h>
#include<chrono>
#include<string>
#include<chrono>

using namespace std;






int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int nsize;
	int ksize;
	int a[100000];


	while (true) {
		cin >> nsize >> ksize;
		if (nsize == 0 && ksize == 0)break;
		for (int i = 0; i < nsize; i++) {
			cin >> a[i];
		}
		int maxval;
		int val = 0;
		for (int i = 0; i < ksize; i++) {
			val += a[i];
		}
		maxval = val;

		for (int i = ksize; i < nsize; i++) {
			val -= a[i - ksize];
			val += a[i];
			if (maxval < val) {
				maxval = val;
			}
		}
		cout << maxval << endl;
	}
	







	return 0;
}

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

int main(){
        while(true){
                int n,k;
                cin>>n>>k;

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

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

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

                cout<<ans<<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.resize(l+1,0);
    vector<int> lists(numn,0);
    for(int n = 0;n<numn;n++){
      cin >> num;
      lists[n] = num;
    }
    for(int k = 0;k<numn-2;k++){
      outn = lists[k] + lists[k + 1] + lists[k + 2];
      if(outp[l] < outn){
        outp[l] = outn;
      }
    }
  }
  for(int q = 0;q<outp.size();q++){
    cout << outp[q] << endl;
  }
}

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

using namespace std;

int main(){


    int n,k,ans=0,ans2;
    while(1){
    scanf("%d%d",&n,&k);
    if(n==0&&k==0)break;
    int num[n];
    for(int y=0;y<n;y++){
        scanf("%d",&num[y]);
    if(y>=k){
        for(int a=0;a<k;a++){
        ans+=num[y-k+a];
        }
        if(ans2<ans){
            ans2=ans;
        }
        ans=0;
    }}
    printf("%d\n",ans2);
    }

return 0;
}

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

int main() {
  int n,k;
  cin>>n>>k;
  vector<int> v(n);
  for(int i=0; i<n; ++i)
    cin>>v[i];

  int maxsum = 0,nsum = 0;
  for(int i=0; i<k; ++i) {
    maxsum += v[i];
    nsum += v[i];
  }
  for(int i=k; i<n; i++) {
    maxsum = max(nsum-v[i-k]+v[i], maxsum);
    nsum = nsum-v[i-k]+v[i];
  }

  cout<<maxsum<<endl;
}

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

const long long INF = 1 << 60;

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

        vector<int> a(n);
        for (int i = 0; i < n; i++) cin >> a[i];

        vector<long long> s(n + 1, 0);
        for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];

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

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

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

int main(){

  int n,k;

  while(cin >> n >> k, n, k){

    int a[100000] = {0},z = 0,x = 0;

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

    for(int i=0;i<k;i++) z += a[i];

    for(int i=k;i<n;i++){
      x = z;
      z = max(x , z + a[i] - a[i-k]);
    }

    cout << z << endl; 
  }
}

C++: #include <stdio.h>

int a[100050];

int main(void)
{
	int k, n;
	int i, j;
	int max = 0, sum;
	while (1){
		
		scanf("%d %d", &n, &k);
		
		if (n == 0 && k == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d", &a[i]);
		}
		
		for (i = 0; i < n - k; i++){
			sum = 0;
			for (j = 0; j < k; j++){
				sum += a[j + i];
			}
			if (sum > max){
				max = sum;
			}
		}
		
		printf("%d\n", max);
	}
	
	
	return (0);
}

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

typedef long long ll;
using namespace std;

ll max_sub_sum(vector<ll> accumulations, int range) {
  ll max_tmp = accumulations[range];

  for(int i = 1; i + range - 1 < accumulations.size(); i++) {
    max_tmp = max(max_tmp, accumulations[i + range - 1] - accumulations[i - 1]);
  }

  return max_tmp;
}

int main() {
  int sequence_num;
  int range;
  vector<ll> accumulations;

  while(true) {
    cin >> sequence_num >> range;

    if(sequence_num == 0 && range == 0) {
      break;
    }
    accumulations.resize(sequence_num + 1);

    accumulations[0] = 0;

    for(int i = 1; i <= sequence_num; i++) {
      int current;
      cin >> current;
      accumulations[i] = accumulations[i - 1] + current;
    }

    cout << max_sub_sum(accumulations, range) << endl;
  }
}