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 <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define rep(i, a, n) for(int i = (a);i < (n);i++)
#define REP(i, n) rep(i,0,n)
#define all(e) (e).begin(),(e).end()

#ifdef LOCAL
#define show(x) cerr<<__LINE__<<": "<<#x<<(x)<<endl
#else
#define show(x) true
#endif

typedef long long ll;
template<class T> using V=vector<T>;

template<class T, class U>
void chmin(T &t, const U u) { if (t > u) t = u; }

template<class T, class U>
void chmax(T &t, const U u) { if (t < u) t = u; }

const int INF = (1 << 30) - 1;
const ll INFL = (ll) 5e15;
const int MOD = 1e9 + 7;

class Solver {
public:
    bool solve() {
        cin >> T >> D >> L;
        if (T == 0) return false;
        res.resize(3 * T);
        REP(i, T) {
            int x;
            cin >> x;
            if (x >= L) {
                res[i]++;
                res[i + D]--;
            }
        }

        rep(i, 1, T + 10) {
            res[i] += res[i - 1];
        }
        REP(i, T - 1) {
            if (res[i] > 0) ans++;
        }

        cout << ans << endl;
        return true;
    }

private:
    int T, D, L;
    V<ll> res;
    ll ans = 0;
};

int main() {

    while (Solver().solve());

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int T,D,L;cin>>T>>D>>L;
        if(T+D+L==0) break;
        
        vector<int> imo(200005,0);
        
        for(int i=1;i<=T;i++){
            int a;cin>>a;
            if(a>=L){
                imo[i+1]++;
                imo[i+1+D]--;
            }
        }
        
        for(int i=1;i<=200003;i++) imo[i]+=imo[i-1];
        
        int ans=0;
        
        for(int i=2;i<=T;i++){
            if(imo[i]) ans++;
        }
        
        cout<<ans<<endl;
    }
}

C++: #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int T, D, L;
    while (cin >> T >> D >> L, T) {
        vector<int> flood(T + D);
        for (int i = 0; i < T; i++) {
            int x; cin >> x;
            if (x < L) continue;
            flood[i] += 1;
            flood[i + D] -= 1;
        }
        for (int i = 1; i < T + D; i++) flood[i] += flood[i - 1];
        int cnt = 0;
        for (int i = 0; i < T - 1; i++) if (flood[i]) cnt++;
        cout << cnt << endl;
    }
    return 0;
}

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

int main(){
  int t,d,l;
  while(cin >> t >> d >> l,t){
    int wave[t];
    for(int i=0; i<t; ++i){
      cin >> wave[i];
    }
    int ans=0,last=-1;
    for(int i=0; i<t; ++i){
      if(i-d <= last && last >=0)ans++;
      if(wave[i]>=l)last = i;
    }
    cout << ans << endl;
  }
}

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

int main()
{
    vector<int> ans;
    while (1)
    {
        int t, d, l;
        cin >> t >> d >> l;
        if (t == 0 && d == 0 && l == 0)
        {
            break;
        }

        int total = 0;
        int dryTime = 0;
        bool wet = false;
        for (int i = 0; i < t; ++i)
        {
            // int input;
            // cin >> input;
            // if (i % 2 == 0)
            // {
            //     a = (input < l ? 0 : 1);
            // }
            // else
            // {
            //     b = (input < l ? 0 : 1);
            // }
            // if (!(a == 0 && b == 0))
            // {
            //     total++;
            // }

            int input = 0;
            cin >> input;
            if (i == t - 1)
                break;
            if (input < l)
            {
                ++dryTime;
                if (dryTime < d && wet)
                    total++;
                if (dryTime >= d)
                    wet = false;
            }
            else
            {
                wet = true;
                ++total;
                dryTime = 0;
            }

            // if (dryTime == d)
            // {
            //     total += d;
            // }
        }

        ans.push_back(total);
    }

    for (int i = 0; i < ans.size(); ++i)
    {
        cout << ans[i] << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main(){
  int t,d,l,x;

  int a[40];
  int count = 0;

  while(cin >> t >> d >> l){
    int check = 0;
    int num = 0;
    
    if(t == 0 && d == 0 && l == 0){ break; }

    for(int i = 0; i< t; i++){
        cin >> x;
        if(i != t-1){
            if(x >= l){ check = d; }
            if(check > 0){
                num++;
                check--;
            }
        }
    }

    a[count] = num;
    count++;
  }

  for(int j = 0; j < count; j++){
    cout << a[j] << endl;
  }

  return 0;
}