Problem p03013 (C++)

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;

#define rep(i, n)                                                              \
  ;                                                                            \
  for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n", a)
#define mem(a) memset(a, 0, sizeof(a))
#define f(i, a, b) for (int i = a; i < b; i++)
#define pri(a) printf("%.14lf\n", a);
#define MOD 1000000007
bool is_int_lround(double x) { return std::lround(x) == x; }
ll keta(ll x) {
  ll n = 0;
  while (x > 0) {
    x /= 10;
    n++;
  }
  return n;
}

ll conbi(int n, int m) {

  cin >> n >> m;
  vector<ll> a(100);
  a[0] = 1;
  for (int i = 0; i < 14; i++) {
    a[i + 1] = a[i] * (i + 1);
  }
  return a[n] / (a[m] * a[n - m]);
}

long long modpow(long long a, long long n, long long mod) {
  long long res = 1; // 繰り返し二乗法
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll kaijo(ll x) {
  ll z = 1;
  while (x > 0) {
    z *= x;
    z %= MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n) {
  vl yakusu(n + 1, 1);
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      n /= i;
      yakusu[i]++;
    }
  }
  if (n != 1)
    yakusu[n]++;
  ll num = 1;
  for (ll i = 0; i <= n; i++) {
    num *= yakusu[i];
  }
  return num;
}

// cout<<""<<endl;
int main() {
  ll N, M;
  cin >> N >> M;
  vl a(M);
  rep(i, M) cin >> a[i];
  vl b(M + 1);
  b[0] = a[0] - 1;
  b[M] = N - a[M - 1] - 1;
  f(i, 1, M) b[i] = a[i] - a[i - 1] - 2; // 段差の数
  sort(all(b));
  if (b[0] < 0)
    cout << 0 << endl;
  else {
    vl dp(N + 10); // MOD
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;

    f(i, 1, N) { dp[i + 2] = (dp[i + 1] % MOD + dp[i] % MOD) % MOD; }
    ll ans = 1;
    rep(i, M + 1) {
      ans *= dp[b[i]];
      ans %= MOD;
    }
    cout << ans << endl;
  }
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;

#define rep(i, n)                                                              \
  ;                                                                            \
  for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n", a)
#define mem(a) memset(a, 0, sizeof(a))
#define f(i, a, b) for (int i = a; i < b; i++)
#define pri(a) printf("%.14lf\n", a);
#define MOD 1000000007
bool is_int_lround(double x) { return std::lround(x) == x; }
ll keta(ll x) {
  ll n = 0;
  while (x > 0) {
    x /= 10;
    n++;
  }
  return n;
}

ll conbi(int n, int m) {

  cin >> n >> m;
  vector<ll> a(100);
  a[0] = 1;
  for (int i = 0; i < 14; i++) {
    a[i + 1] = a[i] * (i + 1);
  }
  return a[n] / (a[m] * a[n - m]);
}

long long modpow(long long a, long long n, long long mod) {
  long long res = 1; // 繰り返し二乗法
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll kaijo(ll x) {
  ll z = 1;
  while (x > 0) {
    z *= x;
    z %= MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n) {
  vl yakusu(n + 1, 1);
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      n /= i;
      yakusu[i]++;
    }
  }
  if (n != 1)
    yakusu[n]++;
  ll num = 1;
  for (ll i = 0; i <= n; i++) {
    num *= yakusu[i];
  }
  return num;
}

// cout<<""<<endl;
int main() {
  ll N, M;
  cin >> N >> M;
  vl a(M);
  rep(i, M) cin >> a[i];
  vl b(M + 1);
  if (M >= 1) {
    b[0] = a[0] - 1;
    b[M] = N - a[M - 1] - 1;
    f(i, 1, M) b[i] = a[i] - a[i - 1] - 2;
  } else
    b[0] = N; // 段差の数
  sort(all(b));
  if (b[0] < 0)
    cout << 0 << endl;
  else {
    vl dp(N + 10); // MOD
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;

    f(i, 1, N) { dp[i + 2] = (dp[i + 1] % MOD + dp[i] % MOD) % MOD; }
    ll ans = 1;
    rep(i, M + 1) {
      ans *= dp[b[i]];
      ans %= MOD;
    }
    cout << ans << endl;
  }
}