Go: package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	parseProblem(os.Stdin)
}

func parseProblem(r io.Reader) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	for true {
		n, k := scanInt(sc), scanInt(sc)
		if n == 0 && k == 0 {
			break
		}
		sum := make([]int, n+2)
		for i := 2; i <= n+1; i++ {
			sum[i] = sum[i-1] + scanInt(sc)
		}
		max := math.MinInt32
		for i := 1; i+k <= n+1; i++ {
			if v := sum[i+k] - sum[i]; max < v {
				max = v
			}
		}
		fmt.Println(max)
	}
	return
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

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

int main(){

  int n, k;
  while( cin >> n >> k, n+k ) {
    int max_sum, sum, data[100000];
    
    cin >> data[0] >> data[1] >> data[2];
    max_sum = sum = data[0] + data[1] + data[2];
    
    for(int i=k; i<n; i++) {
      cin >> data[i];
      sum -= data[i-k];
      sum += data[i];
      max_sum = max(max_sum, sum);
    }

    cout << max_sum << endl;
  }
}

C++: #include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <cstdlib>
#include <algorithm>
using namespace std;
/*
int dfs(int w,int h,int noww,int nowh,int n,int b){
	++n;
	if(noww>w || nowh>h) return 0;
	if(noww==w && nowh==h) return 1;
	int ret=0;
	n=0;
	if(n)
	ret+=dfs(w,h,++noww,nowh,n,b);
	ret+=dfs(w,h,noww,++nowh,n,b);
	ret+=dfs(w,h,++noww,nowh,n,b);
	ret+=dfs(w,h,noww,++nowh,n,b);
	return ret;
}

int main()u{
	int w,h;
	cin >> w >> h;
	cout << dfs(w,h,1,1,2,0) << endl;
	return 0;
}
*/

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

C++: #include <iostream>
#include <vector>
#include <set>
#include <algorithm>
//#include <fstream>

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.maximumsum", "r", stdin );
	int n,k;

	while (1) {
		cin >> n >> k;

		if (n == 0 && k == 0 ){
			break;
		} // end if
		vector <int> a (n, 0 );
//		vector <int> sum (n - k + 1, 0 );
 		set <int, greater<int> > sum;

		for (int i = 0; i < n; ++i){
			cin >> a[i];
		} // end for
		
		for (int i = 0; i < n - k + 1; ++i){
			int s = 0;
			for (int j = i; j < i + k; ++j){
				s += a[j];
			} // end for
			sum.insert (s);
		} // end for

		set <int, greater<int> >::iterator it = sum.begin();

		cout << (*it) << endl;
	} // end loop
		
	return 0;
}

C++: #include <stdio.h>

int main(){
	int a,b,c[1000],d[100],e,i,j;
	while(1){
	scanf("%d %d",&a,&b);
		if(a==0&&b==0){
			return 0;
		}
	for(i=0;i<a;i++){
		scanf("%d",&c[i]);
	}
	for(i=0;i<a-b+1;i++){
		d[i]=0;
		for(j=i;j<b+i;j++){
			d[i]+=c[j];
		}
	}
	for(i=0;i<a-b+1;i++){
		for(j=0;j<a-b-1;j++){
			if(c[j]<=c[j+1]){
				e=d[j];
				d[j]=d[j+1];
				d[j+1]=e;
			}
		}
	}
	printf("%d\n",d[0]);
	}
	return 0;
}

C++: #include <iostream>
 
int kk[100000];
 
int main(){

while(1){

int s=0;
int n,k;
std::cin>>n>>k;
 
if(n==0&&k==0)
break;

for(int i=0;i<k;i++){
std::cin>>kk[i];
s+=kk[i];
}
 
int st=s;
 
for(int i=k;i<n;i++){
std::cin>>kk[i];
s+=kk[i]-kk[i-k];
if(s>st)
st=s;
}
 
std::cout<<st<<std::endl;

}

}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
using ll = long long;
const int INF = 999999999;

vector<ll> ret;

void solve(vector<ll>& a, ll k) {
    ll n = a.size();
    vector<ll> cs(n+1, 0);
    for(int i = 1; i < n+1; i++) {
        cs[i] = cs[i-1];
        cs[i] += a[i-1];
    }

    ll ans = (-1) * INF;
    for(int i = 0; i < n+1; i++) {
        ll now = cs[i+k] - cs[i];
        ans = max(ans, now);
    }
    ret.push_back(ans);
}

int main() {
    do {
        ll n, k;
        cin >> n >> k;
        if (n == 0 && k == 0) break;
        vector<ll> a(n, 0);
        for(int i = 0; i < n; i++) cin >> a[i];
        solve(a, k);
    } while(true);

    for(auto &r : ret) {
        cout << r << endl;
    }
}

C++: #include<iostream>
#include<stdio.h>

using namespace std;

int main(){


    int n,k,ans=0,ans2=0,ans3=0;
    while(1){
    scanf("%d%d",&n,&k);
    if(n==0&&k==0)break;
    int num[n];
    for(int y=0;y<n;y++){
        scanf("%d",&num[y]);
    }
        for(int a=0;a<k;a++){
        ans+=num[a];
        }
        ans3=ans;
    for(int j=0;j<n-k;j++){
        ans2=ans-num[j]+num[j+k];
        if(ans3<ans2){
            ans3=ans2;
        }
    ans=ans2;
    ans2=0;
    }
    printf("%d\n",ans3);
    }

return 0;
}

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

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

int main()
{
  int n, k;
  while (~scanf("%d %d", &n, &k)) {
    if ((n|k) == 0)
      break;

    vector<int> a(n);
    for (int i = 0; i < n; ++i)
      scanf("%d", &a[i]);

    for (int i = 1; i < n; ++i)
      a[i] += a[i-1];

    int ans = a[k-1];
    for (int i = k; i < n; ++i)
      ans = max(ans, a[i]-a[i-k]);

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

C++: #include<iostream>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    while(n!=0||k!=0){
       vector<int> a(n);
        cin >> a;
        S[0]=0;
        for(int i=1;i<n;i++){
            S[i]=S[i-1]+a.at(i-1);
        }
        int 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 <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

int main(){
    int n, k;
    int ans = -50000;
    int sum = 0;
    int lastNum;
    vi series;
    while(cin >> n >> k, n+k){

        for(int i=0; i < n; i++){
            int m;
            cin >> m;
            series.push_back(m);

            if(i < k-1) sum += m;
            else {
                sum += m-series[i-k];
                ans = max(ans, sum);
            }
        }
        cout << ans << endl;
    }
}

C++: #include <stdio.h>
using namespace std;
int main(void)
{
	for (;;)
	{
		int a,b,c,d,max=0;
		scanf("%d %d",&a,&b);
		int e[a];
		if (a==0&&b==0) break;
		for (c=0;c<a;c++){
			scanf("%d",&d);
			e[c]=d;
		}
		for (int f=0;f<=a-b;f++){
			for (int g=1;g<b;g++){
				e[f]=e[f]+e[f+g];
			}
			if (e[f]>=max) max=e[f];
		}
		printf("%d\n",max);
	}
	return 0;
}

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

int main() {
	int n,m;
	while(cin>>n>>m,n,m){
		int ans=0;
		queue<int> que;
		for(int i=0,num;i<m;i++){
			cin>>num;
			que.push(num);
			ans+=num;
		}
		for(int i=m,num,sum=ans-que.front();i<n;i++){
			que.pop();
			cin>>num;
			sum+=num;
			ans=max(ans,sum);
			sum-=que.front();
			que.push(num);
		}
		cout<<ans<<endl;
	}
}