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>

int re[10001];

int main(){
	int n,k,i,j,c;
	re[0]=0;
	while(0<=scanf("%d%d",&n,&k)){
		if(n==0 && k==0)break;
		
		for(i=1;i<=n;i++){
			scanf("%d",&c);
			re[i]=re[i-1]+c;
		}
		c=re[k];
		for(i=1;i+k-1<=n;i++){
			if(c<re[i+k-1]-re[i-1])c=re[i+k-1]-re[i-1];
		}
		printf("%d\n",c);
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int n,k,box[10000]={0},sum=0,summ;
int main(){
    while(1){
        cin >> n >> k;
    if(n==0&&k==0)break;
        int ans=0;
        for(int i=0;i<k;i++){
            cin >> box[i];
            sum+=box[i];
            }
          for(int i=k;i<n;i++){
                cin >> box[i];
                sum+=box[i]-box[i-k];
                if(sum>ans)ans=sum;
        }
    cout << ans <<endl;

    }
    return 0;
}

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

int main()
{
int n,k,d,S ;
while(1){ 
cin >> n >> k ;
if(n==0&&k==0){
break;
}
vector<int> a(n) ;
for(int i=0;i<n;i++){
cin >> d ;
a.at(i)=d ;
}
S=0 ;
for(int j=0;j<k;j++){
S=S+a.at(j) ;
}
int A=0;
A=S ;
for(int l=0;l<n-k;l++){
S=S-a.at(l)+a.at(l+k);
A=max(A,S) ;
}
cout << A << endl;
}
}

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

using namespace std;

int main()
{
    int n, k;
    
    while(true)
    {
        scanf("%d", &n);
        scanf("%d", &k);
        
        if(n == 0 && k == 0) { break; }
        
        vector<int> a(n);
    
        for(int i = 0; i < n; i++)
        {
            scanf("%d", &a[i]);
        }
        
        int sum = 0;
        
        for(int i = 0; i < k; i++)
        {
            sum += a[i];
        }
        
        int ret = sum;
        
        for(int i = k; i < n; i++)
        {
            sum += (a[i] - a[i - k]);
            
            ret = max(ret, sum);
        }
        
        printf("%d\n", ret);
    }
    
    return 0;
}

C++: #include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0516 : Maximum Sum **/
int main()
{
	int N, K; cin>>N>>K;
	vector<int> a(N);
	rep(i, N) cin>>a[i];
	
	int k=0;
	rep(i, K) k+=a[i];
	
	int ans=k;
	REP(i, K, N) {
		k+=a[i]; k-=a[i-K];
		ans = max(ans, k);
	}
	cout << ans << endl;
}

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

#define rep(i, a, b) for(int i = (a); (i) < (b); i++)

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> num;
	int tmp;
	rep(i, 0, n) {
		cin >> tmp;
		num.push_back(tmp);
	}

	int s = 0;
	rep(i, 1, n-k+1) {
		tmp = 0;
		rep(j, 0, k) {
			tmp += num[i+j-1];
		}

		if(s < tmp) s = tmp;
	}

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

C++: #include<cstdio>

int main()
{
    int n,m,a[100008];
    while(~scanf("%d%d",&n,&m))
    {
        if(!n&&!m) break;
        for(int i=0;i<n;i++) scanf("%d",&a[i]);
        for(int i=0;i<m;i++) temp += a[i];
        int sum = 0,cap = 0;
        for(int i=0;i<n;i++){
            if(cap!=m){ sum += a[i]; cap++; }
            else sum += a[i]-a[i-3];
            if(sum>temp) temp=sum;
        }
        printf("%d\n",temp);
    }
    return 0;
}

C++: #include<bits/stdc++.h>

using namespace std ;

int main()
{
	int n ;
	while( cin >> n ,n )
	{
		int m ;
		cin >> m ;
		int num[ n + 1 ] ;
		num[ 0 ] = 0 ;
		for( int i = 1 ; i <= n ; i++ )
		{
			cin >> num[ i ] ;
			num[ i ] += num[ i - 1 ] ;
		}
		int ans = 0 ;
		for( int i = m ; i <= n ; i++ )
			ans = max( ans ,num[ i ] - num[ i - m ] ) ;
		cout << ans << endl ;
	}
	return 0 ;
}

C++: #include <iostream>
using namespace std;
int main()
{
	while(1)
	{
		int n,k; cin >> n >> k ;
		if(n==0 && k==0) break;
		int* a=new int[n]; int sum=0; int max=0;
		for(int i=0;i<n;i++) cin >> a[i] ;
		for(int i=0;i<k;i++) sum+=a[i];
		max=sum;
		for(int i=k;i<n;i++)
		{
			sum=sum+a[i]-a[i-k];
			if(sum>max) max=sum;
		}
		cout << max << '\n';
	}
}

C++: #include <fstream>
#include <cstdint>
#include <algorithm>
#include <cstring>

std::int64_t a[100000];

int main() {
	std::ifstream ifs("input.txt");
	std::ofstream ofs("output.txt");
	
	int n, k;
	while (ifs >> n >> k, n + k != 0) {
		for (int i = 0; i < n; ++i)
			ifs >> a[i];

		std::int64_t res = 0, mem = 0;
		for (int i = 0; i < n; ++i) {
			mem += a[i];

			if (i >= k)
				mem -= a[i - k];

			res = std::max(res, mem);
		}

		ofs << res << std::endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MAX_N 100000

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n, k, a[MAX_N+1];

int main(){
  while(scanf("%d%d", &n, &k) && n+k){
    REP(i, 1, n+1) scanf("%d", a+i);
    REP(i, 1, n+1) a[i] += a[i-1];
    int res = 0;
    REP(i, k, n+1) res = max(res, a[i] - a[i-k]);
    printf("%d\n", res);
  }
  return 0;
}

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

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;
            cin >> n >> k;
        }

    }

}