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----------------------------------------------------------------------------------------------------------------------
#include <bits/stdc++.h>

//using namespace--------------------------------------------------------------------------------------------------------------
using namespace std;

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1 << 25
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << "\n";
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
//const------------------------------------------------------------------------------------------------------------------------
const double EPS = 1e-10;
const double PI = acos( -1.0 );

//global-----------------------------------------------------------------------------------------------------------------------
int n, m, k;
VI a, b, c;
#define mod 1000000007
//function-------------------------------------------------------------------------------------------------------------------- 
int main() {
	while ( true ) {
		scanf( "%d %d", &n, &m );
		if ( !n && !m ) {
			return 0;
		}
		rep( i, n ) {
			scanf( "%d", &k );
			a.push_back( k );
		}
		int mx = 0;
		int d = 0;
		rep( i, m ) {
			d += a[ i ];
			mx = d;
		}
		FOR( i, 1, n - m ) {
			d -= a[ i - 1 ];
			d += a[ i + m - 1 ];
			mx = max( mx, d );
		}
		printf( "%d\n", mx );
		a = VI();
	}
	return 0;
}

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

int main()
{
  int n, k;

  while (cin >> n >> k, n || k){
    int a[100010], num;

    for (int i = 0; i < n; i++){
      cin >> num;
      if (i == 0) a[i] = num;
      else a[i] = a[i - 1] + num;
    }

    int res = 0;
    for (int i = k; i < n; i++){
      res = max(res, a[i] - a[i - k]);
    }
    cout << res << '\n';
  }
}

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

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

		if (n == 0 && k == 0)
			break;

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

		int s = 0;
		for (int i = 0; i != k; ++i)
			s += vec[i];

		int m = 0;
		for (int i = 0; i != n - k; ++i)
		{
			int t = s;
			s -= vec[i];
			s += vec[i + k];
			m = std::max(t, s);
		}

		std::cout << m << std::endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string.h>
 
using namespace std;
 
int a[100000 + 1];
int s[100000 + 1];
 
int main() {
 
    int n, k;
    int i, j, l;
    int sum = 0, asus = 0;
 
    while (true) {
 
        memset(s, 0, sizeof(s));
        memset(a, 0, sizeof(a));
 
        cin >> n >> k;
        if (n == 0 && k == 0) return 0;
 
        for (i = 0; i < n; ++i) cin >> a[i];
 
        for (i = 0; i < n-k; ++i) {
            for (j = 0; j < k; ++j) {
 
                sum += a[i + j];
            }
            asus = max(asus, sum);
            sum = 0;
        }
 
        cout << asus << endl;
    }
}

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

using namespace std;
typedef long long Int;

Int n, k, sum, res;
Int a[108000];

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

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

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

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

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

		vector<int> a;
		for(int i=0; i<n; i++){
			int tmp;
			scanf("%d", &tmp);
			a.push_back(tmp);
		}
		int ans = 0;
		for(int i=0; i<k; i++){
			ans += a[i];
		}
//		printf("%d\n", ans);
		int temp = ans;
		for(int i=0; i+k<n; i++){
			temp -= a[i];
			temp += a[i+k];
			ans = max(ans, temp);
//			printf("%d %d\n", temp, ans);
		}
		printf("%d\n", ans);

	}

	return 0;
}

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

using namespace std;

int main(){
	for(;;){
		unsigned long n,k;
		vector<int> a;
		cin>>n>>k;
		if(!n) return 0;
		int ai;
		for(unsigned long i=0;i<n;i++){
			cin>>ai;
			a.push_back(ai);
		}

		long sum=0,max=0;
		for(unsigned long i=0;i<k;i++){
			sum+=a[i];
		}
		max=sum;
		for(unsigned long i=1;i<n-k+1;i++){
			sum+=a[i+k-1]-a[i-1];
			if(max<sum) max=sum; 
		}
		cout<<max<<endl;
	}
	return 0;
}

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

int main(void)
{
	int n,m,a;

	
	while(cin >> n >> m, n | m){
		int d[10001] = {};
		cin >> d[0];
	
		for(int i = 1; i < n; i++){
			cin >> a;
			d[i] += d[i-1] + a;
		}
		int MAX = 0;
		for(int i = 0; i < n - m; i++){
			if(d[i+m] - d[i] > MAX)
				MAX = d[i+m] - d[i];
		}
		cout << MAX << endl;
	}

	return 0;
}

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 = -10000000000;
	for (int i = 1; i + k < n; i++)
	{
		ans = max(ans, sums[i + k - 1] - sums[i - 1]);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(){
	while (1){
		int n, k;
		int b[100000] = {};
		scanf("%d%d", &n, &k);
		if (n == 0 && k == 0)return 0;
		int base = 0;
		for (int i = 0; i < k; i++){
			int a;
			scanf("%d", &a);
			b[i] = a;
			base += a;
		}
		int sa = 0,ans = 0;
		for (int i = k; i < n; i++){
			int c;
			scanf("%d", &c);
			sa += c - b[0];
			ans = max(ans,sa);
			for (int j = k-1; j > 0; j--){
				b[j-1] = b[j];
			}
			b[k-1] = c;
		}
		printf("%d\n", ans + base);
	}
}