prithivMLmods/Coder-Stat huggingface dataset:
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(k, a, b) for (int k = (a); k < (b); k++)
#define FORE(k, a, b) for (int k = (a); k <= (b); k++)
#define REP(k, a) for (int k = 0; k < (a); k++)

#define ALL(c) (c).begin(), (c).end()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define RANGE(lb, x, ub) ((lb) <= (x) && (x) < (ub))

#define dump(x) cerr << #x << ": " << (x) << endl;

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INF = 1000000000;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int dp[10005];

int main(void) {
  int n, m;
  cin >> n >> m;
  set<int> as;
  REP(i, m) {
    int k;
    cin >> k;
    as.insert(k);
  }

  dp[0] = 1;
  int mod = INF + 7;

  FOR(i, 1, n + 1) {
    if (EXIST(as, i))
      continue;
    if (!EXIST(as, i - 1))
      dp[i] += dp[i - 1];
    if (i >= 2 && !EXIST(as, i - 2))
      dp[i] += dp[i - 2];
    dp[i] = dp[i] % mod;
  }
  cout << dp[n] << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(k, a, b) for (int k = (a); k < (b); k++)
#define FORE(k, a, b) for (int k = (a); k <= (b); k++)
#define REP(k, a) for (int k = 0; k < (a); k++)

#define ALL(c) (c).begin(), (c).end()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define RANGE(lb, x, ub) ((lb) <= (x) && (x) < (ub))

#define dump(x) cerr << #x << ": " << (x) << endl;

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INF = 1000000000;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int dp[100005];

int main(void) {
  int n, m;
  cin >> n >> m;
  set<int> as;
  REP(i, m) {
    int k;
    cin >> k;
    as.insert(k);
  }

  dp[0] = 1;
  int mod = INF + 7;

  FOR(i, 1, n + 1) {
    if (EXIST(as, i))
      continue;
    if (!EXIST(as, i - 1))
      dp[i] += dp[i - 1];
    if (i >= 2 && !EXIST(as, i - 2))
      dp[i] += dp[i - 2];
    dp[i] = dp[i] % mod;
  }
  cout << dp[n] << endl;

  return 0;
}
Problem p03013 (C++)

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

using namespace std;
using ll = long long;

const int MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<bool> ban(N + 1);
  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    ban[a] = true;
  }
  vector<ll> dp(N + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < N; i++) {
    if (ban[i])
      continue;
    dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
    dp[i + 2] = (dp[i + 2] + dp[i]) % MOD;
  }
  cout << dp[N] << '\n';
  return 0;
}


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

using namespace std;
using ll = long long;

const int MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<bool> ban(N + 1);
  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    ban[a] = true;
  }
  vector<ll> dp(N + 2, 0);
  dp[0] = 1;
  for (int i = 0; i < N; i++) {
    if (ban[i])
      continue;
    dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
    dp[i + 2] = (dp[i + 2] + dp[i]) % MOD;
  }
  cout << dp[N] << '\n';
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ll = long long;
const ll mod = 1000000007;

vector<ll> dp;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(m, 0);
  for (ll i = 0; i < m; i++) {
    cin >> a[i];
  }
  dp.resize(n + 5, 0);
  dp[0] = 1;
  int j = 0;
  for (ll i = 1; i <= n; i++) {
    if (a[j] == i) {
      if (j != m - 1)
        j++;
      if (i != n)
        continue;
      else
        break;
    }
    if (i == 1)
      dp[i] = dp[i - 1];
    if (i > 1)
      dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    // cout << "i: " << i << endl;
    // cout << "dp: " << dp[i] << endl;
  }

  cout << dp[n] % mod << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ll = long long;
const ll mod = 1000000007;

vector<ll> dp;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(m + 5, 0);
  for (ll i = 0; i < m; i++) {
    cin >> a[i];
  }
  dp.resize(n + 5, 0);
  dp[0] = 1;
  int j = 0;
  for (ll i = 1; i <= n; i++) {
    if (a[j] == i) {
      if (j != m - 1)
        j++;
      if (i != n)
        continue;
      else
        break;
    }
    if (i == 1)
      dp[i] = dp[i - 1];
    if (i > 1)
      dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    // cout << "i: " << i << endl;
    // cout << "dp: " << dp[i] << endl;
  }

  cout << dp[n] % mod << endl;
  return 0;
}
Problem p03013 (C++)

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

const LL MOD = pow(10, 9) + 7;

int main() {
  int n, m;
  cin >> n >> m;

  vector<int> a(m);
  for (int i = 0; i < m; ++i)
    cin >> a[i];

  vector<int> dp(n + 1, 0);

  dp[0] = 1;
  dp[1] = 1;
  int k = 0;

  if (a[k] == 1) {
    dp[1] = 0;
    k++;
  }

  for (int i = 2; i <= n; ++i) {
    dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
    if (!a.empty() && i == a[k]) {
      dp[i] = 0;
      k++;
    }
  }

  cout << dp[n] << endl;

  return 0;
}


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

const LL MOD = pow(10, 9) + 7;

int main() {
  int n, m;
  cin >> n >> m;

  vector<int> a(m);
  for (int i = 0; i < m; ++i)
    cin >> a[i];

  vector<int> dp(n + 1, 0);

  dp[0] = 1;
  dp[1] = 1;
  int k = 0;

  if (!a.empty() && a[k] == 1) {
    dp[1] = 0;
    k++;
  }

  for (int i = 2; i <= n; ++i) {
    dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
    if (!a.empty() && i == a[k]) {
      dp[i] = 0;
      k++;
    }
  }

  cout << dp[n] << endl;

  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n - 1); i >= 0; i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector<vector<ll>>;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

