Harryxun/stf_run huggingface dataset:
# p37 迷路の最短路

from collections import deque


# (sx, sy) から (gx, gy) への最短距離を求める
# 辿り着けないと INF
def bfs():
    # すべての点を INF で初期化
    d = [[float("inf")] * n for i in range(m)]

    # 移動4方向のベクトル
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    #queの定義
    que = deque([])
   
    for i in range(n):
        for j in range(m):
            # スタートとゴールの座標を探す
            if maze[i][j] == "#":
                sx = i
                sy = j
                que.append((sx, sy))
                d[sx][sy] = 0

    # キューが空になるまでループ
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        # 移動4方向をループ
        for i in range(4):
            # 移動した後の点を (nx, ny) とする
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            # 移動が可能かの判定とすでに訪れたことがあるかの判定
            # d[nx][ny] != INF なら訪れたことがある
            if 0 <= nx < n and 0 <= ny < m and maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                # 移動できるならキューに入れ、その点の距離を p からの距離 +1 で確定する
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1
    ans = 0
    for i in range(n):
        for j in range(m):
            ans = max(ans, d[i][j])
    
    return ans

n, m = map(int, input().split())
maze = [list(input()) for i in range(n)]

print(bfs())


### FIXED CODE ###

from collections import deque

# (sx, sy) から (gx, gy) への最短距離を求める
# 辿り着けないと INF
def bfs():
    # すべての点を INF で初期化
    d = [[float("inf")] * m for i in range(n)]

    # 移動4方向のベクトル
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    #queの定義
    que = deque([])
   
    for i in range(n):
        for j in range(m):
            # スタートとゴールの座標を探す
            if maze[i][j] == "#":
                sx = i
                sy = j
                que.append((sx, sy))
                d[sx][sy] = 0

    # キューが空になるまでループ
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        # 移動4方向をループ
        for i in range(4):
            # 移動した後の点を (nx, ny) とする
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            # 移動が可能かの判定とすでに訪れたことがあるかの判定
            # d[nx][ny] != INF なら訪れたことがある
            if 0 <= nx < n and 0 <= ny < m and maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                # 移動できるならキューに入れ、その点の距離を p からの距離 +1 で確定する
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1
    ans = 0
    for i in range(n):
        for j in range(m):
            ans = max(ans, d[i][j])
    
    return ans

n, m = map(int, input().split())
maze = [list(input()) for i in range(n)]

print(bfs())
N,M,K=map(int,input().split())
import numpy as np
a=np.array(list(map(int,input().split())))
b=np.array(list(map(int,input().split())))
a_s=a.cumsum()
b_s=b.cumsum()
an=0
ans=0
while an<N and a_s[an]<=K:
    bn=0
  while bn<M and a_s[an]+b_s[bn]<=K:
    bn+=1
  if an+bn+1>ans:
    ans=an+bn+1
  an+=1
print(ans)

### FIXED CODE ###

N,M,K=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_s=[0]
b_s=[0]
for i in range(N):
  if a_s[i]+a[i]>K:
    break
  a_s.append(a[i]+a_s[i])
for i in range(M):
  if b_s[i]+b[i]>K:
    break
  b_s.append(b[i]+b_s[i])
bn=len(b_s)-1
ans=0
for i in range(len(a_s)):
  while a_s[i]+b_s[bn]>K:
    bn-=1
  ans=max(ans,i+bn)
  
print(ans)
N,M = map(int,input().split())
a = []
for i in range(M):
    a.append(int(input()))

inf = 1000000007
index = 0
n_way = [0 for i in range(N+2)]
n_way[0] = 1

for i in range(N):
    if a[index] == i:
        index += 1
        index = min(index,len(a)-1)
    else:
        n_way[i+1] += n_way[i]
        n_way[i+1] = n_way[i+1]%inf
        n_way[i+2] += n_way[i]
        n_way[i+2] = n_way[i+2]%inf

print(n_way[N])



### FIXED CODE ###

N,M = map(int,input().split())
a = []
for i in range(M):
    a.append(int(input()))

if M == 0:
    a = [-1]

inf = 1000000007
index = 0
n_way = [0 for i in range(N+2)]
n_way[0] = 1

for i in range(N):
    if a[index] == i:
        index += 1
        index = min(index,len(a)-1)
    else:
        n_way[i+1] += n_way[i]
        n_way[i+1] = n_way[i+1]%inf
        n_way[i+2] += n_way[i]
        n_way[i+2] = n_way[i+2]%inf

