Problem p03167 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long int
#define pb push_back
#define fi(n) for (int i = 0; i < n; i++)
#define fi1(n) for (int i = 1; i < n; i++)
#define fj(n) for (int j = 0; j < n; j++)
#define rep(z, a, n) for (z = a; z < n; z++)
#define rep2(z, a, n) for (z = a; z < n; z += 2)
#define clr(x) memset(x, 0, sizeof(x))
#define print(x, n)                                                            \
  for (int i = 0; i < n; i++)                                                  \
    cout << x[i] << " ";                                                       \
  cout << "\n"
#define nl "\n"
#define vi vector<int>
#define mp make_pair
#define pairi pair<int, int>
#define vpairi vector<pair<int, int>>
#define ff first
#define ss second
#define inf 2e18
#define input                                                                  \
  "C://Users//Piyush Aggarwal//Documents//Cpp files//input-output//input.txt"
#define output                                                                 \
  "C://Users//Piyush Aggarwal//Documents//Cpp files//input-output//output.txt"
#define error                                                                  \
  "C://Users//Piyush Aggarwal//Documents//Cpp files//input-output//error.txt"

int ctoi(char a) {
  int x = a - 48;
  return x;
}
string itos(int a) {
  string out_string;
  stringstream ss;
  ss << a;
  out_string = ss.str();
  return out_string;
}
char itoc(int a) { return itos(a)[0]; }
int pow(int e, int x) {
  int ans = 1;
  while (x > 0) {
    if (x & 1)
      ans *= e;
    e *= e;
    x >>= 1;
  }
  return ans;
}
string bin(int x) {
  bitset<sizeof(1) * CHAR_BIT> bits(x);
  string b = bits.to_string();
  return b;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen(input, "r", stdin);
  freopen(output, "w", stdout);
  freopen(error, "w", stderr);
#endif
  int T = 1;
  // cin>>T;
  while (T--) {
    int n, k, m, x, y;
    cin >> n >> m;
    // int a[n];clr(a);
    int a[n][m];
    clr(a);
    char c[n][m];
    fi(n) { fj(m) cin >> c[i][j]; }
    fi(n) {
      fj(m) {
        if (i == 0 && j == 0) {
          a[i][j] = 1;
        } else if (i == 0) {
          if (c[i][j] == '.')
            a[i][j] = a[i][j - 1];
        } else if (j == 0) {
          if (c[i][j] == '.')
            a[i][j] = a[i - 1][j];
        } else {
          if (c[i][j] == '.')
            a[i][j] = (a[i - 1][j] + a[i][j - 1]) % 1000000007;
        }
      }
    }
    cout << a[n - 1][m - 1] << nl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long int
#define pb push_back
#define fi(n) for (int i = 0; i < n; i++)
#define fi1(n) for (int i = 1; i < n; i++)
#define fj(n) for (int j = 0; j < n; j++)
#define rep(z, a, n) for (z = a; z < n; z++)
#define rep2(z, a, n) for (z = a; z < n; z += 2)
#define clr(x) memset(x, 0, sizeof(x))
#define print(x, n)                                                            \
  for (int i = 0; i < n; i++)                                                  \
    cout << x[i] << " ";                                                       \
  cout << "\n"
#define nl "\n"
#define vi vector<int>
#define mp make_pair
#define pairi pair<int, int>
#define vpairi vector<pair<int, int>>
#define ff first
#define ss second
#define inf 2e18
#define input                                                                  \
  "C://Users//Piyush Aggarwal//Documents//Cpp files//input-output//input.txt"
#define output                                                                 \
  "C://Users//Piyush Aggarwal//Documents//Cpp files//input-output//output.txt"
#define error                                                                  \
  "C://Users//Piyush Aggarwal//Documents//Cpp files//input-output//error.txt"

int ctoi(char a) {
  int x = a - 48;
  return x;
}
string itos(int a) {
  string out_string;
  stringstream ss;
  ss << a;
  out_string = ss.str();
  return out_string;
}
char itoc(int a) { return itos(a)[0]; }
int pow(int e, int x) {
  int ans = 1;
  while (x > 0) {
    if (x & 1)
      ans *= e;
    e *= e;
    x >>= 1;
  }
  return ans;
}
string bin(int x) {
  bitset<sizeof(1) * CHAR_BIT> bits(x);
  string b = bits.to_string();
  return b;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
#endif
  int T = 1;
  // cin>>T;
  while (T--) {
    int n, k, m, x, y;
    cin >> n >> m;
    // int a[n];clr(a);
    int a[n][m];
    clr(a);
    char c[n][m];
    fi(n) { fj(m) cin >> c[i][j]; }
    fi(n) {
      fj(m) {
        if (i == 0 && j == 0) {
          a[i][j] = 1;
        } else if (i == 0) {
          if (c[i][j] == '.')
            a[i][j] = a[i][j - 1];
        } else if (j == 0) {
          if (c[i][j] == '.')
            a[i][j] = a[i - 1][j];
        } else {
          if (c[i][j] == '.')
            a[i][j] = (a[i - 1][j] + a[i][j - 1]) % 1000000007;
        }
      }
    }
    cout << a[n - 1][m - 1] << nl;
  }
  return 0;
}