// 0 false, 1 true
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> vec(m);
  rep(i, m) { cin >> vec.at(i); }

  vector<ll> dp(n + 1);
  dp.at(0) = 1;

  ll tmp = 0;
  rep(i, n + 1) {
    if (i == 1) {
      if (vec.at(tmp) == 1) {
        tmp++;
        continue;
      } else {
        dp.at(1) = 1;
        continue;
      }
    }
    if (tmp < m && i == vec.at(tmp)) {
      tmp++;
      continue;
    }
    if (i >= 2) {
      dp.at(i) = dp.at(i - 1) % MOD + dp.at(i - 2) % MOD;
      dp.at(i) = dp.at(i) % MOD;
    }
  }

  cout << dp.at(n) << endl;
}


Fixed submission:
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n - 1); i >= 0; i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector<vector<ll>>;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

// 0 false, 1 true
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> vec(m);
  rep(i, m) { cin >> vec.at(i); }

  vector<ll> dp(n + 1);
  dp.at(0) = 1;

  ll tmp = 0;
  rep(i, n + 1) {
    if (i == 1) {
      if (tmp < m && vec.at(tmp) == 1) {
        tmp++;
        continue;
      } else {
        dp.at(1) = 1;
        continue;
      }
    }
    if (tmp < m && i == vec.at(tmp)) {
      tmp++;
      continue;
    }
    if (i >= 2) {
      dp.at(i) = dp.at(i - 1) % MOD + dp.at(i - 2) % MOD;
      dp.at(i) = dp.at(i) % MOD;
    }
  }

  cout << dp.at(n) << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
ll MOD = 1000000007;

ll sub(ll n) {
  if (n <= 0) {
    return -1;
  } else {
    vector<ll> list(n + 1);
    rep(i, n + 1) {
      if (i == 0) {
        list.at(i) = 0;
      } else if (i == 1) {
        list.at(i) = 1;
      } else {
        list.at(i) = (list.at(i - 1) + list.at(i - 2)) % MOD;
      }
    }
    return list.at(n);
  }
}

ll ans(vector<ll> v, ll m) {
  ll ans = 1;
  for (ll i = 0; i < m; i++) {
    if (i == 0) {
      ans *= sub(v.at(i));
      ans %= MOD;
    } else {
      ans *= sub(v.at(i) - v.at(i - 1) - 1);
      ans %= MOD;
    }
    if (ans < 0) {
      ans = 0;
    }
  }
  return ans;
}

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(M);
  rep(i, M) { cin >> A.at(i); }
  ll ANS = ans(A, M);
  ANS *= sub(N - A.at(M - 1));
  cout << ANS % 1000000007 << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
ll MOD = 1000000007;

ll sub(ll n) {
  if (n <= 0) {
    return -1;
  } else {
    vector<ll> list(n + 1);
    rep(i, n + 1) {
      if (i == 0) {
        list.at(i) = 0;
      } else if (i == 1) {
        list.at(i) = 1;
      } else {
        list.at(i) = (list.at(i - 1) + list.at(i - 2)) % MOD;
      }
    }
    return list.at(n);
  }
}

ll ans(vector<ll> v, ll m) {
  ll ans = 1;
  for (ll i = 0; i < m; i++) {
    if (i == 0) {
      ans *= sub(v.at(i));
      ans %= MOD;
    } else {
      ans *= sub(v.at(i) - v.at(i - 1) - 1);
      ans %= MOD;
    }
    if (ans < 0) {
      ans = 0;
    }
  }
  return ans;
}

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(M);
  rep(i, M) { cin >> A.at(i); }
  ll ANS = ans(A, M);
  if (M != 0) {
    ANS *= sub(N - A.at(M - 1));
  } else {
    ANS *= sub(N + 1);
  }
  cout << ANS % 1000000007 << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int N;
long long dp[100050];

