Problem p03167 (C++)

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

using namespace std;

#define fto(i, s, e) for (int i = s; i <= e; ++i)
#define fto1(i, s, e) for (int i = s; i < e; ++i)
#define fdto(i, s, e) for (int i = s; i >= e; --i)
#define fit(var, it)                                                           \
  for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define frit(var, it)                                                          \
  for (__typeof(var.rbegin()) it = var.rbegin(); it != var.rend(); ++it)

#define newl '\n'
#define debugt cerr << 0.001 * clock() << newl
#define debug1(x, i) cout << #x << '[' << i << "] = " << x[i] << newl
#define debug(v, l, r) fto(_i, l, r) debug1(v, _i)
#define debug2(x, i, j)                                                        \
  cout << #x << '[' << i << "][" << j << "] = " << x[i][j] << newl
#define debug3(x, i, j, k)                                                     \
  cout << #x << '[' << i << "][" << j << "][" << k << "] = " << x[i][j][k]     \
       << newl

#define ll long long
#define ii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define glen(v) int((v).size())

template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> const &v) {
  return os << '(' << v.ff << ", " << v.ss << ')';
}

#define eps 1e-15
#define oo 1000000007
#define OO 1000000000000000003LL
#define maxn 103

int n, m;
int f[maxn][maxn];
char a[maxn][maxn];

int main() {
#ifndef ONLINE_JUDGE
  // freopen("main.inp", "r", stdin);
  // freopen("main.out", "w", stdout);
#endif
  // ios_base::sync_with_stdio(0); cin.tie(0);

  scanf("%d%d", &n, &m);

  fto(i, 1, n) {
    scanf("%*c");
    fto(j, 1, m) { scanf("%c", &a[i][j]); }
  }

  f[1][1] = 1;

  fto(j, 2, m) if (a[1][j] == '.') f[1][j] = f[1][j - 1];
  fto(i, 2, n) if (a[i][1] == '.') f[i][1] = f[i - 1][1];

  fto(i, 2, n) fto(j, 2, m) if (a[i][j] == '.') {
    f[i][j] = f[i - 1][j] + f[i][j - 1];
    f[i][j] %= oo;
  }

  printf("%d\n", f[n][m]);

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define fto(i, s, e) for (int i = s; i <= e; ++i)
#define fto1(i, s, e) for (int i = s; i < e; ++i)
#define fdto(i, s, e) for (int i = s; i >= e; --i)
#define fit(var, it)                                                           \
  for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define frit(var, it)                                                          \
  for (__typeof(var.rbegin()) it = var.rbegin(); it != var.rend(); ++it)

#define newl '\n'
#define debugt cerr << 0.001 * clock() << newl
#define debug1(x, i) cout << #x << '[' << i << "] = " << x[i] << newl
#define debug(v, l, r) fto(_i, l, r) debug1(v, _i)
#define debug2(x, i, j)                                                        \
  cout << #x << '[' << i << "][" << j << "] = " << x[i][j] << newl
#define debug3(x, i, j, k)                                                     \
  cout << #x << '[' << i << "][" << j << "][" << k << "] = " << x[i][j][k]     \
       << newl

#define ll long long
#define ii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define glen(v) int((v).size())

template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> const &v) {
  return os << '(' << v.ff << ", " << v.ss << ')';
}

#define eps 1e-15
#define oo 1000000007
#define OO 1000000000000000003LL
#define maxn 1003

int n, m;
int f[maxn][maxn];
char a[maxn][maxn];

int main() {
#ifndef ONLINE_JUDGE
  // freopen("main.inp", "r", stdin);
  // freopen("main.out", "w", stdout);
#endif
  // ios_base::sync_with_stdio(0); cin.tie(0);

  scanf("%d%d", &n, &m);

  fto(i, 1, n) {
    scanf("%*c");
    fto(j, 1, m) { scanf("%c", &a[i][j]); }
  }

  f[1][1] = 1;

  fto(j, 2, m) if (a[1][j] == '.') f[1][j] = f[1][j - 1];
  fto(i, 2, n) if (a[i][1] == '.') f[i][1] = f[i - 1][1];

  fto(i, 2, n) fto(j, 2, m) if (a[i][j] == '.') {
    f[i][j] = f[i - 1][j] + f[i][j - 1];
    f[i][j] %= oo;
  }

  printf("%d\n", f[n][m]);

  return 0;
}