Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)
#define fore(i, a) for (auto &i : a)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define isin(i, a, b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using unit = unsigned;
using ull = unsigned long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vp = vector<P>;
void _main();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  _main();
}
template <class T> void YES(T condition) {
  if (condition)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
template <class T> void Yes(T condition) {
  if (condition)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
template <class T> void POSS(T condition) {
  if (condition)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
}
template <class T> void Poss(T condition) {
  if (condition)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
}
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> T gcd(T a, T b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  constexpr ll MOD = 1'000'000'007;
  int N, M;
  cin >> N >> M;
  v(bool) broken(M + 1);
  rep(i, 0, M) {
    int a;
    cin >> a;
    broken[a] = true;
  }

  vi dp(N + 2);
  dp[N] = 1;
  rrep(i, N - 1, 0) {
    if (broken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i + 1] + dp[i + 2]) % MOD;
  }

  cout << dp[0] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)
#define fore(i, a) for (auto &i : a)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define isin(i, a, b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using unit = unsigned;
using ull = unsigned long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vp = vector<P>;
void _main();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  _main();
}
template <class T> void YES(T condition) {
  if (condition)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
template <class T> void Yes(T condition) {
  if (condition)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
template <class T> void POSS(T condition) {
  if (condition)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
}
template <class T> void Poss(T condition) {
  if (condition)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
}
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> T gcd(T a, T b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  constexpr ll MOD = 1'000'000'007;
  int N, M;
  cin >> N >> M;
  v(bool) broken(N + 1);
  rep(i, 0, M) {
    int a;
    cin >> a;
    broken[a] = true;
  }

  vi dp(N + 2);
  dp[N] = 1;
  rrep(i, N - 1, 0) {
    if (broken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i + 1] + dp[i + 2]) % MOD;
  }

  cout << dp[0] << endl;
}