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>
using namespace std;

int main(void)
{
  int n, k;
  int max;
  int sum;
  int num_sequence[100000];
  while (true)
  {
    cin >> n >> k;
    if ( n == 0 && k == 0 ) break;

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

    max = -999999;
    for (int j = 0; j < n-k+1; j++)
    {
      sum = 0;
      for (int i = 0; i < k; i++)
      {
        sum += num_sequence[i+j];
      }
      if ( sum > max ) max = sum;
    }

    cout << max << endl;

    //delete[] num_sequence;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<math.h>
using namespace std;
int a[100000];
int main(){
	int n,k,best,g;
	while(true){
	cin>>n>>k;
	if(n==0&&k==0)
		break;
	best=0;
	g=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i<k)
			g+=a[i];
	}
	best=g;
	for(int i=1;i<=n-k;i++){
		g+=a[i+k-1]-a[i-1];
		if(g>best)
			best=g;
	}
	cout<<best<<endl;
	}
    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,k,sum=0,num,box[10000],ans=0;
    while(1){
    cin>>n>>k;
    if(n==0&&k==0)break;
    for(int i=0;i<n;i++){
        cin>>num;
        for(int j=0;j<k;j++){
            if(i<k){
                sum+=num;
                box[i]=num;
                break;
            }
            else if(i>=k&&j==k-1){
                if(sum-box[0]+num>ans)ans=sum-box[0]+num;
                sum+=num-box[0];
            }
        }
        if(i>=k){
            for(int j=0;j<k;j++){
                if(j==k-1){
                    box[j]=num;
                }
                else box[j]=box[j+1];
            }
        }
    }
    cout<<ans<<endl;
    }
}

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

int main()
{
	while (1)
	{
		int a = 0, b = 0;
		double c = -1000;
		cin >> a;
		cin >> b;
		if (a == 0 && b == 0)
		{
			break;
		}
		vector<double> size;
		vector<double> s;
		for (int i = 0; i < a; i++)
		{
			int w;
			cin >> w;
			size.push_back(w);
		}
		for (int i = 0; i < a - 2; i++)
		{
			double as = 0;
			for (int ii = 0; ii < b; ii++)
			{
				as += size[i + ii];
			}
			s.push_back(as);
		}
		for (int i = 0; i < a - 2; i++)
		{
			if (c < s[i])
			{
				c = s[i];
			}
		}
		cout << c << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
	for (;;)
	{
		int a,b,c,d,max=0,m;
		cin>>a>>b;
		int e[a];
		if (a==0&&b==0) break;
		for (c=0;c<a;c++){
			cin>>e[c];
		}
		m=a-b;
		for (c=0;c<=m;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 <iostream>
using namespace std;

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

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,k,sum=0,num,box[10000],ans=0;
    while(1){
    cin>>n>>k;
    if(n==0&&k==0)break;
    for(int i=0;i<n;i++){
        cin>>num;
        for(int j=0;j<k;j++){
            if(i==j){
                sum+=num;
                box[j]=num;
                break;
            }
            else if(i>=k&&j==k-1){
                if(sum-box[0]+num>ans)ans=sum-box[0]+num;
                sum+=num-box[0];
            }
        }
        if(i>=k){
            for(int j=0;j<k;j++){
                if(j==k-1){
                    box[j]=num;
                }
                else box[j]=box[j+1];
            }
        }
    }
    cout<<ans<<endl;
    }
}

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

#define MAX 1000000000
#define MIN -10000000000

#define ll long long

using namespace std;
int main() {

        ll n,k,i,j,temp,last,maxx;
        cin>>n>>k;
        vector<ll> a(n);
        vector<ll> s(n+1);
        for(i=0;i<n;i++){
            cin>>a[i];
        }
        cin>>temp>>temp;
        s[0]=0;
        for(i=0;i<n;i++){
            s[i+1]=s[i]+a[i];
        }
        maxx=a[k-1]+a[0];
        for(i=0;i<n-k+1;i++){
             //   cout << s[i+k]-s[i] << endl;
                maxx=max(s[i+k]-s[i],maxx);
        }
        cout << maxx << endl;



    return 0;
}

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

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

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 <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vec> vec2;
typedef map<ll,ll> MPll;
typedef set<ll> setl;

const ll INF = 1ll << 60;
const ld EPS = 1e-10;



signed main(){
    ll n,k;
    bool flag = true;
    while(flag) {
        cin >> n;
        cin >> k;
        if(n == 0 and k == 0){
            return 0;
        }
        vec A(n + 1, 0);
        ll a;
        for (ll i = 1; i < n + 1; i++) {
            cin >> a;
            A[i] = A[i - 1] + a;
        };

        ll max = -9223372036854775808;
        ll temp;
        for (int j = k+1; j < n + 1; ++j) {
            temp = A[j] - A[j - k];
            amax(max, temp);
        }

        cout << max<<endl;
    }

}

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

int main(){
	int n, k;
	//while( scanf("%d %d", &n, &k), n!=0 && k ){
		scanf("%d %d", &n, &k);
		vector<int> data(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);
	//}
}