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 P[100001];

int main(){

int n,k;
int x,x1,x2,x3;
while(1){
scanf("%d %d",&n,&k);
if(n==0&&k==0)break;
int s=0,max=0;

for(int i=0;i<n;i++)
{scanf("%d",&P[i]);}


for(int j=0;j<k;j++)
s+=P[j];
max=s;

for(int i=k;i<n;i++)
	{s+=P[i];s-=P[i-k];

if(s>max)max=s;}

printf("%d\n",max);
}
return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

void solve16(int a, int b) {
    vector<int> v;
    REP(i,a) {
        int j;
        cin >> j;
        v.push_back(j);
    }
    vector<long> vl;
    long s = 0;
    REP(i, b) {
        s += v[i];
    }
    vl.push_back(s);
    REP(i,a-b) {
        s -= v[i];
        s += v[b+i];
        vl.push_back(s);
    }
    sort(vl.begin(), vl.end(), greater<long>());
    cout << vl[0] << endl;
}

int main() {
    int a, b;
    while(cin >> a >> b, a+b) {
        solve16(a, b);
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
		int n, k;
		double a[100001] = {}, b[100001] = {}, ans;
		cin >> n >> k;
		if (n == 0 || k == 0)	return 0;
		for (int i = 1; i <= n; i++){
			cin >> a[i];
		}
		for (int i = 1; i <= n; i++){
			for (int x = 0; x<k; x++){
				if (a[i + k] == 0) break;
				b[i] = a[i + x];
			}
			if (b[i]>b[i - 1]){
				ans = b[i];
			}
		}
		cout << ans << endl;
	return 0;
}

C++: #include <stdio.h>
int array[100000],n,k,max;

void func(int now){
	int i,j,temp=0;
	
	if(now==n-k)return;
	
	for(i=now;i<now+k;i++){
		temp+=array[i];
	}
	if(temp>max)max=temp;
	func(now+1);
}
		
		


int main(void){
	int i;
	
	while(scanf("%d",&n),n){
		max=0;
		
		scanf("%d",&k);
		for(i=0;i<n;i++){
			scanf("%d",&array[i]);
		}
		func(0);
		
		printf("%d\n",max);
		
	}
	return 0;
}

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

int main(void){
  int n , k;
  while(cin>>n>>k,n+k){
  vector<int> in(n);
  for(int i = 0 ; i < in.size() ; i ++) 
    cin>>in[i];
  int res = -(1<<22);
  for(int i = 0 ; i < in.size() - k ; i ++){
    int sum = 0;
    for(int j = i ; j < i + k ; j ++){
      sum += in[j]; 
    }
    res = max(res,sum);
  }
  
  cout<<res<<endl;
  }
}

C++: #include <stdio.h>
int main(){
while(1){
int k,n,i,j,x[100000],max=0,sum=0;
scanf("%d%d",&n,&k);
if(n==0 && k==0) break;
for(i=0;i<n;i++){
scanf("%d",&x[i]);
}
for(i=0;i<=n-k;i++){
	sum=0;
for(j=i;j<i+k;j++){
sum+=x[j];
}
if(max<sum) max=sum;
}
printf("%d\n",max);
}
return 0;
}

C++: #include<iostream>
main(){for(int n,k,a[100000],s,M,i;std::cin>>n>>k,n;printf("%d\n",M))for(M=1<<31,i=s=0;i<n;s+=a[i],k<++i&&(s-=a[i-k-1])&&M<s&&(M=s))std::cin>>a[i];}

C++: #include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef vector<int> vi;
#define MAX(X,Y) ((X)>(Y)?(X):(Y))

int main(void){
  int n, k, s, mx;
  vi vec;
  while(true){
    cin >> n >> k;
    if (n==0 && k==0) break;
    for (int i=0; i<n; i++){
      int t; cin >> t;
      vec.push_back(t);
    }
    mx = s = accumulate(vec.begin(), vec.begin()+k, 0);
    for (int i=k; i<n; i++){
      s = s-vec[i-k]+vec[i];
      mx = MAX(mx, s);
    }
    cout << mx << endl;
  }
  return 0;
}

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

int main(){
  int serchn,numn;
  int gh = 0;
  vector<int> outp;
  for(int a = 0;;a++){
    cin >> numn >> serchn;
    if(numn == 0 && serchn == 0){
      break;
    }
    outp.resize(a+1,0);
    outp[a] = 0;
    gh = 0;
    vector<int> num(numn,0);
    for(int n = 0;n<numn;n++){
      cin >> num[n];
    }
    for(int n = 0;n<serchn;n++){
      outp[a] += num[n];
    }
    gh = outp[a];
    int b = serchn;
    for(int a = 0;b<numn;a++){
      gh += num[b];
      gh -= num[a];
      if(gh > outp[a]){
        outp[a] = gh;
      }
      b += 1;
    }
  }
  for(int b = 0;b<outp.size();b++){
    cout << outp[b] << endl;
  }
  return 0;
}

C++: /**********************************************

1.
2.炭田高輝
3.sumita.takaki@gmail.com

last updated: 2013-07-10@16:54

 **********************************************/
#include<iostream>
#include<algorithm>
#include<sstream>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;


int main(void){


        while(1){
                
                int n=0;
                int k=0;
                int total=0, answer=0;
                vector<int> data(5000);

                cin >> n >> k;
                if(n==0 && k==0)break;
                
                for(int i=0; i<n; i++){
                        cin >> data[i];
                        //cout << "data[i]="<< data[i]<<endl;
                }

                for(int j=0; j<n-k+1; j++){
                        
                        if( j == 0){
                                for(int i=0; i<k; i++){
                                        total = total + data[j+i];
                                }
                                //cout << "subtotal1="<<total<<endl;
                        }else{
                                
                                total = total - data[j-1] + data[j+k-1];
                                //cout << "subtotal2="<<total<<endl;
                        }
                        //cout << "answer="<<answer<<"subtotal="<<total<<endl;
                        if( total > answer ){
                                answer = total;
                        }
                        //cout << "answer="<<answer<<endl;
                }
                
                cout << answer << endl;
                
        }

        return 0;

}

C++: #include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<set>
#include<string>
using namespace std;
int n,k,ma;
int main(){
    for(;;){
        int num[100001]={0};
        cin>>n>>k;
        if(n==0&&k==0)break;
        for(int i=0;i<n;i++){
            cin>>num[i];
        }
        for(int i=0;i<n-k;i++){
            int all=0;
            for(int j=0;j<k;j++){
                all+=num[i+j];
            }
        if(i==0)ma=all;
        ma=max(ma,all);
        }
        cout<<ma<<endl;
    }
}

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

using namespace std;

int main(){
  for(int n,k;cin>>n>>k,n|k;){
    int a[100000];
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    int s=0,ms=0;
    for(int i=0;i<k;i++){
      s+=a[i];
    }
    ms=s;
    for(int i=k;i<n;i++){
      s+=-a[i-k]+a[i];
      ms=max(ms,s);
    }
    cout<<ms<<endl;
  }
  return 0;
}