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<iostream>
#include<vector>
#include<algorithm>
using namespace std;

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

		int a[10005];
		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 num[100100];
int main(){
int n,m;
int ans=0;
while(1){
         for(int i=0;i<100100;i++)num[i]=0;
         cin>>n>>m;
         if(n==0&&m==0)break;
         for(int i=0;i<n;i++) cin>>num[i];
         for(int i=0;i<m-n;i++){
              int min=num[i]+num[i+1]+num[i+2];
              if(ans<min)ans=0;
         }
         cout<<ans<<endl;
         ans=0;
    }
    return 0;
}

C++: #include <cstdio>
 
int main(void)
{
  int n, k;
  int max;
  int sum;
  while (true)
  {
    scanf("%d %d", &n, &k);
    if ( n == 0 && k == 0 ) break;
 
    int* num_sequence = new int[n];
    for (int i = 0; i < n; ++i)
    {
      scanf("%d", &num_sequence[i]);
    }
 
    max = -999999;
    for (int j = 0; j < n-k+1; ++j)
    {
      sum = 0;
      for (int i = 0; i < k; ++i)
      {
        sum += num_sequence[i+j];
      }
      if ( sum > max ) max = sum;
    }
    printf("%d\n", max);
  }
  return 0;
}

C++: //Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
int main()
{
while(1)
{
	int n,k;
	scanf("%d %d",&n,&k);
	if(!n) return 0;
	int ret=-INF;
	int res=0;
	queue<int>que;
	for(int i=0;i<k;i++)
	{
		int s; scanf("%d",&s);
		res+=s;
		que.push(s);
	}
	ret=max(ret,res);
	for(int i=k;i<=n;i++)
	{
		int s; scanf("%d",&s);
		res+=s;
		res-=(que.front());
		ret=max(ret,res);
		que.pop();
		que.push(s);
	}
	printf("%d\n",ret);
}
}

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

int main(){

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

    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 <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;


int main() {
    while(true){
        int N,K;
        cin >> N >> K;
        if(N == 0 && K == 0)break;
        vector<int> a(N);
        vector<int> wa(N+1);
        wa.at(0) = 0;
        for(int i = 0; i < N; i++){
            cin >> a.at(i);
            wa.at(i+1) = a.at(i) + wa.at(i);
        }
        int ANS = -INF;
        for(int i = 0; i < N - K +1; i++){
            int ans = wa.at(i+K) - wa.at(i);
            ANS = max(ANS, ans);
        }
        cout << ANS << endl;
    }
    
    
    
    
}

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

int max(int a, int b){
	if(a > b) return a;
	else return b;
}

int main(){
	const int MAX_N = 100000;
	int n, a[MAX_N], k, S, S1, S2;
	int p;
	
	while(true){
		scanf("%d%d", &n, &k);
		if(n == 0 && k == 0) break;
		for(int i = 0; i < n; i++) scanf("%d", &a[i]);
		
		S = 0;
		for(p = 0; p < k; p++){
			S += a[p];
		}
		S1 = S;
		
		while(p < n){
			S2 = S1 + a[p] + a[p - k];
			
			S = max(S, S2);
			
			S1 = S2;
			
			p++;
		}
		
		printf("%d\n", S);
	}
	
	return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	while(1){
	int k,n,s=0,cn=0;
	cin>>k>>n;
	if(k==0 && n==0){
		break;
	}
	int dat[1000];
	for(int i=0;i<k;i++){
		cin>>dat[i];
	}
	for(int j=0;j<k-n+1;j++){
		cn=0;
		for(int k=0;k<n;k++){
			cn+=dat[j+k];
		}
		s=max(s,cn);
	}
	cout<<s<<endl;
	}
	return 0;
}

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

int main()
{
	long long n, k, i, inp, sum, max=0;
	long long *a;
	cin >> n >> k;
	a = new long long[n];
	
	for (i = 0; i < n; i++){
		cin >> inp;
		a[i] = inp;
	}
	
	int o1, o2;
	cin >> o1 >> o2;

	for (i = 0; i < n - 2; i++){
		sum = a[i] + a[i + 1] + a[i + 2];
		if (sum > max){ max = sum; }
	}

	cout << max << endl;

	delete[] a; 
	return 0;
}

C++: #include<iostream>
using namespace std;
int n=0, k=0;
double a[100001] = {}, b[100001] = {}, ans=0;
int main(){
while (cin>>n>>k){
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<iostream>
using namespace std;
int main(){
	while (true){
		int n, k;
		double a[100001] = {}, b[100001] = {}, ans;
		cin >> n >> k;
		if (n == 0 || k == 0)	break;
		for (int i = 1; i <= n; i++){
			cin >> a[i];
		}
		for (int i = 1; i <= n; i++){
			for (int x = 0; x<k; x++){
				if (a[i + k] == 0) break;
				b[i] = a[i + x];
			}
			if (b[i]>b[i - 1]){
				ans = b[i];
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main()
{
	int max,a[100000],sum,k,n;

	
	while(scanf("%d %d",&n,&k) && n || k ){
	
		for(int i = 0; i < n; i++){
			scanf("%d",&a[i]);
		}
	
		sum = 0;
		for(int i = 0; i < k; i++){
			sum += a[i];
		}
	
		max = sum;
		for(int i = k; i < n; i++){
			sum += a[i]-a[i-k];
			if(sum > max){
				max = sum;
			}
		}

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

	return 0;
}

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

int main(){
  int n,k,a[100000],sum,maxv;
  
  while(cin >> n >> k,n||k){
    sum = 0;
    for(int i=0;i<k;i++){
      cin >> a[i]; sum += a[i];
    }
    
    maxv = sum;
    for(int i=k;i<n;i++){
      cin >> a[i]; sum += a[i] - a[i-k];
      maxv = std::max(maxv,sum);
    }
    cout << maxv << endl;
  }
}

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

int main(){
	int n, k;
	int input[100000];
	int sun;
	while(cin >> n >> k, n || k){
		int ans = 0;
		for(int i=0; i < n; i++) cin >> input[i];

		for(int i=0; i < n-k; i++){
			sun = 0;
			for(int j=i; j < i+k; j++){
				sun += input[j];
			}
			ans = max(ans, sun);
		}
		cout << ans << endl;
	}
}