Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
lists = [input() for i in range(H)]
x = 1
y = 1
check = True
while(x<W-1 and y<H-1):
    if(lists[x][y] == "#"):
        if(x!=0 or y!=0 or x==W-1or y==H-1):
            if((lists[x+1][y] == ".") and (lists[x-1][y] == ".") and (lists[x][y-1] == ".") and (lists[x][y+1] == ".")):
                check = False
    x = x+1
    if(x <=W-1):
        x = 1
        y = y+1
if(lists[0][0] == "#"):
     if(lists[0][1] == "." and lists[1][0] == "."):
        check = False
if(lists[H-1][0] == "#"):
     if(lists[H-2][0] == "." and lists[H-1][1] == "."):
            check = False
if(lists[0][W-1] == "#"):
    if(lists[0][W-2] == "." and lists[1][W-1] == "."):
        check = False
if(lists[H-1][W-1] == "#"):
    if(lists[H-2][W-1] == "." and lists[H-1][W-2] == "."):
        check = False
if(check):
    print("Yes")
else :
    print("No")

Fixed submission:
H,W = map(int,input().split())
lists = [input() for i in range(H)]
x = 1
y = 1
check = True
for x in range(1,H-1):
    for y in range(1,W-1):
        if(lists[x][y] == "#"):
            if(x!=0 or y!=0 or x==W-1or y==H-1):
                if((lists[x+1][y] == ".") and (lists[x-1][y] == ".") and (lists[x][y-1] == ".") and (lists[x][y+1] == ".")):
                    check = False
if(lists[0][0] == "#"):
     if(lists[0][1] == "." and lists[1][0] == "."):
        check = False
if(lists[H-1][0] == "#"):
     if(lists[H-2][0] == "." and lists[H-1][1] == "."):
            check = False
if(lists[0][W-1] == "#"):
    if(lists[0][W-2] == "." and lists[1][W-1] == "."):
        check = False
if(lists[H-1][W-1] == "#"):
    if(lists[H-2][W-1] == "." and lists[H-1][W-2] == "."):
        check = False
if(check):
    print("Yes")
else :
    print("No")

Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
lists2 = [input() for i in range(W)]
x = 1
y = 1
check = True
while(x<W-1 and y<H-1):
    if(lists2[x][y] == "#"):
        if(x!=0 or y!=0 or x==W-1or y==H-1):
            if((lists2[x+1][y] == ".") and (lists2[x-1][y] == ".") and (lists2[x][y-1] == ".") and (lists2[x][y+1] == ".")):
                check = False
    x = x+1
    y = y+1
if(check):
    print("Yes")
else :
    print("No")

Fixed submission:
H,W = map(int,input().split())
lists = [input() for i in range(H)]
x = 1
y = 1
check = True
for x in range(1,H-1):
    for y in range(1,W-1):
        if(lists[x][y] == "#"):
            if(x!=0 or y!=0 or x==W-1or y==H-1):
                if((lists[x+1][y] == ".") and (lists[x-1][y] == ".") and (lists[x][y-1] == ".") and (lists[x][y+1] == ".")):
                    check = False
if(lists[0][0] == "#"):
     if(lists[0][1] == "." and lists[1][0] == "."):
        check = False
if(lists[H-1][0] == "#"):
     if(lists[H-2][0] == "." and lists[H-1][1] == "."):
            check = False
if(lists[0][W-1] == "#"):
    if(lists[0][W-2] == "." and lists[1][W-1] == "."):
        check = False
if(lists[H-1][W-1] == "#"):
    if(lists[H-2][W-1] == "." and lists[H-1][W-2] == "."):
        check = False
if(check):
    print("Yes")
else :
    print("No")

Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
lists = [input() for i in range(W)]
x = 1
y = 1
for i in range(H):
    lists[i] = list(lists[i])
lists1 = []
lists2 = []
for i in range(W+1):
    lists1.append(".")
for i in range(W+1):
    lists2.append(".")
for i in range(H):
    lists[i].append(".")
lists2 = lists
check = True
while(x<W-1 and y<H-1):
    if(lists2[x][y] == "#"):
        if(x!=0 or y!=0 or x==W-1or y==H-1):
            if((lists2[x+1][y] == ".") and (lists2[x-1][y] == ".") and (lists2[x][y-1] == ".") and (lists2[x][y+1] == ".")):
                check = False
    x = x+1
    y = y+1
if(check):
    print("Yes")
else :
    print("No")

Fixed submission:
H,W = map(int,input().split())
lists = [input() for i in range(H)]
x = 1
y = 1
check = True
for x in range(1,H-1):
    for y in range(1,W-1):
        if(lists[x][y] == "#"):
            if(x!=0 or y!=0 or x==W-1or y==H-1):
                if((lists[x+1][y] == ".") and (lists[x-1][y] == ".") and (lists[x][y-1] == ".") and (lists[x][y+1] == ".")):
                    check = False
if(lists[0][0] == "#"):
     if(lists[0][1] == "." and lists[1][0] == "."):
        check = False
if(lists[H-1][0] == "#"):
     if(lists[H-2][0] == "." and lists[H-1][1] == "."):
            check = False
if(lists[0][W-1] == "#"):
    if(lists[0][W-2] == "." and lists[1][W-1] == "."):
        check = False
if(lists[H-1][W-1] == "#"):
    if(lists[H-2][W-1] == "." and lists[H-1][W-2] == "."):
        check = False
if(check):
    print("Yes")
else :
    print("No")