Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i, a, b) for (signed i = a; i < (b); ++i)
#define erep(i, a, b) for (signed i = a; i <= (b); ++i)
#define per(i, a, b) for (signed i = (a); i > (b); --i)
#define eper(i, a, b) for (signed i = (a); i >= b; --i)
#define fore(i, x, a) for (auto &&x : a)
#define ITR(i, b, e) for (auto i = (b); i != (e); ++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x), end(x)
#define F first
#define S second
#define debug(x) cout << #x << ": " << (x) << '\n';
const long long INF = 1001001001001001001;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
using namespace std;
using Pii = pair<int, int>;
using vii = vector<int>;
template <class T> using PS_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> using vv = vector<T>;
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 <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  fill((T *)array, (T *)(array + N), val);
}
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
struct edge {
  int from, to, cost;
};
int dy[] = {0, 1, -1, 0};
int dx[] = {1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int n, m, dp[100005];
vii a;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  a.resize(m);
  for (int i = 0; i < m; i++) {
    int t;
    cin >> t;
    a[t] = 1;
  }
  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i + 1] + dp[i + 2]) % MOD;
  }
  cout << dp[0] << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i, a, b) for (signed i = a; i < (b); ++i)
#define erep(i, a, b) for (signed i = a; i <= (b); ++i)
#define per(i, a, b) for (signed i = (a); i > (b); --i)
#define eper(i, a, b) for (signed i = (a); i >= b; --i)
#define fore(i, x, a) for (auto &&x : a)
#define ITR(i, b, e) for (auto i = (b); i != (e); ++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x), end(x)
#define F first
#define S second
#define debug(x) cout << #x << ": " << (x) << '\n';
const long long INF = 1001001001001001001;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
using namespace std;
using Pii = pair<int, int>;
using vii = vector<int>;
template <class T> using PS_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> using vv = vector<T>;
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 <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  fill((T *)array, (T *)(array + N), val);
}
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
struct edge {
  int from, to, cost;
};
int dy[] = {0, 1, -1, 0};
int dx[] = {1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int n, m, dp[100005];
vii a;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  a.resize(n);
  for (int i = 0; i < m; i++) {
    int t;
    cin >> t;
    a[t] = 1;
  }
  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i + 1] + dp[i + 2]) % MOD;
  }
  cout << dp[0] << endl;
  return 0;
}