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

int main(void){
  int n , k;
  while(cin>>n>>k,n+k){
  vector<int> in(n);
  for(int i = 0 ; i < in.size() ; i ++) 
    cin>>in[i];
  int res = -(1<<22);
  for(int i = 0 ; i < in.size() - k ; i ++){
    int sum = 0;
    for(int j = i ; j < i + k ; j ++){
      sum += in[j]; 
    }
    res = max(res,sum);
  }
  
  cout<<res<<endl;
  }
}

C++: #include <stdio.h>
int main(){
while(1){
int k,n,i,j,x[100000],max=0,sum=0;
scanf("%d%d",&n,&k);
if(n==0 && k==0) break;
for(i=0;i<n;i++){
scanf("%d",&x[i]);
}
for(i=0;i<=n-k;i++){
	sum=0;
for(j=i;j<i+k;j++){
sum+=x[j];
}
if(max<sum) max=sum;
}
printf("%d\n",max);
}
return 0;
}

C++: #include<iostream>
main(){for(int n,k,a[100000],s,M,i;std::cin>>n>>k,n;printf("%d\n",M))for(M=1<<31,i=s=0;i<n;s+=a[i],k<++i&&(s-=a[i-k-1])&&M<s&&(M=s))std::cin>>a[i];}

C++: #include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef vector<int> vi;
#define MAX(X,Y) ((X)>(Y)?(X):(Y))

int main(void){
  int n, k, s, mx;
  vi vec;
  while(true){
    cin >> n >> k;
    if (n==0 && k==0) break;
    for (int i=0; i<n; i++){
      int t; cin >> t;
      vec.push_back(t);
    }
    mx = s = accumulate(vec.begin(), vec.begin()+k, 0);
    for (int i=k; i<n; i++){
      s = s-vec[i-k]+vec[i];
      mx = MAX(mx, s);
    }
    cout << mx << endl;
  }
  return 0;
}

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

int main(){
  int serchn,numn;
  int gh = 0;
  vector<int> outp;
  for(int a = 0;;a++){
    cin >> numn >> serchn;
    if(numn == 0 && serchn == 0){
      break;
    }
    outp.resize(a+1,0);
    outp[a] = 0;
    gh = 0;
    vector<int> num(numn,0);
    for(int n = 0;n<numn;n++){
      cin >> num[n];
    }
    for(int n = 0;n<serchn;n++){
      outp[a] += num[n];
    }
    gh = outp[a];
    int b = serchn;
    for(int a = 0;b<numn;a++){
      gh += num[b];
      gh -= num[a];
      if(gh > outp[a]){
        outp[a] = gh;
      }
      b += 1;
    }
  }
  for(int b = 0;b<outp.size();b++){
    cout << outp[b] << endl;
  }
  return 0;
}

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

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

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

 **********************************************/
#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 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];
                        //cout << "data[i]="<< data[i]<<endl;
                }

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

        return 0;

}

C++: #include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<set>
#include<string>
using namespace std;
int n,k,ma;
int main(){
    for(;;){
        int num[100001]={0};
        cin>>n>>k;
        if(n==0&&k==0)break;
        for(int i=0;i<n;i++){
            cin>>num[i];
        }
        for(int i=0;i<n-k;i++){
            int all=0;
            for(int j=0;j<k;j++){
                all+=num[i+j];
            }
        if(i==0)ma=all;
        ma=max(ma,all);
        }
        cout<<ma<<endl;
    }
}

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

using namespace std;

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

C++: #include<stdio.h>


int main(){
	
	int n,m;
	int input[100000];
	int cont;
	int now;
	int max;
	int i;
	
	while(1){
		
		scanf("%d%d",&n,&m);
		if(n==0 && m ==0){
			break;
		}
		
		for(i=0;i<n;i++){
			scanf("%d",&input[i]);
		}
		
		now = 0;
		
		for(i=0;i<m;i++){
			now += input[i];
		}
		max=now;
		
		cont = m;
		
		for(i=m;i<n;i++){
			now-=input[i-m];
			now+=input[i];
			
			if(now>max){
				max=now;
			}
		}
		
		printf("%d\n",max);
	}
	
	return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<math.h>
#include<chrono>
#include<string>
#include<chrono>

using namespace std;






int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int nsize;
	int ksize;
	int a[100000];


	while (true) {
		cin >> nsize >> ksize;
		if (nsize == 0 && ksize == 0)break;
		for (int i = 0; i < nsize; i++) {
			cin >> a[i];
		}
		int maxval;
		int val = 0;
		for (int i = 0; i < ksize; i++) {
			val += a[i];
		}
		maxval = val;

		for (int i = ksize; i < nsize; i++) {
			val -= a[i - ksize];
			val += a[i];
			if (maxval < val) {
				maxval = val;
			}
		}
		cout << maxval << endl;
	}
	






	
	
	//system("pause");
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n,k,sum,max=0,i,j,a[100001];
	while(1){
		scanf("%d%d",&n,&k);
		if(n==0&&k==0) break;
		for(i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		for(i=1;i<=n;i++){
			sum=0;
			if(i+k<=n){
				for(j=i;j<i+k;j++){
					sum+=a[j];
				}
				if(max<sum){
					max=sum;
				}
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  while(n!=0 || k!=0){

    vector<int> a(n);
    for(int i=0;i<n;i++){
      cin >> a.at(i);
    }

    vector<int> s(n);
    s.at(0) = 0;
    for(int i=1;i<n;i++){
      s.at(i) = s.at(i-1)+a.at(i-1);
    }

    int ans=0;
    for(int i=0;i<n-k;i++){
      ans = max(s.at(i+k)-s.at(i),ans);
    }

    cout << ans << endl;

    cin >> n >> k;
  }
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<functional>
#include<cstring>
using namespace std;
int main() {
	int n,k;
	int num[100001] = {0};
	while(scanf("%d%d",&n,&k),(n|k)){
		memset(num,0,sizeof(num));
		for(int i = 0; i < n; i++){
			scanf("%d",&num[i]);
		}
		int sum = 0;
		for(int i = 0; i < k; i++){
			sum += num[i];
		}
		for(int i = k; i < n; i++){
			int tmp = sum;
			tmp += num[i];
			tmp -= num[i-k];
			sum = max(sum,tmp);
		}
		printf("%d\n",sum);
	}
    return 0;
}