Harryxun/stf_run huggingface dataset:
h,w = map(int, input().split())

grid = [[str(i) for i in input()]for _ in range(h)]
dxdy = [[1, 0], [0, 1], [-1, 0], [0, -1]]

for i in range(h):
    for j in range(w):
        if grid[i][j]=="#":
            f = False
            for d in dxdy:
                if(i+d[0]>-1 and j+d[1]>-1 and i+d[0]<w and j+d[1]<h):
                    if grid[i+d[0]][j+d[1]]=="#":
                        f = True
                        continue
            if f==False:
                print("No")
                exit()


print("Yes")


### FIXED CODE ###

h,w = map(int, input().split())

grid = [[str(i) for i in input()]for _ in range(h)]
dxdy = [[1, 0], [0, 1], [-1, 0], [0, -1]]
for i in range(h):
    for j in range(w):
        if grid[i][j]=="#":
            f = False
            for d in dxdy:
                if(i+d[0]>-1 and j+d[1]>-1 and j+d[1]<w and i+d[0]<h):
                    if grid[i+d[0]][j+d[1]]=="#":
                        f = True
                        continue
            if f==False:
                print("No")
                exit()
print("Yes")
data = []

data.extend(list(map(int, input().split(str))))
N = data[0]
K = data[1]

if K == 1:
    print(0)
else:
    print(K - N)

### FIXED CODE ###

data = []

data.extend(list(map(int, input().split(" "))))
N = data[0]
K = data[1]

if K == 1:
    print(0)
else:
    print(N - K)
num = int(input())
l = [int(i) for i in input().split(" ")]

deny = False

for ele in l:
  if ele%2==0:
    if ele%3!=0 and ele%5!=0:
      print("DENIED")
      deny = True
      break;

