Problem:
 Score: 300 points    Problem Statement  We have a canvas divided into a grid with H rows and W columns. The square at the i -th row from the top and the j -th column from the left is represented as (i, j) . Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}=  # , and to make Square (i, j) white when s_{i, j}=  . . However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective.      Constraints   H is an integer between 1 and 50 (inclusive).  W is an integer between 1 and 50 (inclusive).  For every (i, j)  (1 \leq i \leq H, 1 \leq j \leq W) , s_{i, j} is # or . .         Input  Input is given from Standard Input in the following format:  H  W  s_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}  s_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}  :  :  s_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}       Output  If square1001 can achieve his objective, print Yes ; if he cannot, print No .        Sample Input 1 3 3
.#.
###
.#.      Sample Output 1 Yes  One possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.        Sample Input 2 5 5
#.#.#
.#.#.
#.#.#
.#.#.
#.#.#      Sample Output 2 No  square1001 cannot achieve his objective here.       Sample Input 3 11 11
...#####...
.##.....##.
#..##.##..#
#..##.##..#
#.........#
#...###...#
.#########.
.#.#.#.#.#.
##.#.#.#.##
..##.#.##..
.##..#..##.      Sample Output 3 Yes

Solution (Python):
import sys
height, width = map(int, input().split())
array = [0 for i in range(height)]

for i in range(height):
    array[i] = list(input())

h = [-1, 0,0,1]
w = [ 0,-1,1,0]

for a in range(height):
    for b in range(width):
        if array[a][b] == "
            for i in range(4):
                y = a + h[i]
                x = b + w[i]
                if y < 0 or y >= height: continue
                if x < 0 or x >= width: continue
                if array[y][x] == "
                    break
            else:
                print("No")
                sys.exit()
print("Yes")

Solution (Python):
H, W = map(int, input().split())

S = [['.']*(W+2)]

for i in range(H):
    s = input()
    S.append(['.'] + list(s) + ['.'])
    
S.append([['.']*(W+2)])

flag = True

for i in range(1, H):
    for j in range(1, W):
        if S[i][j]=='
            if S[i-1][j]!='
                flag = False
                break
            
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
h, w = map(int, input().split(' '))
dot_map = [input() for _ in range(h)]

for i in range(h):
    for j in range(w):
        link = [(-1, 0), (1, 0), (0, -1), (0, 1)]
        if dot_map[i][j] == '
            count = 0
            for n, m in link:
                if 0<= i + n < h and 0 <= j + m < w and dot_map[i + n][j + m] == '
                    count += 1
            if count == 0:
                print('No')
                exit(0)

print('Yes')

Solution (Python):
H,W = map(int, input().split())
S = []
def canb(h,w):
    if h > 0:
        if S[h-1][w] == '
            return True
    if h < H - 1:
        if S[h+1][w] == '
            return True
    if w > 0:
        if S[h][w-1] == '
            return True
    if w < W - 1:
        if S[h][w+1] == '
            return True
    return False
for h in range(H):
    S.append(input())
check = 'Yes'
for h in range(H):
    for w in range(W):
        if S[h][w] == '
            if canb(h,w) == False:
                check = 'No'
                break
    else:
        continue
    break
print(check)

Solution (Python):



h, w = list(map(int, input().split()))
s_list_list = []

for _ in range(h):
    s_list = list(input().split()[0])
    s_list_list.append(s_list)

done_list_list = [[False] * w for _ in range(h)]
is_ok = True

for h_i, s_list in enumerate(s_list_list):

    for w_i, s in enumerate(s_list):

        if s == '.':
            continue

        
        

        
        if h_i + 1 < h and s_list_list[h_i+1][w_i] == '
            done_list_list[h_i][w_i] = True
            done_list_list[h_i+1][w_i] = True

        if w_i + 1 < w and s_list_list[h_i][w_i+1] == '
            done_list_list[h_i][w_i] = True
            done_list_list[h_i][w_i+1] = True

        if not done_list_list[h_i][w_i]:
            is_ok = False
            break

    if not is_ok:
        break




