Harryxun/stf_run huggingface dataset:
H,W=map(int,input().split())
S=[]
for i in range(H):
    S.append(input())
from collections import deque

def dfs(field, s):
    MOVE = [(0, 1), (1, 0), (0, -1), (-1, 0)]
    q = deque([(0, s)])
    dist = [[-1] * w for _ in range(h)]

    d, i, j = -1, -1, -1
    while q:
        d, (i, j) = q.popleft()
        if dist[i][j] != -1:
            continue
        dist[i][j] = d
        for di, dj in MOVE:
            ni, nj = i + di, j + dj
            if not 0 <= ni < h or not 0 <= nj < w:
                continue
            if field[ni][nj] == '#':
                continue
            if dist[ni][nj] != -1:
                continue
            q.append((d + 1, (ni, nj)))
    return d, i, j

ans=0
for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            d,i,j=dfs(S,(i,j))
            ans=max(ans,d)

print(ans)

### FIXED CODE ###


from collections import deque

def dfs(field, s):
    MOVE = [(0, 1), (1, 0), (0, -1), (-1, 0)]
    q = deque([(0, s)])
    dist = [[-1] * w for _ in range(h)]

    d, i, j = -1, -1, -1
    while q:
        d, (i, j) = q.popleft()
        if dist[i][j] != -1:
            continue
        dist[i][j] = d
        for di, dj in MOVE:
            ni, nj = i + di, j + dj
            if not 0 <= ni < h or not 0 <= nj < w:
                continue
            if field[ni][nj] == '#':
                continue
            if dist[ni][nj] != -1:
                continue
            q.append((d + 1, (ni, nj)))
    return d, i, j

h,w=map(int,input().split())
S=[]
for i in range(h):
    S.append(input())

ans=0
for i in range(h):
    for j in range(w):
        if S[i][j]==".":
            d,i,j=dfs(S,(i,j))
            ans=max(ans,d)