int main() {
  cout << fixed << setprecision(10);
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  rep(i, M) cin >> a[i];
  rep(i, 100010) dp[i] = 0;
  rep(i, M) dp[a[i]] = -1;
  dp[0] = 1;
  if (a[0] != 1 || M == 0) {
    dp[1] = 1;
  } else {
    dp[1] = 0;
  }
  for (int i = 2; i < N + 1; i++) {
    if (dp[i] != -1) {
      dp[i] = dp[i - 2] + dp[i - 1];
    } else {
      dp[i] = 0;
    }
    dp[i] = dp[i] % P;
  }
  cout << dp[N] % P << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int N;
long long dp[100050];

int main() {
  cout << fixed << setprecision(10);
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  rep(i, M) cin >> a[i];
  rep(i, 100010) dp[i] = 0;
  rep(i, M) dp[a[i]] = -1;
  dp[0] = 1;
  if (M == 0 || a[0] != 1) {
    dp[1] = 1;
  } else {
    dp[1] = 0;
  }
  for (int i = 2; i < N + 1; i++) {
    if (dp[i] != -1) {
      dp[i] = dp[i - 2] + dp[i - 1];
    } else {
      dp[i] = 0;
    }
    dp[i] = dp[i] % P;
  }
  cout << dp[N] % P << endl;
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  ll mod = pow(10, 9) + 7;
  ll n, m;
  cin >> n >> m;
  vector<ll> ng(m);
  vector<ll> dp(n + 1);
  for (int i = 0; i < m; i++) {
    cin >> ng[i];
  }
  sort(ng.begin(), ng.end());
  ll now = 0;
  // cout << 0 << endl;
  if (n >= 1)
    dp[1] = 1;
  if (n >= 2)
    dp[2] = 2;
  // cout << 2 << endl;
  if (n >= 1 && m >= 1) {
    if (ng[now] == 1) {
      dp[1] = 0;
      if (n >= 2)
        dp[2] = 1;
      now++;
    }
  }
  // cout << 3 << endl;
  if (n >= 2 && m >= 2) {
    if (ng[now] == 2) {
      dp[2] = 0;
      now++;
    }
  }
  // cout << 1 << endl;
  for (int i = 3; i < n + 1; i++) {
    dp[i] = dp[i - 1] + dp[i - 2];
    dp[i] %= mod;
    while (i >= ng[now]) {
      if (ng[now] == i)
        dp[i] = 0;
      now++;
    }
  }
  cout << dp[n] % mod << endl;
}

Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  ll mod = pow(10, 9) + 7;
  ll n, m;
  cin >> n >> m;
  vector<ll> ng(m);
  vector<ll> dp(n + 1);
  for (int i = 0; i < m; i++) {
    cin >> ng[i];
  }
  sort(ng.begin(), ng.end());
  ll now = 0;
  // cout << 0 << endl;
  if (n >= 1)
    dp[1] = 1;
  if (n >= 2)
    dp[2] = 2;
  // cout << 2 << endl;
  if (n >= 1 && m >= 1) {
    if (ng[now] == 1) {
      dp[1] = 0;
      if (n >= 2)
        dp[2] = 1;
      now++;
    }
  }
  // cout << 3 << endl;
  if (n >= 2 && m >= 2) {
    if (ng[now] == 2) {
      dp[2] = 0;
      now++;
    }
  }
  // cout << 1 << endl;
  for (int i = 3; i < n + 1; i++) {
    dp[i] = dp[i - 1] + dp[i - 2];
    dp[i] %= mod;
    if (m > now) {
      while (i >= ng[now]) {
        if (ng[now] == i)
          dp[i] = 0;
        now++;
      }
    }
  }
  cout << dp[n] % mod << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>

int main() {
  int n, m, a[10005], in;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++)
    a[i] = -1;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &in);
    a[in] = 0;
  }
  if (a[1] != 0)
    a[1] = 1;
  if (a[2] != 0)
    a[2] = 1 + a[1];
  for (int i = 3; i <= n; i++)
    if (a[i] == -1)
      a[i] = (a[i - 2] + a[i - 1]) % 1000000007;
  printf("%d", a[n]);
  return 0;
}

Fixed submission:
#include <cstdio>

int main() {
  int n, m, a[100005], in;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++)
    a[i] = -1;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &in);
    a[in] = 0;
  }
  if (a[1] != 0)
    a[1] = 1;
  if (a[2] != 0)
    a[2] = 1 + a[1];
  for (int i = 3; i <= n; i++)
    if (a[i] == -1)
      a[i] = (a[i - 2] + a[i - 1]) % 1000000007;
  printf("%d", a[n]);
  return 0;
}
Problem p03013 (C++)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i, c)                                                             \
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  rep(i, M) cin >> a[i];

  vector<ll> ans(N + 1, 0);
  for (int i = 0, j = 0; i < N + 1; ++i) {
    if (i == a[j]) {
      j++;
    } else {
      if (i == 0 || i == 1)
        ans[i] = 1;
      else
        ans[i] = (ans[i - 1] + ans[i - 2]) % MOD;
    }
  }
  cout << ans[N] << endl;
  return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i, c)                                                             \
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  rep(i, M) cin >> a[i];

  vector<ll> ans(N + 1, 0);
  for (int i = 0, j = 0; i < N + 1; ++i) {
    if (j < M && i == a[j]) {
      j++;
    } else {
      if (i == 0 || i == 1)
        ans[i] = 1;
      else
        ans[i] = (ans[i - 1] + ans[i - 2]) % MOD;
    }
  }
  cout << ans[N] << endl;
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
inline int_fast64_t read() {
  int_fast64_t x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = x * 10 + c - '0', c = getchar();
  return x * f;
}
inline string read_s() {
  string s = "";
  char c = getchar();
  while (c < '!' || c > '~') {
    c = getchar();
  }
  while (c >= '!' && c <= '~') {
    s += c;
    c = getchar();
  }
  return s;
}
int mod = 1e9 + 7;
int dp[100001];
int fib(int n) {
  if (n == 0)
    return 0;
  if (n == 1)
    return 1;
  if (dp[n] != 0) {
    return dp[n];
  }
  return dp[n] = (fib(n - 1) + fib(n - 2)) % mod;
}
void Main() {
  int N = read(), M = read();
  int_fast64_t ans = 1;
  vector<int> V(M + 1);
  V[0] = read();
  int temp, last = V[0];
  for (int i = 1; i < M; i++) {
    temp = read();
    V[i] = temp - last - 1;
    last = temp;
  }
  V[M] = N - last;
  for (auto v : V) {
    ans *= fib(v);
    ans %= mod;
  }
  printf("%lld\n", ans);
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  Main();
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
inline int_fast64_t read() {
  int_fast64_t x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = x * 10 + c - '0', c = getchar();
  return x * f;
}
inline string read_s() {
  string s = "";
  char c = getchar();
  while (c < '!' || c > '~') {
    c = getchar();
  }
  while (c >= '!' && c <= '~') {
    s += c;
    c = getchar();
  }
  return s;
}
int mod = 1e9 + 7;
int dp[100001];
int fib(int n) {
  if (n == 0)
    return 0;
  if (n == 1)
    return 1;
  if (dp[n] != 0) {
    return dp[n];
  }
  return dp[n] = (fib(n - 1) + fib(n - 2)) % mod;
}
void Main() {
  int N = read(), M = read();
  int_fast64_t ans = 1;
  if (M == 0) {
    printf("%d\n", fib(N + 1));
    return;
  }
  vector<int> V(M + 1);
  V[0] = read();
  int temp, last = V[0];
  for (int i = 1; i < M; i++) {
    temp = read();
    V[i] = temp - last - 1;
    last = temp;
  }
  V[M] = N - last;
  for (auto v : V) {
    ans *= fib(v);
    ans %= mod;
  }
  printf("%lld\n", ans);
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  Main();
  return 0;
}
Problem p03013 (C++)

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

const int mod = 1E9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> A(n + 1, 0);
  vector<int> flg(n, 0);

  for (int i = 1; i <= m; i++) {
    int x;
    cin >> x;
    A[x] = 1;
  }

  flg[0] = 1;

  for (int i = 1; i <= n; i++) {
    if (!A[i])
      flg[i] = (flg[i - 1] + flg[i - 2]) % mod;
  }

  cout << flg[n] << endl;
}

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

