Problem:
 Score: 300 points    Problem Statement  We have a canvas divided into a grid with H rows and W columns. The square at the i -th row from the top and the j -th column from the left is represented as (i, j) . Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}=  # , and to make Square (i, j) white when s_{i, j}=  . . However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective.      Constraints   H is an integer between 1 and 50 (inclusive).  W is an integer between 1 and 50 (inclusive).  For every (i, j)  (1 \leq i \leq H, 1 \leq j \leq W) , s_{i, j} is # or . .         Input  Input is given from Standard Input in the following format:  H  W  s_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}  s_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}  :  :  s_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}       Output  If square1001 can achieve his objective, print Yes ; if he cannot, print No .        Sample Input 1 3 3
.#.
###
.#.      Sample Output 1 Yes  One possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.        Sample Input 2 5 5
#.#.#
.#.#.
#.#.#
.#.#.
#.#.#      Sample Output 2 No  square1001 cannot achieve his objective here.       Sample Input 3 11 11
...#####...
.##.....##.
#..##.##..#
#..##.##..#
#.........#
#...###...#
.#########.
.#.#.#.#.#.
##.#.#.#.##
..##.#.##..
.##..#..##.      Sample Output 3 Yes

Solution (Python):
H,W=map(int,input().split(' '))
S=[list(input()) for i in range(H)]
for h in range(H):
    for w in range(W):
        if S[h][w]=='
            flg = False
            for x,y in [[-1,0],[1,0],[0,-1],[0,1]]:
                if 0<=h+x<H and 0<=w+y<W and S[h+x][w+y]=='
                    flg=True
                    break

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

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

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

flag = True
for i in range(h):
    for j in range(w):
        if S[i][j] == ".":
            continue

        check = False
        for nx, ny in zip(dx, dy):
            nx += i
            ny += j

            if 0 <= nx < h and 0 <= ny < w:
                if S[nx][ny] == "
                    check = True

        if not check:
            flag = False
            break

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

Solution (Python):
def Grid_Repainting(h , w , sl):

    ans = "Yes"
    xl = [1, 0, -1, 0]
    yl = [0 , 1 , 0 , -1]

    for i in range(h):
        for v in range(w):
            count = 0
            countcheck = 4
            if sl[i][v] == "
                for q in range(4):
                    x = i + xl[q]
                    y = v + yl[q]
                    if x >= 0 and x < h and y >= 0 and y < w:
                        if sl[x][y] == ".":
                            count += 1
                    else:
                        countcheck -= 1
            if count == countcheck:
                ans = "No"

    return ans

def main():
    h , w = map(int , input().split())
    sl = [list(str(input())) for i in range(h)]
    print(Grid_Repainting(h , w , sl))

if __name__ == '__main__':
    main()

Solution (Python):

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

glid = ["."+input()+"." for i in range(H)]
glid.append("."*(W+2))
glid.insert(0,"."*(W+2))
ans = "Yes"
for i in range(1,H+1):
    for j in range(1,W+1):
        if glid[i][j]=="
            if glid[i][j-1] != "


                ans = "No"
print(ans)

