Problem p03167 (C++)

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

void fst() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
#endif
}
int nxt() {
  int x;
  cin >> x;
  return x;
}
int nex_l() {
  long long x;
  cin >> x;
  return x;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

#define fr first
#define sc second
#define pb push_back
#define all(v) v.begin(), v.end()
#define binary(n) cout << bitset<31>(n) << "\n";
#define FOR(i, n) for (int i = 0; i < n; i++)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define input_arr(a, n)                                                        \
  for (int i = 0; i < n; i++)                                                  \
    cin >> a[i];
#define print_arr(a, n)                                                        \
  for (int i = 0; i < n; i++)                                                  \
    cout << a[i] << " ";
const int MOD = 1e9 + 7;

int main() {
  fst();
  int h = nxt(), w = nxt();
  vector<string> in(h);
  rep(i, 0, h) cin >> in[i];
  vvi dp(h + 1, vi(w + 1, 0));
  dp[1][1] = 1;
  rep(i, 1, h + 1) {
    rep(j, 1, w + 1) {
      if (i > 1)
        if (in[i - 2][j - 1] != '#' && in[i - 1][j - 1] != '#')
          dp[i][j] += dp[i - 1][j];

      if (j > 1)
        if (in[i - 1][j - 2] != '#' && in[i - 1][j - 1] != '#')
          dp[i][j] += dp[i][j - 1];
      dp[i][j] = dp[i][j] % MOD;
    }
  }
  cout << dp[h][w];
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

void fst() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
#endif
}
int nxt() {
  int x;
  cin >> x;
  return x;
}
int nex_l() {
  long long x;
  cin >> x;
  return x;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

#define fr first
#define sc second
#define pb push_back
#define all(v) v.begin(), v.end()
#define binary(n) cout << bitset<31>(n) << "\n";
#define FOR(i, n) for (int i = 0; i < n; i++)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define input_arr(a, n)                                                        \
  for (int i = 0; i < n; i++)                                                  \
    cin >> a[i];
#define print_arr(a, n)                                                        \
  for (int i = 0; i < n; i++)                                                  \
    cout << a[i] << " ";
const int MOD = 1e9 + 7;

int main() {
  // fst();
  int h = nxt(), w = nxt();
  vector<string> in(h);
  rep(i, 0, h) cin >> in[i];
  vvi dp(h + 1, vi(w + 1, 0));
  dp[1][1] = 1;
  rep(i, 1, h + 1) {
    rep(j, 1, w + 1) {
      if (i > 1)
        if (in[i - 2][j - 1] != '#' && in[i - 1][j - 1] != '#')
          dp[i][j] += dp[i - 1][j];

      if (j > 1)
        if (in[i - 1][j - 2] != '#' && in[i - 1][j - 1] != '#')
          dp[i][j] += dp[i][j - 1];
      dp[i][j] = dp[i][j] % MOD;
    }
  }
  cout << dp[h][w];
}