ans = 'Yes' if is_ok else 'No'
print(ans)

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(H: int, W: int, s: "List[str]"):

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

    for i in range(H):
        for j in range(W):
            if(s[i][j] == '
                f = False
                for k in range(4):
                    iy = i+dy[k]
                    ix = j+dx[k]
                    if(0 <= iy < H and 0 <= ix < W and s[iy][ix] == '
                        f = True
                if(f == False):
                    print(NO)
                    exit()
                
    print(YES)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  
    W = int(next(tokens))  
    s = [next(tokens) for _ in range(H)]  
    solve(H, W, s)

if __name__ == '__main__':
    main()

Solution (Python):
h, w = map(int, input().split())

s=[]
s.append(['.' for i in range(w+2)])
for i in range(h):
    ss = list('.' + input() + '.')
    s.append(ss)
s.append(['.' for i in range(w+2)])

for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == '
            print('No')
            exit()
print('Yes')

Solution (Python):
h,w=map(int,input().split())
paint=[]
for _ in range(h):
    paint.append(input())

d=((-1,0),
    (0,1),
    (0,-1),
    (1,0))

def grid():
    for i in range(h):
        for j in range(w):
            if paint[i][j]=="
                isOk=False
                for di, dj in d:
                    ni=i+di
                    nj=j+dj
                    if ni>=0 and ni<h and nj>=0 and nj<w:
                        if paint[ni][nj]=="
                            isOk=True
                    else:
                        continue
                if not isOk:
                    return False
    return True
            
ans="Yes" if grid() else "No"
print(ans)

Solution (Python):
def main():
    H, W = map(int, input().split())
    mat = []
    for _ in range(H):
        mat.append(input())

    mv = [[1,0],[-1,0],[0,1],[0,-1]]
    for i in range(H):
        for j in range(W):
            if mat[i][j] == "
                isBlack = False
                for di, dj in mv:
                    if 0 <= i+di < H and 0 <= j+dj< W:
                        if mat[i+di][j+dj] == "
                            isBlack = True
                            break
                if not isBlack:
                    return "No"

    return "Yes"

if __name__ == '__main__':
    print(main())

Solution (Python):
H,W = map(int,input().split())
s = []

for i in range(H):
    tmp = list(input())
    s.append(tmp)

for y in range(H):
    for x in range(W):
        if s[y][x] == '

            if x >= 1:
                if s[y][x-1] == '
                    continue

            if x <= W-2:
                if s[y][x+1] == '
                    continue

            if y >= 1:
                if s[y-1][x] == '
                    continue     

            if y <= H-2:
                if s[y+1][x] == '
                    continue

                print("No")
                exit()

print("Yes")

Solution (Python):
H, W = [int(_) for _ in input().split()]

m = [' ' * (W + 2)]
for i in range(H):
    m.append(' ' + input() + ' ')
m.append(' ' * (W + 2))

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if m[i][j] != '
        if not (m[i][j - 1] == '
                m[i][j + 1] == '
                m[i + 1][j] == '
                m[i - 1][j] == '
            print('No')
            exit()
print('Yes')

Solution (Python):
H, W = map(int, input().split())
S = [list(input()) for h in range(H)]
n = [[-1, 0], [1, 0], [0, 1], [0, -1]]
for h in range(H):
    for w in range(W):
        flag = False
        if S[h][w] == '.':
            continue
        for nn in n:
            if h + nn[0] < 0 or h + nn[0] > H-1 or w + nn[1] < 0 or w + nn[1] > W-1:
                continue
            if S[h + nn[0]][w + nn[1]] == '
                flag = True
        if flag:
            continue
        print('No')
        exit()
print('Yes')

Solution (Python):
import os
H, W = map(int, input().split())
s = ["." + input() + "." for _ in range(H)]

s.insert(0, "."*(W+2))
s.insert(H+1, "."*(W+2))

for i in range(1, H+1):
    for j in range(1, W+1):
        target = s[i][j]
        if target == ".":
            continue
        l = s[i][j-1]
        r = s[i][j+1]
        u = s[i-1][j]
        d = s[i+1][j]
        if "
            print("No")
            os.sys.exit()

print("Yes")

Solution (Python):
import sys
input=sys.stdin.readline

H,W=map(int, input().split())
C = [[] for i in range(H)]

for h in range(H):
    C[h] = list(input().strip())


for h in range(H):
    for w in range(W):
        if C[h][w] == "
            if h == 0 or (h>0 and C[h-1][w] == "."):
                if w == 0 or (w>0 and C[h][w-1] == "."):
                    if w == W-1 or (w<W-1 and C[h][w+1] == "."):
                        if h == H-1 or (h<H-1 and C[h+1][w] == "."):
                            print("No")
                            exit()
print("Yes")

Solution (Python):
h,w=map(int,input().split())
s=["."+input()+"." for i in range(h)]
s=["."*(w+2)]+s+["."*(w+2)]
flag=0
for i in range(1,h+1):
  for j in range(1,w+1):
    if s[i][j]=="
      if s[i-1][j]=="." and s[i+1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
        flag=1
print("Yes" if flag==0 else "No")

Solution (Python):
h,w=map(int,input().split())
s=["."+input()+"." for i in range(h)]
s=["."*(w+2)]+s+["."*(w+2)]
flag=0
for i in range(h):
  for j in range(w):
    if s[i][j]=="
      if s[i-1][j]=="." and s[i+1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
        flag=1
print("Yes" if flag==0 else "No")

Solution (Python):
H,W=map(int,input().split())
S=["."+input()+"." for i in range(H)]
S=["."*(W+2)]+S+["."*(W+2)]
flag=0
for i in range(H):
    for j in range(W):
        if S[i][j]=="
            if S[i-1][j]=="." and S[i+1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
                flag=1
print("Yes" if flag==0 else "No")

Solution (Python):
h,w = map(int,input().split())
L =["b"*(w+2)] + ["b"+ input() + "b" for i in range(h)] + ["b"*(w+2)]
ans = "ahe"
for i in range(1,h+1):
    for j in range(1,w+1):
        if L[i][j]=="
            ans="No"
if ans!="No":
    ans="Yes"
print(ans)

Solution (Python):
H, W = map(int, input().split())
s = [input() for i in range(H)]
for i in range(H):
    for j in range(W):
        if s[i][j] == ".":
            continue
        if i == 0 or s[i-1][j] == "
            continue
        if i == H-1 or s[i+1][j] == "
            continue
        if j == 0 or s[i][j-1] == "
            continue
        if j == W-1 or s[i][j+1] == "
            continue
        print("No")
        exit()
print("Yes")

Solution (Python):
h, w = map(int, input().split())
src = [input() for i in range(h)]
ans = []
for row in src:
    ans.append(list(row))
dxy = [(-1, 0), (0, 1), (1, 0), (0, -1)]
for y in range(h):
    for x in range(w):
        for dx, dy in dxy:
            if y + dy < 0 or y + dy > h - 1 or x + dx < 0 or x + dx > w - 1: continue
            if src[y][x] == '
                ans[y][x] = 'b'
                ans[y+dy][x+dx] = 'b'

cnt = 0
for row in ans:
    if row.count('
        cnt += 1 
        
if cnt > 0:
    print('No')
else:
    print('Yes')

Solution (Python):
h,w=map(int,input().split())
S=["."+input()+"." for i in range(h)]
S=["."*(w+2)]+S+["."*(w+2)]
f=True
for i in range(h):
  for j in range(w):
    if S[i][j]=="
      if S[i-1][j]=="." and S[i][j-1]=="." and S[i+1][j]=="." and S[i][j+1]==".":
      	f=False
print("Yes" if f else "No")

Solution (Python):
gyou,retu=map(int,input().split())
l=[input() for _ in range(gyou)]
d=[(0,1),(1,0),(-1,0),(0,-1)]
for g in range(gyou):
  for r in range(retu):
    if l[g][r]=="
      k=0
      for x,y in d:
        try:
          if l[g+x][r+y]=="
            k+=1
        except IndexError:
          pass
      if k==0:
        print("No")
        exit()
print("Yes")

Solution (Python):
h,w=map(int,input().split())
sl=[list(input()) for i in range(h)]

for i in range(h) :
  
  for j in range(w) :
    
    chk=[]
    if sl[i][j]=="." :
      continue
    
    if not i-1<0 :
      chk.append(sl[i-1][j])
    if not i+1>h-1 :
      chk.append(sl[i+1][j])
    if not j-1<0 :
      chk.append(sl[i][j-1])
    if not j+1>w-1 :
      chk.append(sl[i][j+1])
    
    if chk.count("
      print("No")
      exit()
    
print("Yes")

Solution (Python):
h,w = map(int,input().split())
s = [['.'] * (w+2)]
for i in range(h):
    li_tmp = ['.']
    s_tmp = list(input())
    li_tmp += s_tmp 
    li_tmp += ['.']
    s.append(li_tmp)
s.append(['.'] * (w+2))

for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] == '
            if s[i-1][j] == '
                pass
            else:
                print('No')
                quit()
print('Yes')

Solution (Python):
gyou,retu=map(int,input().split())
l=[input() for _ in range(gyou)]
d=[(0,1),(1,0),(-1,0),(0,-1)]
s=0
for g in range(gyou):
  for r in range(retu):
    if l[g][r]=="
      k=0
      for x,y in d:
        try:
          if l[g+x][r+y]=="
            k+=1
        except IndexError:
          pass
      if k==0:
        s+=1
        break
    if s==1:
      break
  if s==1:
    break
print("No") if s==1 else print("Yes")

Solution (Python):
H,W=map(int,input().split())
s=[None]*(H+2)
for i in range(H):
    s[i+1]=input()
s[0]="."*W
s[H+1]="."*W
a=1
for i in range(1,H+1):
    if s[i][0]=="
        a=0
        break
    for j in range(1,W-1):
        if s[i][j]=="
            a=0
            break
    if s[i][W-1]=="
        a=0
        break
if a:
    print("Yes")
else:
    print("No")

Solution (Python):
H, W = map(int, input().split())

L = ["." * (W+2)] + [("." + input() + ".") for _ in range(H)] + ["." * (W+2)]
flg = False
for i in range(H):
  if flg:
    print ("No")
    break
  for j in range(W):
    if L[i][j] == "
      if all((L[i-1][j] == ".", L[i+1][j] == ".", L[i][j+1] == ".", L[i][j-1] == ".")):
        flg = True
        break

else:
  print ("Yes")

Solution (Python):
h,w=map(int,input().split())
a=["."*(w+2)]
for i in range(h):
	x=input()
	a.append("."+x+".")
a.append("."*(w+2))
for i in range(h):
	for j in range(w):
		if a[i+1][j+1]=="
			if a[i][j+1]=="
a[i+2][j+1]=="
a[i+1][j]=="
				continue
			else:
				print("No")
				exit()
print("Yes")

Solution (Python):
import math
import sys
from itertools import accumulate
from functools import reduce
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""

a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 



    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())
    = [list(list(sys.stdin.readline().rstrip())) for i in range(h)] 


    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  
"""

if __name__ == "__main__":
    h,w = map(int, sys.stdin.readline().split())
    s =["."+input()+"." for i in range(h)]
    s =["."*(w+2)]+s+["."*(w+2)]
    flag=0
    for i in range(h):
        for j in range(w): 
            if s[i][j] == "
                if s[i-1][j] =="." and s[i+1][j] =="." and s[i][j-1] =="."  and s[i][j+1] ==".":
                    flag = 1
                    print("No")
                    exit()
    print("Yes" if flag==0 else "No")

Solution (Python):
H,W=map(int,input().split())
S=["."+input()+"." for i in range(H)]
S=["."*(W+2)]+S+["."*(W+2)]
flag=0
for i in range(H):
    for j in range(W):
        if S[i][j]=="
            if S[i-1][j]=="." and S[i+1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
                flag=1
print("Yes" if flag==0 else "No")

Solution (Python):
def judge(ll):
    for i in range(1,int(len(ll))-1):
        for j in range(1,int(len(ll[0]))-1):
            
            if ll[i][j] == '
                return False
    
    return True


h, w = map(int, input().split())
s_ij = [['.' for i in range(w + 2)]]
s_ij += [list('.' + input() + '.') for i in range(h)]
s_ij.append(['.' for i in range(w + 2)])

print("Yes" if judge(s_ij) else "No")

Solution (Python):
h, w = map(int, input().split())
l = [0]*(h+2)
l[0] = '.'*(w+2)
l[-1] = '.'*(w+2)

for _ in range(1, h+1):
  l[_] = '.' + str(input()) + '.'

for i in range(1, h+1):
  for j in range(1, w+1):
    if l[i][j] == '.':
      continue
    else:
      if all (l[i+i_][j+j_] == '.' for i_, j_ in ([1, 0], [-1, 0], [0, 1], [0, -1])):
        print('No')
        exit()
      else:
        continue
else:
  print('Yes')

Solution (Python):
H, W = map(int, input().split())
S = [[] for _ in range(H)]
for i in range(H):
    S[i] = list(input())

count = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            count[i][j] = 10**7
        else:
            count[i][j] = 0

for i in range(H):
    for j in range(W):
        if S[i][j] == '
            if j != W-1: 
                if S[i][j+1] == '
                    count[i][j] += 1
            if j != 0: 
                if S[i][j-1] == '
                    count[i][j] += 1
            if i != H-1: 
                if S[i+1][j] == '
                    count[i][j] += 1
            if i != 0: 
                if S[i-1][j] == '
                    count[i][j] += 1

check = 0
for i in range(H):
    for j in range(W):
        if count[i][j] < 1:
            check = 1

if check == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
H, W = map(int,input().split())

sw_list = []
sw_list.append(["."]*(W+2))
[sw_list.append(["."] + list(input()) + ["."]) for _ in range(H)]
sw_list.append(["."]*(W+2))

def check():
    for h in range(1,H+1):
        for w in range(1,W+1):
            if sw_list[h][w] == "
                if all([sw_list[h-dh][w-dw]=="." for dh,dw in [(-1,0),(0,-1),(1,0),(0,1)]]):
                    return False
    return True

if check():
    print("Yes")
else:
    print("No")

Solution (Python):
if __name__ == '__main__':
    H, W = map(int, input().split())
    S = [[None for _ in range(W+2)] for _ in range(H+2)]
    for h in range(H):
        S[h+1] = [None] + list(map(str, input())) + [None]
    flag = True
    for h in range(H+2):
        for w in range(W+2):
            if S[h][w] == '
                if '
                    flag = False
    if flag:
        print('Yes')
    else:
        print('No')

Solution (Python):
if __name__ == '__main__':
    H, W = map(int, input().split())
    S = [[None for _ in range(W+2)] for _ in range(H+2)]
    for h in range(H):
        S[h+1] = [None] + list(map(str, input())) + [None]
    flag = True
    for h in range(H):
        for w in range(W):
            if S[h][w] == '
                if '
                    flag = False
    if flag:
        print('Yes')
    else:
        print('No')

Solution (Python):
H, W = map(int, input().split())

lst = [list(input()) for i in range(H)]
ans = "Yes"
for i in range(H):
  for j in range(W):
    if lst[i][j] == "
      above = False
      below = False
      left = False
      right = False
      if (i > 0):
        if (lst[i-1][j] == '
          above = True
      if (j > 0):
        if (lst[i][j-1] == '
          left = True
      if (i < H-1):
        if (lst[i+1][j] == '
          below = True
      if (j < W-1):
        if (lst[i][j+1] == '
          right = True
      if (not above and not below and not left and not right):
        ans = 'No'
        break
print(ans)

Solution (Python):
def main():
    H, W = map(int, input().split())
    S = [list(input()) for i in range(H)]

    dy = [1,0,-1,0]
    dx = [0,1,0,-1]
    for h in range(H):
        for w in range(W):
            if S[h][w] == '
                flag = False
                for i in range(4):
                    ny = h + dy[i]
                    nx = w + dx[i]

                    if 0 <= ny < H and 0 <= nx < W:
                        if S[ny][nx] == '
                            flag = True
                if flag == False:
                    print('No')
                    exit()

    print('Yes')
    

main()

Solution (Python):
h, w = map(int, input().split())
S = ['.'+input()+'.' for _ in range(h)]
S = ['.'*(w+2)] + S + ['.'*(w+2)]
flag = False
for i in range(1, h+1):
    for j in range(1, w+1):
        if S[i][j] == '.':
            continue
        if S[i-1][j] != '
            flag = True
print('No' if flag else 'Yes')

Solution (Python):
h,w=map(int,input().split());w+=2
s=["."*w]+["."+input()+"." for _ in[0]*h]+["."*w]
for i in range(1,h+2):
	for j in range(1,w):
		if s[i][j]=="
			if "
				print("No");exit()
print("Yes")

Solution (Python):
h,w = map(int,input().split())

ls = [list(input()) for i in range(h)]

t=True

for i in range(h):
    for j in range(w):
        if (ls[i][j]=='
            count=0
            for x in range(-1,2):
                for y in range(-1,2):
                    if (0<=i+x<h and 0<=j+y<w):
                        if not((x==1 and y==1) or (x==1 and y==-1) or (x==-1 and y==1) or (x==-1 and y==-1)or(x==0 and y==0)):
                      	  if(ls[i+x][j+y]=='
                              count+=1
                      	  else:
                              continue
                        else:
                          continue
                    else:
                      continue
            if(count==0):
              t = False
              break
        else:
          continue      
if(t):
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
h, w = [int(i) for i in sys.stdin.readline().split()]
s = [sys.stdin.readline().strip() for _ in range(h)]

WHITE = '.'
BLACK = '

def can_draw():
    for i in range(h):
        for j in range(w):
            if s[i][j] == WHITE:
                continue

            top = i - 1
            bottom = i + 1
            left = j - 1
            right = j + 1

            if top >= 0:
                if s[top][j] == BLACK:
                    continue

            if bottom < h:
                if s[bottom][j] == BLACK:
                    continue

            if left >= 0:
                if s[i][left] == BLACK:
                    continue

            if right < w:
                if s[i][right] == BLACK:
                    continue

            return False
    return True

if can_draw():
    print('Yes')
else:
    print('No')

Solution (Python):
val = input()
val = [int(x.strip()) for x in val.split(" ")]
h = val[0]
w = val[1]

s = [[0]*w]*h
for i in range(h):
    s[i] = input()

ans = "Yes"

for i in range(h):
    for j in range(w):
        d = 0
        if s[i][j] == ".":
            continue

        if i > 0:
            if s[i-1][j] == "
                d += 1

        if i < h-1:
            if s[i+1][j] == "
                d += 1

        if j > 0:
            if s[i][j-1] == "
                d += 1

        if j < w-1:
            if s[i][j+1] == "
                d += 1
        
        if d == 0:
            ans = "No"
            break
    if ans == "No":
        break

print(ans)

Solution (Python):

import collections
import itertools
import sys

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

h,w=getints()
grid=[input() for _ in range(h)]

def check(y, x):
    if grid[y][x] == '.':
        return True
    for xx in range(x-1, x+2):
        for yy in range(y-1, y+2):
            if abs(xx - x) + abs(yy - y) != 1:
                continue
            if xx < 0 or xx >= w or yy < 0 or yy >= h:
                continue
            if grid[yy][xx] == '
                return True
    return False

ok = True
for i in range(h):
    for j in range(w):
        if not check(i, j):
            ok = False
            break
print("Yes" if ok else "No")

Solution (Python):
H, W = map(int, input().split())
atlas = [[False for _ in range(W + 2)] for _ in range(H + 2)]

for h in range(1, H + 1):
    line = input()
    for w in range(1, W + 1):
        if line[w - 1] == '
            atlas[h][w] = True

for h in range(1, H + 1):
    for w in range(1, W + 1):
        if atlas[h][w]:
            if atlas[h - 1][w] or atlas[h + 1][w] or atlas[h][w - 1] or atlas[h][w + 1]:
                continue
            print('No')
            exit(0)
print('Yes')

Solution (Python):
h,w = map(int,input().split())
s = []
s.append("."*(w+2))
for i in range(h):
    s.append("."+input()+".")
s.append("."*(w+2))

ans = "Yes"
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] == "
            if s[i+1][j] == "." and s[i][j+1] == "." and s[i][j-1] == "." and s[i-1][j] == ".":
                ans = "No"
                break
    if ans == "No":
        break

print(ans)

Solution (Python):
def solve(ls):
    for i in range(1,h+1):
        for j in range(1, w+1):
            if ls[i][j] == "
                return False
    return True

h, w = map(int, input().split())
ls = [["."] * (w+2)]
ls += [["."] + list(input()) + ["."] for i in range(h)]
ls.append(["."] * (w+2))

if solve(ls):
    print("Yes")
else:
    print("No")

Solution (Python):
h, w = map(int, input().split())
canvas = [input() for _ in range(h)]
dx_list = [0, 1, 0, -1]
dy_list = [-1, 0, 1, 0]
clear = True

for y in range(h):
    for x in range(w):
        if canvas[y][x] == '.':
            continue
        else:
            count = 0
            for d in range(4):
                dx = x + dx_list[d]
                dy = y + dy_list[d]

                if 0 <= dx <= w-1 and 0 <= dy <= h-1:
                    if canvas[dy][dx] == '
                        count += 1

            if count == 0:
                clear = False
                break
    if clear is False:
        break

if clear:
    print('Yes')
else:
    print('No')

Solution (Python):
H, W = list(map(int, input().split()))
grid = [list(input()) for _ in range(H)]

D = ((0, 1), (1, 0), (-1, 0), (0, -1))

for y in range(H):
    for x in range(W):
        if grid[y][x] != "
            continue
        flg = True
        for d in D:
            x1 = x + d[0]
            y1 = y + d[1]
            if x1 < 0 or W <= x1 or y1 < 0 or H <= y1:
                continue
            if grid[y1][x1] == "
                flg = False
                break

        if flg:
            print("No")
            import sys
            sys.exit(0)
print("Yes")

Solution (Python):
H, W = map(int, input().split())
S = ['.'+input()+'. ' for _ in range(H)]

S.insert(0, '.'*(W+2))
S.insert(H+1, '.'*(W+2))

flg = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j]=='
            if S[i+1][j]=='.' and S[i-1][j]=='.' and S[i][j+1]=='.' and S[i][j-1]=='.':
                flg = 1
                break
    else:
        continue
    break
    
if flg==0:
    print('Yes')
else:
    print('No')

Solution (Python):
H,W = (int(i) for i in input().split())  
df = [input() for i in range(H)] 
s="." * W
df.insert(0,s)
df.append(s)
for i in range(H+2):
    df[i] = "." + df[i] + "."


ans = True
for h in range(1,H-1):
    for w in range(1,W-1):
        if df[h][w]=="
            if df[h][w-1]=="." and df[h][w+1]=="." and df[h+1][w]=="." and df[h-1][w]==".":
                ans = False
                break
    if ans is False:
        break

if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
h,w=map(int,input().split())
s=[[0]*(w+2)]+[[0]+list(map(int,list(input().replace('
for i in range(1,h+1):
  for j in range(1,w+1):
    if s[i][j]==1:
      if s[i-1][j]+s[i+1][j]+s[i][j-1]+s[i][j+1]==0:
        print('No')
        sys.exit()
print('Yes')

Solution (Python):
h,w = map(int,input().split())
s =[[i for i in input()] for j in range(h)]
for i in range(h):
	for j in range(w):
		if s[i][j]=='
			flag = 0
			for di in range(-1,2):
				for dj in range(-1,2):
					if di!=0 and (dj==-1 or dj==1):
						
						continue
					if di==0 and dj ==0:
						continue
					if not (0<=i+di<h and 0<=j+dj<w):
						
						continue
					if s[i+di][j+dj]=='
						flag = 1
			if flag ==0:
				print('No')
				break		
	else:
		continue
	break

else:
	print('Yes')

Solution (Python):
h, w = map(int, input().split())
sL = [input() for i in range(h)]

ans = "Yes"

for y in range(h):
    for x in range(w):
        if sL[y][x] == ".":
            continue
        if y-1 < 0 or y+1 > h-1 or x-1 < 0 or x+1 > w-1:
            continue
        if sL[y+1][x] == sL[y-1][x]  == sL[y][x+1] == sL[y][x-1] == ".":
            ans = "No"
            break

print(ans)

Solution (Python):
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

H, W = list(map(int, sys.stdin.readline().split()))
S = [sys.stdin.readline().rstrip() for _ in range(H)]


def is_ok(h, w):
    dh = [h, h, h - 1, h + 1]
    dw = [w + 1, w - 1, w, w]
    for h, w in zip(dh, dw):
        if 0 <= h < H and 0 <= w < W:
            if S[h][w] == '
                return True
    return False


ok = True
for h, w in itertools.product(range(H), range(W)):
    if S[h][w] == '
        ok &= is_ok(h, w)
if ok:
    print('Yes')
else:
    print('No')

Solution (Python):
H, W = map(int, input().split())
canvas = list()
canvas.append(['.' for _ in range(W + 2)])
for _ in range(H):
    r = ['.']
    for c in input():
        r.append(c)
    r.append('.')
    canvas.append(r)
canvas.append(['.' for _ in range(W + 2)])

for i in range(len(canvas)):
    row = canvas[i]
    for j in range(len(row)):
        cell = row[j]
        if cell == '
            if '
                continue
            else:
                print('No')
                exit(0)
print('Yes')

Solution (Python):
X,Y = map(int,input().split())
given = []
for x in range(X):
  given.append(input())

nex = [[-1,0],[1,0],[0,-1],[0,1]]
for i in range(X * Y):
  x = i // Y
  y = i % Y
  if given[x][y] == '
    for ex in range(4):
      try:
        if given[x+nex[ex][0]][y+nex[ex][1]] == '
          break
      except:
        pass
    else:
      print('No')
      break
else:
  print('Yes')