const int mod = 1E9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> A(n + 1, 0);
  vector<int> flg(n + 1, 0);

  for (int i = 1; i <= m; i++) {
    int x;
    cin >> x;
    A[x] = 1;
  }

  flg[0] = 1;

  for (int i = 1; i <= n; i++) {
    if (!A[i])
      flg[i] = (flg[i - 1] + flg[i - 2]) % mod;
  }

  cout << flg[n] << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll INF = 1000000000000000;
ll mod = 1000000007;
ll i, j, k, l;

int main() {
  ll n, m;
  cin >> n >> m; // m個は壊れている
  vector<ll> a(m), step(n + 1), dp(n + 1, 0);
  // a:崩壊　step:階段の状態 　dp:i段目に到達するまでの行き方
  for (i = 0; i < m; i++) {
    cin >> a[i];
  }

  for (i = 1; i < m; i++) { // 連続で崩壊していたら渡れない
    if (a[n] == a[n - 1] + 1) {
      cout << 0 << endl;
      return 0;
    }
  }

  for (i = 0; i < m; i++) {
    step[a[i]] = 1; // 崩壊なら1 渡れるなら0
  }

  dp[0] = 1;
  dp[1] = 1;
  for (i = 2; i <= n; i++) { // 崩壊しているところを通らないようなfibo
    if (!step[i - 1]) {
      dp[i] += dp[i - 1];
      dp[i] %= mod;
    }
    if (!step[i - 2]) {
      dp[i] += dp[i - 2];
      dp[i] %= mod;
    }
  }

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

Fixed submission:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll INF = 1000000000000000;
ll mod = 1000000007;
ll i, j, k, l;

int main() {
  ll n, m;
  cin >> n >> m; // m個は壊れている
  vector<ll> a(m), step(n + 1), dp(n + 1, 0);
  // a:崩壊　step:階段の状態 　dp:i段目に到達するまでの行き方
  for (i = 0; i < m; i++) {
    cin >> a[i];
  }

  for (i = 1; i < m; i++) { // 連続で崩壊していたら渡れない
    if (a[i] == a[i - 1] + 1) {
      cout << 0 << endl;
      return 0;
    }
  }

  for (i = 0; i < m; i++) {
    step[a[i]] = 1; // 崩壊なら1 渡れるなら0
  }

  dp[0] = 1;
  dp[1] = 1;
  for (i = 2; i <= n; i++) { // 崩壊しているところを通らないようなfibo
    if (!step[i - 1]) {
      dp[i] += dp[i - 1];
      dp[i] %= mod;
    }
    if (!step[i - 2]) {
      dp[i] += dp[i - 2];
      dp[i] %= mod;
    }
  }

  cout << dp[n] << endl;
  return 0;
}
Problem p03013 (C++)

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

int main() {
  long long mod = 1e9 + 7;
  int N, M;
  cin >> N >> M;
  vector<bool> a(N + 1, true);
  for (int i = 0; i < M; i++) {
    int x;
    cin >> x;
    a[x] = false;
  }
  vector<long long> d(N);
  d[0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j <= min(i + 2, N); j++) {
      if (a[j]) {
        d[j] += d[i];
        d[j] %= mod;
      }
    }
  }
  cout << d[N] << endl;
}


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