print(n_way[N])
import math
def bi(x, y):
    if x < y or y < 0: return 0
    if y == 0: return 1
    r = math.factorial(x) // math.factorial(y) // math.factorial(x - y)
    return r % (10**9 + 7)

n, k = list(map(int, input().split(' ')))
for i in range(1, k + 1):
  	if n - k < i - 1: print(0)
    print(bi(k - 1, i - 1) * (bi(n - k - 1, i - 2) + bi(n - k - 1, i - 1) + bi(n - k, i)) % (10**9 + 7))

### FIXED CODE ###

import math
def bi(x, y):
  if x < y or y < 0 or x < 0: return 0
  if y == 0: return 1
  return math.factorial(x) // math.factorial(y) // math.factorial(x - y)

n, k = list(map(int, input().split(' ')))
for i in range(1, k + 1):
  print(bi(k - 1, i - 1) * bi(n - k + 1, i) % (10**9 + 7))
a, b = input().split()
c = a * b // 2
if c:
    print('Odd')
else:
    print('Even')

### FIXED CODE ###

a, b = map(int, input().split())
c = a * b % 2
if c:
    ans = 'Odd'
else:
    ans = 'Even'
print(ans)
input()
a = list(map(int,input().split()))
a.sorted()
print(sum(a[::2])-sum(a[1::2]))

### FIXED CODE ###

input()
a = list(map(int,input().split()))
a.sort()
a = a[::-1]
print(sum(a[::2])-sum(a[1::2]))
N = input().split
N1 = list(reversed(N))
if N == N1:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N = input()

N1 = N[2]+N[1]+N[0]
if N == N1:
    print("Yes")
else:
    print("No")
A, B = map(int, input().split())

import math

