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>
using namespace std;
int num[100000];
int main() {
	while(true){
	int n,k;
	cin >> n >> k;
	
	if(n==0 && k==0)
		break;
	for(int i=0;i<n;i++){
		cin >> num[i];
	}
	int now=0,maxer=0;
	for(int i=0;i<k;i++){
		now+=num[i];
	}
	maxer=now;
	for(int i=k;i<n;i++){
		now+=num[i]-num[i-k];
		maxer=max(maxer,now);
	}
	cout << maxer << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;//仮想的な無限大の値

int main() {
   int n,k;
   while(cin >> n >> k){
       if(n==0) break;
       vector<int> a(n);//普通の数字
       for(int i=0;i<n;i++){
           cin >> a[i];
       }
       vector<int> s(n+1,0);//n+1個の配列を全て0で初期化
       for(int j=0;j<n;j++){
           s[j+1] = s[j] + a[j];
       }
       int ans = -INF;
       for(int p=1;p<n-k+1;p++){
           int max1 = s[p+k] - s[p];
           ans = max(max1,ans); 
       }
       cout << ans << endl;
   }
}

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

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

		if (n == 0 && k == 0){ break; }
		else{
			int i, inp;
			int *a;
			a = new int[n];

			for (i = 0; i<n; i++){
				cin >> inp;
				a[i] = inp;
			}

			int sum1 = 0, sum2 = 0, max = 0;

			for (i = 0; i<k; i++){ sum1 += a[i]; }
			max = sum1;

			for (i = k; i<n; i++){
				sum2 = sum1 + a[i] - a[i - k];
				if (sum2>max){ max=sum2; }
				sum2 = sum1;
			}

			cout << max << endl;

			delete[] a;
		}
	}
	return 0;
}

C++: aaaaaaaaa

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

int main(){
	int n, k;
	while( scanf("%d %d", &n, &k), n!=0 && k ){
		vector<int> data(n);
		for( int i=0; i<n; i++ ){
			scanf("%d", &data[i]);
		}
		int ans = 0;
		for( int i=0; i<n-k; i++ ){
			int sum = 0;
			for( int j=0; j<k; j++ ) sum += data[i+j];
			ans = max(ans, sum);
		}
		printf("%d\n", ans);
	}
}

C++: #include<stdio.h>
int main(void)
{
	int n,k,max,s,i,j,a[100001];
	while(1){
		scanf("%d%d",&n,&k);
		if(n==0&&k==0) break;
		for(i=1;i<=n;i++) scanf("%d",&a[i]);
		max=0;
		for(i=1;i<=n;i++){
			s=0;
			if(i+k<=n){
				for(j=i;j<i+k;j++) s+=a[j];
				if(max<s) max=s;
			}
		}
		printf("%d\n",max);
	}
	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[i];
	}
	
	cout << a[0] << endl;
	
	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<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        int N,M;
        int lis[20000];
        cin>>N>>M;
        if(N==0&&M==0)break;
        for(int i=0;i<N;i++)cin>>lis[i];
        int now=0,ans=0;
        for(int i=0;i<M;i++)now+=lis[i],ans+=lis[i];
        for(int i=1;i+M<=N;i++)now=now-lis[i-1]+lis[i+M-1],ans=max(now,ans);
        cout<<ans<<endl;
    }
    return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,K;
int S[101010];
signed main(){
    while(cin>>N>>K,N||K){
    rep(i,N){
        cin>>S[i+1];
        S[i+1]+=S[i];
    }

    int ma=-1001001001001001001ll;
    for(int i=0;i+K<=N;i++)chmax(ma,S[i+K]-S[i]);
    cout<<ma<<endl;
    }
    return 0;
}

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

int a[100001],b[100001];

int f(int i,int j){
	return b[i] - b[j+1];
}

int main(){
	int n,k;
	while( cin >> n >> k , n||k ){
		b[0] = 0;
		for(int i=0 ; i < n ; i++ ){
			cin >> a[i];
			b[0] += a[i];
		}
		for(int i=1 ; i <= n ; i++ ){
			b[i] = b[i-1] - a[i-1];
		}
		int s = f(0,k-1);
		for(int i=1 ; i+k < n ; i++ ){
			s = max( s , f(i,i+k-1) );
		}
		cout << s << endl;
	}
}

C++: #include <cstdio>
#include <vector>
using namespace std;
#define MAX_N 100000

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	vector<int> data(MAX_N);
	for( int i=0; i<n; i++ ){
		scanf("%d", &data[i]);
	}
	int ans = 0;
	for( int i=0; i<=n-k; i++ ){
		int sum = 0;
		for( int j=0; j<k; j++ ) sum += data[i+j];
		ans = max(ans, sum);
	}
	printf("%d\n", ans);
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,k,sum=0,num,box[10000],ans=0;
    while(1){
    cin>>n>>k;
    if(n==0&&k==0)break;
    if(n==k){
        for(int i=0;i<n;i++){
            cin>>num;
            ans+=num;
        }
    }
    else{
    for(int i=0;i<n;i++){
        cin>>num;
            if(i<k){
            sum+=num;
            box[i]=num;
        }
        else if(i>=k){
            if(sum-box[0]+num>ans)ans=sum-box[0]+num;
            sum+=num-box[0];
            for(int j=0;j<k;j++){
                if(j==k-1){
                    box[j]=num;
                }
                else box[j]=box[j+1];
            }
        }
    }
    }
    cout<<ans<<endl;
    ans=0;
    }
}

C++: #include<cstdio>
using namespace std;
int main(){
    int n,k;
    int s = 0;
    int a[100000] = {0};
    for(;;){
        scanf("%d%d",&n,&k);
        if(n == 0&&k == 0)break;
        for(int i = 0;i < n; i++){
            scanf("%d",&a[i]);
        }
        int x = 0;
        for(int i = 0;i < k; i++){
            x += a[i];
        }
        s = x;
        for(int i = 0;i < (n-k); i++){
            x -= a[i];
            x += a[i+k];
            if(s < x)s = x;
        }
        printf("%d\n",s);
    }
    return 0;
}

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

using namespace std;

int main()
{
    int n, k;
    
    scanf("%d", &n);
    scanf("%d", &k);
    
    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 <cstdio>

using namespace std;

int main()
{
	int n, k;
	while (scanf("%d %d", &n, &k), n || k) {
		int N[100001];

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

		int sum = 0;

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

		int a = sum;

		for (int i = k; i < n; ++i) {
			a += N[i+1] - N[i-k+1];
			sum = sum > a ? sum : a;
		}

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

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

int main(){
  int n,k;
  while(cin>>n>>k){
    if(n==0 && k==0) break;
    int a[n+1];
    for(int i=0; i<n; i++) cin >> a[i];
    int Max = a[0];

    for(int i=0; i<n; i++){
      int sum=0;
      for(int j=i; j<i+k; j++){
	if(j == n-1) break;
        sum+=a[j];
	//	cout << "j:" << j << " a[j]:" << a[j] << endl;
        if(Max < sum) Max = sum;
      }
    }
    cout << Max << endl;
  }
  return 0;
}