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 <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;

// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

/*---------------------------------------------------*/

int main() {
    const int MAX = 2000001;
    int T, D, L;
    while(1) {
        cin >> T >> D >> L;
        if(T == 0 && D == 0 && L == 0) break;

        int x, p = 0;
        int ans = 0;
        for(int i = 0; i < T - 1; i++) {
            cin >> x;
            if(L <= x) p = D;
            p--;
            if(0 <= p) ans++;
        }
        cin >> x;
        cout << ans << endl;
    }
}

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

int main(){

    while(1){
        int t, d, l; cin >> t >> d >> l;
        if(!t) break;
        vector<int> T(t - 1, 0);
        
        for(int i = 0; i < t; i++){
            int x; cin >> x;
            if(i == t - 1 || x < l) continue;
            T[i]++;
            T[min(t - 1, i + d)]--;
            
        }

        int ans = 0;

        for(int i = 0; i < t - 1; i++){
            //cout << T[i] << " ";
            T[i + 1] += T[i];
            ans += (T[i] > 0);
        }

        cout << ans << endl;
    }
    return 0;
}

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

int T, D, L;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (1) {
        cin >> T >> D >> L;
        if (!T & !D & !L) break;
        int t;
        vector<int> imosu(200010, 0);
        int ans = 0;
        for (int i = 0; i < T; i++) {
            cin >> t;
            if (t >= L) {
                imosu[i + 1] += 1;
                imosu[i + 1 + D] -= 1;
            }
        }
        for (int i = 1; i < imosu.size(); i++) {
            imosu[i] = imosu[i - 1] + imosu[i];
        }
        for (int i = 0; i < T; i++) {
            if (imosu[i] > 0) ans++;
        }
        cout << ans << endl;
    }
}

C++: #pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    while(1){
        int t, d, l; cin>>t>>d>>l;
        if(t == 0) break;
        int wet = 0, ans = 0;
        for(int i=0; i<t; i++){
            int x; cin>>x;
            if(l <= x) wet = d;
            if(0 < wet && i != t - 1) ans++;
            wet--;
        }

        cout << ans << endl;
    }

    return 0;
}

C++: /*  -*- coding: utf-8 -*-
 *
 * 2824.cc: Coastline
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  for (;;) {
    int t, d, l;
    scanf("%d%d%d", &t, &d, &l);
    if (t == 0) break;

    int sum = 0, c = 0;
    for (int i = 0; i < t; i++) {
      if (c > 0) sum++, c--;
      int xi;
      scanf("%d", &xi);
      if (xi >= l) c = d;
    }

    printf("%d\n", sum);
  }
  return 0;
}

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

const int N = 100000;
int a[N] = { 0 };

int main() {
    int t, d, l, x, ans;
    while(cin >> t >> d >> l, t){
        ans = 0;
        for(int i = 0;i < t;++i){
            cin >> x;
            if(x >= l) {
                a[i] = d;
            }
            else {
                a[i] = i > 0 ? a[i - 1] - 1 : 0;
            }
        }
        for(int i = 0;i < t - 1;++i){
            if(a[i] > 0) {
                ++ans;
            }
        }
        cout << ans << endl;
    }
    return 0;
}