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>
using namespace std;
int main() {
	while (1) {
		int n, k, a[100005] = { 0 }, sum[100005] = { 0 }, m = -99999999;
		cin >> n >> k;
		if (n == 0 && k == 0) return 0;
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int i = 0; i < k; i++) {
			sum[0] += a[i];
		}
		for (int i = 1; i < n - 2; i++) {
			sum[i] = sum[i - 1] + a[i + 2] - a[i - 1];
		}
		for (int i = 0; i < n - 2; i++) {
			if (m < sum[i]) {
				m = sum[i];
			}
		}
		cout << m << endl;
	}
}

C++: 

#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}



template< class T >
struct CumulativeSum {
  vector< T > data;

  CumulativeSum(int sz) : data(sz, 0) {};

  CumulativeSum(vector< T> v) : data(v.size()+1,0) {rep(i,v.size()) add(i+1,v[i]); build();};

  void add(int k, T x) {
    data[k] += x;
  }

  void build() {
    for(int i = 1; i < data.size(); i++) {
      data[i] += data[i - 1];
    }
  }

  T query(int l,int r) {  // [l,r)
    if(l < 0) return (0);
    return (data[min(r,(int)data.size()-1)]-data[min(l,(int)data.size()-1)]);
  }
};


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,k;
  while(true){
    cin>>n>>k;
    if(n==0) break;
    vi a(n);
    rep(i,n){
      cin>>a[i];
    }
    CumulativeSum<int> v(a);
    int ans=-INF;
    rep(i,n-k){
      ans=max(ans,v.query(i,i+k));
    }
    cout<<ans<<endl;
  }


}

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

using namespace std;

int suretu[100000];
int cont = 0;
int max_sum = 0;

int ret_maxsum(int n, int k, int wa, bool isBegin)
{
	/*
	int temp = 0;
	int max = 0, cont = 0;
	int wa;							//ツ陳シツ前ツづ個禿アツづつづ個計ツ算ツづ系ツ古つづ個計ツ算ツづ個和
	
	for(int i = 0; i < n-k+1; i++){
		for(int j = 0; j < k; j++){
			temp += suretu[cont+j];
			if(
			printf("suretu%d = %d\n",j,suretu[cont+j]);
		}
		cout << "**" << endl;
		if(temp > max){
			printf("*maxツ更ツ新\n");
			max = temp;
		}
		temp = 0;
		cont++;
	}
	
	return max;
	*/
	
	int temp = 0;
	int i;
	
	if(isBegin == 1){
		for(i = 0; i < k; i++){
			temp += suretu[cont+i];
		}
	}
	else{
		temp += wa + suretu[cont+k-1];
	}
	wa = temp - suretu[cont];
//	printf("temp = %d\nwa = %d\n\n",temp,wa);
	cont++;
	
	if(max_sum < temp){
//		cout << "maxツ更ツ新:" << temp << endl;
		max_sum = temp;
	}
	
	if(cont == n-k+1){
		return max_sum;
	}
	else{
		return ret_maxsum(n, k, wa, 0);
	}
}
	

int main()
{
	for(;;){
		int n,k;
		
		cin >> n;
		cin >> k;
		if(n == 0 && k == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			cin >> suretu[i];
		}
		
		printf("%d\n",ret_maxsum(n, k, 0, 1));
	}
}

C++: #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  int N;
  cin >> N;
  //いもす！！
  vector<int> P(1000, 0);

  for(int i = 0; i < N; i++) {
    int s, e;
    cin >> s >> e;
    P[s]++;
    P[e]--;
  }
  //るいせきわ(=いたにんずう) 1ひいてつかう
  vector<int> S(1001);
  S[0] = 0;
  for(int i = 0; i < N; i++) {
    S[i + 1] = S[i] + P[i];
  }
  bool flag = true;
  for(int i = a; i <= b; i++) {
    if(S[i] > 0) { flag = false; }
  }

  if(flag)
    cout << 0 << endl;
  else
    cout << 1 << endl;

  return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int n, k;
int a[100000];
int s;
int main()
{
	cin >> n >> k;
	while(n*k!=0)
	{
		s=0;
		for(int i=0; i<k; i++)
		{
			cin >> a[i];
			s+=a[i];
		}
		for(int i=k; i<n; i++)
		{
			cin >> a[i];
			s=max(s, s+a[i]-a[i-k]);
		}
		cout << s << endl;
		cin >> n >> k;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    int n, k;
    while(cin>>n>>k, n){
        vector<ll> a(n+10, 0);
        for(int i=1; i<=n; i++){
            cin>>a[i];
            a[i]+=a[i-1];
        }

        ll ans=-INF;
        for(int i=1; i+k-1<=n; i++){
            chmax(ans, a[i+k-1]-a[i-1]);
        }
        cout << ans << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,k,sum,max,a,i;
	int *data;
	while(cin>>n>>k){
		if(n==0 && k==0){break;}
		data=new int[n];
		sum=0;
		for(i=0;i<k;i++){
			cin>>data[i];
			sum+=data[i];
		}
		max=0;
		for(i=k;i<n;i++){
			cin>>data[i];
			sum-=data[i-k];
			sum+=data[i];
			if(sum>max){
				max=sum;
			}
		}
		cout<<max<<endl;
	}
	return 0;
}

C++: #include<stdio.h>
int main(){
int n,m,cont,now,max,i,input[100000];
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);
}
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x) {ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);


int main(){
	int n,k;
	while(cin>>n>>k,n|k){
		vi a(n);
		REP(i,n){
			cin>>a[i];
		}

		int sum=0;
		REP(i,k){
			sum+=a[i];
		}

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

		cout<<ans<<endl;
	}
}

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

int main()
{
    int n,m,result;
    int num[100005];
    int memo[100000];
    while(cin >> n >> m, n+m)
    {
        for(int i = 0; i < n; i++)cin >> num[i];
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                memo[i] = num[m-j];
            }
        }
        for(int i = 0; i < n; i++)
        {
            result = max(result,memo[i]);
        }
        cout << result << endl;
    }
    return 0;
}