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):
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):

import sys
try:
    from typing import List
except ImportError:
    pass

YES = "Yes"  
NO = "No"  


def solve(H: int, W: int, s: "List[str]"):
    print(YES if all(
        any(
            s[y + dy][x + dx] == "
            for dx, dy in [(1, 0), (0, 1), (-1, 0), (0, -1)]
            if 0 <= x + dx < W and 0 <= y + dy < H
        )
        for y in range(H)
        for x in range(W)
        if s[y][x] == "
    ) else NO)


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):


import io
import sys

nim,mike=map(int, input().split())

S = [input() for _ in range(nim)]

d = [-1,0,1,0,-1]

b = 0

for h in range(nim):
    for w in range(mike):
        if S[h][w] == ".": continue
        if any(S[h+x][w+y]=="
            continue
        b = 1
print("YNeos"[b::2])

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):
import sys
H, W = map(int, input().split())
s = [input() for _ in range(H)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
for i in range(H):
    for j in range(W):
        if s[i][j] == '
            for k in range(4):
                try:
                    if s[i + dy[k]][j + dx[k]] == '
                        flag = False
                        break
                    else:
                        flag = True
                except IndexError:
                    pass
            if flag:
                print('No')
                sys.exit()
print('Yes')

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

maze = [['.']*(w+2)] + [['.'] + list(input()) + ['.'] for i in range(h)] + [['.']*(w+2)]

def kuro(a,b):
    dx = [-1,1,0,0]
    dy = [0,0,-1,1]
    p = 0
    for i in range(4):
        if maze[a+dx[i]][b+dy[i]] == '
            p += 1
            maze[a+dx[i]][b+dy[i]] == '.'
    if p == 0:
        return False
    return True




for i in range(1,h+1):
    for j in range(1,w+1):
        if maze[i][j] == '
            if kuro(i,j) == False:
                print('No')
                break
    else:
        continue
    break
else:print('Yes')

Solution (Python):
h,w = map(int,input().split())
array = []
for _ in range(h):
  array.append(list(map(str,input())))
for i in range(h):
  array[i].insert(0,".")
  array[i].append(".")
array.insert(0,["."]*(w+2))
array.append(["."]*(w+2))
for i in range(1,h+1):
  for j in range(1,w+1):
    if array[i][j]=="
      print("No")
      break
    if i==h and j==w:
      print("Yes")
      break
  else:
    continue
  break

Solution (Python):
H, W = map(int, input().split())
cam = [input() for i in range(H)]
ans = 'Yes'
for i in range(1, H-1):
	for j in range(1, W-1):
		if cam[i][j] == "
			if cam[i-1][j] == cam[i+1][j] == cam[i][j-1] == cam[i][j+1] == ".":
				ans = 'No'
				break
print(ans)

Solution (Python):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    h, w = nm()
    s = [['.'] * (w+1)]
    for _ in range(h):
        temp = ['.']
        temp.extend(list(ns()))
        temp.extend(['.'])
        s.append(temp)
    s.append(['.'] * (w+1))

    flag = True
    for i in range(1, h+1):
        for j in range(1, w+1):
            if (
                s[i][j] == '
                s[i-1][j] == '.' and
                s[i][j-1] == '.' and
                s[i+1][j] == '.' and
                s[i][j+1] == '.' 
            ):
                flag = False

    print('Yes' if flag else 'No')
    

if __name__ == '__main__':
    main()

Solution (Python):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    h, w = nm()
    s = [['.'] * (w+1)]
    for _ in range(h):
        temp = ['.']
        temp.extend(list(ns()))
        temp.extend(['.'])
        s.append(temp)
    s.append(['.'] * (w+1))

    flag = True
    for i in range(1, h+1):
        for j in range(1, w+1):
            if (
                s[i][j] == '
                s[i-1][j] == '.' and
                s[i][j-1] == '.' and
                s[i+1][j] == '.' and
                s[i][j+1] == '.' 
            ):
                flag = False

    print('Yes' if flag else 'No')
    

if __name__ == '__main__':
    main()

Solution (Python):
h, w = map(int, input().split())
s = [input() for i in range(h)]
ans = "Yes"
for i in range(h):
    for j in range(w):
        if s[i][j]=="
            ans = "No"
            for x, y in [(-1, 0), (0, -1), (0, 1), (1, 0)]:
                if  0<=i+x<h and 0<=j+y<w and s[i+x][j+y]=="
                    ans = "Yes"
            if ans == "No":
                print(ans)
                exit()
print(ans)

Solution (Python):
h, w = map(int, input().split())
s = ["."*(w+2)]+["."+input()+"." for i in range(h)]+["."*(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())
s=[input() for _ in range(h)]
for i in range(h):
    for j in range(w):
        if i==0:
            if j==0 and s[i][0]=='
                l1=[s[0][1],s[1][0],s[0][0]]
                l1l=l1.count('
                if l1l==1:
                    print('No')
                    exit()
            elif j==w-1 and s[i][w-1]=='
                r1=[s[0][w-2],s[0][w-1],s[1][w-1]]
                r1r=r1.count('
                if r1r==1:
                    print('No')
                    exit()
            elif s[i][j]=='
                l1j=[s[0][j-1],s[0][j+1],s[0][j],s[1][j]]
                l1jj=l1j.count('
                if l1jj==1:
                    print('No')
                    exit()
            else:pass
        elif i==h-1:
            if j==0 and s[i][0]=='
                lh=[s[h-1][0],s[h-2][0],s[h-1][1]]
                lhl=lh.count('
                if lhl==1:
                    print('No')
                    exit()
            elif j==w-1 and s[i][w-1]=='
                rh=[s[h-1][w-1],s[h-1][w-2],s[h-2][w-1]]
                rhr=rh.count('
                if rhr==1:
                    print('No')
                    exit()
            elif j!=0 and j!=w-1 and s[i][j]=='
                lhj=[s[i][j],s[i][j+1],s[i][j-1],s[i-1][j]]
                lhjj=lhj.count('
                if lhjj==1:
                    print('No')
                    exit()
        else:
            if j==0 and s[i][0]=='
                li=[s[i-1][0],s[i][0],s[i][1],s[i+1][0]]
                lil=li.count('
                if lil==1:
                    print('No')
                    exit()
            elif j==w-1 and s[i][w-1]=='
                ri=[s[i-1][w-1],s[i][w-1],s[i][w-2],s[i+1][w-1]]
                rir=ri.count('
                if rir==1:
                    print('No')
                    exit()
            elif s[i][j]=='
                lij=[s[i-1][j],s[i][j],s[i][j+1],s[i][j-1],s[i+1][j]]
                lijj=lij.count('
                if lijj==1:
                    print('No')
                    exit()
            else:pass
print('Yes')

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

dx = [0,0,1,-1]
dy = [1,-1,0,0]
s = []
for i in range(h):
	t = input()
	s.append(t)

for i in range(h):
	for j in range(w):
		if s[i][j] == ".":
			continue
		flg = 0
		for k in range(4):
			x = i + dx[k]
			y = j + dy[k]
			if x < 0 or x >= h or y < 0 or y >= w:
				continue
			if s[x][y] == "
				flg = 1
				break
		if flg == 0:
			print ("No")
			exit()
print ("Yes")

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

for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j]=='
            flag = False

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

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

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

for i,ss in enumerate(pad_s):
  for j,s in enumerate(ss):
    if s == '
      and pad_s[i][j+1] == '.'\
      and pad_s[i][j-1] == '.'\
      and pad_s[i+1][j] == '.'\
      and pad_s[i-1][j] == '.':
      print('No')
      exit()

print('Yes')

Solution (Python):
h,w = map(int,input().split())
t = "."*(w+2)
b = [t]
for i in range(h):
  s = str(input())
  s = "."+ s + "."
  b.append(s)
b.append(t)
for i in range(1,h+1):
  for j in range(1,w+1):
    if b[i][j] == "
      if all([b[i-1][j]==".",b[i+1][j]==".",b[i][j-1]==".",b[i][j+1]=="."]):
        print("No")
        exit()
print("Yes")

Solution (Python):
def checkDraw(S, y, x):
  return S[y][x] == '

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

for h,ss in enumerate(S):
  for w,s in enumerate(ss):
    if s == '
      if h == 0:
        if w == 0:
          if checkDraw(S, h+1, w) or checkDraw(S, h, w+1):
            pass
          else:
            print('No')
            exit()
        elif w == W-1:
          if checkDraw(S, h+1, w) or checkDraw(S, h, w-1):
            pass
          else:
            print('No')
            exit()
        else:
          if checkDraw(S, h+1, w) or checkDraw(S, h, w-1) or checkDraw(S, h, w+1):
            pass
          else:
            print('No')
            exit()
      if h == H-1:
        if w == 0:
          if checkDraw(S, h-1, w) or checkDraw(S, h, w+1):
            pass
          else:
            print('No',1)
            exit()
        elif w == W-1:
          if checkDraw(S, h-1, w) or checkDraw(S, h, w-1):
            pass
          else:
            print('No',2)
            exit()
        else:
          if checkDraw(S, h-1, w) or checkDraw(S, h, w-1) or checkDraw(S, h, w+1):
            pass
          else:
            print('No',3)
            exit()
      if w == 0 and 0 < h < H-1:
        if checkDraw(S, h+1, w) or checkDraw(S, h-1, w) or checkDraw(S, h, w+1):
          pass
        else:
          print('No')
          exit()
      if w == W-1 and 0 < h < H-1:
        if checkDraw(S, h+1, w) or checkDraw(S, h-1, w) or checkDraw(S, h, w-1):
          pass
        else:
          print('No')
          exit()
      if 0 < h < H-1 and 0< w < W-1:
        if checkDraw(S, h-1, w) or checkDraw(S, h+1, w) or checkDraw(S, h, w-1) or checkDraw(S, h, w+1):
          pass
        else:
          print('No')
          exit()

print('Yes')

Solution (Python):
def check_current_posi(map_list, h, w):
  _height = len(map_list)
  _width = len(map_list[0])
  if h == -1 or w == -1 or h >= _height or w >= _width:
    
    return False

  else:
    if map_list[h][w] == "
      
      return True

    else:
      
      return False



def check_around(map_list, h, w):
  posi_list = [
    [h - 1, w], 
    [h, w - 1], 
    [h, w + 1], 
    [h + 1, w] 
  ]

  _result = False

  for check_posi_h, check_posi_w in posi_list:
    if check_current_posi(map_list, check_posi_h, check_posi_w):
      _result = True
      break
  
  return _result
  



_input = list(map(int, input().split(" ")))

_height = _input[0]
_width = _input[1]

_input_map = []

result = True


for h in range(_height):
  _input_map.append(list(input()))

for h in range(_height):
  if result == False:
    break

  for w in range(_width):
    if _input_map[h][w] == "
      if check_around(_input_map, h, w):
        continue
      else:
        result = False
        break

if result == False:
  print("No")
else:
  print("Yes")

Solution (Python):
import numpy as np
import itertools
 
H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)])

def f(H, W, S):
  for i, j in itertools.product(range(H), range(W)):
    if S[i, j] == '
      if np.sum(np.concatenate([S[i-1:i, j], S[i, j-1:j], S[i+1:i+2, j], S[i, j+1:j+2]]) == '
        return False
  return True

if f(H, W, S):
  print('Yes')
else:
  print('No')

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

for i in range(1,h+1):
    for j in range(1,w+1):
        if (p[i][j] == "
        p[i-1][j] == "." and 
        p[i+1][j] == "." and 
        p[i][j-1] == "." and
        p[i][j+1] == "."):
            print("No")
            exit()
print("Yes")

Solution (Python):
h, w = map(int,input().split())
a = []
flag = True
for i in range(h):
    aa = list(input().rstrip())
    a.append(aa)
for i in range(h):
    for j in range(w):
        if a[i][j]=='.': continue
        aa = ['','','','']
        if i!=0: aa[0] = a[i-1][j]
        if i+1!=h: aa[1] = a[i+1][j]
        if j!=0: aa[2] = a[i][j-1]
        if j+1!=w: aa[3] = a[i][j+1]
        if a[i][j] not  in aa:
            flag = False
            break
print('Yes' if flag else 'No')

Solution (Python):
import sys
H, W = map(int,input().split())
table = []
for _ in range(H):
    table.append(list(input()))
t_x = [0,1,0,-1]
t_y = [1,0,-1,0]

for x in range(H):
    for y in range(W):
        if table[x][y] == '
            flag = 1
            for k in range(4):
                n_x = x + t_x[k]
                n_y = y + t_y[k]
                if 0 <= n_x <= H-1 and 0 <= n_y <= W-1 and table[n_x][n_y] == '
                    flag = 0
            if flag:
                print('No')
                sys.exit()
print('Yes')

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

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

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][j+1] == '
                continue
            else:
                ans = 'No'
                break

print(ans)

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))

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

print("Yes")

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

Solution (Python):
h, w = map(int, input().split())
s = [["" for _ in range(h)] for _ in range(w)]
for i in range(h):
    S = input()
    for j in range(w):
        s[j][i] = S[j]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

def bfs(x, y):
    if s[x][y] == ".":
        return True
    flag = False
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx and nx < w and 0 <= ny and ny < h:
            if s[nx][ny] == "
                flag = True
    return flag

ans = True
for i in range(h):
    for j in range(w):
        if bfs(j, i) == False:
            ans = False

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

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

ans='Yes'
for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            continue
        if i > 0 and s[i-1][j]=='
            continue
        if i < h-1 and s[i+1][j]=='
            continue
        if j > 0 and s[i][j-1]=='
            continue
        if j < w-1 and s[i][j+1]=='
            continue
        ans='No'
        break
    if ans=='No':
        break
print(ans)

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

ans = "Yes"
judge = 0

for i in range(w):
  for j in range(h):
    sign = 0
    
    if s[j][i] == ".":
      continue
    
    if (0<=j-1) and (s[j-1][i] == "
      sign = 1
    
    if (0<=i-1) and (s[j][i-1] == "
      sign = 1
      
    if (j+1<h) and (s[j+1][i] == "
      sign = 1
      
    if (i+1<w) and (s[j][i+1] == "
      sign = 1
      
    if sign != 1:
      ans = "No"
      judge = 1
      break
  
  if judge == 1:
    break
      
print(ans)

Solution (Python):
H, W = map(int, input().split())
s_list = []
for i in range(H):
    s = list(input())
    s_list.append(s)
direction = [[-1, 0], [0, -1], [1, 0], [0, 1]]
for i in range(H):
    for j in range(W):
        if s_list[i][j]=="
            ans = "No"
            for x,y in direction:
                if 0 <=i+x<= H-1 and 0 <=j+y<= W-1 and s_list[i+x][j+y]=="
                    ans = "Yes"
            if ans=="No":
                print(ans)
                exit()
print("Yes")

Solution (Python):
import sys
import numpy as np

h, w = map(int, sys.stdin.readline().split())
grid = np.array([list(sys.stdin.readline().rstrip()) for _ in range(h)], dtype='U1')
grid = np.pad(grid, 1, 'constant')
grid = grid == '

def main():
    res = grid[1:-1, 1:-1]
    l = grid[1:-1, :-2]
    r = grid[1:-1, 2:]
    u = grid[:-2, 1:-1]
    d = grid[2:, 1:-1]
    ans = 'No' if np.any(res & ~(l | r | u | d)) else 'Yes'
    print(ans)

if __name__ ==  '__main__':
    main()

Solution (Python):
import sys

h,w = map(int,input().split())
field = [list(input()) for i in range(h)]

field.insert(0,list('.'*w))
field.append(list('.'*w))
for i in range(h+2):
    field[i].insert(0,'.')
    field[i].append('.')

for i in range(1,h+1):
    for j in range(1,w+1):
        c = 0
        if field[i][j] == '
            for x,y in [[0,1], [1,0], [0,-1],[-1,0]]:
                if field[i+x][j+y] == '
                    c += 1
            
            if c == 0:
                print('No')
                sys.exit()
    
print('Yes')

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

ans = []
for s in S:
    ans.append([0 if c == '.' else 1 for c in s])


for i, s in enumerate(S):
    for j in range(0, W - 1):
        if (s[j] == '
            ans[i][j] = 0
            ans[i][j + 1] = 0


S = [list(x) for x in zip(*S)]
ans = [list(x) for x in zip(*ans)]
for i, s in enumerate(S):
    for j in range(0, H - 1):
        if (s[j] == '
            ans[i][j] = 0
            ans[i][j + 1] = 0

if sum([sum(x) for x in ans]):
    print("No")
else:
    print("Yes")

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

dxy=[(-1,0),(0,1),(0,-1),(1,0)]
for i in range(h):
  for j in range(w):
    if s[i][j]=="
      f=False
      for x,y in dxy:
        
        if 0<=i+x<=h-1 and 0<=j+y<=w-1 and s[i+x][j+y]=="
          f=True
      
      if not f:
        print("No")
        exit()
        
        

print("Yes")

Solution (Python):




mod = 10**9 + 7

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

def readInts():
  return list(map(int,input().split()))
def search(S,y,x,h,w):
    
    cnt = 0
    
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        
        if 0 <= nx < w and 0 <= ny < h:
            
            if S[ny][nx] == '
                cnt += 1
    
    if cnt == 0:
        return False
    else:
        return True

def main():
    h,w = readInts()
    S = [input() for _ in range(h)]
    
    for i in range(h):
        for j in range(w):
            if S[i][j] == '
                
                if search(S,i,j,h,w):
                    pass
                else:
                    print('No')
                    exit()
    print('Yes')


if __name__ == '__main__':
  main()

Solution (Python):
h,w = map(int,input().split())
s = [input()for i in range(h)]
OK = True
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':continue
        ok = False
        if i-1>=0 and s[i-1][j] == '
        if j-1>=0 and s[i][j-1] == '
        if i+1<=h-1 and s[i+1][j] == '
        if j+1 <= w-1 and s[i][j+1] == '
        if not ok:
            OK = False
            break
            
if OK :print('Yes')
else:print('No')

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

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

def judge(y,x):
    for i in range(4):
        if (0 <= y + dy[i] and y + dy[i] <= H-1) and (0 <= x + dx[i] and x + dx[i] <= W-1):
            if s[y + dy[i]][x + dx[i]] == "
                return True
    return False

for y in range(H):
    for x in range(W):
        if s[y][x] == "
            if judge(y,x) == False:
                print("No")
                exit()
print("Yes")

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

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

for y in range(H):
    for x in range(W):
        flag = False
        if s[y][x] == "
            for i in range(4):
                if (0 <= y + dy[i] and y + dy[i] <= H-1) and (0 <= x + dx[i] and x + dx[i] <= W-1):
                    if s[y + dy[i]][x + dx[i]] == "
                        flag = True
                        break
            if flag == False:
                print("No")
                exit()
print("Yes")

Solution (Python):
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    h, w = MII()
    ss = ['.'*(w+2)]
    for i in range(h):
        s = '.'+IS()+'.'
        ss.append(s)
    ss.append('.'*(w+2))
    flag = True
    for i in range(1, h+1):
        for j in range(1, w+1):
            if ss[i][j]=='
                if ss[i-1][j]=='
                    continue
                else:
                    flag = False
                    break
    if flag: print('Yes')
    else: print('No')
if __name__ == '__main__':
    main()

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

for i in range(h):
    for j in range(w):
        if s[i][j] == '
            check = 0
            for x, y in ([1,0],[0,1],[0,-1],[-1,0]):
                new_h, new_w = i + x, j + y
                
                if new_h < 0 or new_h >= h or new_w < 0 or new_w >= w:
                    continue
                if s[new_h][new_w] == '.':
                    check += 1
            if check == 4:
                print('No')
                quit()
print('Yes')

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

for i in range(h):
    for j in range(w):
        if s[i][j] == '
            check = 0
            for x, y in ([1,0],[0,1],[0,-1],[-1,0]):
                new_h, new_w = i + x, j + y
                
                if new_h < 0 or new_h >= h or new_w < 0 or new_w >= w:
                    continue
                if s[new_h][new_w] == '.':
                    check += 1
            if check == 4:
                print('No')
                quit()
print('Yes')

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

for i in range(h):
    for j in range(w):
        if s[i][j] == '
            check = 0
            for x, y in ([1,0],[0,1],[0,-1],[-1,0]):
                new_h, new_w = i + x, j + y
                
                if new_h < 0 or new_h >= h or new_w < 0 or new_w >= w:
                    continue
                if s[new_h][new_w] == '.':
                    check += 1
            if check == 4:
                print('No')
                quit()
print('Yes')

Solution (Python):
import sys
import numpy as np

H,W = list(map(int,input().split()))
data = [input().strip().split() for _ in range(H)]
data_ = np.array([list(str(data[i])) for i in range(H)])[:,2:-2]


vec = [[0,1],[1,0],[0,-1],[-1,0]]

where = np.where(data_ == '


for y,x in zip(where[0],where[1]):
	
	check = [data_[y+vy, x+vx] for vy,vx in vec if (0 <= y+vy < H and 0 <= x+vx < W)]
	
	if '
		continue
	else:
		print('No')
		sys.exit()
print('Yes')

Solution (Python):
H,W = map(int,input().split())
s = [list(input()) for i in range(H)]
def judge(h,w):
    h1 = [0,0,1,-1]
    w1 = [1,-1,0,0]
    for i in range(4):
        if 0 <= h+h1[i] <= H-1 and 0 <= w+w1[i] <= W-1:
            if s[h+h1[i]][w+w1[i]] == '
                return True
    return False

ans = 'Yes'
for h in range(H):
    for w in range(W):
        if s[h][w] == '
            ans = 'No'
            break
print(ans)

Solution (Python):
import sys

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


square = [[''] * (w + 2)]
for _ in range(h):
    row = list(input())
    row = ['.'] + row + ['.']
    square.append(row)
square.append([''] * (w + 2))

for i in range(1, h):
    for j in range(1, w):
        if square[i][j] == '
            if square[i + 1][j] == '
                
                continue
            else:
                print('No')
                sys.exit()
print('Yes')

Solution (Python):
import numpy as np
H, W=map(int, input().split())
S=[]
for i in range(H):
  s=list(input())
  S.append(s)
S=np.array(S)  
vec=[(0,1),(1,0),(0,-1),(-1,0)]
ok=True
for i in range(H):
  for j in range(W):
    now=S[i,j]
    if now=="
      suround=False
      for dx,dy in vec:
        nx,ny=i+dx,j+dy
        if 0<=nx and nx<H and 0<=ny and ny<W:
          if S[nx,ny]=="
            suround=True
      if not suround:
        ok=False
        break
if ok:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
S = [input() for i in range(H)]

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

for h in range(H):
    for w in range(W):
        if S[h][w] == "
            cnt = 0
            for i in range(4):
                if 0 <= h + dy[i] < H and 0 <= w + dx[i] < W:
                    if S[h+dy[i]][w+dx[i]] == "
                        cnt += 1
            if cnt == 0:
                print("No")
                exit()
print("Yes")

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

for i in range(h):
  for j in range(w):
    if s[i][j]=="
      if 0<j:c[i][j-1]=1
      if j<w-1:c[i][j+1]=1
      if 0<i:c[i-1][j]=1
      if i<h-1:c[i+1][j]=1

ok=True
for i in range(h):
  for j in range(w):
    if s[i][j]=="
        if c[i][j]!=1:ok=False
print("Yes") if ok else print("No")

Solution (Python):
h,w=map(int,input().split())
lll=[list("."*(w+2))]
G=[list("."+input()+".") for _ in range(h)]
G=lll+G+lll

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

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    S = [input().strip("\n") for _ in range(H)]
    D = ((-1, 0), (0, -1), (1, 0), (0, 1))
    for h in range(H):
        possible = True
        for w in range(W):
            if S[h][w] == "
                for dh, dw in D:
                    if 0 <= h+dh < H and 0 <= w+dw < W and S[h+dh][w+dw] == "
                        break
                else:
                    possible = False
                    break
        if not possible:
            print("No")
            break
    else: print("Yes")


    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]
visited = [[False]*w for _ in range(h)]
flag = True
for y in range(h):
    for x in range(w):
        if s[y][x]=='
            flag = False
            for dy,dx in ((1,0),(0,1),(-1,0),(0,-1)):
                ny,nx = y+dy,x+dx
                if 0<=ny<h and 0<=nx<w and s[ny][nx]=='
                    flag = True
                    break
        
        if not flag:
            break
    if not flag:
        break


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