Buggy python submission (verdict: Runtime Error):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    h, w = i_map()
    str_list = s_row_list(w)
    
    for i in range(h):
        for j in range(w):
            if str_list[i][j] == '.':
                continue
            if i != 0:
                if str_list[i-1][j] == '#':
                    continue
            if j != 0:
                if str_list[i][j-1] == '#':
                    continue
            if i != h - 1:
                if str_list[i+1][j] == '#':
                    continue
            if j != w - 1:
                if str_list[i][j+1] == '#':
                    continue
            print('No')
            exit()

    print('Yes')

if __name__ == '__main__':
    main()


Fixed submission:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    h, w = i_map()
    str_list = s_row_list(h)
    
    for i in range(h):
        for j in range(w):
            if str_list[i][j] == '.':
                continue
            if i != 0:
                if str_list[i-1][j] == '#':
                    continue
            if j != 0:
                if str_list[i][j-1] == '#':
                    continue
            if i != h - 1:
                if str_list[i+1][j] == '#':
                    continue
            if j != w - 1:
                if str_list[i][j+1] == '#':
                    continue
            print('No')
            exit()

    print('Yes')

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    h, w = i_map()
    str_list = s_row_list(w)
    
    for i in range(h):
        for j in range(w):
            if str_list[i][j] == '.':
                continue
            if i != 0:
                if str_list[i-1][j] == '#':
                    continue
            if j != 0:
                if str_list[i][j-1] == '#':
                    continue
            if i != h - 1:
                if str_list[i+1][j] == '#':
                    continue
            if j != w - 1:
                if str_list[i][j+1] == '#':
                    continue
            print('No')
            exit()

    print('Yes')

if __name__ == '__main__':
    main()


Fixed submission:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    h, w = i_map()
    str_list = s_row_list(h)
    
    for i in range(h):
        for j in range(w):
            if str_list[i][j] == '.':
                continue
            if i != 0:
                if str_list[i-1][j] == '#':
                    continue
            if j != 0:
                if str_list[i][j-1] == '#':
                    continue
            if i != h - 1:
                if str_list[i+1][j] == '#':
                    continue
            if j != w - 1:
                if str_list[i][j+1] == '#':
                    continue
            print('No')
            exit()

    print('Yes')

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    h, w = i_map()
    str_list = s_row_list(w)
    
    flag = False

    for i in range(h):
        for j in range(w):
            if str_list[i][j] == '.':
                continue
            if i != 0:
                if str_list[i-1][j] == '#':
                    continue
            if j != 0:
                if str_list[i][j-1] == '#':
                    continue
            if i != h - 1:
                if str_list[i+1][j] == '#':
                    continue
            if j != w - 1:
                if str_list[i][j+1] == '#':
                    continue
            flag = True
            break
        if flag:
            print('No')
            exit()

    print('Yes')

if __name__ == '__main__':
    main()


Fixed submission:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    h, w = i_map()
    str_list = s_row_list(h)
    
    for i in range(h):
        for j in range(w):
            if str_list[i][j] == '.':
                continue
            if i != 0:
                if str_list[i-1][j] == '#':
                    continue
            if j != 0:
                if str_list[i][j-1] == '#':
                    continue
            if i != h - 1:
                if str_list[i+1][j] == '#':
                    continue
            if j != w - 1:
                if str_list[i][j+1] == '#':
                    continue
            print('No')
            exit()

    print('Yes')

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    h, w = i_map()
    str_list = s_row_list(w)
    
    flag = False

    for i in range(h):
        for j in range(w):
            if str_list[i][0][j] == '.':
                continue
            if i - 1 >= 0:
                if str_list[i-1][0][j] == '#':
                    continue
            if j - 1 >= 0:
                if str_list[i][0][j-1] == '#':
                    continue
            if i + 1 < w:
                if str_list[i+1][0][j] == '#':
                    continue
            if j + 1 < h:
                if str_list[i][0][j+1] == '#':
                    continue
            flag = True
            break
        if flag:
            print('No')
            exit()

    print('Yes')

if __name__ == '__main__':
    main()


Fixed submission:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    h, w = i_map()
    str_list = s_row_list(h)
    
    for i in range(h):
        for j in range(w):
            if str_list[i][j] == '.':
                continue
            if i != 0:
                if str_list[i-1][j] == '#':
                    continue
            if j != 0:
                if str_list[i][j-1] == '#':
                    continue
            if i != h - 1:
                if str_list[i+1][j] == '#':
                    continue
            if j != w - 1:
                if str_list[i][j+1] == '#':
                    continue
            print('No')
            exit()

    print('Yes')

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    h, w = i_map()
    str_list = s_row_list(w)
    
    flag = False

    for i in range(h):
        for j in range(w):
            if str_list[i][0][j] == '.':
                continue
            if i - 1 >= 0:
                if str_list[i-1][0][j] == '#':
                    continue
            if j - 1 >= 0:
                if str_list[i][0][j-1] == '#':
                    continue
            if i + 1 < h:
                if str_list[i+1][0][j] == '#':
                    continue
            if j + 1 < w:
                if str_list[i][0][j+1] == '#':
                    continue
            flag = True
            break
        if flag:
            print('No')
            exit()

    print('Yes')

if __name__ == '__main__':
    main()


Fixed submission:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    h, w = i_map()
    str_list = s_row_list(h)
    
    for i in range(h):
        for j in range(w):
            if str_list[i][j] == '.':
                continue
            if i != 0:
                if str_list[i-1][j] == '#':
                    continue
            if j != 0:
                if str_list[i][j-1] == '#':
                    continue
            if i != h - 1:
                if str_list[i+1][j] == '#':
                    continue
            if j != w - 1:
                if str_list[i][j+1] == '#':
                    continue
            print('No')
            exit()

    print('Yes')

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    h, w = i_map()
    str_list = s_row_list(w)
    
    flag = False

    for i in range(h):
        for j in range(w):
            if str_list[i][0][j] == '.':
                continue
            if i - 1 >= 0 and str_list[i-1][0][j] == '#':
                continue
            if j - 1 >= 0 and str_list[i][0][j-1] == '#':
                continue
            if i + 1 < h and str_list[i+1][0][j] == '#':
                continue
            if j + 1 < w and str_list[i][0][j+1] == '#':
                continue
            flag = True
            break
        if flag:
            print('No')
            exit()

    print('Yes')

if __name__ == '__main__':
    main()


Fixed submission:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    h, w = i_map()
    str_list = s_row_list(h)
    
    for i in range(h):
        for j in range(w):
            if str_list[i][j] == '.':
                continue
            if i != 0:
                if str_list[i-1][j] == '#':
                    continue
            if j != 0:
                if str_list[i][j-1] == '#':
                    continue
            if i != h - 1:
                if str_list[i+1][j] == '#':
                    continue
            if j != w - 1:
                if str_list[i][j+1] == '#':
                    continue
            print('No')
            exit()

    print('Yes')

if __name__ == '__main__':
    main()