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 <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[])
{
    int n,k;
    while (cin >> n >> k) 
    {
        if (n == 0 && k==0) 
        {
            break;
        }
        vector<int> vec(n);
        //vector<int> sum(n -k +1);
        int sum=0;
        int sum_max=0;
        int input;
        for (int i = 0; i < n; i++) 
        {
            cin >> vec[i];
        }
        for (int i = 0; i < n - k + 1; i++) 
        {
            sum=0;
            for (int j = 0; j < k; j++) 
            {
                sum += vec[i + j];
            }
            if (sum_max < sum) 
            {
                sum_max = sum;
            }
        }
        cout << sum_max << 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 number[n],sum[n-k+1]={};
		for(int i=0;i<n;i++){
			cin>>number[i];
		}
		for(int i=0;i<n-k;i++){
			for(int j=0;j<k;j++){
				sum[i]+=number[i+j];
			}
		}
		
		int ans;
		for(int i=0;i<n-k-1;i++){
			ans=max(sum[i],sum[i+1]);
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}

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

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n,k,res=-1e9;
  while(cin>>n>>k,n+k){
    vector<int> ary(n);
    int sum = 0;
    rep(i,n){
      cin>>ary[i];
      sum += ary[i];
      if(i >= k){
	sum -= ary[i-k];
      }
      res = max(res,sum);
    }
    cout<<res<<endl;
  }
}

C++: #include <cstdio>

#define MAX(x, y) (x < y) ? y : x

int main(void)
{
	int n, k;
	int data[100000] = {0};
	
	while (1){
		scanf("%d %d", &n, &k);
		if (n == 0 && k == 0) break;
		for (int i = 0; i < n; i++){
			scanf("%d", &data[i]);
		}
		
		for (int i = 0; i < n - 1; i++){
			data[i + 1] += data[i];
		}
		int max = 0;
		for (int i = 0; i <= (n - k); i++){
			max = MAX(max, data[i + k] - data[i]);
		}
		/*
		int max = 0, tmp;
		for (int i = 0; i <= (n - k); i++){
			tmp = 0;
			for (int j = i; j < (i + k); j++){
				tmp += data[j];
			}
			max = MAX(max, tmp);
		}*/
		
		printf("%d\n", max);
	}
	
	return (0);
}

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

using namespace std;

int main()
{
	int n, k, s, b;
	int a[100001];
	while (1)
	{
		cin >> n >> k;
		if (n == 0 && k == 0)
			break;
		int m[100001] = { 0 };
		for (int i = 0;i < n;i++)
			cin >> a[i];

		m[0] = a[0];
		for (int i = 0;i < n;i++)
			m[i + 1] = m[i] + a[i];

		s = m[k] - m[0];
		for (int i = 0;i < n - k + 1;i++)
		{
			b = m[i + k + 1] - m[i + 1];
			if (s < b) 
				s = b;
		}

	}
	cout << s << endl;
	return 0;
}

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;
}