Buggy python submission (verdict: Runtime Error):
while True:
    T,D,L = map(int,input().split())
    if T==0 and D ==0 and L == 0:
        break
    x = [int(input()) for i in range(T)]
    l = [0]*T
    for i in range(T-1):
        if x[i] >= L:
            for j in range(D):
                l[i+j] = 1
    total = 0
    for i in range(T-1):
        total += l[i]

    print(total)


Fixed submission:
while True:
    T,D,L = map(int,input().split())
    if T==0 and D ==0 and L == 0:
        break
    x = [int(input()) for i in range(T)]
    beforeflag=0
    flag=0
    total=0
    for i in range(T):
        if x[i]>=L:
            flag=1
            if beforeflag!=D+1 and beforeflag!=0:
                total+=1
        elif x[i]<L and flag>0 and flag<=D:
            flag+=1
            total+=1
        else:
            flag=0
        beforeflag=flag
    print(total)

Buggy python submission (verdict: Runtime Error):
while True:
    T,D,L = map(int,input().split())
    if T==0 and D ==0 and L == 0:
        break
    x = [int(input()) for i in range(T)]
    l = [0]*(T-1)
    for i in range(T-1):
        if x[i] >= L:
            for j in range(D):
                if i+j<T-1:
                    l[i+j] = 1
    total = 0
    for i in range(T-1):
        total += l[i]

    print(total)



Fixed submission:
while True:
    T,D,L = map(int,input().split())
    if T==0 and D ==0 and L == 0:
        break
    x = [int(input()) for i in range(T)]
    beforeflag=0
    flag=0
    total=0
    for i in range(T):
        if x[i]>=L:
            flag=1
            if beforeflag!=D+1 and beforeflag!=0:
                total+=1
        elif x[i]<L and flag>0 and flag<=D:
            flag+=1
            total+=1
        else:
            flag=0
        beforeflag=flag
    print(total)

Buggy python submission (verdict: Runtime Error):
while True:
    T,D,L = map(int,input().split())
    if T==0 and D ==0 and L == 0:
        break
    x = [int(input()) for i in range(T)]
    l = [0]*(T-1)
    for i in range(T-1):
        if x[i] >= L:
            for j in range(D):
                if i+j<T-1:
                    l[i+j] = 1
    total = 0
    for i in range(T-1):
        total += l[i]

    print(total)



Fixed submission:
while True:
    T,D,L = map(int,input().split())
    if T==0 and D ==0 and L == 0:
        break
    x = [int(input()) for i in range(T)]
    beforeflag=0
    flag=0
    total=0
    for i in range(T):
        if x[i]>=L:
            flag=1
            if beforeflag!=D+1 and beforeflag!=0:
                total+=1
        elif x[i]<L and flag>0 and flag<=D:
            flag+=1
            total+=1
        else:
            flag=0
        beforeflag=flag
    print(total)

Buggy python submission (verdict: Runtime Error):
while True:
    T,D,L = map(int,input().split())
    if T==0 and D ==0 and L == 0:
        break
    x = [int(input()) for i in range(T)]
    l = [0]*1000
    for i in range(T-1):
        if x[i] >= L:
            for j in range(D):
                if i+j<T-1:
                    l[i+j] = 1
    total = 0
    for i in range(T-1):
        total += l[i]

    print(total)



Fixed submission:
while True:
    T,D,L = map(int,input().split())
    if T==0 and D ==0 and L == 0:
        break
    x = [int(input()) for i in range(T)]
    beforeflag=0
    flag=0
    total=0
    for i in range(T):
        if x[i]>=L:
            flag=1
            if beforeflag!=D+1 and beforeflag!=0:
                total+=1
        elif x[i]<L and flag>0 and flag<=D:
            flag+=1
            total+=1
        else:
            flag=0
        beforeflag=flag
    print(total)

Buggy python submission (verdict: Runtime Error):
while True:
    T,D,L = map(int,input().split())
    if T==0 and D ==0 and L == 0:
        break
    x = [int(input()) for i in range(T)]
    l = [0]*(T-1)
    i = 0
    m = 0
    while i<T-1:
         #for i in range(T-1):
        if m < i:
            m = i
        if x[i] >= L and D > m-i:
            tmp=m
            for j in range(D-(tmp-i)):
                if tmp<T-1:
                    l[tmp+j] = 1
                    m += 1
        i+=1
    total = 0
    for i in range(T-1):
        total += l[i]

    print(total)


Fixed submission:
while True:
    T,D,L = map(int,input().split())
    if T==0 and D ==0 and L == 0:
        break
    x = [int(input()) for i in range(T)]
    beforeflag=0
    flag=0
    total=0
    for i in range(T):
        if x[i]>=L:
            flag=1
            if beforeflag!=D+1 and beforeflag!=0:
                total+=1
        elif x[i]<L and flag>0 and flag<=D:
            flag+=1
            total+=1
        else:
            flag=0
        beforeflag=flag
    print(total)

Buggy python submission (verdict: Runtime Error):
while True:
    T,D,L = map(int,input().split())
    if T==0 and D ==0 and L == 0:
        break
    x = [int(input()) for i in range(T)]
    l = [0]*(T-1)
    i = 0
    m = 0
    while i<T-1:
         #for i in range(T-1):
        if m < i:
            m = i
        if x[i] >= L and D > m-i:
            tmp=m
            for j in range(D-(tmp-i)):
                if tmp<T-1:
                    l[tmp+j] = 1
                    m += 1
        i+=1
    total = 0
    for i in range(T-1):
        total += l[i]

    print(total)


Fixed submission:
while True:
    T,D,L = map(int,input().split())
    if T==0 and D ==0 and L == 0:
        break
    x = [int(input()) for i in range(T)]
    beforeflag=0
    flag=0
    total=0
    for i in range(T):
        if x[i]>=L:
            flag=1
            if beforeflag!=D+1 and beforeflag!=0:
                total+=1
        elif x[i]<L and flag>0 and flag<=D:
            flag+=1
            total+=1
        else:
            flag=0
        beforeflag=flag
    print(total)