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;
#include<vector>
#include<algorithm>

int main() {
	long long int n;
	long long int k;
	while (cin >> n >> k && n != 0 && k != 0) {
		vector<long long int> v;
		v.push_back(0);

		for (long long int i = 1; i <= n; ++i) {
			long long int m;
			cin >> m;
			v.push_back(m);
			v[i] += v[i - 1];
		}

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

		cout << sum << endl;
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define int long long
#define PB push_back
#define INF (1LL<<61LL)
//#define BP while(true){}

typedef pair<int, int> pii;

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

  int n, k;
  while (cin >> n >> k, n) {
    int a[100005];

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

    int sum = 0, res = 0;
    for (int i = 0; i < k; ++i)
      sum += a[i];

    res = sum;

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

    cout << res << endl;
  }
  
  return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,ans = 0,sum = 0;
  cin >> n >> k;
  vary(ll,v,n,0);
  rep(i,n){
    cin >> v[i];
  }
  rep(i,k){
    sum += v[i];
  }
  ans = sum;
  REP(i,k,n){
    sum += v[i];
    sum -= v[i-k];
    ans = max(ans,sum);
  }
  cout << ans << endl;
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, k;
	while (cin >> n >> k, n, k) {
		int s[114514] = {};
		for (int i = 1; i <= n; i++) {
			int a; cin >> a;
			s[i] = s[i - 1] + a;
		}
		long long ans = 0;
		for (int i = 1; i <= n - k; i++) {
			ans = max(ans, (long long)(s[i + k] - s[i]));
		}
		cout << ans << endl;
	}
}

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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int a[100000];
int n,k;

int main(){
    while(cin>>n>>k, n|k){
        rep(i,n) cin>>a[i];
        int ans=0;
        rep(i,k) ans+=a[i];
        int t=ans;
        rep(i,n-k){
            t-=a[i]; t+=a[i+k];
            ans=max(t,ans);
        }
        cout<<ans<<endl;
    }
}

C++: #include <cstdio>

int n,k,a;
long long dp[100001];

int main(){
	while(scanf("%d%d",&n,&k), n != 0){
		for(int i = 0; i <= n; i++) dp[i] = 0;
		for(int i = 1; i <= n; i++){
			scanf("%d",&a);
			dp[i] = dp[i-1] + a;
		}
		long long mx = 0;
		for(int i = 0; i <= n - k; i++){
			long long sum = dp[i+k] - dp[i];
			if(sum > mx){
				mx = sum;
			}
		}
		printf("%lld\n",mx);
	}
	return 0;
}

C++: #include<iostream>
#include<string.h>
using namespace std;
long long sin[100001];
int main(){
	while(1){
	memset(sin,0,sizeof(sin));
	int n,k;
	int i,j,max=0,x;
	cin>>n>>k;
		if(n==0&&k==0)break;
	for(i=0;i<n;i++){
		cin>>sin[i];
	}
	for(i=0;i<n-k+1;i++){
		x=sin[i]+sin[i+1]+sin[i+2];
		if(max<x)max=x;
	}
	cout<<max<<endl;
	}
}

C++: #include <iostream>
#include <stdlib.h>
#include <algorithm>

using namespace std;

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

C++: #include<stdio.h>
int main(void){
    int n,k;
    int a[100001]={0};
    int i,j;
    int sum;
    int mem=0;
    while(1){
        for(i=0;i<10000;i++){
            a[i]=0;
        }
        scanf("%d%d",&n,&k);
        if(n==0&&k==0){
            break;
        }
        mem=0;
        for(i=0;i<n;i++){
            scanf("%d",&a[i]);
        }
        sum=0;
        for(i=0;i<n;i++){
            if(i<k){
                sum=sum+a[i];
            }
            else if(i>=k){
                sum=sum+a[i];
                sum=sum-a[i-k];
            }
            if(i==k-1){
                mem=sum;
            }
            if(i>=k-1){
                if(mem<sum){
                    mem=sum;
                }
            }
        }
        printf("%d\n",mem);
    }
    return 0;
}

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

int main(){
	int n, k, x, maxnum = 0;
	cin >> n >> k;
	int wa[100000];
	for(int i=0;i<100000;i++) wa[i] = 0;
	for(int i=0;i<n;i++){
		cin >> x;
		for(int j=0;j<k;j++){
			wa[i+j] += x;
		}

	}
	for(int i=0;i<n;i++){
		if(maxnum < wa[i]) maxnum = wa[i];
	}
	cout << maxnum;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N;i++)
typedef pair<int,int> Pi;
#define F first
#define S second
#define INF 1 << 28

inline void chmax(int &a,int b) {
  a = max(a,b);
}

inline void chmin(int &a,int b) {
  a = min(a,b);
}

int main()
{
  int N, K;
  while(cin >> N >> K,N || K) {
    int data[100005];
    Rep(i,N)cin >> data[i];
    int sum = 0;
    Rep(i,K)sum += data[i];
    int maxv = sum;
    for(int i = K; i < N; i++) {
      sum += data[i] - data[i - K];
      chmax(maxv,sum);
    }
    cout << maxv << endl;
  }
  return 0;
}

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

using namespace std;

int n,m,cnt;
int ans,an;
int a[100000];

int main(void){

  while( cin >> n >> m , n || m ){

    ans = 0;

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

    for( int i = 0 ; i < n ; i++ ){
      an = 0;
      cnt = 3;
      for( int j = i ; j < i + 3 && j < n ; j++ ){
	an += a[j];
      }
      ans = max( ans , an );
    }

    cout << ans << endl;

  }
  return 0;
}