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 <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n,k;
	while(cin >> n >> k, n){
		int a[n];
		int ans = 0;
		rep(i,n){
			cin>>a[i];
			if(i >= k-1){
				int tmp = 0;
				rep(j,k){
					tmp += a[i-j];
				}
				ans = max(ans,tmp);
			}
		}
		FIN(ans);
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
constexpr int MAX_N=100000;

int n,k;
int a[MAX_N];
long long int sum=0;
long long int res=0;

int main(){
    while(1){
        std::cin>>n>>k;
        if(n+k==0)
            break;

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

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

        for(int i=0;i<n-k-1;++i){
            sum-=a[i];
            sum+=a[k];
            res=std::max(res,sum);
        }
        std::cout<<res<<std::endl;
    }
    return 0;
}

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

using namespace std;

int main(){

	int n,k,a[100000],sum,ans;

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

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

	sum=0;

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

    ans=sum;

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

    cout<<ans<<endl;


	}
}

C++: #include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 1000000009;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(), (c).end()

struct edge{ int t, d; };

int main()
{
	int n, k; cin >> n >> k;
	vector<LL> sums(n);
	rep(i, n)
	{
		cin >> sums[i];
		if (i != 0)
			sums[i] += sums[i - 1];
	}
	LL ans = sums[k];
	for (int i = 0; i + k < n; i++)
	{
		ans = max(ans, sums[i + k - 1] - sums[i - 1]);
	}
	cout << ans << endl;
	return 0;
}

C++: #include<iostream>
main(){for(intn,k,a[100000],s,M,i;std::cin>>n>>k,n;printf("%d\n",M))for(M=1<<31,i=s=0;i<n;s+=a[i++],k<i&&(s-=a[ik-1]),M<s&&(M=s))std::cin>>a[i];}

C++: #include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = 1e18+7;

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

/* template */

template<class SemiGroup> struct DisjointStarseTable{
    using F= std::function<SemiGroup(SemiGroup,SemiGroup)>;
    F fn;
    std::vector<std::vector<SemiGroup>> data;
    std::vector<int> height;

    DisjointStarseTable(const std::vector<SemiGroup> &init_vec,F fn) : fn(fn) {
        int n = (int)init_vec.size(), h = 1;
        while((1<<h)<n) h++;
        data.assign(h,std::vector<SemiGroup>(n));
        height.assign((1<<h),0);
        for(int i = 2; i< (1<<h); i++) height[i] = height[i>>1]+1;
        for(int i = 0; i< n; i++) data[0][i] = init_vec[i];
        for(int i = 1; i< h; i++){
            int s = (1<<i);
            for(int j = 0; j<n; j += (s<<1)){
                int t = min(j+s,n);
                data[i][t-1] = init_vec[t-1];
                for(int k = t-2; k >= j; k--){
                    data[i][k] = fn(init_vec[k],data[i][k+1]);
                }
                if(n <= t) break;
                data[i][t] = init_vec[t];
                for(int k = t+1; k< min(t+s,n); k++) data[i][k] = fn(data[i][k-1],init_vec[k]);
            }
        }
    }

    SemiGroup query(int l,int r){
        assert(l<r);
        if(l >= --r) return data[0][l];
        return fn(data[height[l^r]][l],data[height[l^r]][r]);
    }
};

int solve(){
    int n,k; cin >> n >> k;
    if(n==0 && k==0) return 0;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    DisjointStarseTable<ll> c(a,[](ll a,ll b){ return a+b;});
    ll ans = -LNF;
    rep(i,0,n-k+1){
        chmax(ans,c.query(i,i+k));
    }
    cout << ans << endl;
    return 1;
    
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int flag = 1;
    while(flag){
        flag = solve();
    }
}

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

int main() {
	while(1){
		int n, k, num[100000];
		cin >> n >> k;
		if(n == 0 && k == 0)break;
		for(int i = 0; i < n; i++)
			cin >> num[i];
	
		int ans = 0;
		for(int i = 0; i < n; i++){
			if(i + k > n)break;
			int row = 0;
			for(int j = 0; j < k; j++){
				row += num[i + j];
			}
			if(ans < row)
				ans = row;
		}
		
		cout << ans << endl;
	}
	return 0;
}