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 = list(map(int, input().rstrip().split()))
arr = [list(input().rstrip()) for _ in range(h)]
arr.insert(0, ["."] * (w + 2))
arr.append(["."] * (w + 2))
for i in arr[1:-1]:
    i.insert(0, ".")
    i.append(".")

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if arr[i][j] == "
            if arr[i - 1][j] == "
                continue
            elif arr[i + 1][j] == "
                continue
            elif arr[i][j - 1] == "
                continue
            elif arr[i][j + 1] == "
                continue
            else:
                print("No")
                break
    else:
        continue
    break
else:
    print("Yes")

Solution (Python):
h,w=map(int,input().split())
l=[list(input()) for i in range(h)]
f=0
for i in range(h):
  for j in range(w):
    c=0
    if l[i][j]=="
      if i>0 and l[i-1][j]=="
        c+=1
      if i<h-1 and l[i+1][j]=="
        c+=1
      if j>0 and l[i][j-1]=="
        c+=1
      if j<w-1 and l[i][j+1]=="
        c+=1
      if c==0:
        f=1
        break
if f==1:
  print("No")
else:
  print("Yes")

Solution (Python):

h, w = [ int(v) for v in input().split() ]
field = [ list(input()) for i in range(h) ]
ans = "Yes"

for i in range(h):
	for j in range(w):
		if field[i][j] == "
			adjust = [ (i-1,j), (i,j-1), (i,j+1), (i+1,j) ]
			adjust = [ field[k[0]][k[1]] for k in adjust if 0 <= k[0] < h and 0 <= k[1] < w ]
			if adjust.count("
				ans = "No"
				break
print(ans)

Solution (Python):
H,W=map(int,input().split())
L=list(list(input()) for _ in range(H))
for h in range(H):
    for w in range(W):
        if L[h][w]=='
            if not any((0<=h+d<=H-1 and L[h+d][w]=='
                   or (0<=w+d<=W-1 and L[h][w+d]=='
                print('No')
                exit()
print('Yes')

Solution (Python):

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
h,w=IL()
G=[["."]*(w+2)]
for i in range(h):
    G.append(["."]+S()+["."])
G.append(["."]*(w+2))
ret=True

for i in range(1,h):
    for j in range(1,w):
        if G[i][j]==".":
            continue
        ans=False
        for ti,tj in[[-1,0],[1,0],[0,1],[0,-1]]:
            if G[i+ti][j+tj]=="
                ans=True
        if not ans:
            ret=False
if ret:
    print("Yes")
else:
    print("No")

Solution (Python):

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
h,w=IL()
S=[S() for i in range(h)]
ret=True

for i in range(h):
    for j in range(w):
        if S[i][j]==".":
            continue
        ans=False
        for ti in [-1,1]:
            if 0<=i+ti<h:
                if S[i+ti][j]=="
                    ans=True
        for tj in [-1,1]:
             if 0<=j+tj<w:
                if S[i][j+tj]=="
                    ans=True
        if not ans:
            ret=False
if ret:
    print("Yes")
else:
    print("No")

Solution (Python):
H, W = map(int, raw_input().split())
board = []
for i in range(0, H):
	board.append(raw_input())
flag1 = True
for i in range(0, H):
	for j in range(0, W):
		if board[i][j] == '
			flag2 = True
			for k in range(0, 2):
				if 0 <= i-1+2*k and i-1+2*k < H:
					if board[i-1+2*k][j] == '
						flag2 = False
						break
				if 0 <= j-1+2*k and j-1+2*k < W:
					if board[i][j-1+2*k] == '
						flag2 = False
						break
			if flag2:
				flag1 = False
				break
if flag1: print 'Yes'
else: print 'No'

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

S = []

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

for i in range(h):
    S.append(list(input()))


for i in range(h):
    for j in range(w):

        if (S[i][j] == '.'): continue
            
        has_sharp = False

        for dxy in dxy_list:
            ni = i + dxy[0]
            nj = j + dxy[1]

            if (ni < 0 or h <= ni): continue
            if (nj < 0 or w <= nj): continue

            if (S[ni][nj] == '
                has_sharp = True
                break

        if (not has_sharp):
            print('No')
            exit()

print('Yes')

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

def pixel_input(H,W,border="."):
    pixel = [[border]*(W+2)] + \
    [[border] + list(input()) + [border] for _ in range(H)] + \
    [[border]*(W+2)]
    return pixel
S=pixel_input(H,W)
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]==S[i+1][j]==S[i][j-1]==S[i][j+1]==".":
                print("No")
                sys.exit()
print("Yes")

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

Solution (Python):
import sys
H, W = map(int, input().split())
s = [input() for _ in range(H)]
s = ["." * W] + s + ["." * W]
for _ in range(H + 2):
    s[_] = "." + s[_] + "."
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if s[i][j] == "
            if any([
                    s[i - 1][j] == "
                    s[i + 1][j] == "
            ]):
                continue
            else:
                print("No")
                sys.exit()
else:
    print("Yes")

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

def check(i, j):
  return '

for i in range(1, H + 1):
  for j in range(1, W + 1):
    if cells[i][j] == '
      print('No')
      break
  else:
    continue
  break
else:
  print('Yes')

Solution (Python):
h,w=map(int,input().split())
s=eval('input(),'*h)
for i in range(h):
    for j in range(w):
        if s[i][j]=='.':continue
        for y,x in((i-1,j),(i+1,j),(i,j-1),(i,j+1)):
            if h>y>=0 and w>x>=0 and s[y][x]=='
                break
        else:
            print('No')
            exit()
print('Yes')

Solution (Python):
h,w=map(int,input().split())
s=eval('input(),'*h)
for i in range(h):
    for j in range(w):
        if s[i][j]=='.':continue
        for y,x in((i-1,j),(i+1,j),(i,j-1),(i,j+1)):
            if h>y>=0 and w>x>=0 and s[y][x]=='
                break
        else:
            print('No')
            exit()
print('Yes')

Solution (Python):
def check(H, W, S):
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if S[y][x] == '
                if len([1 for i in range(y-1, y+2) if S[i][x] == '
                    return False
    return True

if __name__ == '__main__':
    H, W = list(map(int, input().strip().split(' ')))
    S = [['.' for _ in range(W+2)]] + [list('.' + input() + '.') for _ in range(H)] + [['.' for _ in range(W+2)]]

    if check(H, W, S):
        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)]

flag=True
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=False
print("Yes" if flag else "No")

Solution (Python):
h,w=map(int,input().split())
l=[input() for _ in range(h)]
nb=[(0,1),(1,0),(0,-1),(-1,0)]
for i in range(h):
	for j in range(w):
		if l[i][j]=='
			for a,b in nb:
				if 0<=i+a<=h-1 and 0<=j+b<=w-1 and l[i+a][j+b]=='
					break
			else:
				print('No')
				exit()
print('Yes')

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(H: int, W: int, s: "List[str]"):
    def is_valid(i, j):
        if (i > 0 and s[i - 1][j] == '
            i < H - 1 and s[i + 1][j] == '
            j > 0 and s[i][j - 1] == '
            j < W - 1 and s[i][j + 1] == '
            return True
        return False

    for i, R in enumerate(s):
        for j, c in enumerate(R):
            if c == '
                print(NO)
                return
    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):
import sys
H, W = map(int, input().split())

lst = [['.'] * (W+2)]
lst += [['.'] + list(input()) + ['.'] for _ in range(H)]
lst += [['.'] * (W+2)]

for i in range(1, H+1):
    for j in range(1, W+1):
        if lst[i][j] == '
            if lst[i+1][j] == '
                pass
            else:
                print ('No')
                sys.exit()

print ('Yes')

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

S = [list(input()) for _ in range(H)]

for k in range(1, H - 1):
    for i in range(1, W - 1):
        if S[k][i] == "
            if S[k][i + 1] != "
               S[k - 1][i] != "
                print("No")
                exit()

for i in range(1, W - 1):
    if S[0][i] == "
        if S[0][i + 1] != "
            print("No")
            exit()

    if S[H - 1][i] == "
        if S[H - 1][i + 1] != "
           S[H - 1][i - 1] != "
            print("No")
            exit()

for i in range(1, H - 1):
    if S[i][0] == "
        if S[i + 1][0] != "
            print("No")
            exit()

    if S[i][W - 1] == "
        if S[i + 1][W - 1] != "
           S[i][W - 2] != "
            print("No")
            exit()

if S[0][0] == "
    if S[0][1] != "
        print("No")
        exit()

if S[0][W - 1] == "
    if S[0][W - 2] != "
        print("No")
        exit()

if S[H - 1][0] == "
    if S[H - 2][0] != "
        print("No")
        exit()

if S[H - 1][W - 1] == "
    if S[H - 1][W - 2] != "
        print("No")
        exit()

print("Yes")

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

def array_pointer(L,i,j): 
    L_next=[[i-1,j],[i+1,j],[i,j-1],[i,j+1]]
    if j==W-1:
        del L_next[3]
    elif j==0:
        del L_next[2]
    if i==H-1:
        del L_next[1] 
    elif i==0:
        del L_next[0]
    return L_next

def check(L,L_check):
    for k in L_check:
        a,b=k[0],k[1]
        if L[a][b]=='
            return True
    return False

ans='Yes'
for i in range(H):
    for j in range(W):
        if li[i][j]=='
            li_check=array_pointer(li,i,j)
            if not check(li,li_check):
                ans='No'
                break
print(ans)

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

H,W=map(int,input().split())
grid = [list(input().rstrip()) for _ in range(H)]
for i in range(H):
  for j in range(W):
    if j > 0 and grid[i][j-1] != '.' and grid[i][j] == '
      grid[i][j] = '*'
    elif j < W-1 and grid[i][j+1] != '.' and grid[i][j] == '
      grid[i][j] = '*'
    elif i > 0 and grid[i-1][j] != '.' and grid[i][j] == '
      grid[i][j] = '*'
    elif i < H-1 and grid[i+1][j] != '.' and grid[i][j] == '
      grid[i][j] = '*'
print("No" if sum([row.count('

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

S = [list(input()) for _ in range(H)]

Board = [['.' for _ in range(W+2)] for _ in range(H+2)]

for i in range(H):
    for j in range(W):
        Board[i+1][j+1] = '

ans = "Yes"
for i in range(1, H+1):
    for j in range(1, W+1):
        if Board[i][j] == '.':
            continue
        is_paintable = False
        for di, dj in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
            if Board[i+di][j+dj] == '
                is_paintable = True
                break
        if not is_paintable:
            ans = 'No'
            break

print(ans)

Solution (Python):


from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if (self.parent[i] == i):
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if i < j:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)





def main():
    h, w = intin()
    slistlist = ['.' * (w + 2)]
    for i in range(h):
        row = input()
        row = '.' + row + '.'
        slistlist.append(row)
    slistlist.append('.' * (w + 2))

    for i in range(h + 2):
        for j in range(w + 2):
            if slistlist[i][j] == '
                if slistlist[i-1][j] == '
                    continue
                if slistlist[i+1][j] == '
                    continue
                if slistlist[i][j-1] == '
                    continue
                if slistlist[i][j+1] == '
                    continue
                print('No')
                return

    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
H, W = map(int, input().split())
s = ['.' * (W + 2)]
s = s + ['.' + input() + '.' for _ in range(H)] + s
flg = True
for i in range(1, H + 1, 1):
    for j in range(1, W + 1, 1):
        if s[i][j] == '
            flg = False
            break
    if not flg:
        break
print("Yes" if flg else "No")

Solution (Python):
r, c = map(int, input().split())
d = [list(input()) for i in range(r)]
bom = [(x,y) for (x,i) in enumerate(d) for (y,j) in enumerate(i) if j == '
temp, result = [], "Yes"
for b in bom:
    pattern = [(b[0],b[1]+1), (b[0], b[1]-1), (b[0]+1, b[1]), (b[0]-1, b[1])]
    if sum([1 if x in bom else 0 for x in pattern]) == 0:
        result = "No"
        break
print(result)

Solution (Python):


h, w = map(int, input().split())
s_list = [list(input()) for _ in range(h)]
xy = [[0, 1], [-1, 0], [1, 0], [0, -1]]
flag = False
ans = "Yes"

for i in range(h):
    for j in range(w):
        if s_list[i][j] == "
            for k in xy:
                if (i+k[1] < 0 or i+k[1] >= h or j+k[0] < 0 or j+k[0] >= w) == False:
                    if s_list[i+k[1]][j+k[0]] == "
                        flag = True
            if flag == False:
                ans = "No"
                break
            flag = False
    else:
        continue
    break

print(ans)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    return


def B():
    return


def C():
    return


def D():
    return


def E():
    d = [(1,0),(-1,0),(0,1),(0,-1)]
    h,w = LI()
    s = SR(h)
    for i in range(h):
        for j in range(w):
            if s[i][j] == "
                su = 0
                for dy,dx in d:
                    y = i+dy
                    x = j+dx
                    if 0 <= y < h and 0 <= x < w:
                        if s[y][x] == "
                            su += 1
                if su == 0:
                    print("No")
                    quit()
    print("Yes")
    return


def F():
    a,b,c,X,Y = LI()
    ans = float("inf")
    for z in range(300001):
        if z%2 == 0:
            m = c*z
            x = z//2
            y = z//2
            m += a*max(0,X-x)
            m += b*max(0,Y-y)
            if m < ans:
                ans = m
    print(ans)
    return


def G():
    n = I()
    x = LI()
    f = [(i,x[i]) for i in range(n)]
    f.sort(key = lambda x:x[1])
    g = [(f[i][0],i) for i in range(n)]
    g.sort(key = lambda x:x[0])
    for i in range(n):
        if g[i][1] < n//2:
            print(f[n//2][1])
        else:
            print(f[n//2-1][1])
    return


def H():
    return


def I_():
    return


def J():
    return


if __name__ == "__main__":
    E()

Solution (Python):


import math

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

c = []

for i in range(h):
    l = list(input())
    c.append(l)

for i in range(h):
    for j in range(w):
        flg = 0
        if c[i][j] == "
            if j != 0:
                if c[i][j-1] == "
                    flg = 1
            if j != w-1:
                if c[i][j+1] == "
                    flg = 1
            if i != 0:
                if c[i-1][j] == "
                    flg = 1
            if i != h-1:
                if c[i+1][j] == "
                    flg = 1
            if flg == 0:
                print('No')
                exit()
print('Yes')

Solution (Python):
import numpy as np
h, w = map(int, input().split())
square = np.array([list(input()) for i in range(h)]).ravel()=="
def main():
    for i in range(h*w):
        if square[i] == True:
            flag = 0
            if i // w == 0:
                if square[i+w] == True:
                    flag += 1
            elif i // w == h-1:
                if square[i-w] == True:
                    flag += 1
            else:
                if square[i+w] + square[i-w] == True:
                    flag += 1
            if i % w == 0:
                if square[i+1] == True:
                    flag += 1
            elif i % w == w-1:
                if square[i-1] == True:
                    flag += 1
            else:
                if square[i+1] + square[i-1] == True:
                    flag += 1
            if flag == 0:
                print("No")
                return 0
    print("Yes")
main()

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

def check(i,j):
    if S[i][j] == ".":
        return 0

    if i==0:
        if S[i+1][j] == "
            return 0
    elif i==H-1:
        if S[i-1][j] == "
            return 0
    else:
        if S[i+1][j] == "
            return 0

    if j==0:
        if S[i][j+1] == "
            return 0
    elif j==W-1:
        if S[i][j-1] == "
            return 0
    else:
        if S[i][j+1] == "
            return 0

    return 1

if sum([check(i,j) for i in range(H) for j in range(W)]) == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
height,width=map(int,input().split())
graph = [[s for s in input()] for i in range(height)]

for r in range(height):
    for c in range(width):
        if graph[r][c]==".":
            continue

        if r>0 and graph[r-1][c]=="
            continue

        if r<width-1 and graph[r+1][c]=="
            continue

        if c>0 and graph[r][c-1]=="
            continue

        if c<height-1 and graph[r][c+1]=="
            continue

        print("No")
        exit()
print("Yes")

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

def x_p(x,y):
    if x == H-1:
        return 0
    x += 1
    return ([x,y] in l)

def x_m(x,y):
    if x == 0:
        return 0
    x -= 1
    return ([x,y] in l)

def y_p(x,y):
    if y == W-1:
        return 0
    y += 1
    return ([x,y] in l)

def y_m(x,y):
    if y == 0:
        return 0
    y -= 1
    return ([x,y] in l)

H,W = [int(i) for i in input().split()]
l = []
for i in range(H):
    A = list(input())
    for j in range(W):
        if A[j] == "
            l.append([i,j])

for i in l:
    flag = 0
    x,y = i
    if x_p(x,y) == True or x_m(x,y) == True or y_p(x,y) == True or y_m(x,y) == True:
        flag = 1
    if flag == 0:
        print('No')
        exit()
print('Yes')

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


flag = True

for i in range(H):
    for j in range(W):
        f2 = False
        if s[i][j] == '
            if i-1 >= 0 and s[i-1][j] == '
                f2 = True
            if j-1 >= 0 and s[i][j-1] == '
                f2 = True
            if i+1 < H and s[i+1][j] == '
                f2 = True
            if j+1 < W and s[i][j+1] == '
                f2 = True
            if not(f2):
                flag = False
                break
    else:
        continue
    break


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

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

ds = ((0, 1), (1, 0), (0, -1), (-1, 0))

def move(p, d):
	n = (p[0] + d[0], p[1] + d[1])
	if (0 <= n[0] < H) and (0 <= n[1] < W):
		return n
	return None

def getv(p):
	return STAGE[p[0]][p[1]]

for y in range(H):
	for x in range(W):
		if "
			for d in ds:
				n = move((y, x), d)
				if n and "
					break
			else:
				print("No")
				exit()
print("Yes")

Solution (Python):
h, w = map(int, input().split())
grid = [['.' for j in range(w + 2)]for i in range(h + 2)]
for i in range(h):
    line = list(input())
    grid[i + 1][1:w + 1] = line
direction =[[0, 1], [1, 0], [0, -1], [-1, 0]]
for i, line in enumerate(grid[1:h + 1][1:w + 1]):
    for j, dot in enumerate(line):
        if grid[i][j] == '.':
            continue
        for dire in direction:
            x = i + dire[0]
            y = j + dire[1]
            if grid[x][y] == '
                break
        else:
            print('No')
            exit()
else:
    print('Yes')

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

def solve(H, W, S):
    s = [row + "." for row in S] + ["." * (W + 1)]
    for y in range(H):
        for x in range(W):
            if s[y][x] == "
                and s[y-1][x] == "." and s[y+1][x] == "." \
                and s[y][x-1] == "." and s[y][x+1] == ".":
                return False
    return True

if solve(H, W, S):
    print("Yes")
else:
    print("No")

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] == "
      flag = False
      for x, y in [[1, 0],[-1, 0],[0, 1],[0, -1]]:
        if i + x >= 0 and i + x <= H - 1 and j + y >= 0 and j + y <= W - 1 and s[i + x][j + y] == '
          flag = True
      if not flag:
        print('No')
        exit(0)
print('Yes')

Solution (Python):
import itertools

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] == "
      flag = False
      for x, y in [[1, 0],[-1, 0],[0, 1],[0, -1]]:
        if i + x >= 0 and i + x <= H - 1 and j + y >= 0 and j + y <= W - 1 and s[i + x][j + y] == '
          flag = True
      if not flag:
        print('No')
        exit(0)
print('Yes')

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    h,w = f()
    ss = [input() for i in range(h)]
    for i in range(h):
        for j in range(w):
            if ss[i][j] == '.':
                continue
            if i-1>=0 and ss[i-1][j]=='
                continue
            if i+1<h and ss[i+1][j] == '
                continue
            if j-1>=0 and ss[i][j-1]=='
                continue
            if j+1<w and ss[i][j+1]=='
                continue
            print('No')
            return
    
    print('Yes')

solve()

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

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

x = [0, -1, 0, 1]
y = [-1, 0, 1, 0]

for i in range(1, H + 1):
    for j in range(1, W + 1):
        check = False
        if s[i][j] == '
            for xx, yy in zip(x, y):
                if s[i + xx][j + yy] == '
                    check = True
            if not check:
                print("No")
                exit()

print("Yes")

Solution (Python):

def check(i, j, high, width, data):
    pre_j = max(0, j - 1)
    aft_j = min(width - 1, j + 1)
    pre_i = max(0, i - 1)
    aft_i = min(high - 1, i + 1)

    if pre_i != i:
        if data[pre_i][j] == '
            return 1
    if aft_i != i:
        if data[aft_i][j] == '
            return 1
    if pre_j != j:
        if data[i][pre_j] == '
            return 1
    if aft_j != j:
        if data[i][aft_j] == '
            return 1
    
    return 0


def main():
    high, width = map(int, input().split())
    data = [list(input()) for i in range(high)]

    
    

    for i in range(high):
        for j in range(width):
            if data[i][j] == '
                if check(i, j, high, width, data) == 0:
                    print('No')
                    return

    print('Yes')



if __name__ == '__main__':
    main()

Solution (Python):

import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

YES = "Yes"  
NO = "No"  

def solve(H: int, W: int, s: "List[str]"):
    m = [[0] * W for _ in range(H)]
    for j in range(H):
        for i in range(W):
            if s[j][i] == '
                if j < (H - 1) and s[j+1][i] == '
                    m[j][i] += 1
                    m[j+1][i] += 1
                if i < (W - 1) and s[j][i+1] == '
                    m[j][i] += 1
                    m[j][i+1] += 1
                if m[j][i] == 0:
                    return NO
    return YES


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)]  
    result = solve(H, W, s)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()

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

s = []
s.append("." * (w+2)) 
for _ in range(h):
	s.append("." + input() + ".")
s.append("." * (w+2)) 

ans = "Yes"
dx = [-1, 0, 1, 0]
dy = [ 0, 1, 0,-1]

for i in range(1, h+1):
	for j in range(1, w+1):
		if s[i][j] == "
			CanPaint = False
			for k in range(4):
				if s[i+dx[k]][j+dy[k]] == "
					CanPaint = True
			if not CanPaint:
				ans = "No"

print(ans)

Solution (Python):
H,W = map(int,input().split())
S = [input() for _ in range(H)]
ans = 'Yes'
for i in range(H):
    for j in range(W):
        if S[i][j] == '
            a = S[max(0,i-1)][j] == '
            b = S[i][max(0,j-1)] == '
            c = S[i][min(W-1,j+1)] == '
            d = S[min(H-1,i+1)][j] == '
            if any([a,b,c,d]):
                continue
            else:
                ans = 'No'
                break
print(ans)

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

def DFS():
  cond = True
  for i in range(H):
    for j in range(W):
      if L[i][j] != '
        
        continue
      IND=[(i,j-1), (i,j+1), (i-1,j), (i+1,j)]
      
      conds = []
      for (y, x) in IND:
        if x < 0 or y < 0 or x >= W or y >= H:
          conds.append('.')
        elif L[y][x] == '.':
          conds.append('.')
        else:
          
          conds.append('
      
      if conds.count('
        return 'No'
  return 'Yes'

print(DFS())