print(int((A * B )//math.gcd(A, B)))

### FIXED CODE ###

from fractions import gcd

A, B = map(int, input().split())

print(str((A * B) // gcd(A, B)))
import math
H,A = [int(x) for x in input().spit()] print(math.ceil(A/B)) 

### FIXED CODE ###

import math

H, A = [int(x) for x in input().split()]
print(math.ceil(H/A))
P = (A*3) + P
ans = P / 2

ans = round(ans)

print(ans)



### FIXED CODE ###

A,P = map(int,input().split())
ans = 0

A = int(A)
P = int(P)

P = (A*3) + P
ans = P // 2

print(ans)
from collections import Counter

N = int(input())
S = list(map(str,input().split()))
counter = Counter(S)

res = 0
for s in counter.values():
    res += s
if s == 3:
    print("Three")
else:
    print("Four")

### FIXED CODE ###

N = int(input())
print(N//3)
import math

N, X = map(int,(input().split()))
x = list(map(int,input().split()))
x_min = min(x)

x_0 = [x_- x_min for x_ in x]

gcd = x_0[0]
for x_0_ in x_0:
    gcd = math.gcd(gcd,x_0_)

ans = gcd

if N==1:
    ans = abs(x[0] - X)

print(ans)

### FIXED CODE ###

import fractions as math

N, X = map(int,(input().split()))
x = list(map(int,input().split()))
x.append(X)
x_min = min(x)

x_0 = [x_- x_min for x_ in x]

gcd = x_0[0]
for x_0_ in x_0:
    gcd = math.gcd(gcd,x_0_)

print(gcd)
N, M = map(int, input().split())

MOD = 10 ** 9 + 7
a = []
flag = True
for i in range(M):
  tmp = int(input())
  if i != 0 and tmp == a[-1] + 1 or tmp == 0 or tmp == N:
    print(0)
    flag = False
    break
  a.append(tmp)

if flag:
  max_dis = 0
  dis = []
  for i in range(len(a)):
    if i == 0:
      dis.append(a[i])
    else:
      dis.append(a[i] - a[i - 1])
    max_dis = max(max_dis, dis[-1])
  max_dis = max(max_dis, N - a[-1])
  
  fib = [1, 1]
  for _ in range(max_dis):
    fib.append(fib[-1] + fib[-2])
  ans = 1
  for d in dis:
    ans = (ans * fib[d - 1]) % MOD
  ans *= fib[N - a[-1] - 1]
  
  print(ans % MOD)

### FIXED CODE ###

N, M = map(int, input().split())

MOD = 10 ** 9 + 7
a = []
flag = True
for i in range(M):
  tmp = int(input())
  if i != 0 and tmp == a[-1] + 1:
    print(0)
    flag = False
    break
  a.append(tmp)

if flag:
  max_dis = 0
  dis = []
  for i in range(len(a)):
    if i == 0:
      dis.append(a[i])
    else:
      dis.append(a[i] - a[i - 1] - 1)
    max_dis = max(max_dis, dis[-1])
  if M == 0:
    max_dis = N
    a.append(-1)
  else:
    max_dis = max(max_dis, N - a[-1])
  
  fib = [1, 1]
  for _ in range(max_dis):
    fib.append((fib[-1] + fib[-2]) % MOD)
  ans = 1
  for d in dis:
    ans = (ans * fib[d - 1]) % MOD
  ans *= fib[N - a[-1] - 1] % MOD
  
  print(ans % MOD)
import queue
N,M = map(int,input().split())
tree = [[] for _ in range(M+1)]
for i in range(M):
    a,b = map(int,input().split())
    tree[a].append(b)
    tree[b].append(a)

que = queue.Queue()
que.put(1)

result = [-1]*(N+1)
while(True):
    if que.empty():
        break
    start = que.get()
    for i in tree[start]:
        if result[i] == -1:
            result[i] = start
            que.put(i)


print("Yes")
for i in range(2,N+1):
    print(result[i])






### FIXED CODE ###

import queue
N,M = map(int,input().split())
tree = [[] for _ in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    tree[a].append(b)
    tree[b].append(a)

que = queue.Queue()
que.put(1)
result = [-1]*(N+1)
result[1] = 0
while(True):
    if que.empty():
        break
    start = que.get()
    for i in tree[start]:
        if result[i] == -1:
            result[i] = start
            que.put(i)

if -1 in result[2:]:
    print("No")
else:
    print("Yes")
    for i in result[2:]:
        print(i)
N, result = eval(input()), 1
List = list(map(int, input().split()))
if 0 in List:
  print(0)
  quit()
for i in List[N]:
    result *= i
    
print(result if result <= 10**18 else -1)

### FIXED CODE ###

n = int(input())
List = list(map(int, input().split()))
res = 1
if 0 in List:
    print(0)
    quit()
for x in List:
    res *= x
    if res > 10**18:
        print(-1)
        quit()
print(res)
from itertools import product
from collections import deque

H, W = map(int, input().split())
A = []
checked = []
black = []
INF = 10**9
for i in range(H):
    tmp = input()
    A.append(tmp)
    checked.append([0 if tmp[j] == '#' else INF for j in range(W)])
    black += [((i, j), 0) for j in range(W) if checked[-1][j] == 0]
black = deque(black)
ans = 0
while black:
    (i, j), d = black.popleft()
    ans = max(ans, d)
    if i > 0:
        checked[i-1][j] = min(checked[i-1][j], d+1)
        black.append((i-1, j), checked[i-1][j])
    if i < H-1:
        checked[i+1][j] = min(checked[i+1][j], d+1)
        black.append((i+1, j), checked[i+1][j])
    if j > 0:
        checked[i][j-1] = min(checked[i][j-1], d+1)
        black.append((i, j-1), checked[i][j-1])
    if j < W-1:
        checked[i][j+1] = min(checked[i][j+1], d+1)
        black.append((i, j+1), checked[i][j+1])
print(ans)

### FIXED CODE ###

import numpy as np
from itertools import product
from collections import deque

H, W = map(int, input().split())
val = []
INF = 10**9
for i in range(H):
    tmp = input()
    val.append([0 if tmp[j] == '#' else INF for j in range(W)])
val = np.array(val)

for i in range(H-1):
    val[i+1, :] = np.minimum(val[i, :]+1, val[i+1, :])
for i in range(H-1, 0, -1):
    val[i-1, :] = np.minimum(val[i, :]+1, val[i-1, :])
for j in range(W-1):
    val[:, j+1] = np.minimum(val[:, j]+1, val[:, j+1])
for j in range(W-1, 0, -1):
    val[:, j-1] = np.minimum(val[:, j]+1, val[:, j-1])

print(val.max())
A=str(input())
B=str(input())
a=list(A)
b=list(B)
t=''
for i in range(len(a)):
  t+=a[i]+b[i]
if len(a)>len(b):
  t+=a[len(a)-1]
print(t)


### FIXED CODE ###

A=str(input())
B=str(input())
a=list(A)
b=list(B)
t=''
for i in range(len(b)):
  t+=a[i]+b[i]
if len(a)>len(b):
  t+=a[len(a)-1]
print(t)
import numpy as np
from numba import jit#import numbaで関数前で@numba.jitでもok
@jit
n,l=map(int,input().split())
a = np.arange(l,l+n)
d = abs(a).argmin() # argmin: ndarrayで最小値の要素のインデックスを取得
print(a.sum() - a[d])

### FIXED CODE ###


n,l=map(int,input().split())
aji_lis=[int(l+i-1) for i in range(1,n+1)]

N_sum=sum(aji_lis)
ap=min([abs(i) for i in aji_lis])

if N_sum >=0:
    print(N_sum-ap)
else:
    print(N_sum+ap)
n = int(input())
table = [input() for i in range(n)]
print("{} {} {}".format(min(table),max(table),sum(table)))



### FIXED CODE ###

n = input()
table = list(map(int,input().split()))
print("{} {} {}".format(min(table),max(table),sum(table)))
import sys
from collections import deque

readline = sys.stdin.readline

N = int(readline())

nodes = [deque() for i in range(N)]
node_colors = [-1 for i in range(N)]

for i in range(N - 1):
    u,v,w = map(int, readline().split())
    u, v = u - 1, v - 1
    nodes[u].append([v, w])
    nodes[v].append([u, w])


node_colors[0] = 0

def process(u, parent, w): 
    p_color = node_colors[parent]
    node_colors[u] = p_color if w % 2 == 0 else 1 - p_color
    
    for v, w in nodes[u]:
        if v == parent:
            continue
        process(v, u, w)

for v, w in nodes[0]:
    process(v, 0, w)

for c in node_colors:
    print(c)

### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(200000)
 
readline = sys.stdin.readline
 
N = int(readline())
 
nodes = [deque() for i in range(N)]
node_colors = [-1 for i in range(N)]
 
for i in range(N - 1):
    u,v,w = map(int, readline().split())
    u, v = u - 1, v - 1
    nodes[u].append([v, w])
    nodes[v].append([u, w])
 
 
node_colors[0] = 0
 
def process(u, parent, w): 
    p_color = node_colors[parent]
    node_colors[u] = p_color if w % 2 == 0 else 1 - p_color
    
    for v, w in nodes[u]:
        if v == parent:
            continue
        process(v, u, w)
 
for v, w in nodes[0]:
    process(v, 0, w)
 
for c in node_colors:
    print(c)
# -*- coding: utf-8 -*-
from collections import deque
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

S = input()
T = input()

for i in range(N+1):
    if S == T[i:] + T[:i]:
        print("Yes")
        break
else:
    print("No")

### FIXED CODE ###

S = input()
T = input()

for i in range(len(S)):
    if S[i:] + S[:i] == T:
        print("Yes")
        break
else:
    print("No")
def main():
    N, M = map(int, input().split())
    d = [[float('inf')] * N for _ in range(N)]
    edges = []
    
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        edges.append([a,b,c])

    d = [float('inf')] * N
    d[0] = 0

    for i in range(N-1):
        for edge in edges:
            d[edge[1]] = min(d[edge[1]], d[edge[0]] - edge[2])

    ans = d[N]
    for edge in edges:
        d[edge[1]] = min(d[edge[1]], d[edge[0]] - edge[2])

    if ans == d[N]:
        print(-ans)
    else:
        print(-1)


    

    
main()

### FIXED CODE ###


N, M = map(int, input().split())

edges = []

for i in range(M):
    a, b, c = map(int, input().split())
    edges.append([a,b,c])

dist = [float('inf')] * (N + 1)
dist[1] = 0

for _ in range(N - 1):
    for a, b, c in edges:
        dist[b] = min(dist[b], dist[a] - c)

ans = dist[N]
for a, b, c in edges:
    dist[b] = min(dist[b], dist[a] - c)

if ans == dist[N]:
    print(-ans)
else:
    print('inf')
import math
r = int(input())
print(2*math.pi*r, math.pi*r*r)

### FIXED CODE ###

import math
r = float(input())
print(math.pi*r*r, 2*math.pi*r)
a,b,c,d = map(int,input())

if a+b+c+d == 7:
    print(a+"+"+b+"+"+c+"+"+d+"=7")
elif a+b+c-d == 7:
    print(a+"+"+b+"+"+c+"-"+d+"=7")
elif a+b-c-d == 7:
    print(a+"+"+b+"-"+c+"-"+d+"=7")
elif a-b-c-d == 7:
    print(a+"-"+b+"-"+c+"-"+d+"=7")
elif a-b+c-d == 7:
    print(a+"-"+b+"+"+c+"-"+d+"=7")
elif a-b-c+d == 7:
    print(a+"-"+b+"-"+c+"+"+d+"=7")

### FIXED CODE ###

a,b,c,d = map(int,input())

if a+b+c+d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=" + "7")
elif a+b+c-d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=" + "7")
elif a+b-c+d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=" + "7")
elif a+b-c-d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=" + "7")
elif a-b-c-d == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=" + "7")
elif a-b-c+d == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=" + "7")
elif a-b+c-d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=" + "7")
elif a-b+c+d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=" + "7")
s = list(input())
n = len(s)
x = s.count("x")
a = n-x
if a%2:
    count = 0
    for i in range(n):
        if s[i] != "x":
            count += 1
        if count == a-a//2:
            ind = i
            break
    count = 0
    l = ind-1
    r = ind+1
    c1 = a//2
    while c1 > 0:
        lc = 0
        while l >= 0 and s[l] == "x":
            l += 1
            lc += 1
        rc = 0
        while r < n and s[r] == "x":
            r += 1
            rc += 1
        if s[l] == s[r]:
            count += abs(lc-rc)
            l -= 1
            r += 1
        else:
            print(-1)
            exit()
        c1 -= 1
    count += abs(n-r-(l+1))
    print(count)
else:
    count = 0
    for i in range(n):
        if s[i] != "x":
            count += 1
        if count == a//2:
            l = i
        elif count == a//2+1:
            r = i
            break
    count = 0
    if s[l] != s[r]:
        print(-1)
        exit()
    c1 = a//2-1
    while c1 > 0:
        lc = 0
        while l >= 0 and s[l] == "x":
            l += 1
            lc += 1
        rc = 0
        while r < n and s[r] == "x":
            r += 1
            rc += 1
        if s[l] == s[r]:
            count += abs(lc-rc)
            l -= 1
            r += 1
        else:
            print(-1)
            exit()
        c1 -= 1
    count += abs(n-r-(l+1))
    print(count)

### FIXED CODE ###

s = list(input())
ans = 0
l = 0
r = len(s)-1
while l < r:
    if s[l] != s[r]:
        if s[l] == "x":
            ans += 1
            r += 1
        elif s[r] == "x":
            ans += 1
            l -= 1
        else:
            print(-1)
            exit()
    l += 1
    r -= 1
print(ans)
print(len(set(int(input()) for _ in range(int(input())))))

### FIXED CODE ###

s = str(input())
s1 = s.replace("7","8",1)
print(s1)
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: int, A: int, B: int, C: int, s: "List[str]"):
    ABC = [A, B, C]
    ans = []
    d = {"AB": (0, 1), "BC": (1, 2), "AC": (0, 2)}
    # print(ABC)
    for i in range(N):
        j, k = d[s[i]]
        if ABC[j] == ABC[k] == 0:
            no()
            return
        if ABC[j] == ABC[k] == 1:
            if i != N-1 and (j not in s[i+1]):
                j, k = k, j
            ABC[j] += 1
            ABC[k] -= 1
            ans.append("ABC"[j])
        elif ABC[j] > ABC[k]:
            ABC[j] -= 1
            ABC[k] += 1
            ans.append("ABC"[k])
        else:
            ABC[j] += 1
            ABC[k] -= 1
            ans.append("ABC"[j])

    yes()
    for a in ans:
        print(a)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, A, B, C, s)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: int, A: int, B: int, C: int, s: "List[str]"):
    ABC = [A, B, C]
    ans = []
    d = {"AB": (0, 1), "BC": (1, 2), "AC": (0, 2)}
    # print(ABC)
    for i in range(N):
        j, k = d[s[i]]
        if ABC[j] == ABC[k] == 0:
            no()
            return
        if ABC[j] == ABC[k] == 1:
            if i != N-1 and (j not in d[s[i+1]]):
                j, k = k, j
            ABC[j] += 1
            ABC[k] -= 1
            ans.append("ABC"[j])
        elif ABC[j] > ABC[k]:
            ABC[j] -= 1
            ABC[k] += 1
            ans.append("ABC"[k])
        else:
            ABC[j] += 1
            ABC[k] -= 1
            ans.append("ABC"[j])

    yes()
    for a in ans:
        print(a)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, A, B, C, s)


if __name__ == '__main__':
    main()
N = int(input())
S = list(input())
gr = itertools.groupby(S)
ans = len([1 for key, group in gr])
print(ans)

### FIXED CODE ###

import itertools
N = int(input())
S = list(input())
gr = itertools.groupby(S)
ans = len([1 for key, group in gr])
print(ans)
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 CODE ###

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)
inpt = input.split(',')
print(inpt[0]+' '+inpt[1]+' '+inpt[2])

### FIXED CODE ###

inpt = input().split(',')
print(inpt[0]+' '+inpt[1]+' '+inpt[2])