int main() {
  long long mod = 1e9 + 7;
  int N, M;
  cin >> N >> M;
  vector<bool> a(N + 1, true);
  for (int i = 0; i < M; i++) {
    int x;
    cin >> x;
    a[x] = false;
  }
  vector<long long> d(N + 1);
  d[0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j <= min(i + 2, N); j++) {
      if (a[j]) {
        d[j] += d[i];
        d[j] %= mod;
      }
    }
  }
  cout << d[N] << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  const int64_t l = 1000000007;
  int64_t n, m;
  cin >> n >> m;
  queue<int64_t> a;
  int64_t aa;
  for (int64_t i = 0; i < m; i++) {
    cin >> aa;
    a.push(aa);
  }
  vector<int64_t> p(n + 1, 1);
  p.at(0) = 1;
  p.at(1) = 1;
  p.at(2) = 2;
  for (int i = 0; i < m; i++) {
    p.at(a.front()) = 0;
    a.pop();
  }
  for (int64_t i = 0; i < n - 1; i++) {
    if (p.at(i + 2) != 0) {
      p.at(i + 2) = (p.at(i + 1) + p.at(i)) % l;
    }
  }
  cout << p.at(n) << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  const int64_t l = 1000000007;
  int64_t n, m;
  cin >> n >> m;
  queue<int64_t> a;
  int64_t aa;
  for (int64_t i = 0; i < m; i++) {
    cin >> aa;
    a.push(aa);
  }
  vector<int64_t> p(n + 1, 1);
  p.at(0) = 1;
  p.at(1) = 1;
  for (int i = 0; i < m; i++) {
    p.at(a.front()) = 0;
    a.pop();
  }
  for (int64_t i = 0; i < n - 1; i++) {
    if (p.at(i + 2) != 0) {
      p.at(i + 2) = (p.at(i + 1) + p.at(i)) % l;
    }
  }
  cout << p.at(n) << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

#define MOD 1000000000 + 7

int N, M;
long long A[10 + 10];
long long dp[10 + 10];

int main(void) {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    long long temp;
    cin >> temp;
    A[temp] = 1;
  }

  dp[0] = 1;
  for (int n = 1; n <= N; n++) {
    if (A[n] == 1) {
      continue;
    }
    dp[n] = dp[n - 1];
    if (2 <= n) {
      dp[n] += dp[n - 2];
    }
    dp[n] %= MOD;
  }
  cout << dp[N] << endl;
  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

#define MOD 1000000000 + 7

int N, M;
long long A[100000 + 10];
long long dp[100000 + 10];

int main(void) {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    long long temp;
    cin >> temp;
    A[temp] = 1;
  }

  dp[0] = 1;
  for (int n = 1; n <= N; n++) {
    if (A[n] == 1) {
      continue;
    }
    dp[n] = dp[n - 1];
    if (2 <= n) {
      dp[n] += dp[n - 2];
    }
    dp[n] %= MOD;
  }
  cout << dp[N] << endl;
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;

const ll mod = 1000000007;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<bool> a(n + 1, true);
  rep(i, n) {
    ll x;
    cin >> x;
    a[x] = false;
  }
  vector<ll> dp(n + 1, 0);
  dp[0] = 1;
  rep(i, n) {
    if (a[i + 1])
      dp[i + 1] = (dp[i] + dp[i + 1]) % mod;
    if (i == n - 1)
      break;
    if (a[i + 2])
      dp[i + 2] = (dp[i] + dp[i + 2]) % mod;
  }
  cout << dp[n] << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;

const ll mod = 1000000007;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<bool> a(n + 1, true);
  rep(i, m) {
    ll x;
    cin >> x;
    a[x] = false;
  }
  vector<ll> dp(n + 1, 0);
  dp[0] = 1;
  rep(i, n) {
    if (a[i + 1])
      dp[i + 1] = (dp[i] + dp[i + 1]) % mod;
    if (i == n - 1)
      break;
    if (a[i + 2])
      dp[i + 2] = (dp[i] + dp[i + 2]) % mod;
  }
  cout << dp[n] << endl;

  return 0;
}
Problem p03013 (C++)

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

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  vector<bool> ng(m);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    ng[a] = true;
  }

  const ll mod = 1e9 + 7;
  vector<ll> memo(n + 1, -1);
  memo[0] = 1;
  function<ll(int)> f = [&](int n) -> ll {
    if (n < 0)
      return 0;
    if (memo[n] != -1)
      return memo[n];
    if (ng[n])
      return 0;
    return memo[n] = (f(n - 1) + f(n - 2)) % mod;
  };
  cout << f(n) << endl;

  // vector<ll> dp(n + 1, 0);
  // dp[0] = 1;
  // for (int i = 1; i <= n; i++) {
  //   if (find(a.begin(), a.end(), i) != a.end())
  //     continue;
  //   dp[i] += dp[i - 1];
  //   dp[i] %= mod;
  //   if (i > 1) {
  //     dp[i] += dp[i - 2];
  //     dp[i] %= mod;
  //   }
  // }
  //
  // cout << dp[n] << endl;

  return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  vector<bool> ng(n + 1);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    ng[a] = true;
  }

  const ll mod = 1e9 + 7;
  vector<ll> memo(n + 1, -1);
  memo[0] = 1;
  function<ll(int)> f = [&](int n) -> ll {
    if (n < 0)
      return 0;
    if (memo[n] != -1)
      return memo[n];
    if (ng[n])
      return 0;
    return memo[n] = (f(n - 1) + f(n - 2)) % mod;
  };
  cout << f(n) << endl;

  // vector<ll> dp(n + 1, 0);
  // dp[0] = 1;
  // for (int i = 1; i <= n; i++) {
  //   if (find(a.begin(), a.end(), i) != a.end())
  //     continue;
  //   dp[i] += dp[i - 1];
  //   dp[i] %= mod;
  //   if (i > 1) {
  //     dp[i] += dp[i - 2];
  //     dp[i] %= mod;
  //   }
  // }
  //
  // cout << dp[n] << endl;

  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <map>
