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())
C=['.'*(W+2)]+['.'+input()+'.'for _ in[0]*H]+['.'*(W+2)]
for i in range(1,H+1):
    for j in range(1,W+1):
        if C[i][j]=='
            print('No')
            exit()
print('Yes')

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

field = []

for i in range(H):
  field.append(list(input()))
count = 0
  
for i in range(H):
  for j in range(W):
    if field[i][j]=='
      if j - 1 >= 0 and field[i][j - 1] == "
        continue
      elif j + 1 < W and field[i][j + 1] == "
        continue
      elif i + 1 < H and field[i + 1][j] == "
        continue
      elif i - 1 >= 0 and field[i - 1][j] == "
        continue
      else:
        print("No")
        exit()

print("Yes")

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

s = [list(map(lambda c: c == "
for h in range(H):
    for w in range(W):
        if s[h][w] \
                and (h == 0 or not s[h - 1][w]) \
                and (h == H - 1 or not s[h + 1][w]) \
                and (w == 0 or not s[h][w - 1]) \
                and (w == W - 1 or not s[h][w + 1]):
            print("No")
            exit()

print("Yes")

Solution (Python):
piyo = (input()).split()
H = int(piyo[0])
W = int(piyo[1])
flag = True
pic = []

kuu = [0 for i in range(W+1)]

pic += kuu

for i in range(H):
  pic = pic + [0] + list(input()) + [0]

pic += kuu

for i in range(len(pic)):
  if pic[i] == "
    if not(pic[i-1] == "
      flag = False
      break
      

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

Solution (Python):
a =str(input()).split(" ")
h = int(a[0])
w = int(a[1])
maps= []

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

for i in range(h):
    for j in range(w):
        if maps[i][j] == "
            if j - 1 >= 0 and maps[i][j - 1] == "
                continue
            elif j + 1 < w and maps[i][j + 1] == "
                continue
            elif i + 1 < h and maps[i + 1][j] == "
                continue
            elif i - 1 >= 0 and maps[i - 1][j] == "
                continue
            else:
                print("No")
                exit()
        else:
            pass
print("Yes")

Solution (Python):
import numpy as np
h,w=map(int,input().split())
s=[input() for i in range(h)]
flag=False
ans="Yes"
for i in range(h):
    for j in range(w):
        if(s[i][j]=="
            flag=False
            for k in[-1,1]:
                if(i+k<h and 0<=i+k and s[i+k][j]=="
                    flag=True
                    break
                if(j+k<w and 0<=j+k and s[i][j+k]=="
                    flag=True
                    break
            if(flag==False):
                ans="No"
                break
        
print(ans)

Solution (Python):
import numpy as np
h,w=map(int,input().split())
s=list(input() for i in range(h))
flag=False
ans="Yes"
for i in range(h):
    for j in range(w):
        if(s[i][j]=="
            flag=False
            for k in[-1,1]:
                if(i+k<h and 0<=i+k and s[i+k][j]=="
                    flag=True
                    break
                if(j+k<w and 0<=j+k and s[i][j+k]=="
                    flag=True
                    break
            if(flag==False):
                ans="No"
                break
        
print(ans)

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

ans = 'Yes'
 
for i in range(h):
  for j in range(w):
    if s[i][j] == '
      flag = False
      
      for k in [-1, 1]:
        if k+i>= 0 and k+i<=h-1 and s[k+i][j] == '
          flag = True
          break
        if k+j>= 0 and k+j<=w-1 and s[i][j+k] == "
          flag = True
          break
      
      if flag == False:
        ans = 'No'
        break
        
        
print(ans)

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

grid=[]
for i in range(h):
    grid.append(list(map(int,input().replace("

ans="Yes"

for row in range(1,h-1):
    for col in range(1,w-1):
        if not(grid[row-1][col] or grid[row+1][col] or grid[row][col-1] or grid[row][col+1]) and grid[row][col]:
            ans="No"
            break

print(ans)

Solution (Python):
h,w = map(int, input().split(' '))
s = []
s0 = '.'*(w+2)
s.append(s0)
i = 0
while i < h:
    s0 = '.'+input()+'.'
    s.append(s0)
    i += 1
s0 = '.'*(w+2)
s.append(s0)
f0 = 0
h0 = 0
while h0 < len(s) and f0 == 0:
    slist = list(s[h0])
    indices = [i for i, x in enumerate(slist) if x == "
    for ind in indices:
        if (s[h0][ind-1] == "." and s[h0][ind+1] == '.') and (s[h0-1][ind] == '.' and s[h0+1][ind] == '.'):
            f0 = 1
            break
    h0 += 1
if f0 == 0:
    print('Yes')
else:
    print('No')

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

ans = 'Yes'
for i in range(1, H-1):
    for j in range(1, W-1):
        if square[i][j] == '
            if square[i-1][j] == square[i+1][j] == square[i][j-1] == square[i][j+1] == '.':
                ans = 'No'
                break

print(ans)

Solution (Python):
H, W = list(map(int, input().split()))
s = []
s.append(['.']*(W+2))
for i in range(H):
    
    array =['.']
    array.extend(list(input()))
    array.extend(['.'])
    s.append(array)
s.append(['.']*(W+2))

count = 0
for i in range(1,H+1):
    for j in range(1,W+1):
        if(s[i][j] == '
            count = count+1

if (count==0):
    print("Yes")
else:
    print("No")

Solution (Python):
W, H = map(int,input().split())
arr = [input() for j in range(W)]
ans = 'Yes'

for i in range(0, W):
    for j in range(0, H):
        t = 0
        if arr[i][j] == '
            for k in (-1, 1):
                if (-1 < i+k < W):
                    if arr[i+k][j] == '
                        t = 1
                        break
                        
                if (-1 < j+k < W):
                    if arr[i][j+k] == '
                        t = 1
                        break
            if t == 0:
                ans = 'No'
                break
                
print(ans)

Solution (Python):
def main():
    H, W = map(int, input().split())
    s = [['.'] * (W+2)]
    for i in range(H):
        s.append(list('.' + input() + '.'))
    s.append(['.'] * (W+2))

    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if s[i][j] == '
                if s[i + 1][j] != '
                        s[i][j + 1] != '
                        s[i - 1][j] != '
                        s[i][j - 1] != '
                    print('No')
                    return 0

    print('Yes')
    return


if __name__ == '__main__':
    main()

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

s=[0]*H
for i in range(H):
  s[i] = list(input())


def main():
  for i in range(H):
    for j in range(W):
      if s[i][j]=='.':
        continue
  
      flg=0
      l=j-1
      r=j+1
      t=i-1
      u=i+1
      if l>=0 and s[i][l]=='
        flg=1
  
      if r<W and s[i][r]=='
        flg=1
      
      if t>=0 and s[t][j]=='
        flg=1
  
      if u<H and s[u][j]=='
        flg=1
  
      if not flg:
        print("No")
        return
  
  print("Yes")

main()

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

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

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

res = True

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

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


for i in range(W):
    gyou=input()
    for j in range(H):
        arr[i][j]=gyou[j:j+1]

safe=1



for i in range(W):
    for j in range(H):
        if arr[i][j]=="
            if i-1 >=0 and i+1 < W  and j-1>=0 and j+1<H:
                if arr[i-1][j] == "
                    safe=1
                else:
                    print("No")
                    exit()
                    
                    
print("Yes")

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


lst_S = [["." for i in range(W)]] + lst_S

for i in range(H + 1):
    lst_S[i] = ["."] + lst_S[i] + ["."]

lst_S = lst_S + [["." for i in range(W + 2)]]

count = 0

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if lst_S[i][j] == "
            print("No")
            count += 1
            break
    if count > 0:
        break

if count == 0:
    print("Yes")

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

for i in range(h):
    l.append(list(list(input())))
for i in range(h):
    for j in range(w):
        if(l[i][j] == "
            if (i != 0):
                if(l[i-1][j] == "
            if (j != 0):
                if (l[i][j-1] == "
            if (i != h-1):
                if (l[i+1][j] == "
            if (j != w-1):
                if (l[i][j+1] == "
            print("No")
            exit()
print("Yes")

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

Solution (Python):
h,w=map(int,input().split())
s=[input() for _ in range(h)]
flag=1
nx=[1,0,-1,0]
ny=[0,1,0,-1]
for y in range(h):
  for x in range(w):
    if(s[y][x]=="
      for i in range(4):
        tx,ty=x+nx[i],y+ny[i]
        if(0<=ty and ty<h and 0<=tx and tx<w):
          if(s[ty][tx]=="
      else:
        print("No")
        exit()
print("Yes")

Solution (Python):
def valid(s, r, c):
    if s[r][c] != '
    if r > 0 and s[r-1][c] == '
    if r < H-1 and s[r+1][c] == '
    if c > 0 and s[r][c-1] == '
    if c < W-1 and s[r][c+1] == '
    return False

def solve():
    for i in range(H):
        for j in range(W):
            if not valid(s, i, j): return False
    return True

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

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

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

line_list = []
for i in range(h):
    line_list.append(input())

if h == 1:
    if w == 1:
        print("No")
        exit()
    else:
        current_line = line_list[0]
        j = 0
        while j < w - 1:
            if current_line[j] == "
                if current_line[j + 1] == "
                    j += 1
                    while j < w - 1:
                        if current_line[j + 1] != "
                            break
                        else:
                            j += 1
                    j += 1
                    continue
            j += 1
    print("Yes")
    exit()
elif w == 1:
    if h == 1:
        print("No")
        exit()
    else:
        j = 0
        while j < h - 1:
            if line_list[j] == "
                if line_list[j + 1] == "
                    j += 1
                    while j < h - 1:
                        if line_list[j + 1] != "
                            break
                        else:
                            j += 1
                    j += 1
                    continue
            j += 1
    print("Yes")
    exit()


before_line = [["."] for _ in range(w)]
current_line = list(line_list[0])
for i in range(h-1):
    after_line = list(line_list[i + 1])
    j = 0
    while j < w-1:
        if current_line[j] == "
            if current_line[j+1] == "
                j += 1
                while j < w - 1:
                    if current_line[j + 1] != "
                       break
                    else:
                        j += 1
                j += 1
                continue
            elif before_line[j] != "
                print("No")
                exit()
        j += 1
    before_line = current_line
    current_line = after_line

print("Yes")

Solution (Python):

H, W = map(int, input().split())
field = [list(input()) for i in range(H)] 
count = 0

for i in range(H):
    for j in range(W):
        
        
        if (i == 0 and j == 0) or (i == H-1 and j == 0) or (i == 0 and j == W-1) or (i == H-1 and j == W-1):
            pass
        elif i == 0:
            if field[i][j] == '
                count += 1
        elif i == H-1:
            if field[i][j] == '
                count += 1
        elif j == 0:
            if field[i][j] == '
                count += 1
        elif j == W-1:
            if field[i][j] == '
                count += 1
        elif field[i][j] == '
            count += 1
print('No' if count>=1 else 'Yes')

Solution (Python):


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

ns = ((0, -1), (-1, 0), (0, 1), (1, 0))
for i in range(h):
    for j in range(w):
        if s[i][j] != '
            continue
        for dx, dy in ns:
            nx = j + dx
            ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:
                if s[ny][nx] == '
                    break
        else:
            print('No')
            exit()

print('Yes')

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


def judge(s):
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if s[i][j] == "
                if s[i + 1][j] == "."and s[i][j + 1] == "."and s[i - 1][j] == "."and s[i][j - 1] == ".":
                    return "No"
    return "Yes"


print(judge(s))

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

ls = [[i for i in '.'+input()+'.'] for i in range(h)]

ls.insert(0, ['.' for i in range(w+2)])

ls.append(['.' for i in range(w+2)])

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

Solution (Python):
import itertools

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

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

ans = 'Yes'
for i, j in itertools.product(range(h), range(w)):
    if s[i][j] == '.':
        continue
    c = False
    for k, l in [(-1, 0), (0, -1), (1, 0), (0, 1)]:
        in_range = i + k >= 0 and j + l >= 0 and i + k < h and j + l < w
        if in_range and s[i + k][j + l] == '
            c = True
            break
    if not c:
        ans = 'No'
        break
print(ans)

Solution (Python):
import sys
H,W = map(int,input().split())
temp =[0 for i in range(H)]
for i in range(H):
    temp[i] = input()
dx = [-1,1,0,0]
dy = [0,0,1,-1]
ans = True
for j in range(H):
    for k in range(W):
        if(temp[j][k]=="
            judge =False
            for i in range(4):
                j2 = j+dx[i]
                k2 = k+dy[i]
                if 0 <= j2 < H and 0<= k2 < W and temp[j2][k2] =="
                    judge = True
            if not judge:
                ans =False
if ans:
    print("Yes")
else:
    print("No")

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

def conv_e_2_num(x):
    return 1 if x == "

def is_painted(masu, x, y):
    return masu[y][x] == 1

def check_lrtb(masu, x, y, w, h):
    return (x - 1 >= 0 and is_painted(masu, x - 1, y)) \
        or (x + 1 < w and is_painted(masu, x + 1, y)) \
        or (y - 1 >= 0 and is_painted(masu, x, y - 1)) \
        or (y + 1 < h and is_painted(masu, x, y + 1)) \

def check_all(masu, w, h):
    if w == h and w == 1:
        return True
    for y in range(h):
        for x in range(w):
            if is_painted(masu, x, y):
                if check_lrtb(masu, x, y, w, h):
                    continue
                else:
                    return False
    return True


masu = []
for y in range(h):
    masu.append(list(map(conv_e_2_num, list(input()))))

print('Yes') if check_all(masu, w, h) else print('No')

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


def get_data():
    yield ['.'] * (W + 1)
    for _ in range(H):
        yield ['.'] + list(input()) + ['.']
    yield ['.'] * (W + 1)


def check(array):
    for i, row in enumerate(array):
        if i == 0 or i == len(array) - 1:
            continue
        sharp_index = [i for i, value in enumerate(row) if value == '
        for j in sharp_index:
            if j - 1 in sharp_index or j + 1 in sharp_index:
                continue
            if '
                continue
            return False
    return True


Array = list(get_data())
if check(Array):
    print('Yes')
else:
    print('No')

Solution (Python):
hw = [int(i) for i in input().split()]
ans = "Yes"


field = ["." * (hw[1] + 2)]
for h_i in range(hw[0]):
    field.append("." + input() + ".")
field.append("." * (hw[1] + 2))

for h_i in range(1, hw[0] + 1):
    if ans == "No":
        break
    for w_i in range(1, hw[1] + 1):
        if field[h_i][w_i] == "
            if field[h_i - 1][w_i] == "
            or field[h_i][w_i - 1] == "
                continue
            ans = "No"
            break
print(ans)

Solution (Python):
H, W = map(int, input().split())
Sij = []
for _ in range(H):
    Sij.append(input())
result = []
for a in range(H):
    for b in range(W):
        check = []    
        if Sij[a][b] == '
            if a-1 >= 0:
                H_up = a - 1
                S_H_up = Sij[H_up][b]
                check.append(S_H_up)
            if a+1 <= H-1:
                H_down = a + 1
                S_H_down = Sij[H_down][b]
                check.append(S_H_down)
            if b-1 >= 0:
                W_right = b - 1
                S_W_right = Sij[a][W_right]
                check.append(S_W_right)
            if b+1 <= W-1: 
                W_left = b + 1
                S_W_left = Sij[a][W_left]
                check.append(S_W_left)
            if '
                result.append('good')
            else:
                result.append('bad')
                
if 'bad' in result:
    print('No')
else:
    print('Yes')

Solution (Python):

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


def isSpace(canvas, i, j):
    if i in range(len(canvas)):
        if j in range(len(canvas[i])):
            return True if canvas[i][j] == "." else False
        else:
            return True
    else:
        return True


def isPaintableCanvasBySquare(canvas):
    H = len(canvas)
    W = len(canvas[0])
    for i, j in [(i, j) for i in range(H) for j in range(W)]:
        if(isSpace(canvas, i, j - 1) and
           isSpace(canvas, i, j + 1) and
           isSpace(canvas, i - 1, j) and
           isSpace(canvas, i + 1, j) and
           not isSpace(canvas, i, j)):
            return "No"
    return "Yes"


print(isPaintableCanvasBySquare(canvas))

Solution (Python):
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())
ans = ((i < h-1 and s[i+1][j] == '
if False in ans:
    print("No")
else:
    print("Yes")

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

s_num = []
for i in range(H):
    tmp = []
    for j in range(W):
        if(s[i][j] == "."):
            tmp.append(0)
        else:
            tmp.append(1)
    s_num.append(tmp)


ans = True
for i in range(H):
    for j in range(W):
        if(s_num[i][j] == 1):

            sum_num = 1
            if(i > 0):
                sum_num += s_num[i-1][j]
            if(i < H-1):
                sum_num += s_num[i+1][j]
            
            if(j > 0):
                sum_num += s_num[i][j-1]
            if(j < W-1):
                sum_num += s_num[i][j+1]
            if(sum_num < 2):
                ans = False
                break

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

Solution (Python):
H,W = map(int,input().split())
s = [input() for i in range(H)]
dx=[0,-1,1,0]
dy=[1,0,0,-1]
flag = True
for i in range(H):
    for j in range(W):
        if s[i][j]=='
            cnt = 0
            for k in range(4):
                if 0<=j+dx[k] and j+dx[k]<W and 0<=i+dy[k] and i+dy[k]<H:
                    if s[i+dy[k]][j+dx[k]]=='
                        cnt += 1
            if cnt==0:
                flag=False
print('Yes' if flag else 'No')

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

for i in range(1, h - 1):
    for j in range(1, w - 1):
        if s[i][j] == "
            flg = False

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

Solution (Python):
def is_not_isolated(s_list, i, j):
    map_char_to_bool = {'.': False, '
    not_isolated = False
    for di, dj in ((-1, 0), (1, 0), (0, -1), (0, 1)):
        try:
            not_isolated = not_isolated or map_char_to_bool[s_list[i+di][j+dj]]
        except IndexError:
            pass
    return not_isolated

H, W = [int(elem) for elem in input().split(' ')]
s_list = [list(input()) for _ in range(H)]
assert len(s_list) == H
assert len(s_list[0]) == W

for i in range(len(s_list)):
    for j in range(len(s_list[0])):
        if s_list[i][j] == ".":
            continue
        else:
            if not is_not_isolated(s_list, i, j):
                print("No")
                exit(0)
else:
    print("Yes")

Solution (Python):
import numpy as np
H, W = list(map(int, input().split()))
count = 0
s = np.array([['d']*(W+2)]*(H+2))

for i in range(1, H+1):
    mojiretu = input()
    for j in range(1, W+1):
        s[i][j] = mojiretu[j-1]


def handan():
    for i in range(1, H+1):
        for j in range(1, W+1):
            if s[i][j] == '
                if (s[i-1][j] == ('.' or 'd')) and (s[i+1][j] == ('.' or 'd')) and (s[i][j-1] == ('.' or 'd')) and (s[i][j+1] == ('.' or 'd')):
                    return 'No'
    return 'Yes'

print(handan())

Solution (Python):
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
r = "Yes"
for i in range(1, h-1):
    for j in range(1, w-1):
        if s[i][j] == "
          r = "No"
print(r)

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

ans = True
for i in range(1,h-2):
    for j in range(1,w-2):
        if k[i][j] == "
            ans = False

if ans:
    print('Yes')

else:
    print('No')

Solution (Python):
h, w = map(int, input().split())
S = []
flag = True
for i in range(h):
    r = list(input())
    S.append(r)
for i in range(0,h-1):
    for j in range(0,w-1):
        if S[i][j]=='
            flag = False
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):



S = []
p = []
flag = True


H,W = map(int, input().split())
for i in range(H):
	s = input()
	s_list = list(s)
	S.append(s_list)


for i in range(0, H-1, 1):
	for j in range(0, W-1, 1):
		if S[i][j] == "
			flag = False
		


if flag == True:
	print("Yes")

else:
	print("No")

Solution (Python):
import math
H, W = map(int, input().split())
s = []
flag = 0
ans = "No"
for i in range(H):
  s.append(list(input()))
for i in range(H):
  for j in range(W):
    if flag == 0:
      if s[i][j] == "
        if s[max(0, i - 1)][j] == "
          continue
        else:
          flag += 1
if flag == 0:
  ans = "Yes"
print(ans)

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

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

print(ans)

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

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

Solution (Python):

def searchAround(sheet, h,w):
    
    try:
        isSharpAbove = (sheet[h-1][w]=="
        if h==0:
            isSharpAbove = False
    except IndexError:
        isSharpAbove = False
        
    
    try:
        isSharpBelow = (sheet[h+1][w]=="
    except IndexError:
        isSharpBelow = False
    
    
    try:
        isSharpRight = (sheet[h][w+1]=="
    except IndexError:
        isSharpRight = False
    
    
    try:
        isSharpLeft = (sheet[h][w-1]=="
        if w==0:
            isSharpLeft = False
    except IndexError:
        isSharpLeft = False  
        
        
    
    if isSharpAbove \
    or isSharpBelow \
    or isSharpRight \
    or isSharpLeft:
            return 0
    else:
        return 1
            
    

def main():
    H,W = map(int, input().split())
    sheet = []
    flag = 0
    for h in range(H):
        sheet.append(list(input()))
    
    for h in range(H):
        for w in range(W):
            if sheet[h][w] == "
                flag = searchAround(sheet, h,w)
            if flag==1:
                print('No')
                return 0

    if flag == 0:
        print('Yes')


if __name__ == "__main__":
    main()

Solution (Python):
import sys

line_size, row_size = map(int, input().split())
mapmap = []

for i in range(line_size):
    mapmap.append(list(input()))


def Start_check(mapmap, px, py):
    start_flg = False
    move_x = [1, -1, 0, 0]
    move_y = [0, 0, 1, -1]
    for i in range(4):
        nx = px + move_x[i]
        ny = py + move_y[i]
        if 0 <= nx and nx < line_size and 0 <= ny and ny < row_size:
            if mapmap[nx][ny] == '
                start_flg = True
    
    if start_flg == False:
        print('No')
        sys.exit()


count = 0
for i in range(line_size):
    for j in range(row_size):
        if mapmap[i][j] == '
            Start_check(mapmap, i, j)
            count += 1


print('Yes')

Solution (Python):
h, w = map(int, input().split())
data = ''
for i in range(h):
    data += input()

array = list(data)


for i, x in enumerate(array):
    if x == '.':
        continue
    cnt = 0
    
    if not i < w:
        if array[i - w] == '
            cnt += 1
    
    if i + w < h * w:
        if array[i + w] == '
            cnt += 1
    
    if i % w != 0:
        if array[i - 1] == '
            cnt += 1
    
    if i % w != w - 1:
        if array[i + 1] == '
            cnt += 1

    if cnt == 0:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
r = "Yes"
for i in range(1, h-1):
    for j in range(1, w-1):
        if s[i][j] == "
          r = "No"
print(r)

Solution (Python):
h,w = map(int,raw_input().split())
canv = [[] for i in range(h+2)]
canv[0]=canv[-1] = '.'*(w+2)
for i in range(1,h+1): 
    canv[i] = '.' + raw_input() + '.'
noflag = False
for i in range(1,h+1):
    if noflag:
        break
    for j in range(1,w+1):
        if canv[i][j] == '
            if canv[i+1][j]+canv[i-1][j]+canv[i][j+1]+canv[i][j-1] == '....':
                noflag = True
if noflag:
    print("No")
else:
    print("Yes")

Solution (Python):
HW = input().split()

H = int(HW[0])
W = int(HW[1])

tmp1 = ("." * W) + ".."
s = [list(tmp1)]
for i in range(H):
    tmp2 = "." + input() + "."
    s.append(list(tmp2))
s.append(list(tmp1))

checker = 1
for i in range(1, H+1):
    for j in range(1, W+1):
        if s[i][j] == "
            if s[i][j-1] == "." and s[i-1][j] == "." and s[i][j+1] == "." and s[i+1][j] == ".":
                checker = 0
                break
    if checker == 0:
        break

if checker == 0:
    print("No")
else:
    print("Yes")

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

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

Solution (Python):


def main():
    h, w = map(int, raw_input().split())

    square = []
    for i in range(h):
        square.append(raw_input())

    for i in range(h):
        for j in range(w):
            if square[i][j] == '.':
                continue
            else:
                if check(square, i, j, h, w):
                    continue
                else:
                    print("No")
                    exit()

    print("Yes")

def check(square, i, j, h, w):
    if i-1 >= 0:
        if square[i-1][j] == '
            return True
    if i+1 < h:
        if square[i+1][j] == '
            return True
    if j-1 >= 0:
        if square[i][j-1] == '
            return True
    if j+1 < w:
        if square[i][j+1] == '
            return True

    return False

if __name__ == '__main__':
    main()