Problem:
海岸線
海岸には毎秒波が押し寄せる．基準点
P
を超えて何 m の地点まで波が押し寄せたかを，
T
秒の間だけ毎秒観測し記録したデータがある．データは
T
個の整数
x
1
,
...
,
x
T
からなり，各
i  (1 ≤ i ≤ T)
に対し，観測を始めてから
i
秒後には地点
P
からちょうど
x
i
m の地点までの波が押し寄せ，海水に浸っていたことを表す．
海岸は，最後に海水に浸ってから
D
秒後に乾くことが分かっている．ここで，乾くまでの時間は最後に海水に浸った時間のみに依存し，それ以前に波に浸っていた回数や時間には依存しないことに注意せよ．
基準点
P
から，陸の方向に距離
L
だけ離れた地点が，観測を開始してから 1 秒後と
T
秒後の間に少なくとも何秒間濡れていたかを求めよ．ただし，時刻 0 で海岸は乾いていたことがわかっている．
以下に，Sample Input 第1ケースの図を示す．
図B1: Sample Input 第1ケースの場合
Input
入力データセットは複数のケースから構成される．データセットの個数は最大でも 40 個を超えない．各ケースは次のような形式である．
T
D
L
x
1
...
x
T
1 行目には
T, D, L  (1 ≤ T, D, L ≤ 100,
000)
が半角スペース区切りで与えられる．続く
T
行のうち
i  (1 ≤ i ≤ T)
行目には
x
i
(0 ≤ x
i
≤ 100,
000)
が与えられる．これらは全て整数である．
データセットの終わりは，3 つの 0 からなる行で表される．
Output
各ケースに対し，基準点
P
から，陸の方向に距離
L
だけ離れた地点が 1 秒後から
T
秒後の間で確実に濡れていた時間 (秒) を 1 行で出力せよ．
Sample Input
5 2 3
3
5
1
2
3
3 100 100
3
3
4
20 3 8
3
2
6
1
9
1
8
4
2
2
8
1
8
8
2
5
3
4
3
8
7 2 2
0
2
5
2
5
2
1
0 0 0
Output for Sample Input
3
0
11
5

Submitted solutions:

code_snippet: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);


    int N , D,L;
    while(cin>>N>>D>>L,N||L||D){
    vector<int>a(N+1);
    for(int i = 1 ; i <= N ; i ++){
        cin>>a[i];
    }

    int ans = 0 ; int cnt = 0 ; int left = -2 ;
    int s = 1;
    for(int i = 1 ; i < N ; i ++ ){

        if(a[i]>=L){
            //if(left<=-1)s = i;
            left = D ;
        }
        //cout<<i<<":"<<left<<endl;
        if(left>=0 ){
            left--;
            if(left>=0)ans++;
//            ans = max(ans, i-s);
        }else {
            left--;
        }

    }
    cout<<ans<<endl;
    }
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 3784
final_rank: 5

code_snippet: #include <bits/stdc++.h>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define rep(i, a, n) for(ll i = a; i < n; i++)
#define rrep(i, a, n) for(ll i = a; i >= n; i--)
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
constexpr int IINF = 1001001001;
constexpr ll INF = 1LL<<60;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}