print(ans)
A, B, C, D, E, F = map(int, input().split())
Swater, sugar, percent = 0, 0, 0
for k in range(F//(100*A) + 1):
  for l in range(F//(100*B) + 1):
    if k == 0 and l == 0:
      continue
    M = k*A + l*B
    if 100 * M > F:
      continue
    for x in range(M*E//C + 1):
      for y in range(M*E//D + 1):
        S = C*x + D*y
        if 100*M+S > F:
          continue
        if S > M*E:
          continue
        t = 100*S / (100*M+S)
        if t > percent:
          percent = t
          Swater = 100*M+S
          suger = S
print(Swater, suger)

### FIXED CODE ###

A, B, C, D, E, F = map(int, input().split())
Swater, sugar, percent = 100*A, 0, 0
for k in range(F//(100*A) + 1):
  for l in range(F//(100*B) + 1):
    if k == 0 and l == 0:
      continue
    M = k*A + l*B
    if 100 * M > F:
      continue
    for x in range(M*E//C + 1):
      for y in range(M*E//D + 1):
        S = C*x + D*y
        if 100*M+S > F:
          continue
        if S > M*E:
          continue
        t = 100*S / (100*M+S)
        if t > percent:
          percent = t
          Swater = 100*M+S
          sugar = S
print(Swater, sugar)
#include <iostream>
using namespace std;

int main()
{
    int a, b, c, ab;
    cin >> a >> b >> c;
    ab = max(a, b);

    if (max(ab, c) == (a + b + c) / 2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

### FIXED CODE ###

P = list(map(int, input().split()))
P = sorted(P)

if P[0] + P[1] == P[2]:
    print("Yes")
else:
    print("No")
x=int(input())
c=1
for b in range(1,x):
  for p in range(2,x):
    if b**p<=x:c=max(c,b**p)
      else:break
print(c)


### FIXED CODE ###

x=int(input())
c=1
for b in range(1,x):
    for p in range(2,x):
        if b**p<=x:c=max(c,b**p)
        else:break
print(c)
bari ga ippai

### FIXED CODE ###

while True:
  h, w = map(int, raw_input().split())
  if (h == 0 and w == 0):
    break
  for i in range(0,h):
    if i == 0 or i == h-1:
      print ('#' * w)
    else: 
      print ('#' + '.' * (w - 2) + '#' )
  print
d, n = map(i, input().split())
 
if d==0:
	print(n)
if d==1:
	print(n*100)
if d==2:
	print(n*10000)

### FIXED CODE ###

d, n = map(int, input().split())
 
if d==0:
	if n<100:
		print(n)
	else:
		print(101)    
elif d==1:
	if n<100:
		print(n*100)
	else:
		print(10100)
elif d==2:
	if n<100:
		print(n*10000)
	else:
		print(n*10000+10000)
a,b,n=map(int,input().split())
a=[]
for i in range(1,n+1):
  a.append(int(a*i/b)-5*int(i/b))
print(max(a))

### FIXED CODE ###

a,b,n = map(int, input().split())
i = min(n,b-1)
print(int(a*i/b) - a*int(i/b))
def g():
    from collections import defaultdict
    N, M = map(int, input().split())
    xy = defaultdict(list)
    memo = defaultdict(list)
    for _ in range(M):
        x, y = map(int, input().split())
        xy[x].append(y)

    def g2(x):
        if x in memo:
            return memo[x]
        else:
            r = 0
            for ny in xy[x]:
                r = max(r, g2(ny) + 1)
            memo[x] = r
        return r

    ans = 0
    for i in range(N):
        ans = max(ans, g2(i))
    return ans


if __name__ == '__main__':
    ans = g()
    print(ans)

### FIXED CODE ###

def g():
    from collections import defaultdict
    import sys

    sys.setrecursionlimit(10 ** 6)
    N, M = map(int, input().split())
    xy = defaultdict(list)
    memo = {}
    for _ in range(M):
        x, y = map(int, input().split())
        xy[x].append(y)

    def g2(x):
        if x in memo:
            return memo[x]
        else:
            r = 0
            for ny in xy[x]:
                r = max(r, g2(ny) + 1)
            memo[x] = r
        return r

    ans = 0
    for i in range(1, N + 1):
        ans = max(ans, g2(i))
    return ans


if __name__ == '__main__':
    ans = g()
    print(ans)
a,b,c,d = map(int,input().split())
u = b - a + 1
import math
cd = c * d / math.gcd(c, d)
n_c = b//c - (a-1)//c
n_d = b//d - (a-1)//d
n_cd = b//(cd) - (a-1)//(cd)
print(int(u - n_c - n_d + n_cd))

### FIXED CODE ###

a,b,c,d = map(int,input().split())
u = b - a + 1
from fractions import gcd
cd = c*d//gcd(c,d)
n_c = b//c - (a-1)//c
n_d = b//d - (a-1)//d
n_cd =b//cd - (a-1)//cd
print(int(u - n_c - n_d + n_cd))
l = list(map(int,input().split()))
if l % 2 == 1:
  print('No')
else:
  if l//2 in l:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

l = list(map(int,input().split()))
if sum(l) % 2 == 1:
  print('No')
else:
  if sum(l)//2 in l:
    print('Yes')
  else:
    print('No')
print("Yes" if (int(input())*int(input())) % 2 != 0 else "No")


### FIXED CODE ###

a, b = map(int, input().split())
print("Yes" if a*b % 2 != 0 else "No")
S = int(input())
h = ??????????±????????¨????
m = ???????±????????¨????
s = ?§?????±????????¨????
print(h, m, s, sep=':')

### FIXED CODE ###

S = int(input())
h = S // 3600
m = S % 3600 // 60
s = S % 60
print(h, m, s, sep=':')
while True:
    n = int(raw_input())
    if n == 0:
        break
    m,x,d = int(raw_input())-1,int(raw_input())-1,int(raw_input())
    amida = []
    for i in range(d):
        amida[i] = "0" + raw_input() + "0"
    rroot = []
    for i in range(d-1,-1,-1):
        if amida[i][x-1] == "1":
            x -= 1
        elif amida[i][x] == "1":
            x += 1
        rroot.append(x)
    if m == x:
        print 0
    else:
        root = []
        for i in range(d):
            if amida[i][m-1] == "1":
                m -= 1
            elif amida[i][m] == "1":
                m += 1
            root.append(m)
        rroot.reverse()
        for i in range(d):
            if abs(root[i]-rroot[i]) == 1:
                p = min(root[i],rroot[i])
                if int(amida[i][p-1]) + int(amida[i][p+1]) == 0:
                    print i+1, p+1
                    break
            if i == d-1:
                print 1

### FIXED CODE ###

while True:
    n = int(raw_input())
    if n == 0:
        break
    m,x,d = int(raw_input()),int(raw_input()),int(raw_input())
    amida = ["" for i in range(d)]
    for i in range(d):
        amida[i] = "0" + raw_input() + "0"
    rroot = []
    for i in range(d-1,-1,-1):
        if amida[i][x-1] == "1": x -= 1
        elif amida[i][x] == "1" : x += 1
        rroot.append(x)

    if m == x: print 0
    else:
        root = []
        for i in range(d):
            if amida[i][m-1] == "1": m -= 1
            elif amida[i][m] == "1" : m += 1
            root.append(m)
        rroot.reverse()
        for i in range(d):
            if abs(root[i]-rroot[i]) == 1:
                p = min(root[i],rroot[i])
                if int(amida[i][p-1]) + int(amida[i][p+1]) == 0:
                    print i+1, p
                    break
            if i == d-1: print 1
n, k = map(int,input().split())
d = list(map(int,input().split()))

x = 0
y = 0
while x <4:
    if n // (10**x) >0:
        y = x
    x += 1

i = 0
a = [0]
m = 0
while i <= y:
    a.append(((n//(10**(y-i)))%10))
    i +=1

i = 0
t = 0
while i <= y:
    j = 0
    while j < k:
        if a[y-i+1] == d[j]:
            a[y-i+1] += 1
        if a[y-i+1] == 10:
            a[y-i+1] = 0
            a[y-i] +=1
        j+=1
    i+=1
    if a[0] == 1 and t == 0:
        a[1] = a[2] = a[3] = a[4] = i = 0
        t = 1
        continue

i = 0
while i <= y + 1:
    m += a[y-i+1]*(10**(i))
    i+=1

### FIXED CODE ###

n, k = map(int,input().split())
d = list(map(int,input().split()))

s = 0
while s<k and s == d[s]:
    s += 1

x = 0
y = 0
while x <4:
    if n // (10**x) >0:
        y = x
    x += 1

i = 0
a = [0]
m = 0
while i <= y:
    a.append(((n//(10**(y-i)))%10))
    i +=1

i = 0
t = 0
while i <= y + t:
    j = 0
    while j < k:
        if a[y-i+1] == d[j]:
            a[y-i+1] += 1
            if y-i+1 < y+1:
                a[y-i+2] = s
        if a[y-i+1] == 10:
            a[y-i+1] = 0
            a[y-i] +=1
        j+=1
    i+=1
    if a[0] == 1 and t == 0:
        i = 1
        while i<=y+1:
            a[i] = 0
            i += 1
        i = 0
        t = 1
        continue

i = 0
while i <= y + t:
    m += a[y-i+1]*(10**(i))
    i+=1


print(m)
n, m = map(int, input().split())
req = [list(map(int, input().split())) for i in range(m)]
for i in range(10000):
    st = str(i)
    if len(st) != n:
        continue
    ok = True
    for s, c in req:
        if int(st[s-1]) != int(c):
            ok = False
    if ok:
        print(st)
        exit(0)

print(-1)

### FIXED CODE ###

n = int(input())
if n <=2:
    print(1)
elif n%2 == 0:
    print(n//2)
else:
    print((n//2)+1)
from collections import deque
H, W = list(map(int, input().split()))

g = []

for _ in range(H):
    g.append(list(input()))

queue = deque()
for i in range(H):
    for j in range(W):
        if g[i][j] == "#":
            queue.append((i, j))

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

conter = 0
while len(queue) > 0:
    now_x, now_y = queue.popleft()

    for dx_, dy_ in zip(dx, dy):
        adj_x = now_x + dx_
        adj_y = now_y + dy_

        if (not 0 <= adj_x < W) or (not 0 <= adj_y < H):
            continue

        if g[adj_y][adj_y] == "#":
            continue

        if g[adj_y][adj_x] == ".":
            g[adj_y][adj_x] = "#"
            queue.append((adj_x, adj_y))

    counter += 1

print(counter)


### FIXED CODE ###

from collections import deque
H, W = list(map(int, input().split()))

g = []

for _ in range(H):
    g.append(list(input()))

dist = [[-1 for _ in range(W)] for _ in range(H)]
queue = deque()

for i in range(H):
    for j in range(W):
        if g[i][j] == "#":
            dist[i][j] = 0
            queue.append((j, i))

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

while len(queue) > 0:
    now_x, now_y = queue.popleft()

    for dx_, dy_ in zip(dx, dy):
        adj_x = now_x + dx_
        adj_y = now_y + dy_

        if (not 0 <= adj_x < W) or (not 0 <= adj_y < H):
            continue

        if g[adj_y][adj_x] == "#" :
            continue

        if g[adj_y][adj_x] == ".":
            g[adj_y][adj_x] = "#"
            queue.append((adj_x, adj_y))
            dist[adj_y][adj_x] = dist[now_y][now_x] + 1

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(dist[i][j], ans)

print(ans)
a = int(input)
b = int(input)
if a < b:
    print("LESS")
elif a > b:
    print("GREATER")
else:
    print("EQUAL")

### FIXED CODE ###

a = int(input())
b = int(input())
if a < b:
    print("LESS")
elif a > b:
    print("GREATER")
else:
    print("EQUAL")
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
    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)
s=str(input())
t=str(input())
Ns=len(s)
Nt=len(t)
dp=[["" for i in range(Nt+1)]for j in range(Ns+1)]
for i in range(1,Ns+1):
    for j in range(1,Nt+1):
        if s[i-1]==t[j-1]:
            dp[i][j]=dp[i-1][j-1]+s[i-1]
        else:
            if len(dp[i][j-1])>len(dp[i-1][j]):
                dp[i][j]=dp[i][j-1]
            else:
                dp[i][j]=dp[i-1][j]
print(dp[Ns][Nt])

### FIXED CODE ###

S=input()
T=input()
dp=[[0 for j in range(len(T)+1)] for i in range(len(S)+1)]
for i in range(len(S)):
    for j in range(len(T)):
        if S[i]==T[j]:
            dp[i+1][j+1]=dp[i][j]+1
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j])
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1])
i=len(S)
j=len(T)
ans=""
while i>0 and j>0:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        ans=S[i-1]+ans
        i-=1
        j-=1
print(ans)
A, B, K = [int(x) for x in input().split()]

X = sorted(range(A, B+1))
for i in sorted(set(X[:K]) | set(X[-K:])):
    print(i)


### FIXED CODE ###

A, B, K = [int(x) for x in input().split()]

u = set(range(A, min(B+1, A+K)))
l = set(range(B, max(A-1, B-K),-1))
for i in sorted(u | l):
    print(i)
n,u,v=map(int, input().split())
ab=[list(map(int, input().split())) for _ in range(n-1)]
graph = [[] for _ in range(n+1)]
for vs in ab:
    graph[vs[0]].append(vs[1])
    graph[vs[1]].append(vs[0])

depth=[[-1,-1] for _ in range(n+1)]
depth[v][0]=0
depth[v][1]=0

def dfs1(graph,v):
    vv=graph[v]
    for vvv in vv:
        if depth[vvv][0]==-1:
            depth[vvv][0]=depth[v][0]+1
            dfs1(graph,vvv)

def dfs2(graph,v):
    vv=graph[v]
    for vvv in vv:
        if depth[vvv][1]==-1:
            depth[vvv][1]=depth[v][1]+1
            dfs2(graph,vvv)

dfs1(graph,v)
dfs2(graph,u)
depth=sorted(depth,reverse=True)

for i in range(10**6):
    if depth[i][0]-depth[i][1]>=1:
        print(depth[i][0]-1)
        break


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
 
N,u,v = map(int,input().split())
edges = [list(map(int,input().split())) for _ in range(N-1)]
E = [[] for _ in range(N+1)]
for a,b in edges:
    E[a].append(b)
    E[b].append(a)
 
depth = [[-1,-1] for _ in range(N+1)] 
depth[v][0] = 0
depth[u][1] = 0

def dfs1(E,v):
    vv = E[v]
    for vvv in vv:
        if depth[vvv][0] == -1:
            depth[vvv][0] = depth[v][0] + 1
            dfs1(E,vvv)
 
def dfs2(E,v):
    vv = E[v]
    for vvv in vv:
        if depth[vvv][1] == -1:
            depth[vvv][1] = depth[v][1] + 1
            dfs2(E,vvv)
dfs1(E,v)
dfs2(E,u)
depth = sorted(depth, reverse=True)
idx = 0
while True:
    if depth[idx][0] - depth[idx][1] >= 1:
        print(depth[idx][0]-1)
        exit()
    else:
        idx += 1
h = int(input())
ans = 0
i = 0
while True:
  if(i>=h):
    break
  i+=
if(i = 0):
  print(1)
else:
  print(2**(i+1)-1)


### FIXED CODE ###

h = int(input())
ans = 0
i = 0
while True:
  if(2**i>=h):
    break
  i+=1
if(i == 0):
  print(1)
elif(2**i==h):
  print(2**(i+1)-1)
else:
  print(2**i-1)
n=int(input())
heights=[int(i) for i in input().split()]

ans=[]
trans=0

for i in range(n-1):
  if heights[i]>=heights[i+1]:
    trans+=1
    ans.append(trans)
  else:
    trans=0
    ans.append(trans)
       
print(max(ans))

### FIXED CODE ###

n=int(input())
H=[int(i) for i in input().split()]


cnt=0
ans=[]
for i in range(n-1):
    if H[i]>=H[i+1]:
        cnt+=1
        ans.append(cnt)
    else:
        cnt=0
        ans.append(cnt)

if ans:
  print(max(ans))

else:
  print(0)
from scipy.special import comb

n, k = map(int, input().split())

def co(n, r):
    x = comb(n, r, exact=True) % (10 ** 9 + 7)
    return x

if k >= n:
    ans = (2 ** (n-1)) % (10 ** 9 + 7)
else:
    ans = 0

    for i in range(k+1):
        y = (co(n-1, i) * co(n, i)) % (10 ** 9 + 7)
        ans += y

    ans % (10 ** 9 + 7)

print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
mod = 10 ** 9 + 7
ans = 0
coma = 1
comb = 1
for i in range(min(k+1, n)):
    ans += coma * comb
    ans %= mod
    coma *= (n-i) * pow(i+1, mod-2, mod)
    coma %= mod
    comb *= (n-i-1) * pow(i+1, mod-2, mod)
    comb %= mod

print(ans)
n,q = map(int, input().split())
s = input()
listA = [list(map(str, input().split())) for i in range(q)]
listB =[]
for l in range(n):
    listB.append(1)

def sakana(listC, y):
    if y==0:
        listC[0]=0
    elif y!=0:
        listC[y-1]=listC[y-1]+listC[y]
        listC[y]=0
        
def sakanasan(listD, z):
    if z==n-1 :
        listD[n-1]=0
    elif z!=n-1 :
        listD[z+1]=listD[z+1]+listD[z]
        listD[z]=0

for j in range(q):
    for k in range(n):
        if s[k]==listA[j][0] and listA[j][1]=="L":
            sakana(listB, k)
        elif s[n-1-k]==listA[j][0] and listA[j][1]=="R":
            sakanasan(listB, n-1-k)
print(sum(listB))

### FIXED CODE ###

a,b,c = map(int, input().split())
if a==b and b==c:
    print("Yes")
else:
    print("No")
while True:
    a, b = map(int, input().split())
    print(len(str(a + b)))

### FIXED CODE ###

import fileinput
for line in fileinput.input():
    a, b = map(int, line.split())
    print(len(str(a + b)))
n, m = map(int, input().split())
ship = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1 or b == n:
        ship.append((a, b))

ship.sort()
i = 0

while ship[i][0] == 1:
    i += 1

for j in range(i):
    for k in range(i+1, m):
        if ship[j][1] == ship[k][0]:
            print("POSSIBLE")
            exit()

print("IMPOSSIBLE")


### FIXED CODE ###

n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")
s = list(input())
t = list(input())

count = 0

for i in range(3):
    if s[i] == t[i]:
        count = count + 1

print(count)

### FIXED CODE ###

N = int(input())
pw = N**3
print(pw)
# -*- coding: utf-8 -*-

import sys
import os
import math

directions = [(1, 0), (-1, 0), (0, 1), (0, -1)]

for s in sys.stdin:
    H, W = map(int, s.split())
    if H == W == 0:
        break

    # map
    M = []
    for i in range(H):
        s = input().strip()
        M.append(s)

    # W x H white map
    A = [[None for i in range(W)] for j in range(H)]

    def drawable(x, y):
        if 0 <= x < W and 0 <= y < H and A[y][x] == None:
            return True
        else:
            return False

    color_num = 0

    def fill(x, y):
        global color_num

        A[y][x] = color_num
        for direction in directions:
            new_x = x + direction[0]
            new_y = y + direction[1]
            if drawable(new_x, new_y) and M[y][x] == M[new_y][new_x]:
                fill(new_x, new_y)

    for y in range(H):
        for x in range(W):
            if drawable(x, y):
                color_num += 1
                fill(x, y)

    print(color_num)

### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
import os
import math

directions = [(1, 0), (-1, 0), (0, 1), (0, -1)]

for s in sys.stdin:
    H, W = map(int, s.split())
    if H == W == 0:
        break

    # map
    M = []
    for i in range(H):
        s = input().strip()
        M.append(s)

    # W x H white map
    A = [[None for i in range(W)] for j in range(H)]

    def drawable(x, y):
        if 0 <= x < W and 0 <= y < H and A[y][x] == None:
            return True
        else:
            return False

    color_num = 0

    def fill(x, y):
        global color_num

        Q = [(x, y)]
        while Q:
            p = Q.pop(0)
            _x = p[0]
            _y = p[1]
            A[_y][_x] = color_num
            for direction in directions:
                new_x = _x + direction[0]
                new_y = _y + direction[1]
                if drawable(new_x, new_y) and M[_y][_x] == M[new_y][new_x]:
                    A[new_y][new_x] = color_num
                    Q.append((new_x, new_y))

    for y in range(H):
        for x in range(W):
            if drawable(x, y):
                color_num += 1
                fill(x, y)

    print(color_num)
a,b,c,k=map(int,input().split())
B=0
if a+b>=k:
	print(a+(k-a)*b)
else:
	print((a+B)-1*(k-a-b))

### FIXED CODE ###

a=str(input())
b=str(input())
if a==b[0:-1]:
	print('Yes')
else:
	print('No')
num_list = input().split()
if num_list[0]*num_list[1] /= 0
	print("Even")
  else
  	print("Odd")

### FIXED CODE ###

num_list = input().split()
if ((int(num_list[0]) * int(num_list[1])) % 2) == 0:
	print("Even")
else:
	print("Odd")
A = list(map(int, input().split()))

if max(abs(A[0]-A[1]),abs(A[1]-A[2])) <= d or abs(A[0]-A[2]) <= d:
  print('Yes')
  exit()
print('No')


### FIXED CODE ###

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

if max(abs(A[0]-A[1]),abs(A[1]-A[2])) <= A[3] or abs(A[0]-A[2]) <= A[3]:
  print('Yes')
  exit()
print('No')
k,s = map(int,input().split())

count = 0
for x in range(k+1):
  a = s-k-x
  a = 0 if a < 0
  for y in range(a,k+1):
    if x + y > s:
      break
    for z in num:
      if x + y + z == s:
        count += 1
      elif x + y + z > s:
        break

print(count)

### FIXED CODE ###

k,s = map(int,input().split())

count = 0
for x in range(k+1):
  for y in range(k+1):
    a = s - x - y
    if a >= 0 and a <= k:
      count += 1

print(count)
a = int(input())
b = int(input())

ab = a*10 + b
import math
res = math.sqrt(ab)

if res*res == ab:
    print('Yes')
else:
    print('No')

### FIXED CODE ###



a,b = list(map(str, input().split()))


ab = int(a + b)
import math
res = int(math.sqrt(ab))
if res*res == ab:
    print('Yes')
else:
    print('No')
N, A, B = map(int, input().split())

n = int(N / (A + B))

if(N <= A + B):
    print(A)
else:
    print(N - B * n)

### FIXED CODE ###

S = input()

if(S == "AAA"):
    print('No')
elif(S == "BBB"):
    print('No')
else:
    print('Yes')