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 <algorithm>
using namespace std;

int main(){
        while(true){
                int n,k;
                cin>>n>>k;

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

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

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

                cout<<ans<<endl;
        }

        return 0;
}

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

int main(){
  int numn,lisn,num;
  vector<int> outp;
  int outn = 1;
  for(int l = 0;;l++){
    cin >> numn >> lisn;
    if(numn == 0 && lisn == 0)break;
    outp.resize(l+1,0);
    vector<int> lists(numn,0);
    for(int n = 0;n<numn;n++){
      cin >> num;
      lists[n] = num;
    }
    for(int k = 0;k<numn-2;k++){
      outn = lists[k] + lists[k + 1] + lists[k + 2];
      if(outp[l] < outn){
        outp[l] = outn;
      }
    }
  }
  for(int q = 0;q<outp.size();q++){
    cout << outp[q] << endl;
  }
}

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

using namespace std;

int main(){


    int n,k,ans=0,ans2;
    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]);
    if(y>=k){
        for(int a=0;a<k;a++){
        ans+=num[y-k+a];
        }
        if(ans2<ans){
            ans2=ans;
        }
        ans=0;
    }}
    printf("%d\n",ans2);
    }

return 0;
}

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

int main() {
  int n,k;
  cin>>n>>k;
  vector<int> v(n);
  for(int i=0; i<n; ++i)
    cin>>v[i];

  int maxsum = 0,nsum = 0;
  for(int i=0; i<k; ++i) {
    maxsum += v[i];
    nsum += v[i];
  }
  for(int i=k; i<n; i++) {
    maxsum = max(nsum-v[i-k]+v[i], maxsum);
    nsum = nsum-v[i-k]+v[i];
  }

  cout<<maxsum<<endl;
}

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

const long long INF = 1 << 60;

int main() {
    int n, k;
    while (cin >> n >> k) {
        if (n == 0 && k == 0) break;

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

        vector<long long> s(n + 1, 0);
        for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];

        long long ans = -INF;
        for (int i = 0; i < n - k + 1; i++) {
            ans = max(ans, s[k + i] - s[i]);
        } 

        cout << ans << 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,x = 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++){
      x = z;
      z = max(x , z + a[i] - a[i-k]);
    }

    cout << z << endl; 
  }
}

C++: #include <stdio.h>

int a[100050];

int main(void)
{
	int k, n;
	int i, j;
	int max = 0, sum;
	while (1){
		
		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 - k; i++){
			sum = 0;
			for (j = 0; j < k; j++){
				sum += a[j + i];
			}
			if (sum > max){
				max = sum;
			}
		}
		
		printf("%d\n", max);
	}
	
	
	return (0);
}

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

typedef long long ll;
using namespace std;

ll max_sub_sum(vector<ll> accumulations, int range) {
  ll max_tmp = accumulations[range];

  for(int i = 1; i + range - 1 < accumulations.size(); i++) {
    max_tmp = max(max_tmp, accumulations[i + range - 1] - accumulations[i - 1]);
  }

  return max_tmp;
}

int main() {
  int sequence_num;
  int range;
  vector<ll> accumulations;

  while(true) {
    cin >> sequence_num >> range;

    if(sequence_num == 0 && range == 0) {
      break;
    }
    accumulations.resize(sequence_num + 1);

    accumulations[0] = 0;

    for(int i = 1; i <= sequence_num; i++) {
      int current;
      cin >> current;
      accumulations[i] = accumulations[i - 1] + current;
    }

    cout << max_sub_sum(accumulations, range) << endl;
  }
}

C++: /**********************************************

1.
2.炭田高輝
3.sumita.takaki@gmail.com

last updated: 2013-07-10@16:28

 **********************************************/
#include<iostream>
#include<algorithm>
#include<sstream>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;


int main(void){


        while(1){
                
                int n=0;
                int k=0;
                int all=0;
                int total=0, answer=0;
                vector<int> data(5000);

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

                for(int j=0; j<n-k; j++){
                        
                        if( j == 0){
                                for(int i=0; i<k; i++){
                                        total = total + data[j+i];
                                }
                        }else{
                                
                                total = total - data[j-1] + data[j+k-1];
                        }
                        
                        if( answer < total){
                                answer = total;
                        }
                        
                }
                
                cout << answer << endl;
                
        }

        return 0;

}

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

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

C++: #include <cstdio>
#include <cstring>
#define max(a,b) ((a)>=(b)?(a):(b))
int s[100001],n,k;
int main() {
	while(scanf("%d %d",&n,&k),n|k) {
		int ans=0;
		memset(s,0,sizeof(s));
		for(int i=1;i<=n;i++) scanf("%d",&s[i]),s[i]+=s[i-1];
		for(int i=1;i<=(n-k);i++) ans=max(ans,s[i+k-1]-s[i-1]);
		printf("%d\n",ans);
	}
}

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

using namespace std;

int main() {
    while(true){
    int n,k,max=-1e9,sum=0;
    cin >> n >> k;
        if(n==0) break;
    int ar[n];
    for(int i = 0;i<n;i++){
        int a;
        cin >> a;
        ar[i]=a;
    }
    
    for(int i=0;i<n-k+1;i++){
        for(int j=0;j<k;j++){
            sum += ar[i+j];
        }
    if(sum>max){
        max=sum;
    }
        sum=0;
    }
    cout << max <<endl;
    }
}