ll gcd(ll a, ll b){
    if(a%b == 0){
      return b;
    }else{
      return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a*b / gcd(a, b);
}

ll powMod(ll x, ll n) {
    if (n == 0) return 1 % MOD;
    ll val = powMod(x, n / 2);
    val *= val;
    val %= MOD;
    if (n % 2 == 1) val *= x;
    return val % MOD;
}

int main() {
    while(true){
        ll t, d, l; cin >> t >> d >> l;
        if(t == 0) break;
        vector<ll> x(t);
        rep(i,0,t) cin >> x[i];
        ll pre = 0;
        ll ans = 0;
        rep(i,0,t){
            if(x[i] >= l){
                ans += d-max(0LL,pre-i);
                pre = i+d;
                // cout << ans << " ";
            }
        }
        if(pre >= t-1) ans -= pre-(t-1);
        cout << ans << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 130
memory_kb: 4104
final_rank: 19

code_snippet: #include <bits/extc++.h>

using ll = long long;
using namespace std;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)

bool solve() {
  ll t, d, l;
  cin >> t >> d >> l;
  if (t == 0) return false;
  vector<ll> x(t);
  rep(i, t) cin >> x[i];
  ll ans = 0;
  ll mx = 0;
  rep(i, t - 1) {
    if (x[i] >= l) mx = i + d;
    if (mx > i) ans++;
  }
  cout << ans << "\n";
  return true;
}

int main() {
  while (solve());
}
accuracy: 1
time_ms: 100
memory_kb: 4564
final_rank: 15

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep3(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define rep2(i, a, b) rep3(i, a, b, 1)
#define rep1(i, n) rep2(i, 0, n)
#define rep0(n) rep1(aaaaa, n)
#define ov4(a, b, c, d, name, ...) name
#define rep(...) ov4(__VA_ARGS__, rep3, rep2, rep1, rep0)(__VA_ARGS__)
#define per(i, a, b) for (ll i = (a) - 1; i >= (b); i--)
#define fore(e, v) for (auto&& e : v)
#define all(a) begin(a), end(a)
#define sz(a) (int)(size(a))
#define lb(v, x) (lower_bound(all(v), x) - begin(v))
#define eb emplace_back

template <typename T, typename S>
bool chmin(T& a, const S& b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T, typename S>
bool chmax(T& a, const S& b) {
  return a < b ? a = b, 1 : 0;
}
const int INF = 1e9 + 100;
const ll INFL = 3e18 + 100;
#define i128 __int128_t
struct _ {
  _() { cin.tie(0)->sync_with_stdio(0), cout.tie(0); }
} __;

int main(){
  int T,D,L;
  while(1){
    cin>>T>>D>>L;
    if(T==0)break;
    int ans=0,c=0;
    rep(i,T){
      int X;
      cin>>X;
      if(X>=L)c=D;
      if(c&&i+1<T)ans++;
      c=max(0,c-1);
    }
    cout<<ans<<'\n';
  }
}
accuracy: 1
time_ms: 20
memory_kb: 3584
final_rank: 2

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

namespace noya2 {

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
    os << p.first << " " << p.second;
    return os;
}
template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p){
    is >> p.first >> p.second;
    return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
    int s = (int)v.size();
    for (int i = 0; i < s; i++) os << (i ? " " : "") << v[i];
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v){
    for (auto &x : v) is >> x;
    return is;
}

void in() {}
template <typename T, class... U>
void in(T &t, U &...u){
    cin >> t;
    in(u...);
}

void out() { cout << "\n"; }
template <typename T, class... U, char sep = ' '>
void out(const T &t, const U &...u){
    cout << t;
    if (sizeof...(u)) cout << sep;
    out(u...);
}

template<typename T>
void out(const vector<vector<T>> &vv){
    int s = (int)vv.size();
    for (int i = 0; i < s; i++) out(vv[i]);
}

struct IoSetup {
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        cerr << fixed << setprecision(7);
    }
} iosetup_noya2;

const int iinf = 1'000'000'007;
const long long linf = 2'000'000'000'000'000'000LL;
const long long mod998 =  998244353;
const long long mod107 = 1000000007;
const long double pi = 3.14159265358979323;
const vector<int> dx = {0,1,0,-1,1,1,-1,-1};
const vector<int> dy = {1,0,-1,0,1,-1,-1,1};
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string NUM = "0123456789";

void yes(){ cout << "Yes\n"; }
void no(){ cout << "No\n"; }
void YES(){ cout << "YES\n"; }
void NO(){ cout << "NO\n"; }
void yn(bool t){ t ? yes() : no(); }
void YN(bool t){ t ? YES() : NO(); }


unsigned long long inner_binary_gcd(unsigned long long a, unsigned long long b){
    if (a == 0 || b == 0) return a + b;
    int n = __builtin_ctzll(a); a >>= n;
    int m = __builtin_ctzll(b); b >>= m;
    while (a != b) {
        int mm = __builtin_ctzll(a - b);
        bool f = a > b;
        unsigned long long c = f ? a : b;
        b = f ? b : a;
        a = (c - b) >> mm;
    }
    return a << min(n, m);
}

template<typename T> T gcd_fast(T a, T b){ return static_cast<T>(inner_binary_gcd(abs(a),abs(b))); }

long long sqrt_fast(long long n) {
    if (n <= 0) return 0;
    long long x = sqrt(n);
    while ((x + 1) * (x + 1) <= n) x++;
    while (x * x > n) x--;
    return x;
}

template<typename T> T floor_div(const T n, const T d) {
    assert(d != 0);
    return n / d - static_cast<T>((n ^ d) < 0 && n % d != 0);
}

template<typename T> T ceil_div(const T n, const T d) {
    assert(d != 0);
    return n / d + static_cast<T>((n ^ d) >= 0 && n % d != 0);
}

template<typename T> void uniq(vector<T> &v){
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}

template <typename T, typename U> inline bool chmin(T &x, U y) { return (y < x) ? (x = y, true) : false; }

template <typename T, typename U> inline bool chmax(T &x, U y) { return (x < y) ? (x = y, true) : false; }

template<typename T> inline bool range(T l, T x, T r){ return l <= x && x < r; }

} // namespace noya2

#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define repp(i,m,n) for (int i = (m); i < (int)(n); i++)
#define reb(i,n) for (int i = (int)(n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;

namespace noya2{

/*　~ (. _________ . /)　*/

}

using namespace noya2;

void solve(int t, int d, int l){
    vector<int> imos(t+d+10);
    rep(i,t){
        int x; in(x);
        if (x < l) continue;
        imos[i]++;
        imos[i+d]--;
    }
    int ans = 0;
    rep(i,t-1){
        if (imos[i] >= 1){
            ans++;
        }
        imos[i+1] += imos[i];
    }
    out(ans);
}

int main(){
    while (true){
        int t, d, l; in(t,d,l);
        if (t == 0) break;
        solve(t,d,l);
    }
}
accuracy: 1
time_ms: 30
memory_kb: 4916
final_rank: 7

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using a2 = array<ll, 2>;
using a3 = array<ll, 3>;

template <typename A> void chmin(A &l, const A &r) {
    if(r < l)
        l = r;
}
template <typename A> void chmax(A &l, const A &r) {
    if(l < r)
        l = r;
}

ll mod = 998244353;

ll t, d, l;
vector<ll> v;
void input() {
    cin >> t >> d >> l;
    v.resize(t);
    for(auto &x : v) {
        cin >> x;
    }
}

void solve() {
    vector<ll> ok;
    ll ans = 0;
    for(int i = 0; i < t - 1; i++) {
        if(v[i] >= l)
            ok.push_back(i);

        auto itr = upper_bound(ok.begin(), ok.end(), i);
        if(itr == ok.begin())
            continue;
        itr--;
        if(i - *itr < d)
            ans++;
    }
    cout << ans << endl;
}

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

    while(1) {
        input();
        if(t == 0)
            break;
        solve();
    }

    return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 5700
final_rank: 16

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

using ll =long long;

void solve(ll T,ll D,ll L){
	vector<ll> X(T+1,0);
	for(int i=0;i<T;i++){
		ll x;
		cin>>x;
		if(x>=L){
			X[i]++;
			if(i+D<=T)X[i+D]--;
		}
	}
	ll an=0;
	for(int i=0;i<T-1;i++){
		if(i!=0)X[i]+=X[i-1];
		if(X[i]>0)an++;
	}
	cout<<an<<"\n";

}

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

	ll T,D,L;
	while(cin>>T>>D>>L,T+D+L!=0)solve(T,D,L);
}
accuracy: 1
time_ms: 20
memory_kb: 4584
final_rank: 6

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