Solution (Python):
h,w = map(int,input().split())
s = [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 = [int(x) for x in input().split()]
matrix = [list(input()) for _ in range(h)]
surroundings = ((-1, 0), (1, 0), (0, -1), (0, 1))


def check_surroundings(i, j):
    for dis in surroundings:
        si = i + dis[0]
        sj = j + dis[1]
        if si < 0 or si >= h or sj < 0 or sj >= w:
            continue
        if matrix[si][sj] == '
            break
    else:
        yield True  


for i in range(h):
    for j in range(w):
        if matrix[i][j] == '
            if sum(check_surroundings(i, j)):
                break
            else:
                continue
    else:
        continue

    print('No')
    break

else:
    print('Yes')

Solution (Python):
h,w=map(int,input().split())
_s=[input() for _ in range(h)]
s=[[0]*(w+2) for _ in range(h+2)]
for i in range(1,h+1):
  for j in range(1,w+1):
    if _s[i-1][j-1]=='
      s[i][j]=1
f=False
for i in range(1,h+1):
  for j in range(1,w+1):
    if s[1][j]==1 and s[i-1][j]+s[i+1][j]+s[i][j-1]+s[i][j+1]==0:
      f=True
print(['Yes','No'][f])

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

flag = True
output_rows = [['

for i in range(H):
    for j in range(W):
        if rows[i][j] != '
            continue
        else:
            found = False
            for (dx, dy) in [[0, -1], [0, 1], [-1, 0], [1, 0]]:
                y, x = i + dy, j + dx
                if x < 0 or x > W - 1 or y < 0 or y > H - 1:
                    continue
                else:
                    if rows[y][x] == '
                        found = True
            if not found:
                flag = False
                break

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

Solution (Python):
H, W = map(int, input().split(' '))
board = [input() for _ in range(H)]
dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]
ans = 'Yes'
for i in range(H):
    for j in range(W):
        if (board[i][j] == '
            isFound = False
            for d in range(len(dx)):
                x = i + dx[d]
                y = j + dy[d]
                if (x < 0 or H <= x):
                    continue
                if (y < 0 or W <= y):
                    continue
                if (board[x][y] == '
                    isFound = True
            if (isFound is False):
                ans = 'No'
print(ans)

Solution (Python):
H, W = map(int, input().split(' '))
board = [input() for i in range(H)]
dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]
ans = True
for i in range(H):
    for j in range(W):
        if (board[i][j] == '
            isFound = False
            for d in range(len(dx)):
                x = i + dx[d]
                y = j + dy[d]
                if (x < 0 or H <= x):
                    continue
                if (y < 0 or W <= y):
                    continue
                if (board[x][y] == '
                    isFound = True
            if (isFound is False):
                ans = False
if (ans):
    print('Yes')
else:
    print('No')

Solution (Python):


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

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

field=[]
for _ in range(H):
  field.append(list(input()))

is_success=True

for y in range(H):
  for x in range(W):
    if field[y][x]==".":
      continue
    
    for k in range(4):
      tmp_y=y+dy[k]
      tmp_x=x+dx[k]

      if tmp_y<0 or tmp_y>=H or tmp_x<0 or tmp_x>=W:
        continue
      if field[tmp_y][tmp_x]=="
        break
      if k==3:
        print("No")
        exit()
print("Yes")

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

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

for i in range(h):
    for j in range(w):
        if l[i][j] == "
            ok=False
            for k in range(4):
                nx = j + dx[k]
                ny = i + dy[k]
                if 0<=nx<w and 0<=ny<h and l[ny][nx]=="
                    ok=True
            if not ok:
                print("No")
                exit()
print("Yes")

Solution (Python):
import sys
H,W = map(int,input().split())
S = []
for i in range(H):
    S.append(list(input()))
    S[i].append('0')
S.append(['0']*W)    
for i in range(H):
    for j in range(W):
        black = [S[i][j-1],S[i][j+1],S[i+1][j],S[i-1][j]]
        if S[i][j] == '
            if '
                print('No')
                sys.exit()
print('Yes')

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

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

for i in range(1,H+1):
  for j in range(1,W+1):
    B[i][j]= A[i-1][j-1]

flag=True
for i in range(1,H+1):
  if flag:
    for j in range(1,W+1):
      if B[i][j]=="
        if B[i-1][j]!="
          flag=False
          break
          
if flag:
  print("Yes")
else:
  print("No")

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):
        f = False
        if s[i][j]=='
            if i>0 and s[i-1][j]=='
            if i<h-1 and s[i+1][j]=='
            if j>0 and s[i][j-1]=='
            if j<w-1 and s[i][j+1]=='
            if not f:
                ans = 'No'
print(ans)

Solution (Python):




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

    for i in range(H):
        for j in range(W):
            if j > 0 and S[i][j - 1] != "." and S[i][j] == "
                S[i][j] = "*"
            elif j < W - 1 and S[i][j + 1] != "." and S[i][j] == "
                S[i][j] = "*"
            elif i > 0 and S[i - 1][j] != "." and S[i][j] == "
                S[i][j] = "*"
            elif i < H - 1 and S[i + 1][j] != "." and S[i][j] == "
                S[i][j] = "*"

    print("No" if sum([s.count("


if __name__ == "__main__":
    main()

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

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

for i in range(H):
    for j in range(W):
        if path[i][j] == 0 and grid[i][j] == '
            judge = False
            path[i][j] = 1
            for dx, dy in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
                nx = i + dx
                ny = j + dy
                if 0 <= nx < H and 0 <= ny < W and grid[nx][ny] == '
                    judge |= True
                    path[nx][ny] = 1
            if not judge:
                print('No')
                exit()
print('Yes')

Solution (Python):
height,width = map(int, input().split())
map_list = []
for i in range(height):
    map_list.append(list(input()))
    map_list[i].append('0')
map_list.append(['0'] * width)

for h in range(height):
    for w in range(width):
        if map_list[h][w] == '
            if '
                continue
            else:
                print("No")
                exit()

print("Yes")

Solution (Python):
height,width = map(int, input().split())
map_list = []
flag = False
for i in range(height):
    map_list.append(list(input()))
    map_list[i].append('0')
map_list.append(['0'] * width)


for h in range(height):
    for w in range(width):
        if map_list[h][w] == '
            
            if '
                flag = True
                
                if flag == True:
                    flag = False
                    
            else:
                print("No")
                exit()

print("Yes")

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

Solution (Python):
import sys


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


goal = ["

for ii in range(h):
    st = input()
    goal.append("
    
goal.append("

ng = 0
for i in range(1, h):
    for j in range(1, w):
        if goal[i][j] == "
            if goal[i-1][j] == "." and \
               goal[i+1][j] == "." and \
               goal[i][j-1] == "." and \
               goal[i][j+1] == ".":
                    print("No")
                    ng = 1
                    break
    if ng == 1:
        break
else:
    print("Yes")

Solution (Python):


import numpy as np
import sys
sys.setrecursionlimit(10**6)


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

Mtmp = []
for _ in range(H):
    tmp = list(input())
    Mtmp.append(tmp)

M = np.array(Mtmp)
S = np.array([[0]*W]*H)



digtmp = np.array([[0, 1], [1, 0], [0, -1], [-1, 0]])

def dfs(i, j):
    global ngflag
    global searchflag
    if S[i, j] == 1:
        return
    S[i, j] = 1
    if M[i, j] == '.':
        return
    
    searchflag = 1
    dig = digtmp + np.array([i, j])
    for d in dig:
        if 0 <= d[0] < H and 0 <= d[1] < W:
            if M[d[0], d[1]] == '
                ngflag = 0
                dfs(d[0], d[1])

searchflag = 0
ngflag = 1

while True:
    if 0 not in S:
        if M[target[0], target[1]] == '.':
            ngflag = 0
        break
    target = list(zip(*np.where(S == 0)))[0]
    
    if M[target[0], target[1]] == '
        ngflag = 1
    dfs(target[0], target[1])
    if M[target[0], target[1]] == '
        break




if searchflag == 1 and ngflag == 0:
    ans = 'Yes'
elif searchflag == 1 and ngflag == 1:
    ans = 'No'
else:
    ans = 'Yes'

print(ans)

Solution (Python):
h,w=map(int,input().split())
grid=[list(input()) for i in range(h)]
c=[['.']*w for i in range(h)]
dx=[1,0,-1,0]
dy=[0,1,0,-1]
for i in range(h):
  for j in range(w):
    for k in range(4):
      ny=i+dy[k]
      nx=j+dx[k]
      if 0<=ny<h and 0<=nx<w and grid[i][j]=='
        c[i][j]=c[ny][nx]='
for i in range(h):
  for j in range(w):
    if c[i][j]!=grid[i][j]:
      print('No')
      exit()
print('Yes')

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

ls = []

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

for i in range(1, h+1):
    for j in range(1, w+1):
        if ls[i][j] != '
            continue
        if ls[i][j-1] != '
            print('No')
            exit()

print('Yes')

Solution (Python):
H,W=map(int,input().split())
answers=[]
answers.append([' ',]*(W+2))
for a in range(H):
    S=input()
    T=[b for b in S]
    T.append(' ')
    T.insert(0,' ')
    answers.append(T)
answers.append([' ',]*(W+2))
lll=[]
kotae=0
for a in range(H):
    A=answers[a+1]
    for b in range(W):
        if A[b+1]=='
            if A[b]=='
                pass
            else:
                kotae+=100
if kotae==0:
    print('Yes')
else:
    print('No')

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

s=[input() for _ in range(h)]

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

for i in range(h):
    for j in range(w):
        if(s[i][j]=='.'):continue
        f=False
        for k in range(4):
            ni=i+dx[k]
            nj=j+dy[k]
            if(0<=ni<=h-1 and 0<=nj<=w-1):
                if(s[ni][nj]=='
        if(not f):
           
            print("No")
            exit()
print("Yes")

Solution (Python):
import sys

h,w = map(int,input().split())
c = [None]*h
dx = [1,0,-1,0]
dy = [0,1,0,-1]

for i in range(h):
    c[i] = input()
    
for i in range(h):
    for j in range(w):
        a = 0
        b = 0
        for k in range(4):
            nx = j + dx[k]
            ny = i + dy[k]
            if c[i][j] == '
                b += 1
                if c[ny][nx] == '.':
                    a += 1
                    
        if a == b and b != 0:
            print("No")
            sys.exit()
            
print("Yes")

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



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


for y in range(H):
    for x in range(W):
        if field[y][x] == "
            state = False
            for k in range(4):
                ny = y + dy[k]
                nx = x + dx[k]
                if 0 <= ny and ny < H and 0 <= nx and nx < W:
                    if field[ny][nx] == "
                        state = True
            if state:
                continue
            else:
                flag = False
                break

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

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

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

for i in range(h):
    for j in range(w):
        if flag == False:
            break
        if ans[i][j] == '
            if j-1 >= 0:
                if ans[i][j-1] == '
                    continue
            if i-1 >= 0:
                if ans[i-1][j] == '
                    continue
            if j+1 < w:
                if ans[i][j+1] == '
                    continue
            if i+1 < h:
                if ans[i+1][j] == '
                    continue
            flag = False

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

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

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

    for i in range(h):
        for j in range(w):
            for dx, dy in d:
                m = i + dx
                n = j + dy
                if m < 0 or m > h - 1:
                    pass
                elif n < 0 or n > w - 1:
                    pass
                elif l[i][j] == '
                    l[i][j] = 'z'
                    l[m][n] = 'z'
                elif l[i][j] == 'z' and l[m][n] == '
                    l[m][n] = 'z'
                elif l[i][j] == '
                    l[i][j] = 'z'

    count = 0
    for i in l:
        count += i.count('

    if count == 0:
        return print('Yes')
    else:
        return print('No')

if __name__ == '__main__':
    resolve()

Solution (Python):
h, w = map(int, input().split())
s = [["."] + list(input()) + ["."] for _ in range(h)]
s0 = ["."] * (w + 2)
s.insert(0, s0)
s.append(s0)
v = [[0, 1], [0, -1], [1, 0], [-1, 0]]
ans = 1
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if s[i][j] == "
            c = 0
            for k in v:
                if s[i + k[0]][j + k[1]] == "
                    c += 1
            if c == 0:
                ans = 0

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

Solution (Python):
H, W = map(int,input().split())
S = [list(input()) for _ in range(H)]
for i in range(H):
  for j in range(W):
    up = down = left = right = "."
    if S[i][j] == "
      if i-1 >= 0:
        up = S[i-1][j]
      if j-1 >= 0:
        left = S[i][j-1]
      if i+1 <= H-1:
        down = S[i+1][j]
      if j+1 <= W-1:
        right = S[i][j+1]
      if up == down == left == right == ".":
        print("No")
        exit()
print("Yes")

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

for h in range(1,H+1):
  for w in range(1,W+1):
    if S[h][w] == '
      if '
        print('No')
        exit()
print('Yes')

Solution (Python):

s = input().split()
t = [int(p) for p in s]

a = []
H = t[0]
W = t[1]
for i in range(H):
    a.append(input())


b = ''
for i in range(W+2):
    b += '.'


a.insert(0, b)
for i in range(1, 1+H):
    a[i] = '.' + a[i] + '.'
a.append(b)



def detect(l, h, w):
    answer = 'ng'
    dx = [1, -1, 0, 0]
    dy = [0, 0, 1, -1]
    for i in range(4):
        if(l[h + dy[i]][w + dx[i]] == '
            answer = 'ok'
    return answer


final_answer = 'Yes'
for i in range(len(a)):
    for j in range(len(a[i])):
        if(a[i][j] == '
            
            if(detect(a,i,j) == 'ng'):
                final_answer = 'No'

print(final_answer)

Solution (Python):
H, W = map(int, input().split())
s = []
for _ in range(H):
    s.append(input())
    
Flg = "Yes"
for i in range(H):
    for j in range(W):
        if(s[i][j] == '
            if(s[i][max(j-1, 0)] == "." and s[i][min(j+1, W-1)] == '.' and s[min(i+1, H-1)][j] == '.' and s[max(i-1, 0)][j] == '.'):
                Flg = "No"

print(Flg)

Solution (Python):
H, W = map(int, input().split())
S = [0]*(H+2)
for i in range(1,H+1):
  S[i] = '.'+input()+'.'
S[0]= '.'*(W+2)
S[H+1]= '.'*(W+2)
for i in range(1,H+1):
  for j in range(1,W+1):
    if S[i][j]=='
      check = [S[i-1][j],S[i][j-1],S[i+1][j],S[i][j+1]]
      if '
        print('No')
        exit()
print('Yes')

Solution (Python):
H, W = map(int, input().split())
S = [0]*H
for i in range(H):
  S[i] = input()
for i in range(H):
  for j in range(W):
    if S[i][j]=='
      check = []
      try:
        check.append(S[i-1][j])
      except:
        check.append('.')
      try:
        check.append(S[i][j-1])
      except:
        check.append('.')
      try:
        check.append(S[i+1][j])
      except:
        check.append('.')
      try:
        check.append(S[i][j+1])
      except:
        check.append('.')
      if '
        print('No')
        exit()

print('Yes')

Solution (Python):
h,w=map(int,input().split())
paint=[]
paint.append(["." for _ in range(w+2)])
for i in range(h):
    P=["."] +list(input()) +["."]
    paint.append(P)
paint.append(["." for _ in range(w+2)])
ans="Yes"
for i in range(h):
    for j in range(w):
        if paint[i+1][j+1]=="
            if not(paint[i][j+1]=="
                ans="No"
                break
    else:
        continue
    break
print(ans)

Solution (Python):
from sys import exit

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

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

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

for i in range(h):
  for j in range(w):
    if j > 0 and a[i][j-1] != "." and a[i][j] == "
      a[i][j] = "*"
    elif j < w - 1 and a[i][j+1] != "." and a[i][j] == "
      a[i][j] = "*"
    elif i > 0 and a[i-1][j] != "." and a[i][j] == "
      a[i][j] = "*"
    elif i < h - 1 and a[i+1][j] != "." and a[i][j] == "
      a[i][j] = "*"

print("No" if sum([row.count("

Solution (Python):
inH, inW = map(int, input().split())
inMap = list()

for i in range(inH):
  inMap.append(list(input()))

def chkPaint(x,y):
  mv = [[-1,0], [1,0], [0,-1], [0,1]]
  for pos in mv:
    if x+pos[0]<0 or x+pos[0]>=inH or y+pos[1]<0 or y+pos[1]>=inW  :
      continue
    if inMap[x+pos[0]][y+pos[1]] == "
        return True
  return False

flg=True
for i in range(inH):
  for j in range(inW):
    if inMap[i][j] == "
      flg = chkPaint(i,j)
    if flg == False:
      break
  if flg == False:
    break

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

Solution (Python):
import sys
dx = [0, -1, 1, 0]
dy = [-1, 0, 0, 1]
field = []
H, W = map(int, input().split())
for _ in range(H):
    field.append(list(input()))
for y in range(H):
    for x in range(W):
        if field[y][x] == '
            flag = 0
            for i in range(4):
                nx = dx[i] + x
                ny = dy[i] + y
                if nx < 0 or W <= nx or ny < 0 or H <= ny:
                    continue
                if field[ny][nx] == '
                    flag = 1
                    break
            if flag == 0:
                print('No')
                sys.exit()
print('Yes')

Solution (Python):
h, w = map(int, input().split())
masu = ['.'*(w+2)]
masu += ['.' + input() + '.' for _ in range(h)]
masu.append('.'*(w+2))
ans = 'Yes'
for i in range(1,h+1):
    for j in range(1,w+1):
        if masu[i][j] == '
            if masu[i+1][j] == '
                continue
            else:
                ans = 'No'
                break
print(ans)

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

def hantei(i,j,grid):
  flag=False
  if i>0:
    flag=flag or grid[i-1][j]=='
  if j>0:
    flag=flag or grid[i][j-1]=='
  if i<h-1:
    flag=flag or grid[i+1][j]=='
  if j<w-1:
    flag=flag or grid[i][j+1]=='
  return flag

for i in range(h):
  for j in range(w):
    if grid[i][j]=='.':
      continue
    if hantei(i,j,grid)==False:
      print('No')
      exit()
print('Yes')

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

Solution (Python):



H, W = map(int, input().split())
s_list = [[0]*W for i in range(H)]
for i in range(H):
    tmp = input()
    for j in range(W):
        s_list[i][j] = tmp[j]


is_ok = True
for i in range(H):
    for j in range(W):
        if s_list[i][j]==".":
            continue
        
        if j+1<W:
            if s_list[i][j+1]=="
                continue
        
        if j-1>=0:
            if s_list[i][j-1]=="
                continue
        
        if i+1<H:
            if s_list[i+1][j]=="
                continue
        
        if i-1>=0:
            if s_list[i-1][j]=="
                continue
        
        is_ok = False
        break

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

Solution (Python):
S = input().split(" ")
N = int(S[0])
W = int(S[1])

ARR = []

for i in range(N):
    ar = list(input())
    ARR.append(ar)


def calculate(n, w, arr):
    result = True
    hasShape = False
    for i in range(n):
        for j in range(w):
            if arr[i][j] == "
                hasShape = True
                sss = []
                if i -1 >= 0:
                    sss.append(arr[i-1][j])
                if i + 1 < n:
                    sss.append(arr[i+1][j])

                if j - 1 >= 0:
                    sss.append(arr[i][j-1])
                if j + 1 < w:
                    sss.append(arr[i][j+1])

                if "
                    result = False
                    break

    if hasShape == False:
        print("Yes")
        return

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


calculate(N, W, ARR)

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

Solution (Python):
n,w=map(int,input().split())
st=[]
for i in range(n):
    st.append(list(input())) 
if n==w==1:
    print("Yes")
    exit()

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

print("Yes")

Solution (Python):
import sys
def main():
    input = sys.stdin.readline
    H,W = map(int, input().split())
    s = [list(input().rstrip()) for _ in range(H)]

    def check(i, j):
        for di, dj in [(0,1),(0,-1),(1,0),(-1,0)]:
            ni, nj = i+di, j+dj
            if ni < 0 or ni >= H or nj < 0 or nj >= W: continue
            if s[ni][nj] == '
        return False

    for i in range(H):
        for j in range(W):
            if s[i][j] == '
                if check(i,j) == False: return False
    return True

if __name__ == '__main__':
    print('Yes' if main() else 'No')

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

h,w = MAP()
s = [STR() for _ in range(h)]
ii = [-1, 1, 0, 0]
jj = [0, 0, -1, 1]
for i in range(h):
    for j in range(w):
        if s[i][j] == '
            flag = [False for _ in range(4)]
            for k in range(4):
                iii = i + ii[k]
                jjj = j + jj[k]
                if 0 <= iii < h and 0 <= jjj < w and s[iii][jjj] == '
                    flag[k] = True
            if not sum(flag):
                print('No')
                exit()
print('Yes')

Solution (Python):
n, m = map(int, input().split())
field = [list(input()) for i in range(n)]
flg = True
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
for i in range(n):
    for j in range(m):
        if field[i][j] == "
            f = 0
            for k in range(4):
            
                nx = i + dx[k]
                ny = j + dy[k]
                if 0 <= nx and nx < n and 0 <= ny and ny < m and field[nx][ny] == "
                    f += 1
            if f==False:
                flg = False
                
print("Yes" if flg else "No")

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

h,w = MAP()
s = [STR() for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '
            flag = [False for _ in range(4)]
            if i > 0 and s[i-1][j] == '
                flag[0] = True
            if i < h - 1 and s[i+1][j] == '
                flag[1] = True
            if j > 0 and s[i][j-1] == '
                flag[2] = True
            if j < w - 1 and s[i][j+1] == '
                flag[3] = True
            if sum(flag) == 0:
                print('No')
                exit()
print('Yes')