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):
from sys import stdin
H,W = [int(x) for x in stdin.readline().rstrip().split()]
data = [["."]*(W+2)]
for _ in range(H):
    data.append(["."] + list(input()) + ["."])
data.append(["."]*(W+2))

ans_flag = True
for h in range(1,H+1):
    for w in range(1,W+1):
        flag = True
        if data[h][w] == "
            flag = False
            if data[h+1][w] == "
                flag = True
            if data[h-1][w] == "
                flag = True
            if data[h][w+1] == "
                flag = True
            if data[h][w-1] == "
                flag = True
        
        if flag == False:
            ans_flag = False
if ans_flag:
    print("Yes")
else:
    print("No")

Solution (Python):
if __name__ == '__main__':
    H, W = map(int, input().split())
    s_list = [list(input()) for i in range(H)]


    answer = "Yes"

    for x in range(H):
        for y in range(W):
            if s_list[x][y] == '.':
                continue
            is_all_white = True
            dxs = [0, 1, 0, -1]
            dys = [1, 0, -1, 0]
            for dx, dy in zip(dxs, dys):
                nx = x + dx
                ny = y + dy
                if 0 <= nx <= H-1 and 0 <= ny <= W-1:
                    if s_list[nx][ny] == "
                        is_all_white = False
                        break
            if is_all_white:
                answer = "No"
                break
        if s_list[x][y] == '
            break

    print(answer)

Solution (Python):
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
import sys
dxy = [(1,0),(0,1),(-1,0),(0,-1)]
for i in range(H):
    for j in range(W):
        if s[i][j] == "
            flag = 0
            for dy,dx in dxy:
                if 0<= i+dy < H and 0 <= j+dx < W and s[i+dy][j+dx] == "
                    flag = 1
            if flag == 0:
                print("No")
                sys.exit(0)
print("Yes")

Solution (Python):
H,W = map(int,input().split())
graph = []
for i in range(H+2):
    if i == 0 or i == H+1 :
        graph.append(["." for i in range(W+2)])
    else:
        a = ["."] + list(input()) + ["."]
        graph.append(a)

