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())
fields = []
for i in range(h):
    s = list(input())
    fields.append(s)

mvs = [(0,1),(0,-1),(1,0),(-1,0)]
for i in range(h):
    for j in range(w):
        if fields[i][j] == "
            cnt = 0
            for dy,dx in mvs:
                next_y,next_x = i+dy,j+dx
                if 0 <= next_y < h and 0 <= next_x < w:
                    if fields[next_y][next_x] == "
                        cnt += 1
            if cnt == 0:
                print("No")
                exit()


print("Yes")

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

def search(x,y):
    flag = 0
    if x > 0:
        if G[y][x-1] == "
            flag = 1
    if x < W-1:
        if G[y][x+1] == "
            flag = 1
    if y > 0:
        if G[y-1][x] == "
            flag = 1
    if y < H-1:
        if G[y+1][x] == "
            flag = 1
    if flag == 1:
        return True
    else:
        return False

res = 1
for i in range(H):
    for j in range(W):
        x = j
        y = i
        if G[y][x] == "
            if search(x,y):
                pass
            else:
                res = 0
if res:
    print("Yes")
else:
    print("No")

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

yx = [[1, 0], [0, 1], [0, -1], [-1, 0]]
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if a[i][j] == '
            flag = False
            for k in range(4):
                x = yx[k][0]
                y = yx[k][1]
                if a[i + x][j + y] == '
                    flag = 1

            if not flag:
                print('No')
                exit()
print('Yes')

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

xy = [[1, 0], [0, 1], [0, -1], [-1, 0]]
for i in range(1, h):
    for j in range(1, w):
        if a[i][j] == '
            flag = False
            for k in range(4):
                x = xy[k][0]
                y = xy[k][1]
                if a[i + x][j + y] == '
                    flag = 1
                    
            if not flag:
                print('No')
                exit()
print('Yes')

Solution (Python):
from functools import reduce
H, W = map(int, input().split())
s = [list("." + input() + ".") for _ in range(H)]
s.insert(0, list("."*(W+2)))
s.append(list("."*(W+2)))

