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 = []
answer = "Yes"

for i in range(H):
    s.append(str(input()))

for i in range(H):
    for j in range(W):
        if s[i][j] == "
            if j != 0 and s[i][j-1] == ".":
                if j+1 != W and s[i][j+1] == ".":
                    if i != 0 and s[i-1][j] == ".":
                        if i+1 != H and s[i+1][j] == ".":
                            answer ="No"

print(answer)

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

def search(i,j):
    c = 0

    if i != 0:
        if ss[i-1][j] == "
            c += 1
    if i != h-1:
        if ss[i+1][j] == "
            c += 1
    if j != 0:
        if ss[i][j-1] == "
            c += 1
    if j != w-1:
        if ss[i][j+1] == "
            c += 1

    if c > 0:
        return False
    else:
        return True

ans = "Yes" 
for i in range(h):
    for j in range(w):
        if ss[i][j] == "
            if search(i,j):
                ans = "No"
                break

print(ans)

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

Solution (Python):
import sys

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

dd = [(0,1),(0,-1),(1,0),(-1,0)]
for i in range(h):
    for j in range(w):
        if C[i][j] == '
            b = []
            for di,dj in dd:
                if 0<=i+di<h and 0<=j+dj<w:
                    b.append(C[i+di][j+dj] == '.')
            if all(b):
                print('No')
                sys.exit()
print('Yes')

Solution (Python):
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def yes(n): print("Yes" if n else "No")
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

h, w = f()
target =  ['.'*(w+2)]
for _ in range(h):
    a = '.'
    a += input()
    a += '.'
    target.append(a)
target.append('.'*(w+2))
flag = True

for i in range(1, h+1):
    for j in range(1, w+1):
        if target[i][j] == '
            if '
                flag = False
yes(flag)

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

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

for y in range(1, H+1):
    for x in range(1, W+1):
        if s[y][x] == "
            if s[y-1][x] == "." and s[y+1][x] == "." and s[y][x-1] == "." and s[y][x+1] == ".":
                accept = False

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

Solution (Python):
import sys
sys.setrecursionlimit(100000)

H, W = list(map(int, input().split()))
s = [[c for c in input()] for _ in range(H)]
accept = True

def dfs(x, y, count):
    if  x < 0 or W <= x or y < 0 or H <= y:
        return count - 1
    elif s[y][x] != "
        return count - 1
    else:
        s[y][x] = "."
        return max(dfs(x-1, y, count+1), dfs(x+1, y, count+1), dfs(x, y-1, count+1), dfs(x, y+1, count+1))

for y in range(H):
    for x in range(W):
        if s[y][x] != "
            continue
        elif dfs(x, y, 0) == 0:
            accept = False

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

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




flag = True
for i in range(h):
    for j in range(w):
        if T[i][j] == "
            flag2 = False
            for dx, dy in [(0, 1), (1, 0), (-1, 0), (0, -1)]:
                nx, ny = i + dx, j + dy

                if 0 <= nx < h and 0 <= ny < w and T[nx][ny] == "
                    flag2 = True

            if not flag2:
                flag = False

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

Solution (Python):
H, W =list(map(int, input().split()))
X = []
def neibour(x,y):
    try:
        if X[x][y] == '
            return 1
        else:
            return 0
    except:
        return 0
for i in range(H):
    X.append(list(input()))
for i in range(H):
    for j in range(W):
        if X[i][j] == '
            c = 0
            c += neibour(i+1,j)
            c += neibour(i-1,j)
            c += neibour(i,j+1)
            c += neibour(i,j-1)
            if c == 0:
                print('No')
                exit()
print('Yes')

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


slist = []
slist.append(["." for j in range(W+2)] )
for i in range(H):
    l = [j for j in raw_input()]
    l.insert(0, ".")
    l.append(".")
    slist.append(l)
slist.append(["." for j in range(W+2)])



for i in range(1, H):
    for j in range(1, W):
        if slist[i][j] == "
            if slist[i+1][j] == "." and slist[i][j+1] == "." and \
               slist[i-1][j] == "." and slist[i][j-1] == ".":
                print("No")
                exit(0)