#include <tuple>
#include <vector>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  for (int i = 0; i < M; i++)
    cin >> a[i];

  vector<int> dp(N);
  int x = 0;
  if (a[x] == 1) {
    dp[0] = 0;
    x++;
  } else
    dp[0] = 1;
  if (a[x] == 2) {
    dp[1] = 0;
    x++;
  } else
    dp[1] = 1 + dp[0];

  for (int i = 2; i < N; i++) {
    if (i == a[x] - 1) {
      dp[i] = 0;
      x++;
    } else
      dp[i] = (dp[i - 2] + dp[i - 1]) % 1000000007;
  }
  cout << dp[N - 1];
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <map>
#include <tuple>
#include <vector>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(100000);
  for (int i = 0; i < M; i++)
    cin >> a[i];

  vector<int> dp(N);
  int x = 0;
  if (a[x] == 1) {
    dp[0] = 0;
    x++;
  } else
    dp[0] = 1;
  if (a[x] == 2) {
    dp[1] = 0;
    x++;
  } else
    dp[1] = 1 + dp[0];

  for (int i = 2; i < N; i++) {
    if (i == a[x] - 1) {
      dp[i] = 0;
      x++;
    } else
      dp[i] = (dp[i - 2] + dp[i - 1]) % 1000000007;
  }
  cout << dp[N - 1];
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001; // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main() {

  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  REP(i, m) cin >> a[i];
  vector<bool> flag(n + 1, true);
  for (int i = 0; i < m; i++) {
    flag[a[i]] = false;
  }

  vector<int> dp(n + 1, 0);
  dp[0] = 1;

  for (int i = 1; i <= n + 1; i++) {
    if (flag[i]) {
      dp[i] += dp[i - 1];
      dp[i] %= MOD;
      if (i >= 2) {
        dp[i] += dp[i - 2];
        dp[i] %= MOD;
      }
    } else {
      dp[i] = 0;
    }
  }
  cout << dp[n] << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001; // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main() {

  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  REP(i, m) cin >> a[i];
  vector<bool> flag(n + 1, true);
  for (int i = 0; i < m; i++) {
    flag[a[i]] = false;
  }

  vector<int> dp(n + 1, 0);
  dp[0] = 1;

  for (int i = 1; i <= n; i++) {
    if (flag[i]) {
      dp[i] += dp[i - 1];
      dp[i] %= MOD;
      if (i >= 2) {
        dp[i] += dp[i - 2];
        dp[i] %= MOD;
      }
    } else {
      dp[i] = 0;
    }
  }
  cout << dp[n] << endl;
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

#define rep(i, N) for (int(i) = 0; (i) < (N); (i)++)
#define revrep(i, N) for (int(i) = (N)-1; (i) >= 0; (i)--)
#define dump(vec)                                                              \
  for (int i = 0; i < (vec).size(); i++) {                                     \
    cout << vec.at(i) << ",";                                                  \
  }                                                                            \
  cout << endl

typedef long long ll;

ll func(int n, set<int> &a);

int main(void) {
  int N, M;
  cin >> N >> M;
  set<int> a;
  rep(i, M) {
    int temp;
    cin >> temp;
    a.insert(temp);
  }

  cout << func(N, a) << endl;

  return 0;
}

/* n段目までたどり着くための移動方法と通り数*/
vector<ll> cache(100000, -1);
ll func(int n, set<int> &a) {
  if (n == 0) {
    return 1;
  } else if (n < 0) {
    return 0;
  } else if (cache.at(n) != (-1)) {
    return cache.at(n);
  }

  ll ret = 0;
  if (a.count(n - 1) == 0) {
    ret += func(n - 1, a);
  }
  if (a.count(n - 2) == 0) {
    ret += func(n - 2, a);
  }

  ret = ret % 1000000007;
  cache.at(n) = ret;

  return ret;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

#define rep(i, N) for (int(i) = 0; (i) < (N); (i)++)
#define revrep(i, N) for (int(i) = (N)-1; (i) >= 0; (i)--)
#define dump(vec)                                                              \
  for (int i = 0; i < (vec).size(); i++) {                                     \
    cout << vec.at(i) << ",";                                                  \
  }                                                                            \
  cout << endl

typedef long long ll;

ll func(int n, set<int> &a);

int main(void) {
  int N, M;
  cin >> N >> M;
  set<int> a;
  rep(i, M) {
    int temp;
    cin >> temp;
    a.insert(temp);
  }

  cout << func(N, a) << endl;

  return 0;
}

/* n段目までたどり着くための移動方法と通り数*/
vector<ll> cache(100010, -1);
ll func(int n, set<int> &a) {
  if (n == 0) {
    return 1;
  } else if (n < 0) {
    return 0;
  } else if (cache.at(n) != (-1)) {
    return cache.at(n);
  }

  ll ret = 0;
  if (a.count(n - 1) == 0) {
    ret += func(n - 1, a);
  }
  if (a.count(n - 2) == 0) {
    ret += func(n - 2, a);
  }

  ret = ret % 1000000007;
  cache.at(n) = ret;

  return ret;
}
Problem p03013 (C++)

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

using namespace std;

const int MOD = int(1e9) + 7;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  size_t N, M;
  cin >> N >> M;
  vector<bool> bad(N + 1);
  for (size_t i = 0; i < M; ++i) {
    int a;
    cin >> a;
    bad[a] = true;
  }
  vector<int64_t> dp(N);
  dp[0] = 1;
  for (size_t i = 1; i <= N; ++i) {
    if (bad[i]) {
      continue;
    } else {
      if (i == 1) {
        dp[i] = dp[0];
      } else {
        dp[i] = dp[i - 1] + dp[i - 2];
        dp[i] %= MOD;
      }
    }
  }
  cout << dp[N] << "\n";
  return 0;
}


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

