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<stdio.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,n) for(int i=1;i<=n;i++)

int n,k;
int aa[111111];

int getinput(){
	scanf("%d%d",&n,&k);
	if(n==0)return -1;
	rep(i,n)scanf("%d",&aa[i]);
	return 1;
}


int getfirstsum(int left,int right){
	if(left==right)return aa[left];
	return getfirstsum(left,(left+right)/2) +
			 getfirstsum((left+right)/2+1,right);
}

int main(void){
	while(1){
		if(getinput()==-1)break;
		
		int a = getfirstsum(0,k-1);
		int ans=a;
		rep(i,n-k){
			a = a-aa[i]+aa[i+k];
			if(ans<a){
				ans=a;
			}
		}
		
		printf("%d\n",ans);
	}
}

C++: #include<iostream>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    while(n!=0||k!=0){
       vector<int> a(n);
        cin >> a;
        S[0]=0;
        for(int i=1;i<n;i++){
            S[i]=S[i-1]+a.at(i-1);
        }
        int x=S[k];
        for(int l=1;l<n-k;l++){
            if(x<S[k+l]-S[l]){
                x=S[k+l]-S[l];
            }
        }
        cout << x << endl;
        cin >> n >> k;
        

    }

}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    int n , k;
    cin >> n >> k;
    while(n!=0|| k!=0){
    vector<int>a(n);
    for(int i = 0;i < n;i++){
      cin >> a.at(i);
    }
   vector<int>S(n+1);
   S.at(0) = 0;
   for(int i = 0;i < n;i++){
     S.at(i+1) = S.at(i) + a.at(i);
   }
   int ans = 0;
   for(int i = 0;i+k < n+1;i++){
     if(S.at(i+k)-S.at(i) > ans)
     ans = S.at(i+k) - S.at(i);
   }
   cout << ans << endl;
   cin >> n >> k;
    }
 }

C++: #include<bits/stdc++.h>
#define LL long long
#define rep(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
static const LL INF = 1LL<<61LL;
static const int MAX_N = 1<<18;
typedef pair<int,int> PII;

LL S[MAX_N+1],n,m;
LL ans;

class BIT{
    public:
        int N;
        void init(int _N){
            N=_N;
            rep(i,N+1)S[i]=0;
        }

        LL getSum(int i){
            LL s=0;
            while(i){
                s+=S[i];
                i-=i&-i;
            }
            return s;
        }

        void add(int i,int x){
            while(i<=N){
                S[i]+=x;
                i+=i&-i;
            }
        }
};

int main(){
    while(1){
        BIT bit;
        int t=0;
        cin>>n>>m;
        if(n==0&&m==0)break;
        bit.init(n);
        FOR(i,1,n){
            int x;
            cin>>x;
            bit.add(i,x);
        }
        FOR(i,m,n-m+1){
            LL query=bit.getSum(i)-bit.getSum(t);
            ans=max(query,ans);
            t++;
        }
        cout<<ans<<endl;
        ans=0;
    }
    return 0;
}

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

using namespace std;

int n, k ,i = 0, a[100000];
long long int b[100000];
long long int result[100][2];

int main()
{
	for (;; i++)
	{
		cin >> n >> k;
		if (n == 0)
		{
			break;
		}

		for (int p = 0; p < n; p++)
		{
			cin >> a[p];
		}

		for (int p = 0; p < n - k; p++)
		{
			for (int q = 0; q < k; q++)
			{
				result[i][0] += a[p + q];
			}
			result[i][1] = max(result[i][0], result[i][1]);
			result[i][0] = 0;
		}
	}
	for (int p = 0; p < i; p++)
	{
		cout << result[p][1] << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
	vector<int> sum;
	int n,m,x,max;
	cin>>n>>m;
	cin>>x;
	sum.push_back(0);
	sum.push_back(x);
	max=-1000000;
	for(int i=2;i<=n;i++){
		cin>>x;
		sum.push_back(sum[i-1]+x);
	}
	for(int i=0;i<n;i++){
		if(sum[m+i]-sum[i]>max)
		max=sum[m+i]-sum[i];
	}
	cout<<max<<endl;
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,k,a[100000],s[100001];
  long long b=-1000000000,c;
  cin >> n >> k;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n; i++) {
    s[i+1]=s[i]+a[i];
  }
  for(int i=0; i<=n-k; i++) {
    c=s[k+i]-s[i];
    if(b<c) {
      b=c;
    }
  }
  cout << b << endl;
}

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

int main(){
	int n, k, x, maxnum = 0;
	ifstream ifs;
	ifs.open("input.txt");
	ifs >> n >> k;
	int wa[100000];
	for(int i=0;i<100000;i++) wa[i] = 0;
	for(int i=0;i<n;i++){
		ifs >> x;
		for(int j=0;j<k;j++){
			wa[i+j] += x;
		}

	}
	ifs.close();
	ofstream ofs;
	ofs.open( "output.txt" );
	for(int i=0;i<n;i++){
		if(maxnum < wa[i]) maxnum = wa[i];
	}
	ofs << maxnum;
	ofs.close();
}

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

int main() {
	
	while(true){
	int n,k;
	cin >> n >> k;
	if(n==0&&k==0)break;
	
	vector<int> s(n);
	for(int i=0;i<n;i++){
		cin >> s[i];
	}
	int sum=0;
	for(int i=0;i<k;i++){
		sum+=s[i];
	}
	int ans = sum;
	for(int i=0;i+k<n;i++){
		sum+=s[i+k]-s[i];
		if(sum>ans)ans=sum;
	}
	cout << ans << endl;
	}
	
	return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<limits>
#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>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
ll bit[100010];
int n;
int k;
ll sum(int i){
	ll s = 0;
	while(i > 0){
		s +=bit[i];
		i -=i&-i;
	}
	return s;
}

void add(int i,int x){
	while(i <=n){
		bit[i] +=x;
		i +=i&-i;
	}
}

int main(){
	while(cin>>n>>k,n||k){
		memset(bit,0,sizeof(bit));
		for(int i = 0;i < n;i++){
			int num;
			cin>>num;
			add(i+1,num);
		}
		ll res =numeric_limits<ll>::min();
		for(int i = 1;i+k-1<=n;i++){
			res =max(sum(i+k-1)-sum(i-1),res);
		}
		cout <<res<<endl;
	}
	return 0;
}

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

int main() {
	// your code goes here
	int n,m;
	cin>>n>>m;
	while(n!=0||m!=0){
		int a[100100];
		for(int i=0;i<n;i++){
			int aa;
			cin>>aa;
			a[i]=aa;
		}
		int sum=0;
		int max=0;
		for(int i=0;i<m;i++){
		 sum=sum+a[i];
			
		}
		//cout<<sum<<endl;
		max=sum;
		for(int i=0;i<n-m;i++){
		sum=sum-a[i]+a[m+i]	;
		//cout<<sum<<endl;
		if(sum>max) max=sum;
		//cout<<max<<endl;
		}
		cout<<max<<endl;
		cin>>n>>m;
	}
	return 0;
}

C++: aaaaaaaaa

C++: #include<iostream>
using namespace std;
int main(){
  int n,k;
  while(cin>>n>>k){
    if(n==0&&k==0) break;
    int s[n],ans=0,su=0;
    for(int i=0;i<n;i++) cin >> s[i];
    for(int i=0;i<k;i++) su += s[i];
    ans = su; 
    for(int i=k;i<n;i++){
      su += (s[i] - s[i-k]);
      if(ans<su) ans = su;
    }
    cout << ans << endl;
  }
  return 0;
}