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<cstdio>
using namespace std;
int main(){
    int n,k;
    int s = 0;
    int a[100000] = {0};
    for(;;){
        scanf("%d%d",&n,&k);
        if(n == 0&&k == 0)break;
        for(int i = 0;i < n; i++){
            scanf("%d",&a[i]);
        }
        int x = 0;
        for(int i = 0;i < k; i++){
            x += a[i];
        }
        s = x;
        for(int i = 0;i < (n-k); i++){
            x -= a[i];
            x += a[i+k];
            if(s < x)s = x;
        }
        printf("%d\n",s);
    }
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n,k;
  while(cin >> n >> k) {
    if(n+k == 0) break;
    vector<int> seq(n);
    for(int i=0;i<n;i++) {
      cin >> seq[i];
    }
    int wa = 0;
    for(int i=0;i<k;i++) {
      wa += seq[i];
    }
    int st = 0;
    int now = wa;
    for(int en=k;en<n;en++) {
      now = now - seq[st] + seq[en];
      st++;
      wa = max(wa,now);
    }
    cout << wa << endl;
  }
}

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

C++: #include<stdio.h>
#include <iostream>
int length;
int k;
int* a;
//int sum;
int main(){
  while(1){
  std::cin>>length;
  std::cin>>k;
    if(k==0&&length==0)return 0;
  a=new int[length];
  for(int i=0;i<length;i++){
    int input=0;
    std::cin>>input;
    a[i]=input;
  }
  int* sums=new int[length];
  int s=0;
  for(int i=0;i<length;i++){
    s+=a[i];
    sums[i]=s;
  }
    //std::cout<<"\n";
  int max=0;
  int psum=0;
    int idx=0;
  for(int i=0;i<length-k;i++){
    int diff=sums[i+k]-sums[i];
    if(diff>max){
      max=diff;
      idx=i;
      
    //std::cout<<"\n";
    }
      //std::cout<<diff;
  }
  std::cout<<max;
    std::cout<<"\n";
  //std::cout<<std::to_string(idx)+"\n";
  //std::cout<<s;
  }
  return 0;
}

C++: #include <cstdio>

int main(){
	int n, k;
	int a[100000];
	int sum;
	int max = -99999999;
	
	for(;;){
		scanf("%d %d", &n, &k);
		if(n == 0 && k == 0) break;
		
		for(int i = 0; i < n; i++){
			scanf("%d", a[i]);
		}
	
		for(int i = 0; i < n - k; i++){
			sum = 0;
			for(int j = i; j < i + k; j++){
				sum += a[j];
			}
			if(max < sum) max = sum;
		}
	
		printf("%d\n", max);
	}
	
	return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
long long int n,a[1000001],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 <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);
        ans=0;
        for(int i=0;i<n;i++){
            cin>>a.at(i);
        }
        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;
    }
}

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

using namespace std;

int main() {
	int n, k;
	while (cin >> n >> k) {
		if (n == 0 && k == 0) {
			break;
		}
		vector<int> data(n);
		long long int sum = 0;
		long long int MAX;
		for (int i = 0; i < n; i++) {
			cin >> data[i];
			sum += data[i];
			if (i == k-1) {
				MAX = sum;
			} else if (i > k-1) {
				sum -= data[i-k];
				MAX = max(MAX, sum);
			}
		}
		cout << MAX << endl;
	}
	return 0;
}

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[i];
  }
  int tmp;
  cin >> tmp >> tmp;

  vector<int> s(n);
  for (int i = 0; i < n; i++) {
    s[i + 1] = s[i] + A[i];
  }
  int mx = (1 << 21) * -1;

  for (int i = 0; i < n - k; i++) {
    mx = max(mx, s[i + k] - s[i]);
  }
  cout << mx << endl;
}

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

using namespace std;

int main(){


    int n,k,ans=0,ans2=0,mx=0;
    while(1){
    scanf("%d%d",&n,&k);
    if(n==0&&k==0)break;
    int num[n];
    for(int y=0;y<n;y++){
        scanf("%d",&num[y]);
    }
        for(int a=0;a<k;a++){
        ans+=num[a];
        }
        mx=ans;
    for(int j=0;j<n-k;j++){
        ans2=ans-num[j]+num[j+k];
        if(mx<ans2){
            mx=ans2;
        }
    ans=ans2;
    ans2=0;
    }
    printf("%d\n",mx);
    }

return 0;
}

C++: #include <stdio.h>
int main(){
    long long int n,k,a[10],top;
    while(1){
        scanf("%lld%lld",&n,&k);
        if(n==0)return 0;
        scanf("%lld",&a[0]);
        for(int i=1;i<k;i++){
            scanf("%lld",&a[i]);
            a[i]+=a[i-1];
        }
        top=a[k-1];
        for(int i=k;i<n;i++){
            scanf("%lld",&a[i]);
            a[i]+=a[i-1];
            a[i]-=a[i-k];
            if(i!=k)a[i]+=a[i-k-1];
            if(a[i]>top)top=a[i];
        }
        printf("%lld\n",top);
    }
}

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

using namespace std;

int main() {
    while(true) {
        int n, k;
        cin >> n >> k;
        int sum = 0;
        int ans = 0;
        queue<int> q;
        for(int i = 0; i < n; ++i) {
            int num;
            cin >> num;

            sum += num;
            if(i == k-1) ans = sum;
            if(i >= k) {
                sum -= q.front();
                q.pop();
                ans = max(ans, sum);
            }
            q.push(num);
        }

        cout << ans << endl;
    }
    return 0;
}

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

long long int num[100100];

int main(){
    long long int n,m;
    long long int sum=0;
    long long int ans=0;
    while(1){
        cin>>n>>m;
        if(n==0&&m==0)break;
        for(int i=0;i<100100;i++){
            num[i]=0;
            if(num[i+1]==0)break;
        }
        for(int i=0;i<n;i++){
            cin>>num[i];
            if(i<m)sum+=num[i];
        }
        for(int i=1;i<n;i++){
            sum=sum-num[i-1]+num[i];
            if(ans<sum)ans=sum;
        }
        cout<<ans<<endl;
        ans=0;
        }
    return 0;
}

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

#include<algorithm>

int a[100001];

int main() {
	int n, k;
	while (cin >> n >> k && n != 0 && k != 0) {
		a[0] = 0;
		for (int i = 1; i <= n; ++i) {
			cin >> a[i];
			a[i] += a[i - 1];
		}
		int maxi = 0;
		for (int i = k; i <= n; ++i) {
			maxi = max(maxi, a[i] - a[i - k]);
		}

		cout << maxi << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	while(1){
        int n,k;
        int ans[10010] = {0};
        cin >> n;
        cin >> k;
        if(n == 0 && k == 0) break;
        for(int i = 0; i < n; i++){
            cin >> ans[i];
        }
        int mx = 0,sum = 0;
        for(int i = 0; i < k; i++){
            sum += ans[i];
        }
        mx = sum;
        for(int i = k; i < n; i++){
            sum += ans[i];
            sum -= ans[i-k];
            mx = max(mx,sum);
        }
        cout << mx << endl;
	}
	return 0;
}