Problem p03013 (C++)

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

#define LLINF (1LL << 60)
typedef long long ll;
#define mod 1000000007

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

template <typename T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T> inline T divrup(T a, T b) {
  if (a % b)
    return a / b + 1;
  else
    return a / b;
}

#define dbg_v1(i, V)                                                           \
  do {                                                                         \
    cout << "-v1----\n";                                                       \
    rep(i, V.size()) cout << " " << i << "\t:" << V[i] << endl;                \
    cout << endl;                                                              \
  } while (0)
#define dbg_v2(i, k, V)                                                        \
  do {                                                                         \
    cout << "-v2----\n";                                                       \
    rep(i, V.size()) {                                                         \
      rep(k, V[0].size()) cout << " " << V[i][k];                              \
      cout << endl;                                                            \
    }                                                                          \
  } while (0)

// C++14 (GCC 5.4.1)
int main() {
  int N, M;
  cin >> N >> M;
  bool is = false;

  if (M <= 0) {
    M = 1;
    is = true;
  }

  vector<int> A(M);
  if (is) {
    A[0] = -1;
  } else {
    rep(i, M) cin >> A.at(i);
  }

  //-----------------------------------
  int acnt = 0;
  vector<ll> HOW(N + 1);
  HOW.at(0) = 1;
  if (A.at(acnt) == 1) {
    HOW.at(1) = 0;
    acnt++;
  } else {
    HOW.at(1) = 1;
  }
  repd(i, 2, N + 1) { // 2toN
    if (A.at(acnt) == i) {
      HOW.at(i) = 0;
      while (acnt < M && A.at(acnt) <= i)
        acnt++;
      if (acnt >= M)
        acnt = 0;
    } else {
      HOW.at(i) = (HOW.at(i - 1) + HOW.at(i - 2)) % mod;
    }
  }

  cout << HOW[N] << endl;
  return (0);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

#define LLINF (1LL << 60)
typedef long long ll;
#define mod 1000000007

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

template <typename T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T> inline T divrup(T a, T b) {
  if (a % b)
    return a / b + 1;
  else
    return a / b;
}

#define dbg_v1(i, V)                                                           \
  do {                                                                         \
    cout << "-v1----\n";                                                       \
    rep(i, V.size()) cout << " " << i << "\t:" << V[i] << endl;                \
    cout << endl;                                                              \
  } while (0)
#define dbg_v2(i, k, V)                                                        \
  do {                                                                         \
    cout << "-v2----\n";                                                       \
    rep(i, V.size()) {                                                         \
      rep(k, V[0].size()) cout << " " << V[i][k];                              \
      cout << endl;                                                            \
    }                                                                          \
  } while (0)

// C++14 (GCC 5.4.1)
int main() {
  int N, M;
  cin >> N >> M;
  bool is = false;

  if (M <= 0) {
    M = 1;
    is = true;
  }

  vector<int> A(M);
  if (is) {
    A[0] = -1;
  } else {
    rep(i, M) cin >> A.at(i);
  }
  A.push_back(INT_MAX);

  //-----------------------------------
  int acnt = 0;
  vector<ll> HOW(N + 1);
  HOW.at(0) = 1;
  if (A.at(acnt) == 1) {
    HOW.at(1) = 0;
    acnt++;
  } else {
    HOW.at(1) = 1;
  }
  repd(i, 2, N + 1) { // 2toN
    if (A.at(acnt) == i) {
      HOW.at(i) = 0;
      while (acnt < M && A.at(acnt) <= i)
        acnt++;
      if (acnt >= M)
        acnt = 0;
    } else {
      HOW.at(i) = (HOW.at(i - 1) + HOW.at(i - 2)) % mod;
    }
  }

  cout << HOW[N] << endl;
  return (0);
}