"""

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

Solution (Python):
H,W = map(int,input().split())
S = [input() for i in range(H)]
dy = [0,1,0,-1]
dx = [1,0,-1,0]
for y in range(H):
    for x in range(W):
        if S[y][x] == '.':
            continue
        cnt = 0
        for i in range(4):
            ny = y+dy[i]
            nx = x+dx[i]
            if 0 <= ny < H and 0 <= nx < W and S[ny][nx] == '
                cnt += 1
        if cnt == 0:
            print('No')
            exit()
print('Yes')

Solution (Python):
H, W = [int(hw) for hw in input().split()]
S = [["."]*(W+2)]
for h in range(H):
  S.append(["."]+[s for s in input()]+["."])
S.append(["."]*(W+2))
for h in range(1, H+1):
  for w in range(1, W+1):
    if S[h][w] == "
      if (S[h-1][w]==".")and(S[h+1][w]==".")and(S[h][w-1]==".")and(S[h][w+1]=="."):
        print("No")
        break
  else:
    continue
  break
else:
  print("Yes")

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] == "
      if s[i-1][j] == "." and s[i+1][j] == "." and s[i][j-1] == "." and s[i][j+1] == ".":
        ans = "No"
        break
        
if s[0][0] == "
  if s[0][1] == "." and s[1][0] == ".":
    ans = "No"
if s[0][w-1] == "
  if s[0][w-2] == "." and s[1][w-1] == ".":
    ans = "No"
if s[h-1][0] == "
  if s[h-2][0] == "." and s[h-1][1] == ".":
    ans = "No"
if s[h-1][w-1] == "
  if s[h-2][w-1] == "." and s[h-1][w-1] == ".":
    ans = "No"

for i in range(1,h-1):
  if s[i][0] == "
    if s[i-1][0] == "." and s[i+1][0] == "." and s[i][1] == ".":
      ans = "No"
  if s[i][w-1] == "
    if s[i-1][w-1] == "." and s[i+1][w-1] == "." and s[i][w-2] == ".":
      ans = "No"
for i in range(1,w-1):
  if s[0][i] == "
    if s[0][i-1] == "." and s[0][i+1] == "." and s[1][i] == ".":
      ans = "No"
  if s[h-1][i] == "
    if s[h-1][i-1] == "." and s[h-1][i+1] == "." and s[h-2][i] == ".":
      ans = "No"
print(ans)

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

dxy = [(1,0),(0,1),(0,-1),(-1,0)]
flag = False

for y in range(h):
    for x in range(w):
        if lst[y][x] == ".":
            continue
        sum_count = len(dxy)
        dot_count = 0
        for dx,dy in dxy:
            if x+dx < 0 or x+dx > w-1 or y+dy < 0 or y+dy > h-1:
                sum_count -= 1
                continue
            if lst[y+dy][x+dx] == ".":
                dot_count += 1
        if sum_count == dot_count:
            flag = True
            break
    if flag:
        break

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

Solution (Python):
ans = 'Yes'
h,w = map (int,input().split())
pict = []
for i in range (h) :
      dot = input() + '.'
      
      pict.append(dot)
up = '.' * w
pict.append(up)
left = '.'
for i in range(h) :
      line = tuple (pict[i])
      for d in range(w) :
            if line[d] == '
                  if left == '.' and up[d] == '.' and line[d+1] == '.' and pict[i+1][d] == '.' :
                        ans = 'No'
                        break
            left = line[d]
      up = pict[i]
print(ans)

Solution (Python):
import numpy as np
H,W=map(int,input().split())
M=[list(list("."+input()+".")) for i in range(H)]
M=[[1 if s=='
L=np.array(M)
M=np.array(M)
N=[0]*(W+2)
M=np.vstack((M, N))
M=np.vstack((N, M))
Ans=np.zeros((H,W))
for h in range(H):
  for w in range(W):
    if M[h+1][w+1]==0:
      continue
    else:
      Ans[h][w]=M[h+1][w+1]+M[h][w+1]+M[h+2][w+1]+M[h+1][w]+M[h+1][w+2]
if np.any(Ans==1):
  print("No")
else:
  print("Yes")

Solution (Python):
H,W = map(int,input().split())
S = [input() for i in range(H)]
dy = [0,1,0,-1]
dx = [1,0,-1,0]
for y in range(H):
    for x in range(W):
        if S[y][x] == '.':
            continue
        if any(0<=y+dy[i]<H and 0<=x+dx[i]<W and S[y+dy[i]][x+dx[i]] == '
            continue
        print('No')
        exit()
print('Yes')

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

def count(x, y):
    c = 0
    if x-1 >= 0 and s[x-1][y] =="
        c += 1
    if x+1 <= H-1 and s[x+1][y] =="
        c += 1
    if y-1 >= 0 and s[x][y-1] =="
        c += 1
    if y+1 <= W-1 and s[x][y+1] =="
        c += 1
    return c

for i in range(H):
    for j in range(W):
        if s[i][j] == "
            a = count(i, j)
            if a == 0:
                print("No")
                exit()

print("Yes")

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

for i in range(1, h+1):
  for j in range(1, w+1):
    if li[i][j] == "
      flag = False
      if li[i][j+1] == "
        flag = True
      if not flag:
        print("No")
        exit()
print("Yes")

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

for i in range(h):
    for j in range(w):
        if canvas[i][j] == ".": continue
        candraw = False
        for delta in [-1,1]:
            if 0 <= i + delta < h:
                if canvas[i+delta][j]=="
                    candraw = True
                    break
            if 0 <= j + delta < w:
                if canvas[i][j+delta]=="
                    candraw = True
                    break
        if not candraw:
            print("No")
            exit(0)
print("Yes")

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


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

for i in range(1,H+1):
  for j in range(1,W+1):
    if S[i][j] == '
      for k in range(4):
        if S[i+dire[k][0]][j+dire[k][1]] == '
          break
      else:
        print('No')
        exit()
else:
  print('Yes')

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

grid = list()

for i in range(h):
    grid.append(input())

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

count = 0

for i in range(h):
    for j in range(w):
        count = 0
        if grid[i][j] == '
            for s,t in zip(x,y):
                if h > i+s >= 0 and w > j+t >= 0 and grid[i+s][j+t] == '
                    break
            else:
                print("No")
                exit()
                
print("Yes")

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


def check(h, w):
    if S[h][w] != '
        return True
    ps = [(h, w-1), (h+1, w), (h, w+1), (h-1, w)]
    ps = [p for p in ps if p[0] in range(H) and p[1] in range(W)]
    if any(S[p[0]][p[1]] == '
        return True
    else:
        return False

if any(not check(h, w) for h in range(H) for w in range(W)):
    print('No')
else:
    print('Yes')

Solution (Python):
n,m=map(int,input().split())
l=[]
f=0
nf=0
for i in range(n):
    l.append(list(input()))
    
for i in range(n):
    for j in range(m):
        if l[i][j]=='
            if (i>0 and l[i-1][j]=='
                f=0
            else:
                nf=1
if nf==1:
    print('No')
else:
    print('Yes')

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


def check_around(x, y):
    if 0 < y and campus[y - 1][x] == '
        return True
    elif 0 < x and campus[y][x - 1] == '
        return True
    elif x < W - 1 and campus[y][x + 1] == '
        return True
    elif y < H - 1 and campus[y + 1][x] == '
        return True
    return False


can = True
for y in range(H):
    for x in range(W):
        if campus[y][x] == '
            can = check_around(x, y)
            if not can:
                print('No')
                exit()
print('Yes')

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

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

Solution (Python):

import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())


H, W = mi()
cells = [input() for _ in range(H)]

ispossible = 1
for y, row in enumerate(cells):
  for x, cell in enumerate(row):
    if cell == '.': continue
    else: 
      ispossible = 0
      
      dirset = {(0,1), (0,-1), (1,0), (-1,0)}
      if y == 0: 
        dirset.remove((0,-1)) 
      elif y == H-1: 
        dirset.remove((0,1)) 
      if x == 0: 
        dirset.remove((-1,0)) 
      elif x == W-1: 
        dirset.remove((1,0)) 
      for mx, my in dirset: 
        if cells[y+my][x+mx] == '
          ispossible = 1
          break
      if ispossible == 0:
        print('No')
        exit()

print('Yes')

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

Solution (Python):
h, w = [int(i) for i in input().split()]
s = []
flag = True
for hi in range(h):
    s1 = input()
    s.append(s1)

for hi in range(h):
    for wi in range(w):
        if s[hi][wi] == "
            if hi != 0 and s[hi-1][wi] == "
                pass
            elif hi != h - 1 and s[hi+1][wi] == "
                pass
            elif wi != 0 and s[hi][wi-1] == "
                pass
            elif wi != w - 1 and s[hi][wi+1] == "
                pass
            else:
                flag = False
    if not flag:
        break

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

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

for hi in range(h):
    for wi in range(w):
        if m[hi][wi]=="
            if not ((hi!=0 and m[hi-1][wi]=="
                    (wi!=0 and m[hi][wi-1]=="
                    (hi!=h-1 and m[hi+1][wi]=="
                    (wi!=w-1 and m[hi][wi+1]=="
                print("No")
                exit()
print("Yes")

Solution (Python):
def is_paintable(h,w,matrix):
    
    if h-1 >= 0 and w >= 0:
        if(matrix[h-1][w] == '
            return True
        
    
    if h >= 0 and w-1 >= 0:
        if(matrix[h][w-1] == '
            return True
    
    
    if h >= 0 and w+1 < W:
        if(matrix[h][w+1] == '
            return True

    
    if h+1 < H and w >= 0:
        if(matrix[h+1][w] == '
            return True
            
    return False

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

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

paintable = True
for h in range(H):
    for w in range(W):
        if matrix[h][w] == '
            if(not is_paintable(h, w, matrix)):
                paintable = False
                break
    if(not paintable):
        break

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

Solution (Python):
H, W = [int(x) for x in input().split()]
board = [['.']*(W+2)]
for _ in range(H):
    board.append(['.'] + [x for x in input()] + ['.'])
board.append(['.']*(W+2))
   
cnt = 0
for i in range(1, H+1):
    for j in range(1, W):
        if board[i][j] == '
            cnt += 1

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

Solution (Python):
def search(X, Y, MAP, H, W):
    if X < 0 or X >= H or Y < 0 or Y >= W:
        return False
    elif MAP[X][Y] == '.':
        return False
    else: 
        return True

def each(X, Y, MAP, H, W):
    right = search(X, Y+1, MAP, H, W)
    down = search(X+1, Y, MAP, H, W)
    left = search(X, Y-1, MAP, H, W)
    up = search(X-1, Y, MAP, H, W)
    return (right or down or left or up)

def main():
    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] == '
                if not each(i, j, s, h, w):
                    print("No")
                    exit()
    print("Yes")

main()

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

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

'''for i in l:
    print(i)'''

flag = True

for i in range(h+2):
    for j in range(w+2):
        if l[i][j] == '
            if l[i-1][j]==l[i][j-1]==l[i+1][j]==l[i][j+1]=='.':
                flag = False

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

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

L_input = [["." for i in range(W)] for j in range(H)]
L_width = [["x" for i in range(W)] for j in range(H)]
L_height = [["x" for i in range(W)] for j in range(H)]

flag = 0



for i in range(H) : 
    tmp = list(input())
    for j in range(W) : 
        L_input[i][j] = tmp[j]

for i in range(H) : 
    for j in range(W-1) : 
        if L_input[i][j] == "
            L_width[i][j] = "o"
            L_width[i][j+1] = "o"

for j in range(W) : 
    for i in range(H-1) : 
        if L_input[i][j] == "
            L_height[i][j] = "o"
            L_height[i+1][j] = "o"
            
for i in range(H) : 
    for j in range(W) : 
        if L_input[i][j] == "
            if L_width[i][j] != "o" and L_height[i][j] != "o" : 
                flag = 1
                
if flag == 0 : 
    print("Yes")
else : 
    print("No")

Solution (Python):
def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    field = []
    for row in inputs:
        line = []
        for c in row:
            line.append(c)
        field.append(line)

    if len(field) == 1:
        if len(field[0]) == 1:
            return "No"

    for i, row in enumerate(field):
        for j, _ in enumerate(row):
            available = False
            if field[i][j] == ".":
                continue
            if i - 1 >= 0:
                available |= field[i - 1][j] == "

            if j - 1 >= 0:
                available |= field[i][j - 1] == "
            if j + 1 < len(row):
                available |= field[i][j + 1] == "

            if i + 1 < len(field):
                available |= field[i + 1][j] == "
            if not available:
                return "No"

    return "Yes"


if __name__ == "__main__":
    [N, _] = map(lambda x: int(x), input().split())
    ret = solve(inputs(N))
    print(ret)

Solution (Python):

def main(s_list):
    if len(s_list) == 1 and s_list[0] == '
        print('Yes')
        return

    for i_row, s in enumerate(s_list):
        for j_col, char in enumerate(s):
            if char == '
                neighbor_list = []
                try:
                    neighbor_list.append(s_list[i_row-1][j_col])
                except:
                    pass
                try:
                    neighbor_list.append(s_list[i_row+1][j_col])
                except:
                    pass
                try:
                    neighbor_list.append(s_list[i_row][j_col-1])
                except:
                    pass
                try:
                    neighbor_list.append(s_list[i_row][j_col+1])
                except:
                    pass
                
                if neighbor_list.count('
                    print('No')
                    return

    print('Yes')

if __name__ == "__main__":
    H, W = [int(x) for x in input().split()]
    s_list = []
    for i in range(H):
        s_list.append(input())

    main(s_list)

def test1(capsys):
    inputs = ['.
    out = 'Yes'
    main(inputs)
    captured = capsys.readouterr()    
    assert captured.out == out + '\n'

def test2(capsys):
    inputs = ['
    out = 'No'
    main(inputs)
    captured = capsys.readouterr()    
    assert captured.out == out + '\n'

def test3(capsys):
    inputs = ['...
    out = 'Yes'
    main(inputs)
    captured = capsys.readouterr()    
    assert captured.out == out + '\n'

def test4(capsys):
    inputs = ['
    out = 'Yes'
    main(inputs)
    captured = capsys.readouterr()    
    assert captured.out == out + '\n'

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


dirs = [[0,1],[1,0],[0,-1],[-1,0]]

flag = True
for h,row in enumerate(mass):
    for w,temp in enumerate(row):
        if temp == "
            cont = False
            for dir in dirs:
                x = dir[0]
                y = dir[1]
                hy =h+y
                wx = w + x
                if  hy < 0 or wx< 0 or wx==W or hy == H:
                    continue
                else:
                    if mass[hy][wx] == "
                        cont = True
            if not cont:
                flag = False
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
h,w=map(int,input().split())
G=[list(input()) for i in range(h)]
ans=1
for l in G:
    for i in range(w-1):
        if l[i]==l[i+1]=='
            l[i]='o'
            l[i+1]='o'
        if l[i]=='o' and l[i+1]=='
            l[i+1]='o'
for k in range(h-1):
    for j in range(w):
        if G[k][j]=='
            G[k][j]='o'
            G[k+1][j]='o'
        elif G[k][j]=='
            G[k][j]='o'
        elif G[k][j]=='o' and G[k+1][j]=='
            G[k+1][j]='o'
for l in G:
    if '
        ans*=0
if ans==0:
    print('No')
else:
    print('Yes')

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] == '.':
            continue

        cnt = 0
        for dy in [-1,1]:
            if 0 <= i + dy < H:
                if S[i+dy][j] == '
                        cnt += 1
        for dx in [-1,1]:
            if 0 <= j + dx < W:
                if S[i][j+dx] == '
                    cnt += 1
        if cnt == 0:
            print('No')
            exit()

print('Yes')

Solution (Python):
def solve(H, W, S):
    for h in range(1, H):
        for w in range(1, W):
            if S[h][w] == '
                if not (S[h-1][w] == '
                    return "No"
    return "Yes"


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

S = []
S.append('.' * (W+2))
for _ in range(H):
    S.append("."+input().strip()+".")
S.append('.' * (W+2))
import sys
for row in S:
    print(row, file=sys.stderr)
print(solve(H, W, S))

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

res.append("." * (w + 2))
quit = False
for i in range(h):
    for j in range(w):
        if res[i][j+1] == "." and res[i+1][j:j+3] == ".
            print("No")
            quit = True
            break
    if quit:
        break
else:
    print("Yes")

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

answer = True
for i in range(H):
  for j in range(W):
    if s[i][j] == '
      count = 0
      if i != 0 and s[i - 1][j] == '.':
        count += 1
      if i != H - 1 and s[i + 1][j] == '.':
        count += 1
      if j != 0 and s[i][j - 1] == '.':
        count += 1
      if j != W - 1 and s[i][j + 1] == '.':
        count += 1
      if count == 4:
        answer = False

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

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

for i in range(h):
    s[i+1] = [x for x in input()]

for i in range(h+2):
    s[i].insert(w,".")
    s[i].insert(0,".")

flg ="Yes"
for i in range(h+2):
    for j in range(w+2):
        if s[i][j] == "
            if s[i-1][j]=="
                pass
            else:
                flg = "No"
print(flg)

Solution (Python):
h, w = list(map(int, input().split()))
s = [input() for j in range(h)]
op = [(-1, 0), (0, -1), (0, 1), (1, 0)]
for i in range(h):
  for j in range(w):
    if s[i][j] == '.':
      continue
    count = 0
    for k in range(4):
      x = i + op[k][0]
      y = j + op[k][1]
      if x < 0 or y < 0 or x >= h or y >= w:
        continue
      if s[x][y] == '.':
        count += 1
    if count == 4:
      print('No')
      exit()
      
print('Yes')

Solution (Python):
import sys
h,w=map(int,input().split())
s_list=[]
for i in range(h):
    s_list.append(input())
op=[(1,0),(0,1),(-1,0),(0,-1)]
for i in range(h):
    for j in range(w):
        if s_list[i][j]=='
            count=1
            for k in op:
                if 0<=i+k[0]<=h-1 and 0<=j+k[1]<=w-1:
                    if s_list[i+k[0]][j+k[1]]=='
                        count=0
                    else:
                        pass
            if count==1:
                print('No')
                sys.exit()
print('Yes')

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

ans = True
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if a[i][j] == '
            ans = False

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

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



def search_wall(H, W, x, y):
    tmp = []
    if x + 1 < W:
        tmp.append([0, 1])
    if x - 1 >= 0:
        tmp.append([0, -1])
    if y + 1 < H:
        tmp.append([1, 0])
    if y - 1 >= 0:
        tmp.append([-1, 0])
    return tmp
    
for row in range(H):
    for column in range(W):
        if (maze[row][column] == '
            check = 0
            for y, x in search_wall(H, W, column, row):
                if maze[row + y][column + x] == '
                    check = 1
            if check != 1:
                print("No")
                exit()
print("Yes")

Solution (Python):
h, w = map(int, input().split())
form = []
flg = 0
for i in range(h):
    form.append(input())
for i in range(h):
    for j in range(w):
        if form[i][j]==".":
            continue
        else:
            if i==0:
                if j==0:
                    if form[i][j+1]== "
                        continue
                    else:
                        flg = 1
                        break
                elif j==w-1:
                    if form[i][j-1]== "
                        continue
                    else:
                        flg = 1
                        break
                else:
                    if form[i][j-1]== "
                        continue
                    else:
                        flg=1
                        break
                        
            elif i==h-1:    
                if j==0:
                    if form[i][j+1]== "
                        continue
                    else:
                        flg = 1
                        break
                elif j==w-1:
                    if form[i][j-1]== "
                        continue
                    else:
                        flg = 1
                        break
                else:
                    if form[i][j-1]== "
                        continue
                    else:
                        flg=1
                        break
                
            else:
                if j==0:
                    if form[i][j+1]== "
                        continue
                    else:
                        flg = 1
                        break
                elif j==w-1:
                    if form[i][j-1]== "
                        continue
                    else:
                        flg = 1
                        break
                else:
                    if form[i][j-1]== "
                        continue
                    else:
                        flg = 1
                        break
    if flg ==1:
        break
    
if flg ==0:
    print("Yes")
else:
    print("No")

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  h,w=LI()

  l=[]
  for i in range(h):
    l.append(S())

  a=[[0,-1],[-1,0],[1,0],[0,1]]

  for i in range(h):
    for j in range(w):
      b=l[i][j]
      f=True
      if b=='
        for k in a:
          _i=i
          _j=j
          _i+=k[0]
          _j+=k[1]
          if _i>=0 and _i<=h-1 and _j>=0 and _j<=w-1:
            if l[_i][_j]=='
              f=False
        if f:
          return 'No'
          exit()
  return 'Yes'


print(main())

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(".")

flg = False
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if arr[i][j] == "
            if (
                arr[i - 1][j] != "
                and arr[i + 1][j] != "
                and arr[i][j - 1] != "
                and arr[i][j + 1] != "
            ):
                print("No")
                flg = True
                break
    if flg:
        break
if not flg:
    print("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] != "
                and arr[i + 1][j] != "
                and arr[i][j - 1] != "
                and arr[i][j + 1] != "
            ):
                print("No")
                break
    else:
        continue
    break
else:
    print("Yes")