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>

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 input;
        for (int i = 0; i < n; i++) 
        {
            cin >> vec[i];//input;
            //vec.push_back(input);
        }
        for (int i = 0; i < n - k + 1; i++) 
        {
            sum[i]=0;
            for (int j = 0; j < k; j++) 
            {
                sum[i] += vec[i + j];
                //cout << " " << vec[i+j] << endl;
            }
            //cout << "sum="<< sum[i] << endl;
        }
        //for (int i = 0; i < n-k+1; i++) 
        //{
        //    cout << vec[i]<<endl;
        //}
        sort(sum.begin(), sum.end() , greater<int>() );
        //for (int i = 0; i < n-k+1; i++) 
        //{
        //    cout << vec[i]<<endl;
        //}
        cout << sum[0];
    }
    return 0;
}

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

int main(){
  int n;
  int k;
  int temp;

  while(cin>>n>>k,n,k){
    vector<int> data;
    int max=0;

    for(int i=0;i<n;++i){
      cin>>temp;
      data.push_back(temp);
    }
    
    for(int i=0;i<n-k+1;++i){
      int total=0;
      for(int j=i;j<k+i;++j){
	total+=data[j];
      }
      if(max<total)
	max=total;
    }
    cout<<max<<endl;
  }
}

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

template<typename T>
class CumulativeSum{
public:
  
  int n;
  vector<T> A, S;
  
  CumulativeSum(){ assert( false && "引数がありません" ); };
  CumulativeSum(vector<T> Array) : A(Array) { n = (int)A.size(); apply(); };
  
  // 初期値からAに変更があった場合、この関数を使うまでSが更新されないことに注意
  void apply(){
    S = vector<T>( n + 1 );
    for(int i=1;i<=n;i++) S[i] = S[i-1] + A[i-1];
  }
  
  // 0 origin
  void update(int k, T v){ A[k] = v; }
  
  // 0 origin, [ begin, end )
  T get(int begin, int end){ return S[end] - S[begin]; }
  
};

signed main(){
  
  int n, k;

  while(1){
    
    vector<int> A;

    cin >> n >> k;
    
    if( !n && !k ) break;
    
    for(int i=0;i<n;i++){
      int a;
      cin >> a;
      A.push_back( a );
    }
  
    CumulativeSum<int> C( A );
    
    int ans = -1e10;
    
    for(int i=0;i<n;i++){
      if( n <= i + k ) break;
      ans = max( ans, C.get( i, i + k ) );
    }

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

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<set>
#include<iomanip>
using namespace std;
using ll=long long int;

int main() {

	int n, k;
	while (cin >> n >> k, n ) {
		vector <ll> a(n);
		for (int i = 0; i < n; i++)cin >> a[i];

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

		ll res = -100000000001;

		for (int i = 0; i <= n - k ; i++) {
			ll sum = s[i + k] - s[i];
			res = max(res, sum);
			
		}
		cout << res << endl;
	}


	return 0;
}

C++: //Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#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 pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
int main()
{
while(1)
{
	int n,k;
	scanf("%d %d",&n,&k);
	if(!n) return 0;
	int ret=-INF;
	int res=0;
	queue<int>que;
	for(int i=0;i<k;i++)
	{
		int s; scanf("%d",&s);
		res+=s;
		que.push(s);
	}
	ret=max(ret,res);
	for(int i=k;i<n;i++)
	{
		int s; scanf("%d",&s);
		res+=s;
		res-=(que.front());
		ret=max(ret,res);
		que.pop();
		que.push(s);
	}
	printf("%d\n",ret);
}
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int n,a[100001],k,sum,p;
int main(){
int i,j,h;
cin>>n>>k;
for(i=1;i<=n;i++){
a[i]=0;
}
while(1){
cin>>a[1];
for(i=2;i<=n;i++){
cin>>a[i];
a[i]+=a[i-1];
}
for(i=1;i<=n;i++){
	for(j=i;j<=i+k;j++){
		p=a[i+k]-a[j];
		if(p>=sum){
			sum=p;
		}
	}
}
cout<<sum<<endl;
cin>>n>>k;
if(n==0&&k==0)break;
for(i=1;i<=n;i++){
a[i]=0;
}
cin>>a[1];
}
return 0;
}

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

#define MAX_N 100010
int N, K;
int S[MAX_N];

int main() {
  while (true) {
  cin >> N >> K;
  if (N == 0 && K == 0) break;
  int ans = INT_MIN;
  for (int i=0; i<N; i++) cin >> S[i];

  for (int i=0; i<=N-K; i++) {
    int t = 0;
    for (int j=0; j<K; j++) t += S[i+j];
    ans = max(ans, t);
  }
  cout << ans << "\n";
  }
  return 0;
}

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

using namespace std;

int main(){
  int n,k;
  int sum1=0 , max = 0;
  int now = 0, nextdata, next;
  int* s;
  while(1){
    sum1 = 0;
    max = 0;
    cin >>n >>k;

    if(n == 0) break;

    s = (int*)malloc(sizeof(int) * n);

    int data;
    for(int i = 0; i<k; i++){
      cin >>data;
      s[i] = data;
      sum1 += data;
    }
    max = sum1;
    now = n-1;

    for(int i = 0; i<n-k; i++){
      cin >>data;
      if(now+1 == n) {
	next = 0;
	nextdata = s[0];
      } else{
	next = now + 1;
	nextdata = s[next];
      }

      sum1 = sum1- nextdata + data;
      if( sum1 > max) max = sum1;
      now = next;
    }

    cout << max << endl;
    }
  return 0;
}

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

int main(){
	int n, k, x, maxnum = 0;
	cin >> n >> k;
	int wa[100000];
	for(int i=0;i<100000;i++) wa[i] = 0;
	for(int i=0;i<n;i++){
		cin >> x;
		for(int j=0;j<k;j++){
			wa[i+j] += x;
		}
	}
	cin >> x >> x;
	for(int i=k-2;i<n;i++){
		if(maxnum < wa[i]) maxnum = wa[i];
	}
	cout << maxnum;
}

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

int main() {
    int n,k,i,ans=0;
    cin >> n >> k;
    while(n!=0 || k!=0){
        int a[n+1],sum[n+1],S[n+1];
        cin >> a[0];
        sum[0]=a[0];
    
        for(i=1;i<n;++i){
            cin >> a[i];
            sum[i] = sum[i-1] + a[i];//2n
        }
    
        for(i=0;i<n-k+1;++i){
        S[i]=S[i+k-1]-S[i];
        ans = min(ans,S[i]);
        }
    
        cout << ans << endl;
        cin >> n >> k;
    }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
	for (;;)
	{
		int a,b,c,d,e[100000]={0},max=0;
		cin>>a>>b;
		if (a==0&&b==0) break;
		for (c=0;c<a;c++){
			cin>>d;
			e[c]=d;
		}
		for (int f=0;f<=a-b;f++){
			for (int g=1;g<b;g++){
				e[f]=e[f]+e[f+g];
			}
			if (e[f]>=max) max=e[f];
		}
		cout<<max<<endl;
	}
	return 0;
}