Problem p03013 (C++)

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll, ll>;
using str = string;
using vpl4 = vector<pair<ll, ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x)                                                                \
  ll(x);                                                                       \
  cin >> (x);
#define stin(x)                                                                \
  str(x);                                                                      \
  cin >> (x);
#define vllin(x, n)                                                            \
  vll(x)(n);                                                                   \
  FOR(i, 0, n - 1) { cin >> (x)[i]; }
#define vllin2(a, b, n)                                                        \
  vll(a)(n);                                                                   \
  vll(b)(n);                                                                   \
  FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i]; }
#define vllin3(a, b, c, n)                                                     \
  vll(a)(n);                                                                   \
  vll(b)(n);                                                                   \
  vll(c)(n);                                                                   \
  FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i] >> (c)[i]; }
#define vlling(x, n)                                                           \
  (x).assign(n, 0);                                                            \
  FOR(i, 0, n - 1) { cin >> (x)[i]; }
#define vlling2(a, b, n)                                                       \
  (a).assign(n, 0);                                                            \
  (b).assign(n, 0);                                                            \
  FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i]; }
#define vlling3(a, b, c, n)                                                    \
  (a).assign(n, 0);                                                            \
  (b).assign(n, 0);                                                            \
  (c).assign(n, 0);                                                            \
  FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i] >> (c)[i]; }
#define vpl4in(x, n)                                                           \
  vpl4(x)((n), mp(0, 0));                                                      \
  FOR(i, 0, n - 1) { cin >> x[i].fi >> x[i].se; }
#define FOR(i, a, b) for (ll i = a; i <= b; i++)
#define rFOR(i, b, a) for (ll i = a; i >= b; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout << (x);
#define sal(x) cout << (x) << endl;
#define says(x) cout << (x) << (' ');
#define sas cout << (' ');
#define sayR(x) cout << fixed << setprecision(10) << (x);
#define salR(x) cout << fixed << setprecision(10) << (x) << endl;
#define yn(a) cout << ((a) ? "yes" : "no") << endl;
#define Yn(a) cout << ((a) ? "Yes" : "No") << endl;
#define YN(a) cout << ((a) ? "YES" : "NO") << endl;
#define Imp(a) cout << ((a) ? "Possible" : "Impossible") << endl;
#define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
#define pow(a, b) ll(pow(a, b))

ll MOD = 1000000007;

signed main() {
  llin(n);
  llin(m);
  vllin(a, m);
  vll c(n, 0);
  if (n == 1) {
    sal(1) return 0;
  }
  c[0] = 1;
  c[1] = 1;
  FOR(i, 2, n) { c[i] = (c[i - 1] + c[i - 2]) % MOD; }
  if (m == 0) {
    sal(c[n]) return 0;
  }
  ll k = c[a[0] - 1];
  FOR(i, 1, m - 1) {
    if (a[i] - a[i - 1] == 1) {
      sal(0) return 0;
    }
    k = (k * c[a[i] - a[i - 1] - 2]) % MOD;
  }
  k = (k * c[n - a[m - 1] - 1]) % MOD;
  sal(k)
}


Fixed submission:
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll, ll>;
using str = string;
using vpl4 = vector<pair<ll, ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x)                                                                \
  ll(x);                                                                       \
  cin >> (x);
#define stin(x)                                                                \
  str(x);                                                                      \
  cin >> (x);
#define vllin(x, n)                                                            \
  vll(x)(n);                                                                   \
  FOR(i, 0, n - 1) { cin >> (x)[i]; }
#define vllin2(a, b, n)                                                        \
  vll(a)(n);                                                                   \
  vll(b)(n);                                                                   \
  FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i]; }
#define vllin3(a, b, c, n)                                                     \
  vll(a)(n);                                                                   \
  vll(b)(n);                                                                   \
  vll(c)(n);                                                                   \
  FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i] >> (c)[i]; }
#define vlling(x, n)                                                           \
  (x).assign(n, 0);                                                            \
  FOR(i, 0, n - 1) { cin >> (x)[i]; }
#define vlling2(a, b, n)                                                       \
  (a).assign(n, 0);                                                            \
  (b).assign(n, 0);                                                            \
  FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i]; }
#define vlling3(a, b, c, n)                                                    \
  (a).assign(n, 0);                                                            \
  (b).assign(n, 0);                                                            \
  (c).assign(n, 0);                                                            \
  FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i] >> (c)[i]; }
#define vpl4in(x, n)                                                           \
  vpl4(x)((n), mp(0, 0));                                                      \
  FOR(i, 0, n - 1) { cin >> x[i].fi >> x[i].se; }
#define FOR(i, a, b) for (ll i = a; i <= b; i++)
#define rFOR(i, b, a) for (ll i = a; i >= b; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout << (x);
#define sal(x) cout << (x) << endl;
#define says(x) cout << (x) << (' ');
#define sas cout << (' ');
#define sayR(x) cout << fixed << setprecision(10) << (x);
#define salR(x) cout << fixed << setprecision(10) << (x) << endl;
#define yn(a) cout << ((a) ? "yes" : "no") << endl;
#define Yn(a) cout << ((a) ? "Yes" : "No") << endl;
#define YN(a) cout << ((a) ? "YES" : "NO") << endl;
#define Imp(a) cout << ((a) ? "Possible" : "Impossible") << endl;
#define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
#define pow(a, b) ll(pow(a, b))

ll MOD = 1000000007;

signed main() {
  llin(n);
  llin(m);
  vllin(a, m);
  vll c(n + 1, 0);
  if (n == 1) {
    sal(1) return 0;
  }
  c[0] = 1;
  c[1] = 1;
  FOR(i, 2, n) { c[i] = (c[i - 1] + c[i - 2]) % MOD; }
  if (m == 0) {
    sal(c[n]) return 0;
  }
  ll k = c[a[0] - 1];
  FOR(i, 1, m - 1) {
    if (a[i] - a[i - 1] == 1) {
      sal(0) return 0;
    }
    k = (k * c[a[i] - a[i - 1] - 2]) % MOD;
  }
  k = (k * c[n - a[m - 1] - 1]) % MOD;
  sal(k)
}