using ll = long long;

#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define all(A) A.begin(), A.end()

int main() {
  
  while(1) {
    ll T, D, L; cin >> T >> D >> L;
    if(T + D + L == 0) break;
    vector<ll> X(T);
    for(auto &x : X) cin >> x;
    
    ll res = 0;
    ll now = 0;
    rep(i, T) {
      if(X[i] >= L) now = i + D;
      if(i < T-1 && i < now) res++;
    }
    cout << res << '\n';
  }
  
  return 0;
}
accuracy: 1
time_ms: 90
memory_kb: 4560
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define ll long long

int solve(){
  ll t,d,l;
  cin>>t>>d>>l;
  if(t==0 && d==0 && l==0){
    return 0;
  }
  ll count=100000000,ans=0;
  ll line;
  for(int i=0;i<t;i++){
    cin>>line;
    if(i==0){
      if(line>=l){
        count=0;
      }
      continue;
    }
    if(line>=l){
      if(count>=d){

      }
      else{
        ans+=1;
      }
      count=0;
    }
    else{
      count+=1;
      if(count>d){

      }
      else{
        ans+=1;
      }
    }
  }
  cout<<ans<<endl;
  return 1;
}

int main(){
	while(solve()){};
}
accuracy: 1
time_ms: 130
memory_kb: 3204
final_rank: 11

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

