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 <algorithm>
#define MAX 100000
using namespace std;

int a[MAX];

int main(void){
 	int n,k;
	cin >> n >> k;
	int ans=-1000000000;
	int cmax=0;
	for(int i=0;i<k;i++){
		cin >> a[i];
		cmax+=a[i];
	}
	ans=max(ans,cmax);
	for(int i=k;i<n;i++){
		cin >> a[i];
		cmax+=a[i];
		cmax-=a[i-k];
		ans=max(ans,cmax);
	}
	cout << ans << endl;
}

C++: #include <iostream>
using namespace std;
int main(void)
{
	for (;;)
	{
		int a,b,c,d,max=0;
		cin>>a>>b;
		int e[a];
		if (a==0&&b==0) break;
		for (c=0;c<a;c++){
			cin>>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];
		}
		cout<<max<<endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){

  int in, k;

  while(cin >> in >> k){
    if(in == 0 && k == 0) break;
    int data[in];
    int sum;

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

   

    for(int i = 0; i <= in-k; i++){
      int tmp = 0; 
      for(int j = i; j < i+k; j++){
	tmp += data[j];
      }
      if(i == 0 || sum < tmp) sum = tmp;
    }

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

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;



const int mod = 100000;
struct Mod {
public:
	int num;
	Mod() : Mod(0) { ; }
	Mod(long long int n) : num((n % mod + mod) % mod) {
		static_assert(mod<INT_MAX / 2, "mod is too big, please make num 'long long int' from 'int'");
	}
	Mod(int n) : Mod(static_cast<long long int>(n)) { ; }
	operator int() { return num; }
};

Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int  b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) { return Mod((mod + a.num - b.num) % mod); }
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) { return Mod(((long long)a.num * b.num) % mod); }
Mod operator*(const long long int a, const Mod b) { return Mod(a)*b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b)*a; }
Mod operator*(const Mod a, const int b) { return Mod(b)*a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod& a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
	if (n == 0) return Mod(1);
	Mod res = (a * a) ^ (n / 2);
	if (n % 2) res = res * a;
	return res;
}
Mod mod_pow(const Mod a, const long long  int n) {
	if (n == 0) return Mod(1);
	Mod res = mod_pow((a * a), (n / 2));
	if (n % 2) res = res * a;
	return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
	assert(b.num != 0);
	return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) {
	return Mod(a) / b;
}
Mod operator/=(Mod &a, const Mod b) {
	return a = a / b;
}

#define MAX_MOD_N 1024000

Mod fact[MAX_MOD_N], factinv[MAX_MOD_N];
void init(const int amax = MAX_MOD_N) {
	fact[0] = Mod(1); factinv[0] = 1;
	for (int i = 0; i < amax - 1; ++i) {
		fact[i + 1] = fact[i] * Mod(i + 1);
		factinv[i + 1] = factinv[i] / Mod(i + 1);
	}
}
Mod comb(const int a, const int b) {
	return fact[a] * factinv[b] * factinv[a - b];
}

int main() {
	while (1) {
		int N, K; cin >> N >> K;
		if (!N)break;
		vector<int>as(N);
		for (int i = 0; i < N; ++i) {
			cin >> as[i];
		}
		long long int sum = 0;
		for (int i = 0; i < K; ++i) {
			sum += as[i];
		}
		long long int ans = sum;
		for (int i = K; i < N; ++i) {
			sum += as[i] - as[i - K];
			ans = max(ans, sum);
		}
		cout << ans << endl;
	}

	return 0;
}

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

int main(){
  int n,k,a,s;
  while(cin>>n>>k,n||k){
    int m=-10001;a=0;
    queue<int> q;
    n-=k;
    while(k--){
      cin>>s;
      a+=s;q.push(s);
    }
    m=max(m,a);
    while(n--){
      cin>>s;
      q.push(s);
      a=a+s-q.front();
      q.pop();
      m=(m>a)?m:a;
    }
    cout<<m<<endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

	int n, k;
	int a[100000];

	while(cin >> n >> k) {
		if(n==0&&k==0) {
			break;
		}
		for(int i=0; i<n; i++) {
			cin >> a[i];
		}
		int max=a[0];
		for(int i=0; i<=n-k; i++) {
			int t=0;
			int l=0;
			for(int j=i; j<n; j++) {
				l++;
				t+=a[j];
				if(t>max) {
					max=t;
				}
				if(l==k) {
					break;
				}
			}
		}
		cout << max << endl;
	}

	return 0;

}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
int main(){
  int n, k;
  int N[100001], ans, sum;
  while(cin >> n >> k, n && k){
    ans = 0;
    for(int i = 0 ; i < n ; i++){
      cin >> N[i];
    }
    for(int i = 0 ; i < n - k ; i++){
      sum = 0;
      for(int j = i ; j < k + i ; j++){
	sum += N[j];
	//if(N[j+k-1] > 10000) break;
      }
      ans = max(ans, sum);
      //cout << ans << endl;
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>

int main(){
	int n,k,S,max,count;

	while(true){
		scanf("%d %d",&n,&k);
		if(n == 0 && k == 0)break;
		max = -1000000001;
		S = 0;
		count = 0;
		int array[n];
		for(int i = 0; i < n; i++){
			scanf("%d",&array[i]);
			count++;
			if(count == k){
				S += array[i];
				max = (max >= S)?max:S;
			}else if(count >  k){
				S -= array[i-k];
				S += array[i];
				max = (max >= S)?max:S;
			}else{
				S += array[i];
			}
		}
		printf("%d\n",max);
	}

	return 0;
}

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

using namespace std;

int main()
{
	int n, k, s, b;
	while (1)
	{
		cin >> n >> k;
		if (n == 0 && k == 0)
			break;
		int m[100001] = { 0 };
		int a[100001];
		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 ] - m[i ];
			if (s < b) 
				s = b;
		}

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