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<bits/stdc++.h>
using namespace std;


void f(int t,int d,int l){
  int ans=0,c=0;

  while(t--){
    int x;
    cin>>x;
    if(t==0) break;
    if(x>=l){
      c=d;
    }else{
      c=max(0,c-1);
    }
    if(c>0){
      ans++;
    }
  }

  cout<<ans<<endl;
}


main(){
  int t,d,l;
  while(true){
    cin>>t>>d>>l;
    if(t==0) break;
    f(t,d,l);
  }

}

C++: #include <bits/stdc++.h>
#define loop for(;;)
#define rep(i, n) for(long i = 0; i < (long)(n); ++i)
typedef std::vector<long> LI;

struct Solver {
   void solve() {
      long t, d, l; std::cin >> t >> d >> l;
      if( t == 0 or d == 0 or l == 0 ) exit(0);
      long rem = 0;
      LI xs(t); rep(i, t) std::cin >> xs[i];
      long res = 0;
      LI ys(t+d, 0);
      for(long i = 0; i < t; ++i) {
         if( l <= xs[i] ) {
            ys[i]   += 1;
            ys[i+d-1] -= 1;
         }
      }
      long s = 0;
      for(long i = 0; i < t + d; ++i) {
         s += ys[i];
         if( s != 0 ) res += 1;
      }
      printf("%ld\n", res);
   }
};

int main() { loop std::shared_ptr<Solver>(new Solver())->solve(); }

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int t,d,l;
  while(cin>>t>>d>>l,t){
    int x[100002]={};
    for(int i=0;i<t;i++){
      int r;cin>>r;
      if(r>=l){
        x[i]++;
        x[min(t-1,i+d)]--;
      }
    }
    for(int i=1;i<=t;i++){
      x[i]+=x[i-1];
    }
    int cnt=0;
    for(int i=0;i<t;i++){
      if(x[i]>0)cnt++;
    }
    cout<<cnt<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}



signed main(){
	//IOS();
	vector<int>ans;
	while(1){
		int T,D,L;
		cin>>T>>D>>L;
		if(!T&&!D&&!L)break;
		vector<int>imos(100010,0);
		rep(i,1,T+1){
			int t;
			cin>>t;
			if(t<L)continue;
			imos[i]++;
			imos[min(T,i+D)]--;
		}
		rep(i,0,100009)imos[i+1]+=imos[i];
		int sum=0;
		rep(i,1,T+1)if(imos[i])sum++;
		ans.push_back(sum);
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}

C++: #include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
ll inf = 1e18;

ll T, D, L;
ll x[100010];
int main(){
	while(cin >> T >> D >> L && T > 0){
		REP(i,0,T) cin >> x[i];
		ll now = 0;
		ll ans = 0;
		REP(i,0,T){
			if(now > 0){
				ans++;
			}
			if(x[i] >= L){
				now = D;
			}else{
				now--;
			}

		}
		p(ans);
	}

	return 0;
}

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    while(1) {
        ll t, d, l;
        cin >> t >> d >> l;
        if(!t) break;
        ll res = 0;
        ll s = 1;
        while(--t) {
            if(s>0) s--;
            ll x;
            cin >> x;
            if(x >= l) s = d;
            if(s) res++;
        }
        cin >> s;
        cout << res << endl;
    }
}

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

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

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


int main(){
  ll t,d,l;
  while(cin>>t>>d>>l && t){
  ll count=0;
  ll b=-1000000;
  for(int i=0;i<t;i++){
    ll x;
    cin>>x;
    if(i+1==t){continue;}
    if(x>=l){
      b=i;
    }
    count+=i-b<d;
  }
  cout<<count<<endl;
  }





  return 0;
}

C++: #include<stdio.h>
int main(){
	long T,D,L,x[100000];
	while(1){
		int count=0;
		scanf("%d %d %d",&T,&D,&L);
		if(T==0&&D==0&&L==0)break;
		for(int i=0;i<T;i++){
			scanf("%d",&x[i]);
		}
		for(int i=0;i<T;i++){
			if(x[i]>=L){
				for(int j=1;j<=D;j++){
					if(x[i+j]<L){
						count++;
					    i++;
					}
					else break;
				}
			}
		}
		printf("%d\n",count);
	}
	
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
void solve(int T, int D, int L){
    vector<int> V(T);
    rep(i,0,T)cin >> V[i];
    int cnt = 0, last = -INF;
    rep(i,0,T){
        if(i <= last + D)cnt++;
        if(V[i] >= L)last = i;
    }
    cout << cnt << endl;
}
main(){
    int T,D,L;
    cin >> T >> D >> L;
    while(T){
        solve(T,D,L);
        cin >> T >> D >> L;
    }
}