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 n=0, k=0;
double a[100001] = {}, b[100001] = {}, ans=0;
int main(){
while (true){
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<bits/stdc++.h>
using namespace std;

typedef long long ll;

int n = 0;
int k = 0;
ll sum[100020] = {0};

ll solve()
{
  ll ans = -1001001001001;
  for (int i = 0; i < n; i++)
  {
    if (!i) ans = max(ans, sum[k-1]);
    else ans = max(ans, sum[i+k-1]-sum[i-1]);
  }
  return ans;
}

int main()
{
  while(1)
  {
    cin >> n >> k;
    if (!n && !k) break;
    for (int i = 0; i < n; i++)
    {
      int cmp = 0;
      cin >> cmp;
      if (i == 0) sum[0] = cmp;
      else sum[i] = sum[i-1] + cmp;
    }
    printf("%lld\n", solve());
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,x;
    cin >> n >> k;
    while(n!=0||k!=0){
       vector<int> a(n);
        int S[100010];
        for(int j=0;j<n;j++){
            cin >> a.at(j);
        }
        S[0]=0;
        for(int i=1;i<n;i++){
            S[i]=S[i-1]+a.at(i-1);
        }
        x=S[k];
        for(int l=1;l<n-k;l++){
            if(x<S[k+l]-S[l]){
                x=S[k+l]-S[l];
            }
        }
        cout << x << endl;
        cin >> n >> k;
        

    }

}

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

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

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

		int ans = 0;
		for (int i = 0;i <= n - k;i++) {
			int s = 0;
			for (int j = 0;j < k;j++) {
				s += a[i + j];
			}
			if (s > ans)ans = s;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
	int n,k,max,buf,*a;
	
	while(1){
		cin >> n >> k;
		
		if(n || k){
			max = 0;
			
			a = new int[n];
			
			for(int i = 0; i < n; i++){
				cin >> a[i];
			}
			
			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<bits/stdc++.h>
using namespace std;
int N,K;
int a[100000];


int main()
{
    scanf("%d%d",&N,&K);
    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 ma=sum;
    for(int i=K;i<N;i++){
        sum-=a[i-K];
        sum+=a[i];
        ma=max(ma,sum);
    }
    printf("%d\n",ma);
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int s[100000];
	int n;
	int k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	int q=0;
	for(int i=0;i+k-1<=n;i++){
		int t=0;
		for(int ii=0;ii<k;ii++){
			t+=s[i+ii];
		}
		if(q<t)
			q=t;
	}
	cout<<q<<endl;
	return 0;
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int n, k;
	ll result, tmp;

	cin >> n >> k;

	vi nums(n);
	result = -_UI64_MAX;

	REP(i, n) {
		cin >> nums[i];
	}

	REP(i, n-k+1) {
		tmp = 0;

		REP(j, k) {
			tmp += nums[i+j];
		}

		if(result < tmp) {
			result = tmp;
		}
	}

	cout << result << 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[100003]={0};
  int sum[100003]={0};
  int max=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];
      }
      }
      }

    sort(sum,sum+k,greater<int>());
  
    printf("%d\n",sum[0]);

  }

  return 0;

}

C++: #include<cstdio>                                                                                   
#include<algorithm>                                                                                
using namespace std;                                                                               
                                                                                                   
int N,K,dat[100000];                                                                               
long long r,t;                                                                                     
                                                                                                   
int main(){                                                                                        
    while(scanf("%d%d",&N,&K),N||K){                                                               
        for(int i=0;i<N;i++){                                                                      
            scanf("%d",dat+i);                                                                     
        }                                                                                          
        t=0;                                                                                       
        for(int i=0;i<K;i++){                                                                      
            t+=dat[i];                                                                             
        }                                                                                          
        r=t;                                                                                       
        for(int i=K;i<N;i++){                                                                      
            t=t-dat[i-K]+dat[i];                                                                   
            r=max(r,t);                                                                            
        }                                                                                          
        printf("%lld\n",r);                                                                        
    }                                                                                              
}

C++: #include<stdio.h>

int main(void){
	int i,n,k,sum,max;
	int N[150000];

	while(0==0){
		scanf("%d %d",&n,&k);
		sum=0;
		if(n==0 && k==0) break;

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

		for(i=0;i<k;i++)
		    sum+=N[i];
		
		max=sum;

		for(i=k;i<n;i++){
			sum+=N[i];
			sum-=N[i-k];
			if(sum>max)max=sum;
		}

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