bool solve() {
    int T, D, L;
    cin >> T >> D >> L;
    if (T == 0 && D== 0 && L == 0) return false;
    vector<int> A(T);
    for (int i = 1; i <= T; i++) {
        int x;
        cin >> x;
        if (i < T && x >= L) {
            A[i]++;
            if (i + D < T) A[i + D]--;
        }
    }
    int ans = 0;
    for (int i = 0; i < T; i++) {
        if (i) A[i] += A[i - 1];
        ans += A[i] > 0;
    }
    cout << ans << '\n';
    return true;
}

int main() {
    while (solve()) {}
}
accuracy: 1
time_ms: 90
memory_kb: 3920
final_rank: 9

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

#include <atcoder/all>
using namespace atcoder;

using ll = long long;
using mint = modint998244353;

bool solve() {
    int T, D, L;
    cin >> T >> D >> L;
    if(T == 0) return false;
    vector<int> imos(T + D + 1);
    for(int i = 1; i <= T; i++) {
        int x;
        cin >> x;
        if(x >= L) {
            imos[i] += 1;
            imos[i + D] -= 1;
        }
    }
    for(int i = 1; i <= T; i++) {
        imos[i] += imos[i - 1];
    }
    int ans = 0;
    for(int i = 1; i <= T - 1; i++) {
        // cout << imos[i] << endl;
        ans += (imos[i] > 0);
    }
    cout << ans << endl;
    return true;
}

int main() {
    while(solve());
}
accuracy: 1
time_ms: 90
memory_kb: 4892
final_rank: 17

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

#include <atcoder/all>
using namespace atcoder;

using ll = long long;
using mint = modint998244353;

bool solve() {
    int T, D, L;
    cin >> T >> D >> L;
    if(T == 0) return false;
    vector<int> imos(T + D);
    for(int i = 0; i < T; i++) {
        int x;
        cin >> x;
        if(x >= L) {
            imos[i] += 1;
            imos[i + D] -= 1;
        }
    }
    int ans = 0;
    for(int i = 0; i < T - 1; i++) {
        ans += (imos[i] > 0);
        imos[i + 1] += imos[i];
    }
    cout << ans << endl;
    return true;
}

int main() {
    while(solve());
}
accuracy: 1
time_ms: 90
memory_kb: 4896
final_rank: 18

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