using namespace std;

const int MOD = int(1e9) + 7;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  size_t N, M;
  cin >> N >> M;
  vector<bool> bad(N + 1);
  for (size_t i = 0; i < M; ++i) {
    int a;
    cin >> a;
    bad[a] = true;
  }
  vector<int64_t> dp(N + 1);
  dp[0] = 1;
  for (size_t i = 1; i <= N; ++i) {
    if (bad[i]) {
      continue;
    } else {
      if (i == 1) {
        dp[i] = dp[0];
      } else {
        dp[i] = dp[i - 1] + dp[i - 2];
        dp[i] %= MOD;
      }
    }
  }
  cout << dp[N] << "\n";
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  for (auto &A : a)
    cin >> A;
  vector<int> path(N + 1);
  path[0] = 1;
  int idx = 0;
  int mod = 1000000007;
  for (int i = 1; i <= N; ++i) {
    if (a[idx] == i) {
      path[i] = 0;
      ++idx;
      continue;
    }
    int sum = 0;
    if (0 <= i - 1)
      sum += path[i - 1];
    if (0 <= i - 2)
      sum += path[i - 2];
    path[i] = sum % mod;
  }
  cout << path[N];
  return 0;
}


Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  for (auto &A : a)
    cin >> A;
  vector<int> path(N + 1);
  path[0] = 1;
  int idx = 0;
  int mod = 1000000007;
  for (int i = 1; i <= N; ++i) {
    if ((idx < M) && (a[idx] == i)) {
      path[i] = 0;
      ++idx;
      continue;
    }
    int sum = 0;
    if (0 <= i - 1)
      sum += path[i - 1];
    if (0 <= i - 2)
      sum += path[i - 2];
    path[i] = sum % mod;
  }
  cout << path[N];
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define p(s) cout << (s) << endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x, 0, sizeof(x))
typedef long long ll;

using namespace std;

static const ll MOD = 1e9 + 7;
static const ll INF = 1e18;
static const ll MAX_N = 10000;
static const ll MAX_M = 10000;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

void pvector(vector<int> A) {
  cout << "[vector]";
  for (int i = 0; i < A.size(); i++) {
    cout << A[i] << " ";
  }
  cout << endl;
}

int main() {
  ll N, M;
  cin >> N >> M;
  int A[MAX_N + 1] = {0};
  REP(i, M) {
    int a;
    cin >> a;
    A[a]++;
  }
  ll dp[MAX_N + 1] = {0}; // i段目での場合の数
  dp[0] = 1;
  dp[1] = 1;
  for (int i = 2; i <= N; i++) {
    if (A[i] == 0) {
      if (A[i - 1] == 0 && A[i - 2] == 0)
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
      else if (A[i - 1] == 0 && A[i - 2] != 0)
        dp[i] = dp[i - 1] % MOD;
      else if (A[i - 1] != 0 && A[i - 2] == 0)
        dp[i] = dp[i - 2] % MOD;
      else
        dp[i] = 0;
    }
  }
  p(dp[N]);
}

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define p(s) cout << (s) << endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x, 0, sizeof(x))
typedef long long ll;

using namespace std;

static const ll MOD = 1e9 + 7;
static const ll INF = 1e18;
static const ll MAX_N = 100000;
static const ll MAX_M = 100000;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

void pvector(vector<int> A) {
  cout << "[vector]";
  for (int i = 0; i < A.size(); i++) {
    cout << A[i] << " ";
  }
  cout << endl;
}

int main() {
  ll N, M;
  cin >> N >> M;
  int A[MAX_N + 1] = {0};
  REP(i, M) {
    int a;
    cin >> a;
    A[a]++;
  }
  ll dp[MAX_N + 1] = {0}; // i段目での場合の数
  dp[0] = 1;
  dp[1] = 1;
  for (int i = 2; i <= N; i++) {
    if (A[i] == 0) {
      if (A[i - 1] == 0 && A[i - 2] == 0)
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
      else if (A[i - 1] == 0 && A[i - 2] != 0)
        dp[i] = dp[i - 1] % MOD;
      else if (A[i - 1] != 0 && A[i - 2] == 0)
        dp[i] = dp[i - 2] % MOD;
      else
        dp[i] = 0;
    }
  }
  p(dp[N]);
}
Problem p03013 (C++)

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

const long long MOD = 1000000007;
vector<long long> dp(100001, -1);
vector<bool> broken(100001);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  int N, M;
  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    broken.at(a) = true;
  }

  dp.at(0) = 1;
  dp.at(1) = 1;

  for (int i = 1; i <= N; i++) {
    if (broken.at(i)) {
      dp.at(i) = 0;
    } else {
      dp.at(i) = (dp.at(i - 1) + dp.at(i - 2)) % MOD;
    }
  }
  cout << dp.at(N) << endl;
}


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

