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++: /**********************************************

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;
    }
}

C++: #include <iostream>
#include <vector>
//#include <set>
#include <algorithm>
//#include <fstream>

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.maximumsum", "r", stdin );
	int n,k;

	while (1) {
		cin >> n >> k;

		if (n == 0 && k == 0 ){
			break;
		} // end if
		vector <int> a (n, 0 );
//		vector <int> sum (n - k + 1, 0 );
//		set <int, greater<int> > sum;
		int res = 0;
		for (int i = 0; i < n; ++i){
			cin >> a[i];
		} // end for
		
		for (int i = 0; i < n - k + 1; ++i){
			int s = 0;
			for (int j = i; j < i + k; ++j){
				s += a[j];
			} // end for
			res = max (res, s );
		} // end for

		cout << res << endl;
	} // end loop
		
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int k,n,a[10000]={0};
    double cube=0,ans=0;
    while(1){
       cin >> n >> k;
       if(n==0&&k==0)break;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n-k;i++){
       cube=0;
       for(int j=0;j<k;j++){
        cube +=a[i+j];
       }
       if(cube>ans)ans=cube;
    }
    cout << ans << endl;
    }
return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
    int N, K;
    while (cin >> N >> K, N) {
        vector<int> a(N);
        int sum = 0, res = -(1e9);
        for (int i = 0; i < K; i++) {
            cin >> a[i];
            sum += a[i];
        }

        res = max(res, sum);
        for (int i = K; i < N; i++) {
            cin >> a[i];
            sum += a[i] - a[i-K];
            res = max(res, sum);
        }
        cout << res << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	int n, k, s, b;
	int a[100001];
	while (1)
	{
		cin >> n >> k;
		if (n == 0 && k == 0)
			break;
		int m[100001] = { 0 };
		for (int i = 0;i < n;i++)
			cin >> a[i];

		m[0] = 0;
		for (int i = 0;i < n;i++)
			m[i + 1] = m[i] + a[i];

		s = 0;
		for (int i = 0;i < n - k + 1;i++)
		{
			b = m[i + k + 1] - m[i + 1];
			if (s < b) 
				s = b;
		}

	}
	cout << s << 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;

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

    cout << z << endl; 
  }
}

C++: #include <iostream>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[])
{
    int n,k;
    while (cin >> n >> k) 
    {
        if (n == 0 && k==0) 
        {
            break;
        }
        vector<int> vec(n);
        int sum_max=0;
        int j;
        int sum=0;
        for (int i = 0; i < n; i++) 
        {
            cin >> vec[i];
            if (k  == i + 1) 
            {
                for (j = 0; j < k; j++) 
                {
                    sum += vec[i - j];
                    cout << i-j << " ";
                }
                cout << endl;
                sum_max = max(sum ,sum_max);
                sum -= vec[i-k+1];
            }

            else if (k  < i + 1) 
            {
                sum += vec[i];
                sum_max = max(sum ,sum_max);
                sum -= vec[i-k+1];
            }
        }
        cout << sum_max << 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);
        for(int i=0;i<n;i++){
            cin>>a.at(i);
        }
        ans=0;
        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<<endl;
    }
}

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

using namespace std;

int main() {
    int n, m;
    vector<int> ans;
    while(cin >> n >> m) {
        if(n == 0 && m == 0) {
            break;
        }
        int nums[n];
        for(int i = 0; i < n; i++) {
            cin >> nums[i];
        }
        int max = 0;
        for(int i = 0; i < m; i++) {
            i += nums[i];
        }
        for(int i = 1; i < n - m + 1; i++) {
            int sum = 0;
            int k = i;
            for(int j = 0; j < m; j++) {
                sum += nums[k + j];
            }
            if(sum > max) {
                max = sum;
            }
        }
        ans.push_back(max);
    }
    for(int i = 0; i < ans.size(); i++) {
        cout << ans.at(i) << endl;
    }
}