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>
using namespace std;
int main(){
	int cnt,n,m,dat[110000];
	while(1){
	cin>>n>>m;
	if(n==0 && m==0){
		break;
	}
	for(int i=0;i<n;i++){
		cin>>dat[i];
	}
	int ans=0;
	int cnt=0;
	for(int i=0;i<m;i++){
		ans+=dat[i];
	}
	cnt=ans;
	for(int i=m;i<n;i++){
		cnt+=dat[i]-dat[i-m];
		
	}
	cout<<ans<<endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(void){
	int a[100001];
	int n,k,sum,t;
	for(;;){
		scanf("%d%d",&n,&k);
		if(n==0&&k==0)return 0;
		sum=t=0;
		for(int i=0;i<n;i++){
			scanf("%d",a+i);
			t+=a[i];
			if(i>=k){
				t-=a[i-k];
				sum=max(sum,t);
			}
			//printf("t %d\n",t);
		}
		printf("%d\n",sum);
	}
}

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

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.maximumsum", "r", stdin );
	int n,k;

	while (1) {
		cin >> n >> k;

		if (n == 0 && k == 0 ){
			break;
		} // end if
		vector <int> a (n, 0 );
		vector <int> sum (n - k + 1, 0 );
 
		for (int i = 0; i < n; ++i){
			cin >> a[i];
		} // end for
		
		for (int i = 0; i < n - k + 1; ++i){
			for (int j = i; j < i + k; ++j){
				sum[i] += a[j];
			} // end for
		} // end for
		sort (sum.begin(), sum.end(), greater<int>() );
		cout << sum[0] << endl;
	} // end loop
		
	return 0;
}

C++: #include <stdio.h>

int a[100000],e[100000];
int main(){
	int b,c,d,f,g=-100000000;
	while(1){
		scanf("%d %d",&c,&b);
		if(c==0){
			return 0;
		}
		for(d=0;d<c;d++){
			scanf("%d",a[i]);
		}
		for(d=0;d<c-b;d++){
			for(f=0;f<b;f++){
				e[d]+=a[f];
			}
		}
		for(d=0;d<c-b;d++){
			if(g<=e[d]){
				g=e[d];
			}
		}
		printf("%d\n",g);
	}
}

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



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

                max=0;
                temp=0;
                for(int i=0; (i+k)<=n; i++) {
                        for(int j=0; j<k; j++) {
                                temp+=v[i+j]; //tempにvのiからi+k番目までの総和を代入
                        }
                        //cout<<temp<<endl;
                        if(temp>max) max=temp; //tempが最も大きい数値ならmaxを更新
                        temp=0; //tempの初帰化
                }
                cout<<max<<endl;
        }
}

C++: #include<iostream>
using namespace std;
int main(){
	while (true){
		int n, k;
		double a[100001] = {}, b[100001] = {}, ans;
		cin >> n >> k;
		if (n == 0 || k == 0)	break;
		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<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int cl(int a, int b) {
	return (a - (a%b)) / b;//b=0だと積む
}
int up(int a, int b) {
	return cl(a + b - 1, b);//b=0だと積む
}
int main() {
    int az=0;
    while(az==0){
    int n,k, ns,tu; int ans = 0;
	cin >> n >> k;
    if(n==0){
    az=1;
    }
    else{
	int wa = 0;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < k; i++) {
		wa = wa + a[i];
	}
	ans = wa;
	for (int i = k - 1; i+1 < n; i++) {
		wa = wa - a[i - k + 1] + a[i + 1];
		ans = max(ans, wa);
	}
	cout << ans<<endl;  
    }
    }
}

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

int main()
{
    int n,m,result;
    int num[100005];
    int memo[100000];
    while(1)
    {
        cin >> n >> m;
        if(n == 0 && m == 0)break;
        for(int i = 0; i < n; i++)cin >> num[i];
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                memo[i] = num[m-j];
            }
        }
        for(int i = 0; i < n; i++)
        {
            result = max(result,memo[i]);
        }
        cout << result << endl;
    }
    return 0;
}

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

int main() {
  for (int i = 0; i < 5; i++) {
    int n, k;
    cin >> n >> k;

    // プログラム終了の合図
    if (n == 0 && k == 0) {
      return 0;
    }

    // 累積和
    vector<int> s(n + 1, 0);
    for (int i = 1; i <= n; i++) {
      int num;
      cin >> num;
      s.at(i) = s.at(i - 1) + num;
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
      int left = i;
      int right = i + k;

      if (right > n) {
        break;
      }

      int dif = s.at(right) - s.at(left);
      ans = max(ans, dif);
    }

    cout << ans << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int a,b=0,t,j,k,n,i,s[100000+1],v,c[100000+1]={0};
	while(1)
	{
		cin>>n>>k;
		if(n==0&&k==0)
		{
			break;
		}
		for(i=0;i<n;i++)
		{
			cin>>s[i];
		}
		v=n-k+1;
		for(i=0;i<v;i++)
		{
			for(a=i;a<k+i;a++)
			{
				c[i]=c[i]+s[a];

			}
		}
		for(i=0;i<v;i++)
		{
			if(b<c[i])
			{
				b=c[i];
			}
		}
		cout<<b<<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[n];
    for(int i=0; i<n; i++){
        cin>> a[i];
    }

    long long sum=0, ans=0;
    for(int i=0; i<k; i++){
        sum+=a[i];
        ans=max(ans, sum);
    }
    for(int i=0; k<n; i++, k++){
        sum-=a[i];
        sum+=a[k];
        ans=max(ans, sum);
    }

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

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1LL<<60;

int main()
{
  ll n, k;
  while (cin>>n>>k){
    if (n == 0) continue;

    ll sum = -INF;
    vector<ll> a(n);
    rep(i, n) cin>>a[i];

    vector<ll> s(n+1, 0);
    rep(i, n) s[i+1] = s[i] + a[i];

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