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

void solve(int t, int d, int l) {
    vector<int> x(t);
    for (int i = 0; i < t; i++) cin >> x[i];
    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < t; i++) {
        if (cnt > 0) ans++;
        if (x[i] >= l) cnt = d;
        else cnt--;
        cnt = max(cnt, 0);
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T, D, L;
    while (true) {
        cin >> T >> D >> L;
        if (T == 0 && D == 0 && L == 0) break;
        solve(T, D, L);
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

bool solve(){
  int t,d,l;
  
  scanf("%d%d%d",&t,&d,&l);

  if(t == 0) return false;

  int ans = 0;
  int sec = 0;
  
  for(int i=0;i<t;i++){
    int x;

    scanf("%d",&x);

    if(t-1 == i) continue;
    
    sec--;
    if(x >= l){
      sec = d;
    }

    if(sec > 0) ans++;
  }

  
  printf("%d\n",ans);

  return true;
}

int main(){
  while(solve());
  
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
int T,D,L;
int X[100005];
int main(void)
{
  while(cin >> T >> D >> L && T)
    {
      int ans=0;
      for(int i=0;i<T;i++)
	{
	  cin >> X[i];
	}
      int sink=0;
      for(int i=0;i<T;i++)
	{
	  if(X[i]>=L) sink=D;
	  if(sink>0) 
	    {
	      ans++;
	    }
	   sink=max(sink-1,0);
	}
      cout << max(0,ans-1) << endl;
    }
  return 0;
}

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

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll t, d, l;
    while (cin >> t >> d >> l, t) {

        vector<ll> x(t);
        REP(i, t) cin >> x[i];
        vector<int> wet(t, 0);
        REP(i, t) {
            if (x[i] >= l) {
                wet[i]++;
                if (i+d < t) wet[i+d]--;
            }
        }
        REP(i, t-1) {
            wet[i+1] += wet[i];
        }
        ll ans = 0;
        REP(i, t-1) {
            if (wet[i]) ans++;
        }
        cout << ans << endl;

    }

}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T,D,L;
    while(cin >> T >> D >> L && T){
        vec<int> imos(T+2);
        for(int i=1;i<=T;i++){
            int x;
            cin >> x;
            if(x>=L){
                imos[i]++;
                imos[min(i+D,T+1)]--;
            }
        }
        int ans = 0;
        for(int i=1;i<T;i++){
            if(imos[i]>0) ans++;
            imos[i+1] += imos[i];
//            cerr << i << " " << imos[i] << "\n";
        }
        cout << ans << "\n";
    }
}

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

signed main(){
  
  while(1){
  
    int T, D, L;
    
    cin>>T>>D>>L;
    if( !T && !D && !L ) break;
    
    int ans = 0, prev = -1e9;
    
    for(int i=0;i<T;i++){
      
      int x;
      cin>>x;

      if( i <= prev + D ) ans++;
      
      if( x >= L ) prev = i;
      
    }
    
    cout<<ans<<endl;
    
  }
  
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int t, d, l; cin >> t >> d >> l;
    if(t == 0) break;
    int now = 0;
    int ans = 0;
    REP(i, t) {
      int tmp; cin >> tmp;
      if(i == t-1) break;
      if(tmp >= l) {
        now = d-1;
        ans++;
      } else if(now > 0) {
        ans++;
        now--;
      }
    }
    cout << ans << endl;
  }
}