bool solve() {
    int T, D, L;
    cin >> T >> D >> L;
    if (T == 0 && D == 0 && L == 0) return false;
    vector<int> S(T);
    for (int i = 1; i <= T; i++) {
        int X;
        cin >> X;
        if (i < T && X >= L) {
            S[i]++;
            if (i + D < T) S[i + D]--;
        }
    }
    int ans = 0;
    for (int i = 0; i < T; i++) {
        if (i) S[i] += S[i - 1];
        ans += S[i] > 0;
    }
    cout << ans << '\n';
    return true;
}

int main() {
    while (solve()) {}
}
accuracy: 1
time_ms: 130
memory_kb: 3752
final_rank: 14

code_snippet: // AOJ 2824 - Coastline
// JAG Practice Contest for Japan Domestic 2017 - Problem B

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

int main() {
  while(true) {
    int T, D, L; cin >> T >> D >> L;
    if(T == 0) break;
    vector<int> X(T);
    for(int i=0; i<T; ++i) cin >> X[i];

    int ans = 0;
    int last = -1;
    for(int i=0; i<T; ++i) {
      if(last != -1 && i - last <= D) ++ans;
      if(X[i] >= L) last = i;
    }
    cout << ans << endl;
  }
}
accuracy: 1
time_ms: 130
memory_kb: 3572
final_rank: 12

code_snippet: #line 1 "2017JAGB.cpp"
#include <bits/stdc++.h>
#line 1 "/home/ardririy/repos/cp-libs/libraries-cpp/input.hpp"


#line 6 "/home/ardririy/repos/cp-libs/libraries-cpp/input.hpp"
using namespace std;
vector<long long> i64_vec_IN(int n) {vector<long long> res(n); for(int i=0; i<n; i++) { cin >> res[i]; } return res; }
vector<string> str_vec_IN(int n) { vector<string> res(n); for(int i=0; i<n; i++) { cin >> res[i]; } return res; }
vector<vector<int>> graph_IN(int n, int m) { vector<vector<int>> g(n); int u, v; for(int i=0; i<m; i++) { cin >> u >> v; u--; v--; g[u].emplace_back(v); g[v].emplace_back(u); } return g; }
vector<vector<pair<int, long long>>> weighted_graph_IN(int n, int m) { vector<vector<pair<int, long long>>> g(n); int u, v; long long w; for(int i=0; i<m; i++) { cin >> u >> v >> w; u--; v--; g[u].push_back({v, w}); g[v].push_back({u, w}); } return g; }


#line 3 "2017JAGB.cpp"

using namespace std;

// using namespace atcoder;

#ifdef ADRY
#include <dbg.h>
#else
// DO NOTHING
#define dbg(x, ...)
#endif


#define all(v) v.begin(),v.end()
#define resort(v) sort(v.rbegin(),v.rend())
using ll = long long;
using ull = unsigned long long;
using vll=vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,ll>;
using vp=vector<pair<ll, ll>>;
using djks=priority_queue<P, vp, greater<P>>;

const int inf=1ll<<30;
#define mod10 (ll)1e9+7
#define mod99 (ll)998244353
const double PI = acos(-1);

#define rep(i,n) for (ll i=0;i<(n);++i)
#define per(i,n) for(ll i=(n)-1;i>=0;--i)
#define rep2(i,a,n) for (ll i=(a);i<(n);++i)
#define per2(i,a,n) for (ll i=(n)-1;i>=(a);--i)


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

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


int solve(){
    ll t, d, l; cin >> t >> d >> l;
    if(t==0) return 1;

    ll last_time = -inf;
    ll ans = 0;
    ll ti;
    rep(i,t) {
        cin >> ti;
        if(ti>=l) last_time = i;
        dbg(i, last_time, d);
        if(i+1 != t && i-last_time<d) ans++;
    }
    cout << ans << '\n';
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(!solve());
}
accuracy: 1
time_ms: 40
memory_kb: 3348
final_rank: 3

code_snippet: #if __has_include(<yoniha/all.h>)
#include <yoniha/all.h>
using namespace atcoder;
#else
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#endif
using namespace std;