print("Yes")

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

for i in range(H):
	for j in range(W):
		if picture[i][j] == '
			if i == 0 or picture[i-1][j] == '.':
				if j == 0 or picture[i][j-1] == '.':
					if i == H-1 or picture[i+1][j] == '.':
						if j == W-1 or picture[i][j+1] == '.':
							print('No')
							exit()

print('Yes')

Solution (Python):
h,w=map(int,input().split())
c=[]
c.append("."*(w+2))
for i in range(h):
    c.append(".{}.".format(input()))
c.append("."*(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 = list(map(int, input().split()))
S = [input() for _ in range(H)]


def f(h, w):
    if h < 0 or h >= H or w < 0 or w >= W:
        return False
    return S[h][w] == '


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

Solution (Python):
import sys

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

s=[["" for i in range(w)] for j in range(h)]

for i in range(h):
    a=input()
    for j in range(w):
        s[i][j]=a[j]
        
for i in range(h):
    for j in range(w):
        if s[i][j] == "
            if i != 0:
                if s[i-1][j] == "
                    continue
            if i != h-1:
                if s[i+1][j] == "
                    continue
            if j != 0:
                if s[i][j-1] == "
                    continue
            if j != w-1:
                if s[i][j+1] == "
                    continue
            print("No")
            sys.exit()
print("Yes")

Solution (Python):


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

for i in range(h):
    for j in range(w):
        t,r,l,b = [""]*4
        if m[i][j] == "
            if i-1 >= 0:
                t = m[i-1][j]
            if j+1 < w:
                r = m[i][j+1]
            if j-1 >= 0:
                l = m[i][j-1]
            if i+1 < h:
                b = m[i+1][j]
            if [t,r,l,b].count("
                print("No")
                exit()
print("Yes")

Solution (Python):
H, W = map(int, raw_input().split())
board = []
for i in range(0, H):
	board.append(raw_input())

flag = True

for i in range(0, H):
	for j in range(0, W):
		if board[i][j] == '
			tmp = False
			if i-1 >= 0:
				if board[i-1][j] == '
					tmp = True
			if j-1 >= 0:
				if board[i][j-1] == '
					tmp = True
			if i+1 <= H-1:
				if board[i+1][j] == '
					tmp = True
			if j+1 <= W-1:
				if board[i][j+1] == '
					tmp = True
			flag = flag and tmp

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

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

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

for i in range(1,h-1):
    for j in range(1, w-1):
        if s[i][j]=="
            print("No")
            exit()

for j in range(1,w-1):
    if s[0][j] == "
        print("No")
        exit()
    if s[h-1][j] == "
        print("No")
        exit()


for i in range(1,h-1):
    if s[i][0] == "
        print("No")
        exit()
    if s[i][w-1] == "
        print("No")
        exit()

if s[0][0]=="
    print("No")
    exit()

if s[h-1][0]=="
    print("No")
    exit()

if s[0][w-1]=="
    print("No")
    exit()

if s[h-1][w-1]=="
    print("No")
    exit()

print("Yes")

Solution (Python):
import sys

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




s = [["" for j in range(W)] for i in range(H)]

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



for i in range(H):
    for j in range(W):
        if s[i][j] == "
            if i != 0:
                if s[i-1][j] == "
                    continue
            if i != H-1:
                if s[i+1][j] == "
                    continue
            if j != 0:
                if s[i][j-1] == "
                    continue
            if j != W-1:
                if s[i][j+1] == "
                    continue
            print("No")
            sys.exit()
print("Yes")

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

grid = [['.' for i in range(0, W+2)] for i in range(0, H+2)]
temp = []

for i in range(1, H+1):
    temp.append(list(input()))
    grid[i][1:1+W] = temp[i-1][::]
    
ans = 'Yes'
    
for i in range(1, H+1):
    for j in range(1, W+1):
        if grid[i][j] == '
            if grid[i+1][j] == '
                pass
            elif grid[i][j+1] == '
                pass
            else:
                ans = 'No'

print(ans)

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

S = [None] * H

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

flag_break = False

for h in range(H):
    if flag_break == False:
        for w in range(W):
            if S[h][w] == '
                if S[max(0, h-1)][w] != '
                    flag_break = True
                    break

if flag_break == True:
    print('No')
else:
    print('Yes')

Solution (Python):
H, W = map(int, input().split())
S = [input() for i in range(H)]
dd = ((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 dd:
      nx = j + dx
      ny = i + dy
      if 0 <= nx < W and 0 <= ny < H and S[ny][nx] == '
        break
    else:
      print('No')
      quit()
print('Yes')

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

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

ans_flg = True
for i in range(h):
    for j in range(w):
        if s[i][j] == '
            flg = False
            for dr, dc in [(-1, 0), (0, -1), (1, 0), (0, 1)]:
                r = i + dr
                c = j + dc
                if 0 <= r < h and 0 <= c < w:
                    if s[r][c] == '
                        flg = True
                        break
            if not flg:
                ans_flg = False
                break
        if not ans_flg:
            break
print('Yes' if ans_flg else 'No')

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

for i in range(H):
    for j in range(W):
        if grid[i][j] == '
            flag = False
            for d in diff:
                if 0 <= i + d[0] < H and 0 <= j + d[1] < W:
                    if grid[i+d[0]][j+d[1]] =='
                        flag = True
            if not flag:
                print('No')
                exit()
print('Yes')

Solution (Python):
import sys

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

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


for r in range(H):
    for line in range(W):
        
        if(A[r][line] != "
            continue

        

        if(line == 0 or W == 1):
            L = False
        else:
            L = A[r][line - 1] == "

        if(r == 0 or H == 1):
            U = False
        else:
            U = A[r - 1][line] == "

        if(line == W - 1 or W == 1):
            R = False
        else:
            R = A[r][line + 1] == "

        if(r == H - 1 or H == 1):
            D = False
        else:
            D = A[r + 1][line] == "

        
        
        if((L or U or R or D) is False):
            print("No")
            sys.exit()

print("Yes")

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

def countSharp(x,y):
    res = 0
    if x!=0:
        res += s[x-1][y]=='
    if y!=0:
        res += s[x][y-1]=='
    if x!=h-1:
        res += s[x+1][y]=='
    if y!=w-1:
        res += s[x][y+1]=='
    return res

flag = [[False for _ in range(w)] for oijqd in range(h)]
for i,l in enumerate(s):
    for j,c in enumerate(l):
        if c=='.':
            flag[i][j] = True

for i in range(h):
    for j in range(w):
        if s[i][j]=='
            flag[i][j] = True
            if i!=0:
                flag[i-1][j] = True
            if j!=0:
                flag[i][j-1] = True
            if i!=h-1:
                flag[i+1][j] = True
            if j!=w-1:
                flag[i][j+1] = True

res = True
for l in flag:
    if False in l:
        res = False
        break

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

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

for i in range(h):
    for j in range(w):
        if s_list[i][j] == '
            flag = False
            for dy in range(-1, 2):
                for dx in range(-1, 2):
                    
                    if dy == 0 and dx == 0:
                        continue
                    
                    if dy == 0 or dx == 0:
                        ny = dy + i
                        nx = dx + j
                        
                        if ny < 0 or nx < 0 or ny >= h or nx >= w:
                            continue
                        
                        if s_list[ny][nx] == '
                            flag = True
                            break
                if flag:
                    break
            
            if not flag:
                print('No')
                exit()
print('Yes')

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

for i in range(h):
    for j in range(w):
        ss[i+1][j+1]=s[i][j]

flag = 1

for i in range(h):
    for j in range(w):
        if ss[i+1][j+1]=="
            if ss[i][j+1]=="." and ss[i+2][j+1]=="." and ss[i+1][j]=="." and ss[i+1][j+2]==".":
                flag = 0
                break
                
if flag==1:
    print("Yes")
else:
    print("No")

Solution (Python):
H,W = map(int, input().split())
m = [list(input()) for _ in range(H)]
for r in range(H):
  for c in range(W-1):
    if m[r][c] != '.' and m[r][c+1] != '.':
      m[r][c],m[r][c+1] = '*','*'
for c in range(W):
  for r in range(H-1):
    if m[r][c] != '.' and m[r+1][c] != '.':
      m[r][c],m[r+1][c] = '*','*'
c = sum([sum([1 if m[r][c] == r'
print('No' if c else 'Yes')

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

bk = '
wt = '.'

for r in range(h):
    for c in range(w):
        if M[r][c] == bk:
            flg = False
            for dx, dy in [(-1, 0), (0, -1), (1, 0), (0, 1)]:
                r2 = r + dy
                c2 = c + dx
                if (0 <= r2 < h) and (0 <= c2 < w):
                    if M[r2][c2] == bk:
                        flg = True
                        break
            if not flg:
                print('No')
                exit()
print('Yes')

Solution (Python):
h, w = map(int, input().split())
s = [[] for i in range(h+2)]
s[0] = '.'*(w+2)
for i in range(1, h+1):
    s[i] = '.' + input() + '.'
s[h+1] = '.'*(w+2)
s2 = [[False for j in range(w)] for i in range(h)]
judge = True
for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == "
            if [s[i+1][j], s[i-1][j], s[i][j-1], s[i][j+1]] \
            == ['.', '.', '.', '.']:
                judge = False

        else:
            continue
        if not judge:
            break
    if not judge:
        break
if judge:
    print('Yes')
else:
    print('No')

Solution (Python):

line = input().split(" ")
h = int(line[0])
w = int(line[1])

s = []

for _ in range(h):
    s.append(input())

diff = [
    [0,1]
    ,[0,-1]
    ,[1,0]
    ,[-1,0]
]
for hi in range(h):
    for wi in range(w):
        if s[hi][wi]=="
            flag = False
            for d in diff:
                if h>hi+d[0]>=0 and w>wi+d[1]>=0:
                    if s[hi+d[0]][wi+d[1]]=="
                        flag = True
            if not flag:
                print("No")
                exit()

print("Yes")

Solution (Python):
def main():
  t = input().split(" ")
  H, W = int(t[0]), int(t[1])
  
  s = ["."*(W+2)]
  for i in range(H):
    t = input().strip()
    s.append("".join(['.', t, '.']))
  s.append("."*(W+2))
  flag = True
  for i in range(H):
    for j in range(W):
      if s[i+1][j+1] == '
        if s[i][j+1]=='.' and s[i+2][j+1]=='.' and s[i+1][j]=='.' and s[i+1][j+2]=='.':
          flag = False
  if flag:
    print("Yes")
  else:
    print("No")
main()

Solution (Python):


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


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

    for y in range(H):
        for x in range(W):
            if field[y][x] == "
                ok = False
                for i in range(4):
                    ny = y + dy4[i]
                    nx = x + dx4[i]

                    if inside(ny, nx, H, W) and field[ny][nx] == "
                        ok = True

                if not ok:
                    print(No)
                    return
    print(Yes)

if __name__ == '__main__':
    main()

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

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

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

print(f())

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

Solution (Python):

"""
Created on Tue Aug  7 23:17:21 2018

@author: Yuki
"""


def check_good(S, w, h, W, H):
    upper_flag = True
    down_flag = True
    left_flag = True
    right_flag = True
    if w == 0:
        left_flag = False
    if w == W - 1:
        right_flag = False
    if h == 0:
        upper_flag = False
    if h == H - 1:
        down_flag = False
    tmp = []
    if left_flag:
        tmp.append(S[h][w-1] == '
    if right_flag:
        tmp.append(S[h][w+1] == '
    if upper_flag:
        tmp.append(S[h-1][w] == '
    if down_flag:
        tmp.append(S[h+1][w] == '
    return sum(tmp)
def main():
    H, W = map(int, input().split())
    S = []
    for i in range(H):
        S.append(input())
    
    Yes_flag = True
    for w in range(W):
        for h in range(H):
            if S[h][w] == '
                res = check_good(S, w, h, W, H)
                if res == 0:
                    Yes_flag = False

            if Yes_flag == False:
                break
        if Yes_flag == False:
            break
    if Yes_flag:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

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

grid = np.zeros((H, W), dtype=int)

for h in range(H):
    S = input()
    for i, s in enumerate(S):
        if s == '
            grid[h][i] = 1




def is_safe(h, w):
    ns = []
    ns.append((h-1, w))
    ns.append((h, w-1))
    ns.append((h+1, w))
    ns.append((h, w+1))

    safe = False
    for n in ns:
        if 0 <= n[0] and n[0] < H \
           and 0 <= n[1] and n[1] < W \
           and grid[n[0]][n[1]] == 1:
            safe = True

    if safe is False:
        print("No")
        exit(0)

    
for h in range(H):
    for w in range(W):
        if grid[h][w] == 1:
            is_safe(h, w)

print("Yes")
exit(0)

Solution (Python):
r, c = (int(x) for x in raw_input().split())
g = [raw_input() for _ in xrange(r)]
pts = [(i, j) for i in xrange(r) for j in xrange(c) if g[i][j] == '
good_pts = [(i,j) for (i,j) in pts if (i+1,j) in pts or (i-1,j) in pts or (i,j-1) in pts or (i,j+1) in pts]
print "Yes" if len(pts) == len(good_pts) else "No"

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(10000)


def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))


def to_bin(x):
    return bin(x)[2:]



dp = None

def main():
    H, W = map(int, input().split())
    S = []
    Dx, Dy = [-1, 0, 0, 1], [0, -1, 1, 0]

    for i in range(H):
        S.append(input())

    for i in range(H):
        for j in range(W):
            if S[i][j] == "
                flg = False
                for dx, dy in zip(Dx, Dy):
                    x = i + dx
                    y = j + dy

                    if not (0 <= x < H and 0 <= y < W):
                        continue

                    if S[x][y] == "
                        flg = True
                        break
                
                if not flg:
                    print("No")
                    sys.exit()
    
    print("Yes")


main()

Solution (Python):
H, W = map(int, input().split())
input_list = []
for i in range(H):
    input_list.append(input())
def contain_sharp(x, y):
    if input_list[y][x] == ".": return True
    dxy = [[0,1], [0, -1], [1,0],[-1,0]]
    for dx,dy in dxy:
        if 0<= y + dy < H and 0 <= x + dx < W:
            if input_list[y+dy][x+dx] == "
                return True
    else :
        return False


for y in range(H):
    for x in range(W):
        if not contain_sharp(x,y):
            print("No")
            exit()
print("Yes")

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

graph = [[] for _ in range(H+2)]
graph[0].extend(["." for i in range(W+2)])
for h in range(H):
    graph[h+1].append(".")
    graph[h+1].extend(list(input().rstrip()))
    graph[h+1].append(".")
graph[H+1].extend(["." for i in range(W+2)])

canAchieve = True
for h in range(1,H+1):
    for w in range(1,W+1):
        if graph[h][w] == '
            if graph[h+1][w] == "
                continue
            elif graph[h-1][w] == "
                continue
            elif graph[h][w+1] == "
                continue
            elif graph[h][w-1] == "
                continue
            
            canAchieve = False
            
if canAchieve:
    print("Yes")
else:
    print("No")

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

dxy = [(0,1),(1,0),(0,-1),(-1,0)]
def is_isolated(x,y):
    if src[y][x] == '.': return False
    for dx,dy in dxy:
        if not 0 <= x+dx < W: continue
        if not 0 <= y+dy < H: continue
        if src[y+dy][x+dx] == '
    else:
        return True

for y in range(H):
    for x in range(W):
        if is_isolated(x,y):
            print('No')
            exit()
print('Yes')

Solution (Python):
def get_adjacent(lists, pos, hw):
	h, w = hw
	x, y = pos
	adjacents = []
	for adjust_y, adjust_x in ((0, 1), (1, 0), (0, -1), (-1, 0)):
		if 0 <= y+adjust_y < h and 0 <= x+adjust_x < w:
			adjacents.append(lists[y+adjust_y][x+adjust_x])
	return adjacents

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

for y in range(h):
	for x in range(w):
		if s[y][x] == "
			if "
				print("No")
				exit()
print("Yes")

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

for y in range(h):
	for x in range(w):
		if s[y][x] == "
			is_have_hash = False
			for adjust_y, adjust_x in ((0, 1), (1, 0), (0, -1), (-1, 0)):
				if 0 <= y+adjust_y < h and 0 <= x+adjust_x < w:
					if s[y+adjust_y][x+adjust_x] == "
						is_have_hash = True
						break
			if not is_have_hash:
				print("No")
				exit()
print("Yes")

Solution (Python):
from itertools import product

H, W = map(int, input().split())
C = ['.' * (W + 2)] + ['.' + input() + '.' for _ in [0] * H] + ['.' * (W + 2)]

ans = True
for i, j in product(range(1, H+1), range(1, W + 1)):
    if C[i][j] == '
            '
        ans = False
        break

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

Solution (Python):
def getinputdata():

    
    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

h = int(arr_data[0][0])
w = int(arr_data[0][1])

arr=[]
for i in range(1,1+h):
    
    arr_temp=[]
    for v in arr_data[i][0]:
        
        arr_temp.append(v)
    
    arr.append(arr_temp)

chkflg=True

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

        if arr[i][j]=="
         
            if i==0 and j==0:
                
                if not(arr[i+1][j]=="
                    
                    chkflg=False
                    break

            elif i==0 and j==w-1:

                if not(arr[i+1][j]=="
                    
                    chkflg=False
                    break


            elif i==0 and 0<j<w-1:

                if not(arr[i+1][j]=="
                    
                    chkflg=False
                    break

            elif i==h-1 and j==0:
                
                if not(arr[i-1][j]=="
                    
                    chkflg=False
                    break

            elif i==h-1 and j==w:

                if not(arr[i-1][j]=="
                    
                    chkflg=False
                    break
                    
            elif i==h and 0<j<w-1:
                
                if not(arr[i-1][j]=="
                    
                    chkflg=False
                    break

            elif 0<i<h-1 and j==0:
                
                if not(arr[i-1][j]=="
                    
                    chkflg=False
                    break

            elif 0<i<h-1 and j==w:

                if not(arr[i-1][j]=="
                    
                    chkflg=False
                    break
                    
            elif 0<i<h-1 and 0<j<w-1:

                if not(arr[i-1][j]=="
                    
                    chkflg=False
                    break
                    
print("Yes" if chkflg else "No")

Solution (Python):
'''input
11 11
...
.




.
.

..
.
'''
from sys import exit
def check(x,y):
	xx = [(0,-1),(0,1),(1,0),(-1,0)]
	flag = False
	for i in xx:
		x1 = x+i[0]
		y1 = y+i[1]
		if x1 < 0 or x1 > h-1 or y1 < 0 or y1 > w-1:
			continue
		else:
			if arr[x1][y1] == '
				flag = True
				break
	return flag
h,w = map(int,raw_input().split())
arr = []
for i in range(h):
	t = list(raw_input().strip())
	arr.append(t)
for i in range(h):
	for j in range(w):
		if arr[i][j] == '
			if not check(i,j):
				print "No"
				exit(0)
print "Yes"

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

s = [list(input()) for i in range(H)]
x = [-1, 0, 1, 0]
y = [0, 1 , 0, -1]
for i in range(H):
    for j in range(W):
        if (s[i][j] == "
            flag = False
            for d in range(4):
                if (i+y[d] >= 0 and i+y[d] < H and j+x[d] >= 0 and j+x[d] < W):
                    if(s[i+y[d]][j+x[d]] == "
                        flag = True
            if (flag == False):
                print("No")
                quit()
print("Yes")