if !deny:
  print("APPROVED)

### FIXED CODE ###

num = int(input())
l = [int(i) for i in input().split(" ")]
 
deny = False
 
for ele in l:
  if ele%2==0:
    if ele%3!=0 and ele%5!=0:
      print("DENIED")
      deny = True
      break;
 
if not deny:
  print("APPROVED")
S = input()
T = input()

N = len(S)
M = len(T)

if N < M:
    print('UNRESTORABLE')
    exit()

ans = 'UNRESTORABLE'
for i in range(N-M+1):
    make = True
    for j in range(M):
        if S[i+j] != '?' and S[i+j] != T[j]:
            make = 0
    if make:
        ans = S[:i] + T + S[i+M:]
ans = list(ans)
for i in range(N):
    if ans[i] == '?':
        ans[i] = 'a'
print(''.join(ans))



### FIXED CODE ###

S = list(input())
T = list(input())
lenS = len(S)
lenT = len(T)
change = 0
for i in range(lenS-lenT,-1,-1):
    a = 1
    for j in range(lenT):
        if S[i+j] != T[j] and S[i+j] != '?':
            a = 0
    if a == 1:
        for j in range(lenT):
            S[i+j] = T[j]
        change = 1
        break

for i in range(lenS):
    if S[i] == '?':
        S[i] = 'a'

if change == 1:
    print(''.join(S))
else:
    print('UNRESTORABLE')
s = input()
t = input()

count = 0

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

### FIXED CODE ###

s = input()
t = input()

count = 0

for i in range(3):
    if s[i] == t[i]:
        count += 1
        
print(count)
b=input()
if b =="A"
  print("T")
elif b =="T"
  print("A")
elif b =="G"
  print("C")
elif b =="C"
  print("G")

### FIXED CODE ###

b=input()
if b =="A":
  print("T")
elif b =="T":
  print("A")
elif b =="G":
  print("C")
elif b =="C":
  print("G")
import pysnooper

@pysnooper.snoop()
def rec(n,me,stair):
    if me[n-1]!=0:
        return me[n-1]
    elif n in stair:
        return 0
    elif n==1:
        if n-1 in stair:
            me[n-1]=0
            return 0
        me[n-1]=1
        return 1
    elif n==2:
        test1=n-1 in stair
        test2=n-2 in stair
        if test1 and test2:
            me[n-1]=0
            return 0
        elif test1 or test2:
            me[n-1]=1
            return 1
        me[n-2]=2
        return 2
    else:
        ans=rec(n-2,me,stair)+rec(n-1,me,stair)
        me[n-1]=ans
        return ans

n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
memo=[0]*(n+1)
print(rec(n,memo,a)%1000000007)


### FIXED CODE ###

n,m=map(int,input().split())
stair_m=[True]*(110000)
for i in range(m):
    a=int(input())
    stair_m[a]=False
dp=[0]*(110000)
dp[0]=1
for i in range(1,n+1):
    if stair_m[i]:
        dp[i]=dp[i-1]+dp[i-2]
    else:
        dp[i]=0
print(dp[n]%1000000007)
n = int(input())

if n == 1:
    print("Hello World")
else:
    a, b = map(int, input().split())
    print(a + b)

### FIXED CODE ###

n = int(input())

if n == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    
    print(a + b)
import math

def gcd(num_list):
    if len(num_list) > 2:
        num_list_new = [math.gcd(*num_list[:2])]
        num_list_new.extend(num_list[2:])
        return gcd(num_list_new)
    elif len(num_list) == 2:
        return math.gcd(*num_list)

def lcm(num_list):
    if len(num_list) > 2:
        num_list_new = [lcm(num_list[:2])]
        num_list_new.extend(num_list[2:])
        return lcm(num_list_new)
    elif len(num_list) == 2:
        return num_list[0] * num_list[1] // math.gcd(num_list[0], num_list[1])

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

lcm_of_a = lcm(a)
count = M * 2 // lcm_of_a
if count % 2 == 0:
    print(count // 2)
else:
    print((count + 1) // 2)
    

### FIXED CODE ###

from fractions import gcd
from functools import reduce
import sys

def lcm(nums):
    return reduce(lambda x, y: x * y // gcd(x, y), nums)

n, m = map(int, input().split())
a = [int(item) // 2 for item in input().split()]
b = [0] * n

for i in range(n):
    tmp = a[i]
    while True:
        if tmp % 2 == 0:
            b[i] += 1
            tmp /= 2
        else:
            break

if len(set(b)) != 1:
    print(0)
    sys.exit()

a_lcm = lcm(a)
count = m // a_lcm
if count % 2 == 0:
    print(count // 2)
else:
    print((count + 1) // 2)
N, A = map(int, input().split())
print(N ** 2 - A)


### FIXED CODE ###

N = int(input())
A = int(input())
print(N ** 2 - A)
n = int(inputs[0])
A = list(map(int, inputs[1].split()))

B = list(map(lambda x: x[1]-x[0], enumerate(A, 1)))
b = floor(sum(B) / n)
b1 = round(sum(B) / n)
b2 = ceil(sum(B) / n)
C = list(map(lambda x: abs(x-b), B))
C1 = list(map(lambda x: abs(x-b1), B))
C2 = list(map(lambda x: abs(x-b2), B))
print(min(list(map(sum, [C, C1, C2])))

### FIXED CODE ###

import sys
from statistics import median_low
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))

B = list(map(lambda x: x[1]-x[0], enumerate(A, 1)))
b = median_low(B)
C = list(map(lambda x: abs(x-b), B))
print(sum(C))
x = list(map(int, input().split()))
if x[4] - x[0] < x[-1]:
    print("Yay!")
else:
    print(":(")

### FIXED CODE ###

x = [int(input()) for i in range(6)]
if x[4] - x[0] <= x[-1]: print("Yay!")
else: print(":(")
a = input()
b = input()
if b>=a:
    print("unsafe")
else:
    print("safe")

### FIXED CODE ###

a,b = map(int,input().split())
if b>=a:
    print("unsafe")
else:
    print("safe")
f=[1]
for i in range(1,100):
    f.append(i*f[i-1])

n,m=map(int,input().split())
sum=0
if m>=2:
    sum+=(f[m]//(f[2]*f[m-2]))
if n>=2:
    sum+=(f[n]//(f[n-2]*f[2]))
print(sum)

### FIXED CODE ###

f=[1]
for i in range(1,101):
    f.append(i*f[i-1])

n,m=map(int,input().split())
sum=0
if m>=2:
    sum+=(f[m]//(f[2]*f[m-2]))
if n>=2:
    sum+=(f[n]//(f[n-2]*f[2]))
print(sum)
N, K = map(int, input().split())
A = list(map(int, input().split()))

cnt = [0] * N
ex = [0] * N
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            cnt[i] += 1
for i in range(N):
    for j in range(i):
        if A[i] > A[j]:
            ex[i] += 1

ans = 0
for i in range(N):
    ans += cnt[i] * ((K + 1) * K // 2) % MOD
for i in range(N):
    ans -= ex[i] * K
print(ans % MOD)

### FIXED CODE ###

import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

cnt = [0] * N
ex = [0] * N
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            cnt[i] += 1
for i in range(N):
    for j in range(i):
        if A[i] > A[j]:
            ex[i] += 1

ans = 0
for i in range(N):
    ans += cnt[i] * ((K + 1) * K // 2) % MOD
for i in range(N):
    ans -= ex[i] * K
print(ans % MOD)
(a, b) = [int(i) for i in input().split()]

d = a // b
r = a % b
f = a / b


print('s% s% %.5f' (d, r, f))

### FIXED CODE ###

(a, b) = [int(i) for i in input().split()]

d = int(a / b)
r = a % b
f = a / b


print('%s %s %.5f' % (d, r, f))
def solve(N, As):
    def f(n):
        c = 0
        while n % 2 == 0:
            c += 1
            n //= 2
        return c
    return sum([f(a) for a in As])


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N))


### FIXED CODE ###

def solve(N, As):
    def f(n):
        c = 0
        while n % 2 == 0:
            c += 1
            n //= 2
        return c
    return sum([f(a) for a in As])


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))
N,K=(int(x) for x in input().split())
k=0
a=K
while a<=N:
    k=+1
    a=K**k
break
print(k+1)

### FIXED CODE ###

N,K=(int(x) for x in input().split())
b=1
a=1
if N==1:
    print(1)
else:
     while a<=N:
          b=b+1
          a=K**b
     else:
          print(b)
s=input()
a=""
for i in range(len(s):
    if i%2==0:
        a=a+s[i]
print(a)

### FIXED CODE ###

s=input()
a=""
for i in range(len(s)):
    if i%2==0:
        a=a+s[i]
print(a)
a,b,c,d = map(int,input().split())
ans = 0
if a > b:
  ans += a
  else:
    ans += b
if c > d
  ans += c
  else:
    ans += d
print(ans)
	

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
ans = 0
if a > b:
  ans += b
else:
  ans += a
if c > d:
  ans += d
else:
  ans += c
print(ans)
a=input().split()
a=[int(i) for i in a]
a.sort()
if a=[5, 5, 7]:
	print("YES")
else:
 	print("NO")
 
  

### FIXED CODE ###

a=input().split()
a=[int(i) for i in a]
a.sort()
if a[0]==5 and a[1]==5 and a[2]==7:
	print("YES")
else:
 	print("NO")
def get(i):
    mx = 0
    while i > 0:
        if bit[i] > mx:
            mx = bit[i]
        i -= i & -i
    return mx


def update(i, x):
    while i < n + 1:
        if x > bit[i]:
            bit[i] = x
        i += i & -i


def f(hs, a_s):
    for h, a in zip(hs, a_s):
        update(h, get(h - 1) + a)
    print(max(bit))


n = int(input())
hs = list(map(int, input().split()))
a_s = list(map(int, input().split()))
bit = [0] * (n + 1)
f(n, hs, a_s)


### FIXED CODE ###

def get(i):
    mx = 0
    while i > 0:
        if bit[i] > mx:
            mx = bit[i]
        i -= i & -i
    return mx


def update(i, x):
    while i < n + 1:
        if x > bit[i]:
            bit[i] = x
        i += i & -i


n = int(input())
hs = list(map(int, input().split()))
a_s = list(map(int, input().split()))

bit = [0] * (n + 1)
for h, a in zip(hs, a_s):
    update(h, get(h - 1) + a)
print(max(bit))
N, M = map(int, input().split())

if N==1 or M==1:
    if N==M==1:
        print(0)
    else:
        if N<M:
            N,M = M,N
        print(N-2)

else:
    print((N*M) - N*2 - M*2 + 4)


### FIXED CODE ###

c1 = input()
c2 = input()
c3 = input()

print(c1[0]+c2[1]+c3[2])
x,y = map(int, input().split())


dp =[[0] * (y+1) for i in range(x+1)]
dp[0][0] = 0
dp[1][2] = 1
dp[2][1] = 1

for i in range(2,x+1):
    for j in range(2,y+1):
        dp[i][j] = dp[i-1][j-2] % (10**9+7) + dp[i-2][j-1] % (10**9+7)

print(dp[x][y] % (10**9+7))


### FIXED CODE ###

x,y = map(int, input().split())

mod = 10**9+7
def inv(x):
        return pow(x, mod-2, mod)
def fact(x):
        f = 1 
        for i in range(1, x + 1): 
                f *= i
                f %= mod    
        return f
def comb(n, r): 
        return (fact(n) * inv(fact(n-r)) * inv(fact(r))) % mod 

if (x + y) % 3 != 0 or y / x < 1/2 or y/x > 2:
    print(0)
else:
    n = (2*y-x)//3
    m = (2*x-y)//3
    res = comb(n+m, m)
    print(res)
a, b, c = map(int, input().split)
s = a * 100 + b * 10 + c
r = "YES" if s % 4 == 0 else "NO"
print(r)

### FIXED CODE ###

a, b, c = map(int, input().split())
s = a * 100 + b * 10 + c
r = "YES" if s % 4 == 0 else "NO"
print(r)
a=input()
if a[3]!="8":
    a[3]="8"
    print(a)
else:
    print(a)

### FIXED CODE ###

a=input()
print("2018"+a[4:])
N = int(input())
words = []
l = []
for i in range(N):
    a = input()
    if i == 0:
        l.append(a)
        b = list(a)
        words.append(b[len(b)-1])
    elif i > 0:
        b = list(a)
        if i == N-1:
            words.append(b[0])
        else:
            words.append(b[0])
            words.append(b[len(b)-1])
        l.append(a)

if len(set(l)) != len(l):
    print("No")
    exit(1)

for h in range(0,len(words),2):
    if words[h] == words[h+1]:
        words[h] = True
        words[h+1] = True
    else:
        print("No")
        exit(1)
    
if all(l):
    print("Yes")


### FIXED CODE ###

N = int(input())
words = []
l = []
for i in range(N):
    a = input()
    if i == 0:
        l.append(a)
        b = list(a)
        words.append(b[len(b)-1])
    elif i > 0:
        b = list(a)
        if i == N-1:
            words.append(b[0])
        else:
            words.append(b[0])
            words.append(b[len(b)-1])
        l.append(a)

if len(set(l)) != len(l):
    print("No")
    exit()

for h in range(0,len(words),2):
    if words[h] != words[h+1]:
        print("No")
        exit()
print("Yes")
def dfs(node, edges, dp, visited):
    visited.add(node)
    for child in edges.get(node, []):
        if not child in visited:
            dfs(child, edges, dp, visited)
        dp[node] = max(dp[node], 1 + dp[child])

def main(n, edges):
    dp = [0] * (n + 1)
    visited = set()
    for i in range(1, n + 1):
        if not i in visited:
            dfs(i, edges, dp, visited)
    return max(dp)

assert main(6, { 2: [3], 4: [5], 5: [6] }) == 2
assert main(4, { 1: [2, 3], 3: [2, 4], 2: [4] }) == 3

n, m = map(int, input().split())
edges = {}
for _ in range(m):
    u, v = map(int, input().split())
    if u not in edges:
        edges[u] = set([v])
    else:
        edges[u].add(v)
ans = main(n, edges)
print(ans)



### FIXED CODE ###

from collections import deque

def main(n, edges):
    deg = [0] * (n + 1)
    adj = {}

    for j in range(1, n + 1):
        adj[j] = []

    for u, v in edges:
        adj[u].append(v)
        deg[v] += 1

    S = deque()

    dp = [-1] * (n + 1)

    for u in range(1, n + 1):
        if deg[u] == 0:
            S.append(u)
            dp[u] = 0

    L = []

    while S:
        v = S.popleft()
        L.append(v)
        for u in adj[v]:
            deg[u] -= 1
            if deg[u] == 0:
                S.append(u)
                dp[u] = max(dp[u], dp[v] + 1)

    return max(dp)

assert main(6, [ (2, 3), (4, 5), (5, 6) ]) == 2
assert main(4, [ (1, 2), (1, 3), (3, 2), (3, 4), (2, 4) ]) == 3

n, m = map(int, input().split())
edges = []
for _ in range(m):
    u, v = map(int, input().split())
    edges.append((u, v))
ans = main(n, edges)
print(ans)
W, H, x, y, r = map(int, input()split())
if r < x and x < W-r and r < y and y < H-r:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

W, H, x, y, r = map(int, input().split())
if x+r <= W and x-r >= 0 and y+r <= H and y-r >=0:
    print("Yes")
else:
    print("No")
a, b, c, d, e, f = map(int, input().split())
sug, dif = 0, 100
s = {}
wat1, wat2 = 100*a, 100*b
cap1, cap2 = a*e, b*e

for i in range(1,f//wat1+1):
    for j in range(f//wat2+1):
        if (wat1+cap1)*i+(wat2+cap2)*j<=f:
            s[cap1*i+cap2*j] = wat1*i+wat2*j
for i in s.keys():
    for j in range(i//c+1):
        for k in range(i//d+1):
            if 0<=i-(c*j+d*k)<dif:
                dif = i-(c*j+d*k)
                wat,sug1,sug2 = s[i],j,k
print(c*sug1+d*sug2+wat, c*sug1+d*sug2)

### FIXED CODE ###

a, b, c, d, e, f = map(int, input().split())
sug, dif2 = 0, 100
s = {}
wat1, wat2 = 100*a, 100*b
cap1, cap2 = a*e, b*e
for i in range(1,f//wat1+1):
    for j in range(f//wat2+1):
        if (wat1+cap1)*i+(wat2+cap2)*j<=f:
            s[cap1*i+cap2*j] = wat1*i+wat2*j
if s == {}:
    dif1 = f-wat1
    for i in range(10):
        for j in range(10):
            if 0<=(f-wat1)-(c*i+d*j)<dif1:
                dif1 = (f-wat1)-(c*i+d*j)
                sug3 = c*i+d*j
    print(wat1+sug3, sug3)
    exit(0)
for i in s.keys():
    for j in range(i//c+1):
        for k in range(i//d+1):
            if 0<=i-(c*j+d*k)<dif2:
                dif2 = i-(c*j+d*k)
                wat,sug1,sug2 = s[i],j,k
print(c*sug1+d*sug2+wat, c*sug1+d*sug2)
import math
num = int(input())
arr = input().split()
arr = sorted([int(i) for i in arr])
arr = list(set(arr))

lis1 = [0]*(arr[-1]+1)

for num in arr:
  for j in range(0, len(lis1), num):
    lis1[j] += 1

cnt = 0
for num in arr:
  if lis1[num]==1: cnt+=1
    
print(cnt)

### FIXED CODE ###

import math
num = int(input())
arr = input().split()
arr = sorted([int(i) for i in arr])

lis1 = [0]*(arr[-1]+1)

for num in arr:
  for j in range(0, len(lis1), num):
    lis1[j] += 1

cnt = 0
for num in arr:
  if lis1[num]==1: cnt+=1
    
print(cnt)
n = int(input())
A = []
B = []
for i in range(n):
  a, b = map(int,input().split())
  A.append(a)
  B.append(b)
print(max(a)+min(b))

### FIXED CODE ###

n = int(input())
A = []
B = []
for i in range(n):
  a, b = map(int,input().split())
  A.append(a)
  B.append(b)
print(max(A)+min(B))
from math import pi
maped = map(int, raw_input().split())
r = maped[0]
area = r**2*pi
length = 2*r*pi
print "%f %f"%(area, length)

### FIXED CODE ###

from math import pi
r, = map(float, raw_input().split())
area = r**2*pi
length = 2*r*pi
print "%f %f"%(area, length)
param_k = int(input())

if param_k % 2 == 0:
  print(-1)
  
elif param_k %  == 0:
  print(-1)
  
else:
  n=0
  for i in range(param_k + 10):
    n = 10n + 7
    if n % 7 == 0:
      print(i+1)
      break
    if i == param_k + 10 - 1:
      print(-1)

### FIXED CODE ###

# https://atcoder.jp/contests/abc174/submissions/15768313 さんの回答、参照

K = int(input())
num = 0
if K%2 == 0:
    print(-1)
else:
    for i in range(1, 1000000):
        num = num*10 + 7
        num %= K
        if num == 0:
            print(i)
            break
    else:
        print(-1)
N = int input()
a = list(map(int,input().split()))
b = 0

for i in range(N):
  if a[i] % != 2:
    if a[i] % != 3 and a[i] % != 5:
      b = 1
      break
if b == 0:
  print("APPROVED")
else:
  print("DNIDED")

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
c = 0
for i in range(N):
    if A[i] % 2 == 0:
        if A[i] %3 != 0 :
            if A[i] %5 != 0:
                c = 1
                break
if c == 0:
    print("APPROVED")
else:
    print("DENIED")
[a,b]=map(raw_input().split())
x=long(a)
y=long(b)
z=float(x)
w=float(y)
d=x/y
r=x%y
f=1.0000*z/y
print d,r,f

### FIXED CODE ###

[a,b]=raw_input().split()
x=long(a)
y=long(b)
z=float(a)
w=float(b)
d=x/y
r=x%y
f=z/y
print"%d %d %.5f" % (d,r,f)
def canbuy(n):
    for i in range(int(100/7)):
        if (n-7*i)>3 and (n-7*i)%4==0:
            return 'Yes'
    return 'No'

n=input()
print(canbuy(n))


### FIXED CODE ###

def canbuy(n):
    for i in range(int(100/7)):
        tmp = n-7*i
        if tmp==0 or (tmp>3 and tmp%4==0):
            return 'Yes'
    return 'No'

n=int(input())
print(canbuy(n))
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created:  2016-10-10
#

# Usage
#
"""

def read_value():
    first_line = input()
    status = first_line.split(" ")

    num_of_contestant = status[0]
    basis = status[1]
    oversea_limit = status[2]

    second_line = input()
    rank_str = second_line

    return [num_of_contestant, basis, oversea_limit, rank_str]


def check_japan(rank, basis, oversea_limit):
    if rank < basis + oversea_limit:
        return "Yes"
    else:
        return "No"

def check_overseas(rank, oversea_rank, basis, oversea_limit):
    if rank < basis + oversea_limit and oversea_rank < oversea_limit:
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    input_items = read_value()

    basis = input_items[1]
    oversea_limit = input_items[2]
    rank_str = input_items[3]

    oversea_rank = 0

    for rank, type in enumerate(rank_str):
        if type == "a":
            print(check_japan(rank, basis, oversea_limit))

        if type == "b":
            oversea_rankt += 1
            print(check_overseas(rank, oversea_rank, basis, oversea_limit))

        if type == "c":
            print("No")






### FIXED CODE ###

# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created:  2016-10-10
#

# Usage
#
"""

def read_value():
    first_line = input()
    status = first_line.split(" ")

    num_of_contestant = int(status[0])
    basis = int(status[1])
    oversea_limit = int(status[2])

    second_line = input()
    rank_str = second_line

    return [num_of_contestant, basis, oversea_limit, rank_str]


def check_japan(rank, basis, oversea_limit):
    if rank < basis + oversea_limit:
        return "Yes"
    else:
        return "No"

def check_overseas(rank, oversea_rank, basis, oversea_limit):
    if rank < basis + oversea_limit and oversea_rank <= oversea_limit:
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    input_items = read_value()

    basis = input_items[1]
    oversea_limit = input_items[2]
    rank_str = input_items[3]

    oversea_rank = 0
    passed = 0

    for rank, type in enumerate(rank_str):
        if type == "a":
            if check_japan(passed, basis, oversea_limit) == "Yes":
                print("Yes")
                passed += 1
            else:
                print("No")

        if type == "b":
            oversea_rank += 1
            if check_overseas(passed, oversea_rank, basis, oversea_limit) == "Yes":
                print("Yes")
                passed += 1
            else:
                print("No")

        if type == "c":
            print("No")
from itertools import accumulate
from math import factorial as fc

def cmb_2(n):
    return n*(n-1)//2

N,K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
A = [i-1 for i in A]

sumA = list(accumulate(A))
sumA = [0]+[i % K for i in sumA]
x = sumA[:K]
modmap = [0]*K
for i in x:
    modmap[i] += 1

ans = 0
for i in range(K):
    ans += cmb_2(modmap[i],2)

for i in range(N-K+1):
    modmap[sumA[K+i]] += 1
    modmap[sumA[i]] -= 1
    ans += modmap[sumA[K+i]]-1

print(ans)

### FIXED CODE ###

N = input()
if N == "SUN":
    print(7)
elif N == "SAT":
    print(1)
elif N == "FRI":
    print(2)
elif N == "MON":
    print(6)
elif N == "THU":
    print(3)
elif N == "WED":
    print(4)
elif N == "TUE":
    print(5)
# coding: utf-8
import numpy as np
N, A, B = map(int, input().split())
# print("N:", N, "A:", A, "B:", B)
if A == 0:
    print(0)
elif B == 0:
    print(N)
elif N <= A:
    print(N)
elif N <= A + B:
    print(A)
else:
    lst = np.array([1 for i in range(A)])
    # print(lst)
    lst2 = np.array([0 for i in range(B)])
    # print(lst2)
    lst3 = np.append(lst, lst2)
    # print(lst3)
    while lst3.size <= N:
        lst3 = np.append(lst3, lst3)
    lst3 = lst3[:N]
    print(np.count_nonzero(lst3 == 1))

### FIXED CODE ###

# coding: utf-8
N, A, B = map(int, input().split())
# print("N:", N, "A:", A, "B:", B) 
if A == 0:
    print(0)
elif B == 0 or N <= A:
    print(N)
else:
    num = int(N / (A + B)) * A + min(A, N % (A + B))
    print(num)
from math import sqrt
n = int(input())
m = int(sqrt(n))
li = list(range(m + 1))
#0と1は考えない
for i in range(2, m + 1):
    while li[i] < n:
        li[i] *= i
    li[i] = int(li[i] / i)
print(max(li))

### FIXED CODE ###

a, b, c, d = map(int, input().split())
print('Yes' if abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d) else 'No')