Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define ppi pair<int, int>
#define endl "\n"
#define nl cout << "\n"
#define deb(x) cout << #x << " " << x << endl;

const int N = 1010;
const int mod = 1e9 + 7;
int H, W;
char grid[N][N];

// dp[i][j] = #Ways to reach from (i, j) to (H, W)
int dp[N][N];

int Top_Down(int x = 1, int y = 1) {
    // Base Case
    if(x == H && y == W) return (dp[x][y] = 1);
    // Choice
    if(dp[x][y] != -1) return dp[x][y];
    int ways = 0;
    if(x <= H && grid[x+1][y] == '.') ways += Top_Down(x+1, y)%(mod);
    if(y <= W && grid[x][y+1] == '.') ways += Top_Down(x, y+1)%(mod);
    return (dp[x][y]=ways%(mod));
}

int32_t main() {
    IOS;
    memset(dp, -1, sizeof(dp));
    cin >> H >> W;
    for(int i = 1; i <= H; ++i) 
        for(int j = 1; j <= W; ++j) {
            cin >> grid[i][j];
        }
    //
    for(int i = 1; i <= H; ++i){
        for(int j = 1; j <= W; ++j)
            if((i == H and j == W) and grid[i][j]=='.') dp[i][j] = 1;
    }
    cout << Top_Down()%(mod) << endl;
    // for(int i = 1; i <= H; ++i){
    //     for(int j = 1; j <= W; ++j) cout << dp[i][j] << " ";
    //     cout << endl;
    // }
}

Fixed submission:
n ,m = map(int,input().split())

grid = []

for i in range(n):
  temp = list(input())
  grid.append(temp)
  
#dp[n][m]
mod = 10**9+7
dp = [[0 for i in range(m)] for j in range(n)]
dp[0][0] = 1

for i in range(n):
  for j in range(m):
    if grid[i][j]=='#':
      continue
    if i>0:
      dp[i][j] += dp[i-1][j]%mod
    if j>0:
      dp[i][j] +=dp[i][j-1]%mod
      
print(dp[n-1][m-1]%mod)

Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define ppi pair<int, int>
#define endl "\n"
#define nl cout << "\n"
#define deb(x) cout << #x << " " << x << endl;

const int N = 1010;
const int mod = 1e9 + 7;
int H, W;
char grid[N][N];

// dp[i][j] = #Ways to reach from (i, j) to (H, W)
int dp[N][N];

int Top_Down(int x = 1, int y = 1) {
    // Base Case
    if(x == H && y == W) return (dp[x][y] = 1);
    // Choice
    if(dp[x][y] != -1) return dp[x][y];
    int ways = 0;
    if(x <= H && grid[x+1][y] == '.') ways += Top_Down(x+1, y)%(mod);
    if(y <= W && grid[x][y+1] == '.') ways += Top_Down(x, y+1)%(mod);
    return (dp[x][y]=ways%(mod));
}

int32_t main() {
    IOS;
    memset(dp, -1, sizeof(dp));
    cin >> H >> W;
    for(int i = 1; i <= H; ++i) 
        for(int j = 1; j <= W; ++j) {
            cin >> grid[i][j];
        }
    //
    for(int i = 1; i <= H; ++i){
        for(int j = 1; j <= W; ++j)
            if((i == H and j == W) and grid[i][j]=='.') dp[i][j] = 1;
    }
    cout << Top_Down()%(mod) << endl;
    // for(int i = 1; i <= H; ++i){
    //     for(int j = 1; j <= W; ++j) cout << dp[i][j] << " ";
    //     cout << endl;
    // }
}

Fixed submission:
n ,m = map(int,input().split())

grid = []

for i in range(n):
  temp = list(input())
  grid.append(temp)
  
#dp[n][m]
mod = 10**9+7
dp = [[0 for i in range(m)] for j in range(n)]
dp[0][0] = 1

for i in range(n):
  for j in range(m):
    if grid[i][j]=='#':
      continue
    if i>0:
      dp[i][j] += dp[i-1][j]%mod
    if j>0:
      dp[i][j] +=dp[i][j-1]%mod
      
print(dp[n-1][m-1]%mod)