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

int main() {
    int t, d, l;
    while (cin >> t >> d >> l, t != 0) {
        int x;
        int ans = 0;
        int D = 0;

        for (int i = 0; i < t; i++) {
            cin >> x;
            if (x >= l) {
                D = d;
            }
            if (D > 0) {
                ans++;
                D--;
            }
        }

        if (ans > 0) ans--;
        cout << ans << endl;
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  int t, d, l;

  while(cin>>t>>d>>l, t){
    int x, a=0, z=0;
    for(int i=0;i<t;i++){
      cin>>x;
      if(x>=l){
        if(a>0)z++;
        a=d;
      }
      else{
        if(a>0) z++; 
        a--;
      }
    }
    cout<<z<<endl;
  }
}

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

int main(){

    while(1){
        int t,d,l;
        cin >> t >> d >> l;
        if(t==0&&d==0&&l==0)break;
        vector<int> x(t);
        for(int i=0;i<t;i++){
            cin >> x[i];
        }
        int cnt=0;
        int ans=0;
        for(int i=0;i<t-1;i++){
            if(x[i]>=l){
                cnt=d;
            }else{
                cnt--;
            }
            if(cnt>0)ans++;
            //cout << cnt << endl;
        }
        cout << ans << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#define REP(i, n) for(long long i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
	while(1) {
		int t, d, l;
		cin>>t>>d>>l;
		if(t==0&&d==0&&l==0) break;
		int buf = 0;
		int res = 0;
		REP(i, t - 1) {
			int x;
			cin>>x;
			if(x >= l) {
				buf = d - 1;
				res++;
			} else if(buf > 0) {
				++res;
				--buf;
			}
		}
		int x;
		cin>>x;
		cout<<res<<endl;
	}
}