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;

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

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int t,d,l;
int a[100010];

void solve() {
  for (int i = 0; i < t; i++) {
    cin >> a[i];
  }
  int ans = 0;

  int mx = -1;
  int begin = 0;
  int end = 0;
  bool f = 0;
  for (int i = 0; i < t; i++) {
    if (a[i] >= l) {
      if (f) {
        end = i + d;
        end = min(t-1,end);
      } else {
        f = 1;
        begin = i;
        end = i + d;
        end = min(t-1,end);
      }
    } else {
      if (f) {
        if (i >= end) {
          ans += end - begin;
          f = 0;
        }
      }
    }
  }
  if (f) ans += end - begin;
  cout << ans << endl;
}

int main(int argc, char *argv[]){

  /*Regular*/
  // if (argc > 1 && stoi(argv[1])) cin >> case_num;
  // REP(case_no, case_num) {
  //   cerr << endl << "case " << case_no + 1 << endl;
  //   solve();
  // }

  /*ICPC*/
  while (cin >> t >> d >> l, t) {
    solve();
  }

  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
using namespace std;

int T, D, L;

void solve()
{
  int res = 0;
  int f = 0;
  rep(i, T-1) {
    int x;
    cin >> x;
    if (x >= L) {
      res++;
      f = D - 1;
    } else if (f) {
      res++;
      f--;
    }
  }
  int t;
  cin >> t;
  cout << res << endl;
}

bool init()
{
  cin >> T >> D >> L;
  return T > 0;
}

int main(void)
{
  while (init()) {
    solve();
  }
}

C++: #include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int t, d, l;
    while(cin >> t >> d >> l, t){
        vector<int> v(t);
        int ans = 0, p = -1;
        for (auto &&i : v) scanf("%d", &i);
        for (int i = 0; i < t; ++i) {
            if(i && v[i-1] >= l) p = d;
            else p--;
            if(p > 0) ans++;
        }
        cout << ans << "\n";
    }
    return 0;
}

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

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

C++: #include <iostream>
#include <vector>
#include <bitset>
#include <cstring>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int t,d,l; cin >> t >> d >> l;
		if(t==0&&d==0&&l==0)break;
		vector<int> x(t);
		vector<int> s(t);
		for(int i=0;i<t;i++){
			cin >> x[i];
			if(x[i]>=l){
				s[i]++;
				s[min(t-1,i+d)]--;
			}
		}
		for(int i=0;i<t-1;i++){
			s[i+1]+=s[i];
		}
		int ans=0;
		for(int i=0;i<t;i++){
			if(s[i]>0)ans++;
		}
		cout << ans << endl;
	}
}

C++: #include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define rep(i, j, k) for (auto i = j; i < k; i++)
#define rrep(i, j, k) for (auto i = j; i > k; i--)
using namespace std;

int a[100011];

void solve(int &t, int &d, int &l) {
  fill(a, a + 100001, 0);
  rep(i, 0, t) {
    int x; cin >> x;
    if (x >= l) {
      a[i]++;
      if (i + d < 100011) a[i + d]--;
    }
  }
  rep(i, 1, 100001) a[i] = a[i] + a[i - 1];
  int ans = 0; 
  rep(i, 0, t - 1) if (a[i]) ans++;
  cout << ans << endl;
}

int main() {
  int t, d, l;
  while (cin >> t >> d >> l, t) solve(t, d, l);
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
	while(1){
		long long int T,D,L,i[100000]={0},wet[100000]={0},num=0;
		cin>>T>>D>>L;
		if(T==0&&D==0&&L==0)	break;
		for(int y=0;y<T;y++){
			cin >> i[y];
			if(i[y]>=L){
				for(int x=y;x<D+y;x++){
					wet[x] = 1;
				}
			}
		}
		for(int y=0;y<T-1;y++){
			num = num+wet[y];
		}
		cout  << num <<"\n";
}
	return 0;
}