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 <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;
		int res = 0;
		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
			res = max (res, s );
		} // end for

		cout << res << endl;
	} // end loop
		
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int k,n,a[10000]={0};
    double cube=0,ans=0;
    while(1){
       cin >> n >> k;
       if(n==0&&k==0)break;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n-k;i++){
       cube=0;
       for(int j=0;j<k;j++){
        cube +=a[i+j];
       }
       if(cube>ans)ans=cube;
    }
    cout << ans << endl;
    }
return 0;
}

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

using namespace std;

int main()
{
    int N, K;
    while (cin >> N >> K, N) {
        vector<int> a(N);
        int sum = 0, res = -(1e9);
        for (int i = 0; i < K; i++) {
            cin >> a[i];
            sum += a[i];
        }

        res = max(res, sum);
        for (int i = K; i < N; i++) {
            cin >> a[i];
            sum += a[i] - a[i-K];
            res = max(res, sum);
        }
        cout << res << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	int n, k, s, b;
	int a[100001];
	while (1)
	{
		cin >> n >> k;
		if (n == 0 && k == 0)
			break;
		int m[100001] = { 0 };
		for (int i = 0;i < n;i++)
			cin >> a[i];

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

		s = 0;
		for (int i = 0;i < n - k + 1;i++)
		{
			b = m[i + k + 1] - m[i + 1];
			if (s < b) 
				s = b;
		}

	}
	cout << s << endl;
	return 0;
}

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

int main(){

  int n,k;

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

    int a[100000] = {0},z = 0;

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

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

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

    cout << z << endl; 
  }
}

C++: #include <iostream>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[])
{
    int n,k;
    while (cin >> n >> k) 
    {
        if (n == 0 && k==0) 
        {
            break;
        }
        vector<int> vec(n);
        int sum_max=0;
        int j;
        int sum=0;
        for (int i = 0; i < n; i++) 
        {
            cin >> vec[i];
            if (k  == i + 1) 
            {
                for (j = 0; j < k; j++) 
                {
                    sum += vec[i - j];
                    cout << i-j << " ";
                }
                cout << endl;
                sum_max = max(sum ,sum_max);
                sum -= vec[i-k+1];
            }

            else if (k  < i + 1) 
            {
                sum += vec[i];
                sum_max = max(sum ,sum_max);
                sum -= vec[i-k+1];
            }
        }
        cout << sum_max << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k,ans,sum;
    while(1){
        cin>>n>>k;
        if(n==0&&k==0){
            return 0;
        }
        vector<int> a(n);
        for(int i=0;i<n;i++){
            cin>>a.at(i);
        }
        ans=0;
        for(int i=0;i<k;i++){
            ans+=a.at(i);
        }
        sum=ans;
        for(int i=1;i<n-k;i++){
            sum=sum+a.at(i+k-1)-a.at(i-1);
                ans=max(ans,sum);
        }
        cout<<ans<<endl;
    }
}

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

using namespace std;

int main() {
    int n, m;
    vector<int> ans;
    while(cin >> n >> m) {
        if(n == 0 && m == 0) {
            break;
        }
        int nums[n];
        for(int i = 0; i < n; i++) {
            cin >> nums[i];
        }
        int max = 0;
        for(int i = 0; i < m; i++) {
            i += nums[i];
        }
        for(int i = 1; i < n - m + 1; i++) {
            int sum = 0;
            int k = i;
            for(int j = 0; j < m; j++) {
                sum += nums[k + j];
            }
            if(sum > max) {
                max = sum;
            }
        }
        ans.push_back(max);
    }
    for(int i = 0; i < ans.size(); i++) {
        cout << ans.at(i) << endl;
    }
}

C++: #include <iostream>
#include <queue>
using namespace std;
int main(){
	queue<int> a;
	int n,k,num,max,tmp;
	max=tmp=0;
	cin >> n >> k;
	for(int i=0;i<k;i++){
		cin >> num;
		a.push(num);
		max+=num;
	}
	n-=k;
	tmp=max;
	while(n--){
		cin >> num;
		a.push(num);
		tmp+=a.back()-a.front();
		a.pop();
		if(max<tmp) max = tmp;
	}
	cout << max << endl;
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;

int a[100000] = {};

signed main() {
	int k;
	int n;
	
	cin >> n >> k;
	while (n != 0 && k != 0) {
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}

		int m = -9999999999;
		int tmp = 0;
		int cnt = 0;

		for (int i = 0; i < n; i++) {
			if (i < k) {
				tmp += a[i];
			}
			else {
				tmp -= a[i - k];
				tmp += a[i];
				m = max(m, tmp);
			}
		}

		cout << m << 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[1000003]={0};
  int max,sum[1000003]={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];
      }
      }
    }

    max=sum[0];
    for(i=0;i<n;i++){
      if(sum[i]>max){
	max=sum[i];
      }
    }
  
    printf("%d\n",max);

  }

  return 0;

}

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

std::int64_t a[100000];

int main() {
	int n, k;
	while (std::cin >> n >> k, n + k != 0) {
		for (int i = 0; i < n; ++i)
			std::cin >> a[i];

		std::int64_t res = 0, mem = 0;
		for (int i = 0; i < n; ++i) {
			mem += a[i];

			if (i >= k) {
				mem -= a[i - k];
				res = std::max(res, mem);
			}
		}

		std::cout << res << std::endl;
	}
}