#define int long long
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n - 1); i >= 0; i--)
template <typename T> bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template <typename T> bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

// using mint = modint;

void solve(int t, int d, int l){
  vector over(0, 0ll);
  rep(i, t){
    int x; cin >> x;
    if(x >= l) over.emplace_back(i);
  }
  if(over.empty()){
    cout << 0 << '\n';
    return;
  }
  int ans = 0;
  rep(i, over.size() - 1){
    ans += min(d, over.at(i + 1) - over.at(i));
  }
  ans += min(d, t - 1 - *--over.end());
  cout << ans << '\n';
}

signed main(){
  while(true){
    int t, d, l; cin >> t >> d >> l;
    if(t == 0) return 0;
    solve(t, d, l);
  }
}
accuracy: 1
time_ms: 90
memory_kb: 5200
final_rank: 20

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	for (; ; ) {
		ll t, d, l; cin >> t >> d >> l;
		if (t == d and d == l and l == 0) return 0;
		ll ans = 0, remain = 0;
		REP(i, t) {
			if (remain > 0) ans++, remain--;
			ll x; cin >> x;
			if (x >= l) remain = d;
		}
		cout << ans << '\n';
	}
}
accuracy: 1
time_ms: 20
memory_kb: 3456
final_rank: 1

code_snippet: #include <iostream>
using namespace std;

