Buggy python submission (verdict: Runtime Error):
import sys


def find_paths(mat, n, m):

    for i in range(n):

        if mat[i][0] != "#":
            dp[i][0] = 1

        else:
            break

    for j in range(m):

        if mat[0][j] != "#":
            dp[0][j] = 1

        else:
            break

    dp[0][0] = 0

    for i in range(1, n):
        for j in range(1, m):
            if mat[i][j] == "#":
                dp[i][j] = 0

            else:
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1]

    # print(dp)
    return int(dp[n - 1][m - 1] % (1e9+7))



n, m = list(map(int, sys.stdin.readline().split()))

mat = []
dp = [[0 for i in range(1001)] for j in range(1001)]

for i in range(n):
    mat.append([ch for ch in sys.stdin.readline().strip()])

# print(mat)
print(find_paths(mat, n, m))


Fixed submission:
h, w = map(int, input().split())

mat = []
dp = []
m = 10**9+7

for i in range(h):
    mat.append(list(input()))
    dp.append(list([0]*w))

dp[0][0] = 1


for x in range(h):
    for y in range(w):

        if x != 0 or y != 0:
            if mat[x][y] == "#":
                dp[x][y] = 0

            else:
                dp[x][y] += (dp[x - 1][y] + dp[x][y - 1]) % m

print(dp[h - 1][w - 1])

Buggy python submission (verdict: Runtime Error):
import sys


def find_paths(mat, n, m, i, j, dp):

    if i == n - 1 and j == m - 1:
        return 1

    if i >= n or j >= m:
        return 0

    if mat[i][j] == "#":
        return 0

    if (i, j) in dp:
        return dp[(i, j)]

    dp[(i, j)] = int((find_paths(mat, n, m, i+1, j, dp) + find_paths(mat, n, m, i, j+1, dp)) % (1e9 + 7))
    return dp[(i, j)]



n, m = list(map(int, sys.stdin.readline().split()))

mat = []

for i in range(n):
    mat.append([ch for ch in sys.stdin.readline().strip()])


dp = {}
# print(mat)
print(find_paths(mat, n, m, 0, 0, dp))


Fixed submission:
h, w = map(int, input().split())

mat = []
dp = []
m = 10**9+7

for i in range(h):
    mat.append(list(input()))
    dp.append(list([0]*w))

dp[0][0] = 1


for x in range(h):
    for y in range(w):

        if x != 0 or y != 0:
            if mat[x][y] == "#":
                dp[x][y] = 0

            else:
                dp[x][y] += (dp[x - 1][y] + dp[x][y - 1]) % m

print(dp[h - 1][w - 1])

Buggy python submission (verdict: Runtime Error):
import sys


def find_paths(mat, n, m):

    dp = [[0 for i in range(m)] for j in range(n)]

    for i in range(n):

        if mat[i][0] != "#":
            dp[i][0] = 1

        else:
            break

    for j in range(m):

        if mat[0][j] != "#":
            dp[0][j] = 1

        else:
            break

    dp[0][0] = 0


    for i in range(1, n):
        for j in range(1, m):
            if mat[i][j] == "#":
                dp[i][j] = 0

            else:
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1]

    # print(dp)
    return int(dp[n - 1][m - 1] % (1e9+7))



n, m = list(map(int, sys.stdin.readline().split()))

mat = []

for i in range(n):
    mat.append([ch for ch in sys.stdin.readline().strip()])


dp = {}
# print(mat)
print(find_paths(mat, n, m))


Fixed submission:
h, w = map(int, input().split())

mat = []
dp = []
m = 10**9+7

for i in range(h):
    mat.append(list(input()))
    dp.append(list([0]*w))

dp[0][0] = 1


for x in range(h):
    for y in range(w):

        if x != 0 or y != 0:
            if mat[x][y] == "#":
                dp[x][y] = 0

            else:
                dp[x][y] += (dp[x - 1][y] + dp[x][y - 1]) % m

print(dp[h - 1][w - 1])