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 <bits/stdc++.h>
using namespace std;
int main(){
    int N, k;
    cin >> N >> k;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
    	if(i < 3){
    	    total += a[i];
    	}else{
    	    total = total + a[i] - a[i-3];
    	}
	    if(ans < total){
	        ans = total;
	    }
    }
    cout << ans << endl;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int n,a[100001],k,sum,p;
int main(){
int i,j,h;
cin>>n>>k;
cin>>a[1];
for(i=2;i<=n;i++){
cin>>a[i];
a[i]+=a[i-1];
}
for(i=1;i<=n;i++){
	for(j=i;i<=i+k;j++){
		p=a[i+k]-a[j];
		if(p>=sum){
			sum=p;
		}
	}
}
cout<<sum<<endl;
return 0;
}

C++: #include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
  int n,k;
  scanf("%d%d\n",&n,&k );
  int a[100000];
  while (n) {
    for (int i = 0; i < n; i++) {
      scanf("%d\n",&a[i] );
    }
    int s = 0;
    for (int i = 0; i < k; i++) {
      s += a[i];
    }
    int ans = s;
    for (int i = k; i < n; i++) {
      s -= a[i - k];
      s += a[i];
      ans = max(ans,s);
    }
    printf("%d\n",ans );
    scanf("%d%d\n",&n,&k );
  }
  return 0;
}

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

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

using namespace std;

int main()
{
	int n, k, num, ans, sam;
	
	while(cin >> n >> k)
	{
		if(!n && !k) break;
		queue<int> que;
		ans = 0;
		sam = 0;
		for(int i = 0; i < n; i++)
		{
			cin >> num;
			que.push(num);
			sam += num;
			if(que.size() == k )
			{
				if(ans < sam)
				{
					ans = sam;
				}
				sam -= que.front();
				que.pop();
			}
		}
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n,k;
	int a[100001];
	while(cin >> n >> k, n){
		int ans = 0;
		rep(i,n){
			cin>>a[i];
		}
		rep(i,k)ans += a[i];
		int sum = 0;
		int tmp = ans;
		for(int i = k; i < n; i++){
			sum = tmp;
			sum -= a[i-k];
			sum += a[i];
			ans = max(ans,sum);
			tmp = sum;
		}
		FIN(ans);
	}

	return 0;
}

C++: #include <cstdio>

#define MAX(x, y) (x < y) ? y : x

int main(void)
{
	int n, k;
	int data[100000] = {0};
	
	while (1){
		scanf("%d %d", &n, &k);
		if (n == 0 && k == 0) break;
		for (int i = 0; i < n; i++){
			scanf("%d", &data[i]);
		}
		
		for (int i = 0; i < n - 1; i++){
			if (data[j] < 0) data[j] *= 2;
		}
		
		for (int i = 0; i < n - 1; i++){
			data[i + 1] += data[i];
		}
		int max = 0;
		for (int i = 0; i <= (n - k); i++){
			int tmp = data[i + k] - data[i];
//			for (int j = i; j < (i + k); j++){
//				if (data[j] < 0) tmp += data[j];
//			}
			max = MAX(max, tmp);
		}
		
		/*
		int max = 0, tmp;
		for (int i = 0; i <= (n - k); i++){
			tmp = 0;
			for (int j = i; j < (i + k); j++){
				tmp += data[j];
			}
			max = MAX(max, tmp);
		}*/
		
		printf("%d\n", max);
	}
	
	return (0);
}

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

signed main()
{
	int n,k;
	while(cin>>n>>k,n){
	
	int a[100000];
	for(int i=0;i<n;i++)cin>>a[i];
	
	int s=0;
	for(int i=0;i<k;i++)s+=a[i];
	int ma=s;
	for(int i=k;i<n;i++)
	{
		s-=a[i-k];
		s+=a[i];
		ma=max(ma,s);
	}
	cout<<ma<<endl;}
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>


using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

int main(){

	int n,k;
	int a[100001];

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

	int ub,lb;
	ub=lb=0;
	ll cSum=0;
	for(int i = 0; i < k; i++){
		cSum += a[i];
	}
	ll maxSum = cSum;
	for(int i = 1; i <= n - k; i++){
		cSum -= a[i-1];
		cSum += a[i+k-1];
		maxSum = max(maxSum,cSum);
	}

	cout << maxSum << endl;

	int x;
	cin >> x;

	return 0;
}

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

using namespace std;

int main(int argc, char **argv)
{
	int n, m, *a, tmp;
	
	while(1){
		cin >> n >> m;
		if(n == 0){
			break;
		}
		a = (int *)calloc(n, sizeof(int));
		
		for(int i = 0; i < n; i++){
			cin >> tmp;
			a[i] = tmp;
		}
		
		tmp = 0;
		for(int i = 0, tmp2 = 0; i <= (n-m); i++, tmp2 = 0){
			for(int j = 0; j < m; j++){
				tmp2 += a[i+j];
			}
			if(tmp < tmp2){
				tmp = tmp2;
			}
		}
		
		cout << tmp << endl;
		free(a);
	}
	
	return 0;
}

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



int main(){
        int n, k,max,temp,num,total;
        while(true) {  //ベクターに格納
                cin >> n>>k;
                if(n==k!=0) break;
                vector<double> v;
                total=0;
                v.push_back(total);
                for(int i=0;i<n;i++){
                  cin>>num; //入力をnumに代入
                  total+=num;
                  v.push_back(total); //ベクターvにプッシュ
                }

                max=0;
                temp=0;
                for(int i=0; i+k<=n; i++) {
                        temp=v[i+k]-v[i];
                        if(temp>max) max=temp; //tempが最も大きい数値ならmaxを更新
                        temp=0; //tempの初帰化
                }
                cout<<max<<endl;
        }
}

C++: #include<iostream>
using namespace std;
int a[1000000]
int main(){
	int i,i2,n,k,max=-100000000,sum;
	cin>>n>>k;
	while(n!=0){
		for(i=1;i<=n;i++)cin>>a[i];
		for(i=1;i<=n-k+1;i++){
			sum=0;
			for(i2=i;i2<i+k;i2++)sum+=a[i2];
			if(sum>max){
				max=sum;
			}
		}
		cout<<max<<endl;
		cin>>n>>k;
	}
}
/*#include <stdio.h>
 
int a[100000];
 
int main() {
  int i, j, n, m, k, t;
  while (1) {
    scanf("%d%d", &n, &k);
    if (!n && !k) break;
    for (i = 0; i < n; i++) ~scanf("%d",a+i);
    for (i = m = 0; i < n - k; i++) {
      for (j = t = 0; j < k; j++) t += a[i+j];
      if (t > m) m = t;
    }
    printf("%d\n", m);
  }
  return 0;
}*/

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

int main(){
	int n,k,max=0,*a,buf;
	
	cin >> n >> k;
	
	a = new int[n];
	
	for(int i = 0; i < n; i++){
		cin >> a[n];
	}
	
	for(int i = 0; i < n-k; i++){
		buf = 0;
		
		for(int j = 0; j < k; j++){
			buf += a[i+j];
		}
		
		if(max < buf){
			max = buf;
		}
	}
	
	cout << max << endl;
	
	return 0;
}