Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		t, d, l := io.NextInt(), io.NextInt(), io.NextInt()
		if t == 0 {
			break
		}
		cnt := 0
		elapsed := math.MaxInt32
		for i := 0; i < t-1; i++ {
			x := io.NextInt()
			if x >= l {
				cnt++
				elapsed = 1
			} else if elapsed < d {
				cnt++
				elapsed++
			}
		}
		_ = io.NextInt()
		io.Println(cnt)
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int T,D,L;

int main() {
    cin>>T>>D>>L;
	while(T!=0){
		long long int res=0,inp,water=0;
		for(int i=1;i<=T;i++){
			
			if(water>0){res++;water--;}
			cin>>inp;
			if(inp>=L){water=D;}
		}	
		cout<<res<<endl;
		cin>>T>>D>>L;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}


signed main(){
    int t,d,l;
    while(cin>>t>>d>>l,t){
        int x=0,res=0;
        rep(i,t){
            if(x)res++;
            int y;cin>>y;
            if(x)x--;
            if(y>=l)x=d;
        }
        cout<<res<<endl;
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>
#define loop for(;;)
#define rep(i, n) for(long i = 0; i < (long)(n); ++i)
typedef std::vector<long> LI;

struct Solver {
   void solve() {
      long t, d, l; std::cin >> t >> d >> l;
      if( t == 0 or d == 0 or l == 0 ) exit(0);
      long rem = 0;
      LI xs(t); rep(i, t) std::cin >> xs[i];
      long res = 0;
      LI ys(t+d, 0);
      for(long i = 0; i < t; ++i) {
         if( l <= xs[i] ) {
            ys[i]     += 1;
            ys[i+d-1] -= 1;
         }
      }
      long s = 0;
      for(long i = 0; i <= t; ++i) {
         s += ys[i];
         if( s != 0 ) res += 1;
      }
      printf("%ld\n", res);
   }
};

int main() { loop std::shared_ptr<Solver>(new Solver())->solve(); }

C++: #include "bits//stdc++.h"
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
int wet[100001];
int main() {
	int T, D, L;
	while (cin >> T >> D >> L, T) {
		memset(wet, 0, sizeof(wet));
		for (int i = 1; i <= T; i++) {
			int x;
			cin >> x;
			if (x >= L) {
				wet[i]++;
				if (i + D <= T) wet[i + D]--;
			}
		}
		int ans = 0;
		for (int i = 1; i < T; i++) {
			wet[i] += wet[i - 1];
			if (wet[i] > 0) ans++;
		}
		cout << ans << endl;
	}
}

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

int main() {
  while (true) {
    int t, d, l;
    cin >> t >> d >> l;
    if (t + d + l == 0) return 0;
    
    vector<int> x(t);
    for (int i = 0; i < t; i++) cin >> x.at(i);
    
    vector<int> imos(210000);
    for (int i = 0; i < t; i++) {
      if (x[i] >= l) {
        imos[i + 1]++;
        imos[i + 1 + d]--;
      }
    }
    
    for (int i = 1; i < 209999; i++) imos[i] += imos[i - 1];
    
    int ans = 0;
    for (int i = 1; i <= t - 1; i++) {
      if (imos[i] > 0) ans++;
    }
    
    cout << ans << '\n';
  }
}

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

int main() {
    int N, D, L;
    while (cin >> N >> D >> L, N || D || L) {
        vector<int> v(N);
        for (int i = 0; i < N; i++) {
            int l;
            cin >> l;
            if (l >= L) v[i]++, v[min(N-1, i+D)]--;
        }

        int count = 0;
        int ans = 0;
        for (int i = 0; i < N-1; i++) {
            count += v[i];
            if (count > 0) ans++;
        }

        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;
using ll=long long;

void solve(){
  while(1){
    int t,d,l;
    cin >> t >> d >> l;
    if(!(t|d|l))return;
    int res=0,last=-1;
    for(int i=1;i<=t;i++){
      int x;
      cin >> x;
      if(x>=l){
        if(last!=-1)
          res+=min(i-last,d);
        last=i;
      }
    }
    if(last!=-1)
      res+=min(t-last,d);
    cout << res << endl;
  }
}

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