Go: package main

import "fmt"

func main() {

	for true {
		var n, k int
		fmt.Scan(&n, &k)

		if n == 0 && k == 0 {
			return
		}
		
		a := make([]int, n)
		ans := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
			if i == 0 {
				ans[i] = a[i]
			} else {
				ans[i] = ans[i-1] + a[i]
			}
		}
		max := 0
		for i := k; i < n; i++ {
			t := ans[i] - ans[i-k]
			if max < t {
				max = t
			}
		}
		fmt.Println(max)
	}
}

C++: #include <iostream>
#include <queue>
using namespace std;
int main(){
	queue<int> a;
	int n,k,num,max,tmp;
	max=tmp=0;
	cin >> n >> k;
	for(int i=0;i<k;i++){
		cin >> num;
		a.push(num);
		max+=num;
	}
	n-=k;
	tmp=max;
	while(n--){
		cin >> num;
		a.push(num);
		tmp+=a.back()-a.front();
		a.pop();
		if(max<tmp) max = tmp;
	}
	cout << max << endl;
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;

int a[100000] = {};

signed main() {
	int k;
	int n;
	
	cin >> n >> k;
	while (n != 0 && k != 0) {
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}

		int m = -9999999999;
		int tmp = 0;
		int cnt = 0;

		for (int i = 0; i < n; i++) {
			if (i < k) {
				tmp += a[i];
			}
			else {
				tmp -= a[i - k];
				tmp += a[i];
				m = max(m, tmp);
			}
		}

		cout << m << endl;
	}
	return 0;
}

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

int main(){

  int n,k,i,j;

  while(1){

  int a[1000003]={0};
  int max,sum[1000003]={0};

    scanf("%d %d",&n,&k);

    if(n==0 && k==0){
      break;
    }

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

    for(i=0;i<n;i++){
      if(i+k<=n){
      for(j=i;j<i+k;j++){
	sum[i]+=a[j];
      }
      }
    }

    max=sum[0];
    for(i=0;i<n;i++){
      if(sum[i]>max){
	max=sum[i];
      }
    }
  
    printf("%d\n",max);

  }

  return 0;

}

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

std::int64_t a[100000];

int main() {
	int n, k;
	while (std::cin >> n >> k, n + k != 0) {
		for (int i = 0; i < n; ++i)
			std::cin >> 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);
			}
		}

		std::cout << res << std::endl;
	}
}

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

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

using namespace std;

typedef long long ll;

ll solve(int n, int k) {
    ll a[n+1];
    a[0] = 0;
    for(int i=1;i<=n;++i){
        cin >> a[i];
        a[i] += a[i-1];
    }

    ll ans = 0LL;
    for(int i=1;i<=n-k;++i) {
        ans = max(ans, a[i+k-1]-a[i-1]);
    }
    return ans;
}

int main() {
    int n, k;
    cin >> n >> k;

    while(n) {
        cout << solve(n, k) << endl;
        cin >> n >> k;
    }
}

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

int main(){
    int n, k, a[100000], max = -1000000000;
    while( true ){
        cin >> n >> k;
        if( n == 0 && k == 0 ) break;
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        for(int i = 0; i < n-k+1; i++){
            int s = 0;
            for(int j = 0; j < k; j++){
                s += a[i+j];
            }
            if( s > max ) max = s;
        }
        cout << max << endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int num[1000000];
int main()
{
	int n, k, ans = 0, sans=0;
	while (1)
	{
		scanf("%d%d", &n, &k);
		if (n == 0 && k == 0)
			break;
		for (int i = 0; i < n; i++)
		{
			scanf("%d", &num[i]);
		}
		for (int i = 0; i < n - k; i++)
		{
			for (int j = i; j < i + k; j++)
			{
				sans += num[j];
			}
			if (ans < sans)
				ans = sans;
			sans = 0;
		}
		printf("%d\n", ans);
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int t[100000],sum,n,m,ans;
int main(){
  while(cin>>n>>m&&n&&m){
    sum=0;
    for(int i=0;i<n;i++){
      cin>>t[i];
      if(i<m)sum+=t[i];
    }
    ans=sum;
    for(int i=m;i<n;i++){
      sum+=t[i];
      sum-=t[i-m];
      ans=max(ans,sum);
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main(){
	int n, k;
	int a[100000];
	int sum = 0;
	int Max = 0;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	for(int i = 0; i < n-k+1; i++){
		sum = 0;
		for(int j = i; j < i+k; j++){
			sum += a[j];
		}
		Max = max(Max, sum);
	}
	
	cout << Max << endl;
	
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );

	while ( true )
	{
		int n, k;
		cin >> n >> k;

		if ( !( n | k ) )
		{
			break;
		}

		VI as( n );

		EACH( a, as )
		{
			cin >> a;
		}

		VI csum( 1, 0 );

		partial_sum( ALL( as ), back_inserter( csum ) );

		int res = INT_MIN;

		for ( int i = 0; i + k <= n; i++ )
		{
			res = max( res, csum[ i + k ] - csum[i] );
		}

		cout << res << endl;
	}

	return 0;
}

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 <stdio.h>
int RB[100005],ans;
int main() {int N,K,i,j=0;while (1) {scanf("%d %d",&N,&K);if (!N || N==EOF) return 0;for (i=0,K--;i<K;i++) scanf("%d",&RB[i]),j+=RB[i];ans=j;for (i=K;i<N;i++) scanf("%d",&RB[i]),j+=RB[i],(ans=(ans>j)?ans:j),j-=RB[i-K]; printf("%d\n",ans);}}