Go: package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	parseProblem(os.Stdin)
}

func parseProblem(r io.Reader) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	for true {
		n, k := scanInt(sc), scanInt(sc)
		if n == 0 && k == 0 {
			break
		}
		sum := make([]int, n+2)
		for i := 2; i <= n+1; i++ {
			sum[i] = sum[i-1] + scanInt(sc)
		}
		max := math.MinInt32
		for i := 1; i+k <= n+1; i++ {
			if v := sum[i+k] - sum[i]; max < v {
				max = v
			}
		}
		fmt.Println(max)
	}
	return
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,n2[100001],n_sum[100001];
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>n2[i];
    }
    n_sum[0]=0;
    for(int i=1;i<=n;i++){
        n_sum[i]=n_sum[i-1]+n2[i-1];
    }
    int maxx=-10000001;
    for(int i=k-1;i<n;i++){
        int sum=0;
        sum=n_sum[i]-n_sum[i-k];
       // cout<<sum<<endl;
        maxx=max(maxx,sum);
    }
    cout<<maxx<<endl;
   // for(int i=0;i<=n;i++){
      //  cout<<n_sum[i]<<endl;
   // }
}

C++: #include <iostream>
#include <vector>
using namespace std;
const long INF = 1L<<60;

int main() {
    int N, K;
    while (cin >> N >> K) {
        if (N == 0) break;
        vector<long> a(N);
        for (int i = 0; i < N; ++i) cin >> a[i];

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

        long res = -INF;
        for (int i = 0; i <= N-K; ++i) {
            long val = s[K+i] - s[i];
            if (res < val) res = val;
        }
        cout << res << endl;
    }
}

C++: #include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0516 : Maximum Sum **/
int main()
{
	int N, K;
	while (cin>>N>>K, N||K) {
		vector<int> a(N);
		rep(i, N) cin>>a[i];
	
		int k=0;
		rep(i, K) k+=a[i];
		
		int ans=k;
		REP(i, K, N) {
			k+=a[i] - a[i-K];
			ans = max(ans, k);
		}
		cout << ans << endl;
	}
}

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

int a[200000];
int n,l,s,maxn;;

int main(){
    while(true){
        cin>>n>>l;
        if(n==0 && l==0){break;}
        for(int i=0;i<n;i++){
            cin>>a[i];
            if(i<l){s+=a[i];}
        }
        maxn=s;
        for(int i=0;i<n-l;i++){
            s-=a[i];
            s+=a[i+l];
            maxn=max(s,maxn);
        }
        cout<<maxn<<endl;
    }
}

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

  for(int i=1;i<n-1;i++){
    if(set[i-1]+set[i]+set[i+1]>max || i==1) max=set[i-1]+set[i]+set[i+1];
  }
  cout << max << endl;
  }
}

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

	return 0;
	

}

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>
using namespace std;
int main() {
	while (1) {
		int n, k, a[100005] = { 0 }, sum[100005] = { 0 };
		long long m = -9999999999;
		cin >> n >> k;
		if (n == 0 && k == 0) return 0;
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int i = 0; i < k; i++) {
			sum[0] += a[i];
		}
		for (int i = 1; i < n - 2; i++) {
			sum[i] = sum[i - 1] + a[i + 2] - a[i - 1];
		}
		for (int i = 0; i < n - 2; i++) {
			if (m < sum[i]) {
				m = sum[i];
			}
		}
		cout << m << endl;
	}
}

C++: #include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,k,a[100000],ans=0,sum=0;
    while(cin>>n>>k,n||k){
    ans=0,sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        if(i>=k)
            sum-=a[i-k];
        if(i>=k-1)
            ans=max(ans,sum);
    }
    cout<<ans<<endl;}
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    ll n,k;
    while(cin>>n>>k,n+k){
    vl dp;
    vl sum(n,0);
    rep(i,n){
        ll ujimatu; cin>>ujimatu;
        dp.push_back(ujimatu);
        if(!i)sum[i]=ujimatu;
        else if(i<k)sum[i]=sum[i-1]+ujimatu;
        else sum[i]=ujimatu+sum[i-1]-dp[i-k];
        
    }
    ll ans=-INF*INF;
    rep(i,n)if(i>=k-1)cmax(ans,sum[i]);
    ///ep(i,n)if(i>=k-1)cout<<sum[i]<<endl;
    cout<<ans<<endl;
    }
}

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

using namespace std;

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

C++: #include <cstdio>
#include <vector>
using namespace std;
#define MAX_N 100000

int main(){
	int n, k;
	scanf("%d %d", &n,&k);
	vector<int> data(MAX_N);
	for( int i=0; i<n; i++ ){
		scanf("%d", &data[i]);
	}
	int ans = 0;
	for( int i=0; i<n-k; i++ ){
		int sum = 0;
		for( int j=0; j<k; j++ ) sum += data[i+j];
		ans = max(ans, sum);
	}
	printf("%d\n", ans);
}