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 <iostream>
#include <algorithm>

using namespace std;

int main( void )
{
	int n, k, input[100000];
	while(cin >> n >> k, n | k) {
		int sum = 0;
		for(int i=0; i < n; ++i) {
			cin >> input[i];
			if(i < k) sum += input[i];
		}
		int i, j, ans = sum;
		i = 0; j = k-1;
		while(j < n-1) {
			sum -= input[i++];
			sum += input[++j];
			ans = max(ans, sum);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int num[100100];
int main(){
int n,m;
int ans=0;
while(1){
         for(int i=0;i<100100;i++)num[i]=0;
         cin>>n>>m;
         if(n==0&&m==0)break;
         for(int i=0;i<n;i++) cin>>num[i];
         for(int i=0;i<m-n;i++){
              int min=num[i]+num[i+1]+num[i+2];
              if(ans<min)ans=0;
         }
         count<<ans<<endl;
         ans=0;
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	long long n,k;
	while(1){
		cin>>n>>k;
		if(!n && !k)break;
		vector<long long> sum;
		long long num[n];
		rep(i,n)cin>>num[i];
		rep(i,n-k+1){
			long long alt=0;
			loop(j,i,i+k/2+1){
				alt+=num[j];
				if(j!=(i+k-1-j))alt+=num[i+k-1-j];
			}
			sum.push_back(alt);
		}
		sort(sum.begin(),sum.end());
		cout<<sum[sum.size()-1]<<endl;
	}
	return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	while(1){
	int k,n,s=0,cn=0;
	cin>>k>>n;
	if(k==0 && n==0){
		break;
	}
	int dat[n+10];
	for(int i=0;i<k;i++){
		cin>>dat[i];
	}
	for(int j=0;j<k-n+1;j++){
		cn=0;
		for(int k=0;k<n;k++){
			cn+=dat[j+k];
		}
		s=max(s,cn);
	}
	cout<<s<<endl;
	}
	return 0;
}

C++: #include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<set>
#include<string>
using namespace std;
int n,k,ma;
int main(){
    for(;;){
        int num[100001]={0},all=0;
        cin>>n>>k;
        if(n==0&&k==0)break;
        for(int i=0;i<n;i++){
            cin>>num[i];
        }
        for(int i=0;i<n-k;i++){
            if(i==0){
                for(int j=0;j<k;j++){
                    all+=num[i+j];
                    ma=all;
                }
                continue;
            }
        all=all-num[i-1]+num[i+k-1];
        ma=max(ma,all);
        }
        cout<<ma<<endl;
    }
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
using namespace std;
const int INF = 1 << 30;
int main(){
	int n, k;
	for (cin >> n >> k, n) {
		vector<int> a(n);
		for (int &x : a)cin >> x;
		int pos = 0;
		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum += a[i];
		}
		int max = sum;
		for (int i = 0; i < n - k; i++) {
			sum += a[i + k] - a[i];
			max = std::max(max, sum);
		}
		cout << max << endl;
	}
	return 0;
}

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

int main()
{
    int n, k, a[100000];

    while( cin >> n >> k )
    {
        if( n == 0 && k == 0 )
            break;
            
        for( int i = 0; i < n; i++ )
            cin >> a[i];
        
        int max = 0;
        for( int i = 0; i <= n - k; i++ )
        {
            int sum = 0;
            for( int j = i; j < i + k; j++ )
                sum += a[j];
            if( max < sum )
                max = sum;
        }

        cout << max << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int num[100005],ans,n,k,sum;
int main(){

    while(1){
    cin >> n >> k;
    if(n==0&&k==0)break;
    for(int i=0;i<n;i++){
            cin >> num[i];
            if(k>i)sum+=num[i];
    }


    for(int i=k;i<n;i++){
        ans=max(ans,sum);
        //cout << "#" << sum << endl;
        sum-=num[i-k];
        sum+=num[i];
    }

    cout << ans << endl;
    ans=0;
    sum=0;
    }

return 0;
}

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

using namespace std;

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

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

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

using namespace std;

int main() {
    int n,k,max=-1e9,sum=0;
    cin >> n >> k;
    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>
#include <algorithm>
using namespace std;
int main(void)
{
	for (;;)
	{
		int a,b,c,d,max=0;
		cin>>a>>b;
		int e[a];
		if (a==0&&b==0) break;
		for (c=0;c<a;c++){
			cin>>e[c];
		}
		for (c=0;c<=a-b;c++){
			for (d=1;d<b;d++){
				e[c]=e[c]+e[c+d];
			}
			if (e[c]>=max) max=e[c];
		}
		cout<<max<<endl;
	}
	return 0;
}

C++: #include <stdio.h>
int main(){
    long long int n,k,a[1000000],top;
    while(1){
        scanf("%lld%lld",&n,&k);
        if(n==0)return 0;
        scanf("%lld",&a[0]);
        for(int i=1;i<k;i++){
            scanf("%lld",&a[i]);
            a[i]+=a[i-1];
        }
        top=a[k-1];
        for(int i=k;i<n;i++){
            scanf("%lld",&a[i]);
            a[i]+=a[i-1];
            a[i]-=a[i-k];
            if(i!=k)a[i]+=a[i-k-1];
            if(a[i]>top)top=a[i];
        }
        printf("%lld\n",top);
    }
}

C++: #include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
static const int MAX = 100001;
int arr[MAX];

int main() {

    int N, k;
    long long global_max, current_max;
    for (; ;) {
        scanf("%d %d", &N, &k);
        if (N == 0 && k == 0) break;
        current_max = 0;
        for (int i = 0; i < k; i++) {
            scanf("%d", &arr[i]);
            current_max += arr[i];
        }
        global_max = current_max;
        for (int i = k; i < N; i++) {
            std::scanf("%d", &arr[i]);
            current_max += arr[i] - arr[i-k];
            global_max = max(global_max, current_max);
        }
        std::cout << global_max << std::endl;
    }
    return 0;
}