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

using namespace std;

int main(int argc, char **argv)
{
	int n, m, *a, tmp;
	
	while(1){
		cin >> n >> m;
		if(n == 0){
			break;
		}
		a = (int *)calloc(n, sizeof(int));
		
		for(int i = 0; i < n; i++){
			cin >> tmp;
			a[i] = tmp;
		}
		
		tmp = 0;
		for(int i = 0, tmp2 = 0; i <= (n-m); i++, tmp2 = 0){
			for(int j = 0; j < m; j++){
				tmp2 += a[i+j];
			}
			if(tmp < tmp2){
				tmp = tmp2;
			}
		}
		
		cout << tmp << endl;
		free(a);
	}
	
	return 0;
}

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



int main(){
        int n, k,max,temp,num,total;
        while(true) {  //ベクターに格納
                cin >> n>>k;
                if(n==k!=0) break;
                vector<double> v;
                total=0;
                v.push_back(total);
                for(int i=0;i<n;i++){
                  cin>>num; //入力をnumに代入
                  total+=num;
                  v.push_back(total); //ベクターvにプッシュ
                }

                max=0;
                temp=0;
                for(int i=0; i+k<=n; i++) {
                        temp=v[i+k]-v[i];
                        if(temp>max) max=temp; //tempが最も大きい数値ならmaxを更新
                        temp=0; //tempの初帰化
                }
                cout<<max<<endl;
        }
}

C++: #include<iostream>
using namespace std;
int a[1000000]
int main(){
	int i,i2,n,k,max=-100000000,sum;
	cin>>n>>k;
	while(n!=0){
		for(i=1;i<=n;i++)cin>>a[i];
		for(i=1;i<=n-k+1;i++){
			sum=0;
			for(i2=i;i2<i+k;i2++)sum+=a[i2];
			if(sum>max){
				max=sum;
			}
		}
		cout<<max<<endl;
		cin>>n>>k;
	}
}
/*#include <stdio.h>
 
int a[100000];
 
int main() {
  int i, j, n, m, k, t;
  while (1) {
    scanf("%d%d", &n, &k);
    if (!n && !k) break;
    for (i = 0; i < n; i++) ~scanf("%d",a+i);
    for (i = m = 0; i < n - k; i++) {
      for (j = t = 0; j < k; j++) t += a[i+j];
      if (t > m) m = t;
    }
    printf("%d\n", m);
  }
  return 0;
}*/

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

int main(){
	int n,k,max=0,*a,buf;
	
	cin >> n >> k;
	
	a = new int[n];
	
	for(int i = 0; i < n; i++){
		cin >> a[n];
	}
	
	for(int i = 0; i < n-k; i++){
		buf = 0;
		
		for(int j = 0; j < k; j++){
			buf += a[i+j];
		}
		
		if(max < buf){
			max = buf;
		}
	}
	
	cout << max << endl;
	
	return 0;
}

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

int main(){
	int n, k;
	int input[100000];
	int sun;
	int ans = 0;
	cin >> n >> k;

	for(int i=0; i < n; i++) cin >> input[i];

	for(int i=0; i < n-k; i++){
		sun = 0;
		for(int j=i; j < i+k; j++){
			sun += input[j];
		}
		ans = max(ans, sun);
	}
	cout << ans << endl;
}

C++: #include <iostream>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int a,b
  while(cin>>a>>b,a){
    int c[a],w=0;
    r(i,a)cin>>c[i];
    r(i,a-2)w=max(w,c[i]+c[i+2]+c[i+1];
    cout<<w<<endl;
  }
}

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) * k);

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

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

      sum1 = sum1- nextdata + data;
      if( sum1 > max) max = sum1;
      now = next;
      s[now] = data;
      /*for(int j = 0; j < k; j++){
	cout << s[j]<<" ";
      }
      cout << endl;*/
    }

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

C++: #include<iostream>

using namespace std;

int main(){
	
	while(1){
		int n,m;
		
		cin>>n>>m;
		
		if(n==0 && m ==0){
			break;
		}
		int input[100000];
		
		for(int i=0;i<n;i++){
			cin>>input[i];
		}
		
		int cont = m;
		
		int now = 0;
		for(int i=0;i<m;i++){
			now += input[i];
		}
		
		
		int max = now;
		for(int i=m;i<n;i++){
			now-=input[i-m];
			now+=input[i];
			
			if(now>max){
				max=now;
			}
		}
	
	cout<<max<<endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>
using namespace std;

int main()
{
	while (1)
	{
		int a = 0, b = 0;
		double c = -1000;
		double as = 0;
		cin >> a;
		cin >> b;
		if (a == 0 && b == 0)
		{
			break;
		}
		vector<double> size;
		for (int i = 0; i < a; i++)
		{
			int w;
			cin >> w;
			size.push_back(w);
		}
		for (int i = 0; i < a - 2; i++)
		{
			
			for (int ii = 0; ii < b; ii++)
			{
				as += size[i + ii];
			}
			size.push_back(as);
		}
		for (int i = 0; i < a - 2; i++)
		{
			if (c < size[i + a])
			{
				c = size[i + a];
			}
		}
		cout << c << endl;
	}
	getchar();
	getchar();
	return 0;
}

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

using namespace std;

int main(){
	int n,k,sum=0,max=0;
	int a[100001];
	while(scanf("%d %d",&n,&k)){
		if(n==0&&k==0)
		break;
		for(int i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		for(int i=0;i<n;i++){
			if(i<k)
			sum+=a[i];
			else if(i>=k){
				sum+=a[i];
				sum-=a[i-k];
			}
			if(i==k-1)
			max=sum;
			else if(i>k-1){
				max=(max<sum ? sum:max);
			}
		}
		printf("%d\n",max);
	}
}

C++: #include <cstdio>

using namespace std;

typedef unsigned long long ull;

ull max1(ull a, ull b) { return a > b ? a : b; }

int main()
{
	ull n, k; scanf("%llu %llu", &n, &k);

	ull N[100001];

	for (ull i = 1; i <= n; ++i) scanf("%llu", &N[i]);

	ull sum = 0;

	for (ull i = 1; i <= k; ++i) sum += N[i];

	for (ull i = k; i < n; ++i) sum = max1(sum, sum - N[i-k+1] + N[i+1]);

	printf("%llu\n", sum);
}

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

int sum(int S[], int begin, int end) {
    int ans = 0;
    for (int i = begin; i < end; ++i) {
        ans += S[i];
    }
    return ans;
}

int main() {

    int n, k;
    cin >> n >> k;
    int S[100000] = {0};
    for (int i = 0; i < n; ++i) {
        cin >> S[i];
    }

    int m = n - k + 1;
    int tmp = 0;
    int ans = -1000000000;
    for (int i = 0; i < m; ++i) {
        int tmp = sum(S, i, i + k);
        if (ans < tmp) ans = tmp;
    }

    cin >> n >> k;
    if (n == 0 && k == 0) cout << ans << endl;

    return 0;
}

C++: #include<iostream>
#include<algorithm>
#define N 100000

using namespace std;

int main(){
  int n, k, data[N];
  while(1){
    cin >> n >> k;
    if(!n && !k) break;
    int x=0;
    for(int i=0; i<n; ++i){
      cin >> data[i];
      if(i<k) x += data[i];
    }
    int max_=x;
    for(int i=k; i<n; ++i){
      x -= data[i-k];
      x += data[i];
      max_ = max(max_, x);
    }
    cout << max_ << endl;
  }
  return 0;
}