const long long MOD = 1000000007;
vector<long long> dp(100001, -1);
vector<bool> broken(100001);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  int N, M;
  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    broken.at(a) = true;
  }

  dp.at(0) = 1;
  if (broken.at(1)) {
    dp.at(1) = 0;
  } else {
    dp.at(1) = 1;
  }
  for (int i = 2; i <= N; i++) {
    if (broken.at(i)) {
      dp.at(i) = 0;
    } else {
      dp.at(i) = (dp.at(i - 1) + dp.at(i - 2)) % MOD;
    }
  }
  cout << dp.at(N) << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> broken(m + 1);
  rep(i, m) {
    int a;
    cin >> a;
    broken[a] = 1;
  }
  vector<int> dp(n + 2);
  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    if (broken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i + 2] + dp[i + 1]) % 1000000007;
  }
  cout << dp[0] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> broken(n + 1);
  rep(i, m) {
    int a;
    cin >> a;
    broken[a] = 1;
  }
  vector<int> dp(n + 2);
  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    if (broken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i + 2] + dp[i + 1]) % 1000000007;
  }
  cout << dp[0] << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;

#ifdef DEBUG
#define IFD if (true)
#else
#define IFD if (false)
#endif

int main() {
  long long dp[100001];
  priority_queue<int, vector<int>, greater<int>> a;
  int N, M;

  memset(dp, 0, sizeof(dp));

  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int n;
    cin >> n;
    a.push(n);
  }

  dp[0] = 1;

  for (int i = 1; i <= N; i++) {
    if (i == a.top()) {
      a.pop();
      continue;
    }
    if (i == 1) {
      dp[1] = dp[0];
    } else {
      dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
    }
  }

  cout << dp[N] << endl;

  return 0;
}


Fixed submission:
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;

#ifdef DEBUG
#define IFD if (true)
#else
#define IFD if (false)
#endif

int main() {
  long long dp[100001];
  priority_queue<int, vector<int>, greater<int>> a;
  int N, M;

  memset(dp, 0, sizeof(dp));

  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int n;
    cin >> n;
    a.push(n);
  }

  dp[0] = 1;

  for (int i = 1; i <= N; i++) {
    if (!a.empty() && i == a.top()) {
      a.pop();
      continue;
    }
    if (i == 1) {
      dp[1] = dp[0];
    } else {
      dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
    }
  }

  cout << dp[N] << endl;

  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> v(n, false);
  vector<ll> dp(n, 0);
  rep(i, m) {
    int a;
    cin >> a;
    a--;
    v.at(a) = true;
  }
  if (!v.at(0))
    dp.at(0) = 1;
  if (!v.at(1))
    dp.at(1) = dp.at(0) + 1;
  for (int i = 2; i < n; i++) {
    if (v.at(i))
      continue;
    dp.at(i) = (dp.at(i - 1) + dp.at(i - 2)) % mod;
  }
  cout << dp.at(n - 1) << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> v(n, false);
  vector<ll> dp(n, 0);
  rep(i, m) {
    int a;
    cin >> a;
    a--;
    v.at(a) = true;
  }
  if (!v.at(0))
    dp.at(0) = 1;
  if (n > 1 && !v.at(1))
    dp.at(1) = dp.at(0) + 1;
  for (int i = 2; i < n; i++) {
    if (v.at(i))
      continue;
    dp.at(i) = (dp.at(i - 1) + dp.at(i - 2)) % mod;
  }
  cout << dp.at(n - 1) << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define tl 1000000007
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<ll> DP(n + 1, 0);
  vector<ll> A(m, 0);
  REP(i, m) {
    cin >> A[i];
    DP[A[i]] = -1;
  }
  DP[0] = 1;
  REP(i, n) {
    if (DP[i] == -1)
      continue;
    if (DP[i + 1] != -1)
      DP[i + 1] = (DP[i + 1] + DP[i]) % tl;
    if (DP[i + 2] != -1)
      DP[i + 2] = (DP[i + 2] + DP[i]) % tl;
  }
  cout << DP[n] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define tl 1000000007
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<ll> DP(n + 2, 0);
  vector<ll> A(m, 0);
  REP(i, m) {
    cin >> A[i];
    DP[A[i]] = -1;
  }
  DP[0] = 1;
  REP(i, n) {
    if (DP[i] == -1)
      continue;
    if (DP[i + 1] != -1)
      DP[i + 1] = (DP[i + 1] + DP[i]) % tl;
    if (DP[i + 2] != -1)
      DP[i + 2] = (DP[i + 2] + DP[i]) % tl;
  }
  cout << DP[n] << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> d(m);
  for (int i = 0; i < m; i++)
    cin >> d[i];
  vector<int> dp(n + 1, 0);
  dp[0] = dp[1] = 1;
  int tmp = 0;
  if (d[0] == 1) {
    tmp++;
    dp[1] = 0;
  }
  for (int i = 2; i <= n; i++) {
    if (tmp < m && d[tmp] == i) {
      tmp++;
      continue;
    }
    dp[i] = dp[i - 1] + dp[i - 2];
    dp[i] %= mod;
  }
  cout << dp[n] << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> d(m);
  for (int i = 0; i < m; i++)
    cin >> d[i];
  vector<int> dp(n + 1, 0);
  dp[0] = dp[1] = 1;
  int tmp = 0;
  if (d.size() > 0 && d[0] == 1) {
    tmp++;
    dp[1] = 0;
  }
  for (int i = 2; i <= n; i++) {
    if (tmp < m && d[tmp] == i) {
      tmp++;
      continue;
    }
    dp[i] = dp[i - 1] + dp[i - 2];
    dp[i] %= mod;
  }
  cout << dp[n] << endl;
  return 0;
}