int main() {
    while (true) {
        int t, d, l;
        cin >> t >> d >> l;
        if (t + d + l == 0) {
            break;
        }
        int ans = 0;
        int pre = -1 << 29, last = -1;
        for (int i = 0; i < t; i++) {
            bool is_start = i >= pre + d;
            int x;
            cin >> x;
            if (l <= x) {
                pre = i;
            }
            if (i < pre + d) {
                if (last == -1) {
                    last = i;
                }
            } else if (last != -1) {
                ans += i - last;
                last = -1;
            }
        }
        if (last != -1) {
            ans += t - last - 1;
        }
        cout << ans << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 100
memory_kb: 3456
final_rank: 8

code_snippet: #pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
//#include <atcoder/all>
#include <bitset>
#include <cmath>
#include <deque>
#include <exception>
#include <fstream>
#include <iostream>
#include <map>
#include <mutex>
#include <queue>
#include <ratio>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// using namespace atcoder;
// using mint = modint1000000007;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define drep(i, n) for (int i = n - 1; i >= 0; i--)
#define srep(i, j, n) for (int i = j; i < n; i++)
#define sqrep(i, n) for (ll i = 1; i * i <= n; i++)
#define INF (int)(1e9 + 1e8)
#define LINF (ll)(1e18 + 1e17)
#define all(a) a.begin(), a.end()
#define eb emplace_back
#define mkp make_pair
#define mkt make_tuple
using ull = unsigned long long;
using vi = vector<int>;
using vd = vector<double>;
using vl = vector<ll>;
using vi2 = vector<vi>;
using vd2 = vector<vd>;
using vl2 = vector<vl>;
using vi3 = vector<vi2>;
using vl3 = vector<vl2>;
using vs = vector<string>;
using pi = pair<int, int>;
using tp = pair<int, pi>;
// using vm = vector<mint>;
// using vm2 = vector<vm>;
// using vm3 = vector<vm2>;

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 <class T> inline void show_vector(vector<T>& a) {
    for (int i = 0; i < a.size(); i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

template <class T> inline void show_vector2(vector<vector<T>>& a) {
    for (int i = 0; i < a.size(); i++) {
        show_vector(a[i]);
    }
    cout << endl;
}

template <class T, class U> inline void show_map(map<T, U>& a) {
    for (pair<T, U> p : a) {
        cout << p.first << ": " << p.second << endl;
    }
}
template <class T, class U> inline void cerr_map(map<T, U>& a) {
    for (pair<T, U> p : a) {
        cerr << p.first << ": " << p.second << endl;
    }
}
template <class T, class U> inline void show_pair(pair<T, U>& a) {
    cout << a.first << " " << a.second << endl;
}
template <class T, class U> inline void cerr_pair(pair<T, U>& a) {
    cerr << a.first << " " << a.second << endl;
}
template <class T> inline void show_set(set<T>& a) {
    for (T i : a) {
        cout << i << " ";
    }
    cout << endl;
}
template <class T> inline void cerr_set(set<T>& a) {
    for (T i : a) {
        cerr << i << " ";
    }
    cerr << endl;
}

inline void yn(bool a) {
    if (a)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll ncr[100][100];

void calc_ncr() {
    ncr[0][0] = 1;
    for (int i = 0; i < 40 - 1; i++) {
        for (int j = 0; j <= i; j++) {
            ncr[i + 1][j] += ncr[i][j];
            ncr[i + 1][j + 1] += ncr[i][j];
        }
    }
}

// struct S {
//     mint a;
// };
// struct F {
//     int b;
// };
//  using S = int;
// S op(S a, S b) { return {a.a + b.a}; }
// S eee() { return {0}; }
// S mapping(F f, S x) { return {x.a + f.b}; }
// F composition(F f, F g) { return {f.b + g.b}; }
// F id() { return {0}; }
// using SEG = segtree<S, op, eee>;
//  using LAZY_SEG = lazy_segtree<S, op, eee, F, mapping, composition, id>;
void show_seg(int n) // SEG s, int n)
{
    rep(i, n) {
        // cout << s.get(i) << " ";
    }
    cout << endl;
}
struct UnionFind {
    vector<int> par;  // 親ノード
    vector<int> rank; // ランク

    UnionFind(int n = 1) { init(n); }

    void init(int n = 1) {
        par.resize(n);
        rank.resize(n);
        for (int i = 0; i < n; ++i)
            par[i] = i, rank[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        } else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) { return root(x) == root(y); }

    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

ll gcd_ext(ll a, ll b, ll& x, ll& y) {
    x = 1;
    ll x_next = 0;
    ll r = a;
    ll r_next = b;
    while (r_next != 0) {
        ll tmp = x_next;
        x_next = x - x_next * (r / r_next);
        x = tmp;

        tmp = r_next;
        r_next = r % r_next;
        r = tmp;
    }
    y = (r - a * x) / b;
    return r;
}
template <class T> inline void cerr_vector(vector<T>& a) {
    for (int i = 0; i < a.size(); i++) {
        cerr << a[i] << " ";
    }
    cerr << endl;
}

template <class T> inline void cerr_vector2(vector<vector<T>>& a) {
    for (int i = 0; i < a.size(); i++) {
        cerr_vector(a[i]);
    }
    cerr << endl;
}
int popcount(ull a) {
    int res = 0;
    while (a > 0) {
        if (a & 1) { res++; }
        a >>= 1;
    }
    return res;
}

ll pow_ll(ll b, ll k, ll g) {
    ll res = 1;
    ll tmp = b;
    while (k > 0) {
        if (k & 1) {
            /*
            if (k != 0 && res > __LONG_LONG_MAX__ / tmp)
            {
                return -1;
            }*/
            res *= tmp;

            res %= g;
        }
        k >>= 1;
        // todo: 消す
        /*
        if (k != 0 && tmp > __LONG_LONG_MAX__ / tmp)
        {
            return -1;
        }*/
        tmp *= tmp;

        tmp %= g;
    }
    return res;
}
using PQP = priority_queue<pair<ll, int>, vector<pair<ll, int>>,
                           greater<pair<ll, int>>>;
using P = pair<ll, ll>;
using vp = vector<P>;
using P3 = pair<ll, P>;
using vp3 = vector<P3>;
using P4 = pair<P3, int>;
using vp2 = vector<vp>;
using T = tuple<int, int, int, int>;
using t3 = tuple<ll, ll, ll>;
using vt = vector<T>;
vi dx = {0, 1, 0, -1, 1, 1, -1, -1};
vi dy = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {

    while (1) {
        int t, d, l;
        cin >> t >> d >> l;
        if (t == 0) break;
        int ed = -INF;
        int ans = 0;
        rep(i, t) {
            int x;
            cin >> x;
            if (i - ed <= d) ans++;
            if (x >= l) ed = i;
        }
        cout << ans << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 120
memory_kb: 3352
final_rank: 10

code_snippet: #include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <ranges>
#include <regex>
#include <set>
#include <span>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
// #include <atcoder/dsu>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(a) a.begin(), a.end()
using namespace std;

template <class T> inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <class T1, class T2>
std::ostream &operator<<(std::ostream &out, const pair<T1, T2> &A) {
	cout << "{" << A.first << "," << A.second << "}";
	return out;
}

template <class T1, class T2>
std::ostream &operator<<(std::ostream &out, const map<T1, T2> &M) {
	for (const auto &A : M) {
		cout << "{" << A.first << "," << A.second << "}";
	}
	return out;
}

template <class T1>
std::ostream &operator<<(std::ostream &out, const set<T1> &M) {
	cout << "{";
	for (const auto &A : M) {
		cout << A << ", ";
	}
	cout << "}" << endl;
	return out;
}

template <class T1>
std::ostream &operator<<(std::ostream &out, const multiset<T1> &M) {
	cout << "{";
	for (const auto &A : M) {
		cout << A << ", ";
	}
	cout << "}" << endl;
	return out;
}

template <class T>
std::ostream &operator<<(std::ostream &out, const vector<T> &A) {
	for (const T &a : A) {
		cout << a << " ";
	}
	return out;
}

void print() { cout << endl; }

template <typename Head, typename... Tail> void print(Head H, Tail... T) {
	cout << H << " ";
	print(T...);
}

template <class T> std::istream &operator>>(std::istream &in, vector<T> &A) {
	for (T &a : A) {
		std::cin >> a;
	}
	return in;
}

using ll = long long;
// using mint = modint1000000007;
// using PII = pair<int, int>;
// using PLL = pair<ll, ll>;
// using Graph = vector<vector<int>>;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr ll LINF = numeric_limits<ll>::max() / 2;

// ランレングス圧縮
// イテレータを受け取る
// verify: https://atcoder.jp/contests/abc380/submissions/60002447
template <typename T, typename Iterator>
vector<pair<T, int>> RLE(Iterator begin, Iterator end) {
	vector<pair<T, int>> res;
	for (auto itr = begin; itr != end; ++itr) {
		if (res.empty() || res.back().first != *itr) {
			res.emplace_back(*itr, 1);
		} else {
			res.back().second++;
		}
	}
	return res;
}

// 座標圧縮
// unordered_mapが使えない場合はmapに変更しよう
// https://atcoder.jp/contests/abc213/submissions/60002695
template <typename T> unordered_map<T, int> compress(vector<T> &X) {
	auto tmp = X;
	ranges::sort(tmp);
	tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());
	unordered_map<T, int> res;
	for (int i = 0; i < (int)tmp.size(); i++) {
		res[tmp[i]] = i;
	}
	return res;
}
bool solve() {
	// ここからスタート
	int T, D, L;
	cin >> T >> D >> L;
	if (T == 0)
		return false;
	vector<int> x(T);
	vector<bool> nure(T, false);
	rep(i, T) cin >> x[i];
	int t = 0; // 乾くまでの時間
	rep(i, T) {
		if (x[i] >= L) {
			nure[i] = true;
			t = D;
		} else {
			t--;
			if (t > 0) {
				nure[i] = true;
			}
		}
	}
	cout << count(nure.begin(), nure.end() - 1, true) << endl;
	return true;
}

int main(void) {
	std::cin.tie(0)->sync_with_stdio(0);
	while (solve())
		;
}
accuracy: 1
time_ms: 30
memory_kb: 3952
final_rank: 4