while "
    hantei = reduce(lambda x,y: x+y, s)
    index = hantei.index("
    
    h = -(-index//(W+2)) - 1
    w = index - (W+2)*(h+1) - 1
    roop = False
    if (s[h-1][w] == "
        s[h][w] = "Z"
        s[h-1][w] = "Z"
        roop = True
    if (s[h][w-1] == "
        s[h][w] = "Z"
        s[h][w-1] = "Z"
        roop = True
    if (s[h][w+1] == "
        s[h][w] = "Z"
        s[h][w+1] = "Z"
        roop = True
    if (s[h+1][w] == "
        s[h][w] = "Z"
        s[h+1][w] = "Z"
        roop = True
    if not roop:
        break

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

Solution (Python):
H, W = map(int, input().split())
A = []
for _ in range(H):
  A.append(input())
  
all_flag = True
for i in range(H):
  for j in range(W):
    if A[i][j] == '.':
      flag = True
    else:
      flag = False
      if i > 0:
        if A[i-1][j] == '
          flag = True
      if i < H-1:
        if A[i+1][j] == '
          flag = True
      if j > 0:
        if A[i][j-1] == '
          flag = True
      if j < W-1:
        if A[i][j+1] == '
          flag = True
    if not flag:
      all_flag = False
      break
  if not all_flag:
    break
if all_flag:
  print('Yes')
else:
  print('No')

Solution (Python):
H,W = map(int,input().split())
S =[["."]*(W+2)]

for i in range(H):
    S.append("."+input()+".")
    
S.append("."*(W+2))

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]==".":
                print("No")
                exit()
print("Yes")

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




ok = True
for hi in range(h):
    for wi in range(w):
        if s[hi][wi] == '
            drawable = False
            
            if hi >= 1:
                drawable = (s[hi-1][wi] == '
            
            if hi <= h-2:
                drawable = (s[hi+1][wi] == '
            
            if wi >= 1:
                drawable = (s[hi][wi-1] == '
            
            if wi <= w-2:
                drawable = (s[hi][wi+1] == '

            
            

            if not drawable:
                ok = False

print("Yes" if ok else "No")

Solution (Python):



















import numpy as np
height, width = map(int, input().split())
_s_list = [input() for i in range(height)]
s_list = [list(ss) for ss in _s_list]  
s_arr  = np.array(s_list)


its_ok = True
for _h in range(height):
    for _w in range(width):
        
        if s_arr[_h, _w] == '
            checker = False
            
            if _h >= 1:
                if s_arr[_h-1, _w] == '
                    checker = True
            
            if _h != height-1:
                if s_arr[_h+1, _w] == '
                    checker = True
            
            if _w >= 1:
                if s_arr[_h, _w-1] == '
                    checker = True
            
            if _w != width-1:
                if s_arr[_h, _w+1] == '
                    checker = True
            
            if checker is False:
                its_ok = False
                break
    
    if its_ok is False:
        break

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

Solution (Python):
import numpy as np
height, width = map(int, input().split())
_s_list = [input() for i in range(height)]
s_list = [list(ss) for ss in _s_list]  
s_arr  = np.array(s_list)


its_ok = True
for _h in range(height):
    for _w in range(width):
        
        if s_arr[_h, _w] == '
            checker = False
            
            if _h >= 1:
                if s_arr[_h-1, _w] == '
                    checker = True
            
            if _h != height-1:
                if s_arr[_h+1, _w] == '
                    checker = True
            
            if _w >= 1:
                if s_arr[_h, _w-1] == '
                    checker = True
            
            if _w != width-1:
                if s_arr[_h, _w+1] == '
                    checker = True
            
            if checker is False:
                its_ok = False
                break
    
    if its_ok is False:
        break

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

Solution (Python):
H,W=map(int, input().split())
S=["."+input()+"." for _ in range(H)]
S=["."*(W+2)]+S+["."*(W+2)]
ans="Yes"
for i in range(H):
  for j in range(W):
    if S[i][j]=="
      ans="No"
print(ans)

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

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

ans = 1
for h in range(H):
    for w in range(W):
        if ans == 0:
            break
        if grid[h][w] == "
            if h == 0:
                if w == 0:
                    if grid[h + 1][w] == "." and grid[h][w+1] == ".":
                        ans = 0
                elif w == W - 1:
                    if grid[h + 1][w] == "." and grid[h][w-1] == ".":
                        ans = 0
                else:
                    if grid[h + 1][w] == "." and grid[h][w - 1] == "." and grid[h][w + 1] == ".":
                        ans = 0

            elif h == H - 1:
                if w == 0:
                    if grid[h - 1][w] == "." and grid[h][w+1] == ".":
                        ans = 0
                elif w == W - 1:
                    if grid[h - 1][w] == "." and grid[h][w-1] == ".":
                        ans = 0
                else:
                    if grid[h - 1][w] == "." and grid[h][w - 1] == "." and grid[h][w + 1] == ".":
                        ans = 0

            else:
                if w == 0:
                    if grid[h - 1][w] == "." and grid[h][w+1] == "."and grid[h + 1][w] == ".":
                        ans = 0
                elif w == W - 1:
                    if grid[h - 1][w] == "." and grid[h][w-1] == "."and grid[h + 1][w] == ".":
                        ans = 0
                else:
                    if grid[h - 1][w] == "." and grid[h][w - 1] == "." and grid[h][w + 1] == "." and grid[h + 1][w] == ".":
                        ans = 0

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

Solution (Python):

import sys, math, fractions, itertools

YES = "Yes"  
NO = "No"  

def solve(H: int, W: int, s: "List[str]"):
    flag = True
    for h in range(H):
        for w in range(W):
            if s[h][w] == '
                if h == H-1: U = True
                else: U = s[h+1][w] != '
                if h == 0: D = True
                else: D = s[h-1][w] != '
                if w == 0: L = True
                else: L = s[h][w-1] != '
                if w == W-1: R = True
                else: R = s[h][w+1] != '
                if all([U, D, L, R]):
                    flag = False
    if flag:
        print('Yes')
    else:
        print('No')
    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())
buf = '
lst = [buf]
for i in range(h):
    s = '
    lst.append(s)
lst.append(buf)

def check(x,y):
    if (lst[x-1][y]=='
        return True
    else:
        return False

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

Solution (Python):
def check(i, j, s, H, W):
    if i != 0:
        if s[i-1][j] == '
            return True
    if i != H-1:
        if s[i+1][j] == '
            return True
    if j != 0:
        if s[i][j-1] == '
            return True
    if j != W-1:
        if s[i][j+1] == '
            return True
    return False

H, W = map(int, input().split())

s = []
for i in range(H):
    s.append(input())

ans = 'Yes'
for i in range(H):
    for j in range(W):
        if s[i][j] == '
            if check(i, j, s, H, W) == False:
                ans = 'No'

print(ans)

Solution (Python):
def solve():
    h, w = list(map(int, input().split()))
    field = [["."] * (w + 2)] + [["."] + list(input()) + ["."] for _ in range(h)] + [["."] * (w + 2)]
    for i in range(1, h + 2):
        for j in range(1, w + 2):
            if field[i][j] == "
                return "No"
    return "Yes"


def is_paintable(field: list, i: int, j: int):
    return "


if __name__ == "__main__":
    print(solve())

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())
s=["."*(w+2)]+["."+input()+"." for _ in range(h)]+["."*(w+2)]
for i in range(1,h+2):
	for j in range(1,w+2):
		if s[i][j]=="
			if "
				print("No");exit()
			else:pass
		else:pass
print("Yes")

Solution (Python):
h,w = map(int,input().split())
li = [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 li[i][j] == ".":
      continue
    for k in range(4):
      if not(0<=i+dx[k]<h) or not(0<=j+dy[k]<w):
        continue
      else:
        if li[i+dx[k]][j+dy[k]] == "
          break
    else:
      print("No")
      exit()
print("Yes")

Solution (Python):
h, w = map(int, input().split())
s = [input() for _ in range(h)] 
 
d = {(i, j):c for i, row in enumerate(s) for j, c in enumerate(row)}
 
def next_to_black(i, j):
    directions = ((-1, 0), (1, 0), (0, -1), (0, 1))
    surroundings = ((i + a, j + b) for a, b in directions)
    colors = (d.get(cell, '.') for cell in surroundings)
    return any(color == '
 
black_coords = (coord for coord, c in d.items() if c == '
paintable = all(next_to_black(*coord) for coord in black_coords)
print('Yes' if paintable else 'No')

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

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

s1=[['.' for i in range(w+2)] for i in range(h+2)]

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

Solution (Python):
h,w=map(int,input().split())
s=['.'*(w+2)]+['.'+input()+'.' for _ in [0]*h]+['.'*(w+2)]
a='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+1][j]=='.' and s[i][j-1]=='.' and s[i][j+1]=='.':a='No'
print(a)

Solution (Python):
import sys
h,w = map(int,input().split())
a = ["."*(w+2)]+['.'+input()+'.' for i in range(h)]+["."*(w+2)]
for i in range(h):
    for j,q in enumerate(a[i+1]):
        if q == "
            if a[i][j] != "
                print("No")
                sys.exit()
print("Yes")

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

s = [input() for i in range(H)]

def draw(i,j):
	if j>0 and s[i][j-1] == "
		return "Yes"
	if j<W-1 and s[i][j+1] == "
		return "Yes"
	if i>0 and s[i-1][j] == "
		return "Yes"
	if i<H-1 and s[i+1][j] == "
		return "Yes"
	return "No"

ans = "Yes"
for i in range(H):
	for j in range(W):
		if s[i][j] == "
			ans = draw(i,j)
			if ans == "No":
				print(ans)
				exit()

print(ans)

Solution (Python):
import itertools
H, W = map(int, input().split())
pic = [input() for i in range(H)]
for i, j in itertools.product(range(H), range(W)):
    if pic[i][j] == "
        S = set()
        if i > 0:
            S.add(pic[i-1][j])
        if i < H-1:
            S.add(pic[i+1][j])
        if j > 0:
            S.add(pic[i][j-1])
        if j < W-1:
            S.add(pic[i][j+1])
        if not "
            print("No")
            exit()
else:
    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]=='
            flg=True
            if i>0:
                if s[i-1][j]=='
                    flg=False
            if j>0:
                if s[i][j-1]=='
                    flg=False
            if i<h-1:
                if s[i+1][j]=='
                    flg=False
            if j<w-1:
                if s[i][j+1]=='
                    flg=False
            if flg:
                print('No')
                exit()
print('Yes')

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

canvas = []
for i in range(H):
	canvas.append(input())

check = False

for i in range(H):
	for j in range(W):
		if canvas[i][j] == '
			check = True
			if i > 0:
				if canvas[i-1][j] == '
					check = False
			if i < H - 1 and check:
				if canvas[i+1][j] == '
					check = False
			if j > 0 and check:
				if canvas[i][j-1] == '
					check = False
			if j < W - 1 and check:
				if canvas[i][j+1] == '
					check = False
			if check:
				print('No')
				break
	if check:
		break
	if i == H - 1:
		print('Yes')

Solution (Python):
H, W = map(int, input().split())
s = []
for _ in range(H):
    sr = input()
    s.append(sr)
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):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007


def A():
    a, b = LI()
    if a <= b:
        print(a)
    else:
        print(a-1)
    return


def B():
    a, b, c = LI()
    k = II()
    print(a + b + c + max(a, b, c) * ((2 ** k) - 1))
    return


def C():
    H, W = LI()
    s = SR(H)
    for h in range(H):
        for w in range(W):
            if s[h][w] == "
                for mh, mw in [(0, 1), (1, 0), (-1, 0), (0, -1)]:
                    hm = mh + h
                    wm = mw + w
                    if 0 <= hm < H and 0 <= wm < W:
                        if s[hm][wm] == "
                            break
                else:
                    print("No")
                    return

    print("Yes")
    return


def D():
    n = II()
    ans = []
    sosu = [2]
    i = 2
    while len(ans) != n:
        for k in sosu:
            if i % k == 0:
                i += 1
                break
        else:
            sosu.append(i)
            if i % 5 == 1:
                ans.append(i)
            i += 1
    for i in ans:
        print(i, end=" ")
    print()
    return



if __name__ == '__main__':
    C()

Solution (Python):
H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(input())
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            continue
        count = 0
        for xs, ys in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            if i + ys < 0 or i + ys >= H or j + xs < 0 or j + xs >= W:
                break
            pos_x = j + xs
            pos_y = i + ys
            if S[i][j] == "
                count += 1
        if count == 4:
            print("No")
            exit()
print("Yes")

Solution (Python):


import sys

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
h = hoge[0]
w = hoge[1]

list = [[0 for i in range(w+2)] for j in range(h+2)]

for i in range(0,h):
	fuga = input()
	for j in range(0,w):
		if(fuga[j]=="."):
			list[i+1][j+1]=0
		else:
			list[i+1][j+1]=1

flg=0
for i in range(1,h+1):
	for j in range(1,w+1):
		if(list[i+1][j+1] == 1):
			if(list[i][j+1] == 0)and(list[i+1][j] == 0)and(list[i+1][j+2] == 0)and(list[i+2][j+1] == 0):
				flg=1
if(flg):
	print("No")
else:
	print("Yes")

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

finish = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if campus[i][j] == '
            if campus[i-1][j] != '
                finish = False
                break
    else:
        continue
    break
if finish:
    print('Yes')
else:
    print('No')

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

def drow(i,j, map = map):
  if j > 0 and map[i][j-1] == "
    return "Yes"
  if j < W-1 and map[i][j+1] == "
    return "Yes"
  if i > 0 and map[i-1][j] == "
    return "Yes"
  if i < H -1 and map[i+1][j] == "
    return "Yes"
  return "No"

ans = "Yes"
for i in range(H):
  for j in range(W):
    if map[i][j] == "
      ans = drow(i,j)
      if ans == "No":
        print(ans)
        exit()
print(ans)

Solution (Python):

H,W = map(int,input().split())
s = [list(input()) for i in range(H)]
for i in range(H):
	for j in range(W):
		if s[i][j] == "
			if s[max(0,i-1)][j] == "." and s[min(H-1,i+1)][j] == "." and s[i][max(0,j-1)] == "." and s[i][min(W-1,j+1)] == ".":
			    print("No")
			    exit()
print("Yes")

Solution (Python):
H, W = map(int, input().split())
state = [[1 if a == '
state.extend([[0]*(W+1)])


ans = 'Yes'
for h in range(H):
    for w in range(W):
        if state[h][w] == 0:
            continue
        nexts = [[h+1, w], [h-1, w], [h, w+1], [h, w-1]]
        ok = False
        for n in nexts:
            if state[n[0]][n[1]] == 1:
                ok = True
        if not ok:
            ans = 'No'
            break
    if ans == 'No':
        break

print(ans)

Solution (Python):
if __name__ == '__main__':
  check_flag = True
  
  h, w = map(int, input().split())
  s = []
  
  s.append('.' + '.' * w + '.')
  for i in range(h):
      s.append('.' + input() + '.')
  s.append('.' + '.' * w + '.')
  

  for i in range(h):
      for j in range(w):
          target_cell = ''
          if s[i + 1][j + 1] == '
            target_cell += s[i+1][j:j+3]
            target_cell += s[i][j+1]
            target_cell += s[i+2][j+1]
              
            if target_cell.count('
                check_flag = False
                break
      if not check_flag:
          break

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

Solution (Python):
import sys


		
def check_near_black(c,i,j):
	dd=[[1,0],[0,1],[-1,0],[0,-1]]
	for dx,dy in dd:
		if c[i+dy][j+dx] == '
			return True
	return False

def main():
	h,w = map(int, input().split())
	camp=[]
	ww=list('.'*(w+2))
	camp.append(ww)
	for i in range(h):
		s = '.'+input()+'.'
		camp.append(list(s))
	camp.append(ww)
	
	for i in range(1,1+h):
		for j in range(1,1+w):
			
			if camp[i][j]=='
				return 'No'
				
				
	return 'Yes'
		
	
	
	


if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

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

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
memo = [[0]*W for i in range(H)]

S = []
for i in range(H):
    S.append(list(input()))



for i in range(H):
    for j in range(W):
        if S[i][j] == '
            flag = False
            for n in range(4):
                if i+dy[n] > -1 and i+dy[n] < H and j+dx[n] > -1 and j+dx[n] < W:
                    if S[i+dy[n]][j+dx[n]] == '
                        flag = True

            if flag == False:
                print('No')
                exit()


print('Yes')

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

for i in range(h):
    for j in range(w):
        if s[i][j]=="
            count = 0
            for k in range(4):
                x = i + dx[k]
                y = j + dy[k]
                if x >= 0 and x <= h-1 and y >= 0 and y <= w-1 and s[x][y] == "
                    count += 1
            if count == 0:
                Bool = False
                
if Bool == True:
    print("Yes")
else:
    print("No")

Solution (Python):
H, W = map(int,input().split())
B = []
B.append(["." for _ in range(W+2)])
for _ in range(H):
    S = input()
    L = []
    L.append(".")
    for s in S:
        L.append(s)
    L.append(".")
    B.append(L)
B.append(["." for _ in range(W+2)])

for i in range(H):
    for j in range(W):
        if B[i+1][j+1] == "
            print("No")
            exit()
print("Yes")

Solution (Python):

H, W = map(int, input().split())

s = ["." * (W + 2) for _ in range(H + 2)]

for i in range(1, H + 1):
    s[i] = "." + input() + "."

judge = "Yes"

for i in range(1, H + 1):
    for j in range(1, W + 1):
        
        if s[i][j] == ".":
            continue
        
        if s[i - 1][j] + s[i][j - 1] + s[i][j + 1] + s[i + 1][j] == "....":
            
            judge = "No"
            
            break

print(judge)

Solution (Python):
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
for x in range(h):
    for y in range(w):
        if(s[x][y] == '
            up = s[max(0, x-1)][y]
            down = s[min(h-1, x+1)][y]
            right = s[x][max(0, y-1)]
            left = s[x][min(w-1,  y+1)]
            if(up == '.' and down == '.' and right == '.' and left == '.'):
                print("No")
                exit()
print("Yes")

Solution (Python):
h, w = map(int, input().split())
s = [input() for i in range(h)]
up = down = right = left = '.'
for x in range(h):
    for y in range(w):
        if(list(s[x])[y] == '
            if(y != w-1):
                right = list(s[x])[y+1]
            if(x != h-1):
                down = list(s[x+1])[y]
            if(x != 0):
                up = list(s[x-1])[y]
            if(y != 0):
                left = list(s[x])[y-1]
            if(up != '
                print("No")
                exit()
            up = down = right = left = '.'
print("Yes")

Solution (Python):
H,W = map(int,input().split())
s = [input() for _ in range(H)]
if H==1 and W==1:
    if s[0][0] == '.':print('Yes')
    else:print('No')
else:
    island = False
    for i in range(H):
        for j in range(W):
            if s[i][j] == '
                bis = False
                if i-1>=0:
                    if s[i-1][j] == '
                if i+1<H:
                    if s[i+1][j] == '
                if j-1>=0:
                    if s[i][j-1] == '
                if j+1<W:
                    if s[i][j+1] == '
                if bis == False:
                    island = True
    if island:
        print('No')
    else:
        print('Yes')

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

def find_black(x,y):
    m_x = [ 0, 1,0,-1]
    m_y = [-1,0,1,0]
    

    for ii in range(len(m_x)):
        nx, ny = (x + m_x[ii]), (y + m_y[ii])
        
        if (0 <= nx < w) and (0 <= ny < h):
            if dat[ny][nx] == "
                
                return True
    return False

c = True
for i in range(h):
    for j in range(w):
        if dat[i][j] == "
            
            if find_black(j, i) is False:
                c = False

print("Yes" if c else "No")

Solution (Python):
h, w = map(int, input().split())
 
lst = ["." + input() + "." for _ in range(h)]
matrix = ["." * (w + 2)] + lst + ["." * (w + 2)]
 
 
ans = "Yes"
for i in range(1, h + 1):
    for j in range(1, w + 1):
        center = matrix[i][j]
        up = matrix[i - 1][j]
        down = matrix[i + 1][j]
        left = matrix[i][j - 1]
        right = matrix[i][j + 1]
        if center == "
            ans = "No"
print(ans)

Solution (Python):
H, W = map(int, input().split())
s = [input() for i in range(H)]
dy, dx = [1, 0, -1, 0], [0, 1, 0, -1]
for i in range(H):
    for j in range(W):
        if s[i][j] == '.': continue
        f = 1
        for d1, d2 in zip(dy, dx):
            ni, nj = i + d1, j + d2
            if 0 <= ni < H and 0 <= nj < W and s[ni][nj] == '
                f = 0
                break
        if f:
            print('No')
            quit()
print('Yes')

Solution (Python):


import sys

sys.setrecursionlimit(10**7)


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def paintable(H, W, S, i, j):
    return (i - 1 >= 0 and S[i - 1][j] == '
        j - 1 >= 0 and S[i][j - 1] == '


def main():
    H, W = read_h()
    S = read_v(H, typ=str)

    for i, row in enumerate(S):
        for j, c in enumerate(row):
            if c == '.':
                continue

            if not paintable(H, W, S, i, j):
                print('No')
                return

    print('Yes')


if __name__ == '__main__':
    main()

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

mp = []
for i in range(h):
    tmp = list(input())
    tml = []
    for j in range(w):
        tml.append(0 if tmp[j] == "." else 1)
    mp.append(tml)
    


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

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

Solution (Python):
H, W = map(int, input().split())
C = [list(input()) for i in range(H)]
X = [1,0,-1,0]
Y = [0,-1,0,1]
for y in range(H):
  for x in range(W):
    check = 0
    if C[y][x] == "
      for i in range(4):
        nx = x + X[i]
        ny = y + Y[i]
        if 0 <= nx < W and 0 <= ny < H and C[ny][nx] == "
          check = 1
          break
      if check == 0:
        print("No")
        exit()
print("Yes")