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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPP(i, m, n) for (int i = m; i < n; i++)
#define ALL(N) (N.begin(), N.end())
#define de cout << "debug" << endl;
#define pb push_back
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int a[100010] = {};
  REP(i, M) cin >> a[i];
  ll dp[100100] = {};

  dp[0] = 0;
  dp[1] = 1;
  dp[2] = 2;
  REP(i, M) {
    if (a[i] == 1) {
      dp[1] = 0;
      dp[2] = 1;
    }
    if (a[i] == 2) {
      dp[2] = 0;
    }
  }
  int O = 0;
  REPP(i, 3, N + 1) {
    dp[i] = dp[i - 1] + dp[i - 2];
    dp[i] %= 1000000007;
    REPP(j, O, M) {
      if (i == a[j]) {
        dp[i] = 0;
        O++;
      }
    }
  }

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPP(i, m, n) for (int i = m; i < n; i++)
#define ALL(N) (N.begin(), N.end())
#define de cout << "debug" << endl;
#define pb push_back
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int a[100010] = {};
  REP(i, M) cin >> a[i];
  ll dp[100100] = {};

  dp[0] = 0;
  dp[1] = 1;
  dp[2] = 2;
  REP(i, M) {
    if (a[i] == 1) {
      dp[1] = 0;
      dp[2] = 1;
    }
    if (a[i] == 2) {
      dp[2] = 0;
    }
  }
  int O = 0;
  REPP(i, 3, N + 1) {
    dp[i] = dp[i - 1] + dp[i - 2];
    dp[i] %= 1000000007;
    REPP(j, O, M) {
      if (i == a[j]) {
        dp[i] = 0;
        O++;
        break;
      }
    }
  }

  cout << dp[N] << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for (int i = (s); i < (int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for (int i = (int)(s - 1); i >= (int)(e); i--)
#define pb push_back
#define all(r) r.begin(), r.end()
#define rall(r) r.rbegin(), r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template <typename T> T chmax(T &a, const T &b) { return a = (a > b ? a : b); }
template <typename T> T chmin(T &a, const T &b) { return a = (a < b ? a : b); }

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> dp(n + 1, 0);
  vector<int> ng(n + 1);
  rep(i, m) {
    int a;
    cin >> a;
    ng[a] = 1;
  }
  dp[0] = 1;
  rep(i, n) {
    if (ng[i + 1] == 0)
      (dp[i + 1] += dp[i]) %= MOD;
    if (ng[i + 2] == 0)
      (dp[i + 2] += dp[i]) %= MOD;
  }
  cout << dp[n] << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for (int i = (s); i < (int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for (int i = (int)(s - 1); i >= (int)(e); i--)
#define pb push_back
#define all(r) r.begin(), r.end()
#define rall(r) r.rbegin(), r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template <typename T> T chmax(T &a, const T &b) { return a = (a > b ? a : b); }
template <typename T> T chmin(T &a, const T &b) { return a = (a < b ? a : b); }

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> dp(n + 2, 0);
  vector<int> ng(n + 2);
  rep(i, m) {
    int a;
    cin >> a;
    ng[a] = 1;
  }
  dp[0] = 1;
  rep(i, n) {
    if (ng[i + 1] == 0)
      (dp[i + 1] += dp[i]) %= MOD;
    if (ng[i + 2] == 0)
      (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() {
  int N, M, x, bk = 0;
  cin >> N >> M;
  vector<int> a(M), sum(N + 1);
  sum[0] = 1;
  sum[1] = 1;
  for (int i = 0; i < M; i++) {
    cin >> x;
    a[i] = x;
  }

  if (M != 0) {
    if (a[0] == 1) {
      sum[1] = 0;
      bk++;
    }
  }

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

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

using namespace std;

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

  if (M != 0) {
    if (a[0] == 1) {
      sum[1] = 0;
      bk++;
    }
  }

  for (int i = 2; i < N + 1; i++) {
    if (M != 0) {
      if (i == a[bk]) {
        sum[i] = 0;
        bk++;
        if (bk == M) {
          bk--;
        }
      } else {
        sum[i] = sum[i - 2] + sum[i - 1];
        sum[i] %= 1000000007;
      }
    } else {
      sum[i] = sum[i - 2] + sum[i - 1];
      sum[i] %= 1000000007;
    }
  }
  cout << sum[N] << endl;
}
Problem p03013 (C++)

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

#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep2(i, s, n) for (long long i = (s); i < (long long)(n); i++)

typedef long long ll;

const ll inf = 1e18 + 7;
const ll mod = 1e9 + 7;

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

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

  rep(i, m) {
    int a;
    cin >> a;
    bkn[a] = 0;
  }

  dp[0] = 1;
  dp[1] = bkn[1];

  rep2(i, 2, n + 2) {
    if (bkn[i]) {
      dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    }
  }

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


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

#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep2(i, s, n) for (long long i = (s); i < (long long)(n); i++)

typedef long long ll;

const ll inf = 1e18 + 7;
const ll mod = 1e9 + 7;

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

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

  rep(i, m) {
    int a;
    cin >> a;
    bkn[a] = 0;
  }

  dp[0] = 1;
  dp[1] = bkn[1];

  rep2(i, 2, n + 1) {
    if (bkn[i]) {
      dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    }
  }

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

template <typename T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}
template <typename T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

int in() {
  int x;
  scanf("%d", &x);
  return x;
}
ll lin() {
  ll x;
  scanf("%lld", &x);
  return x;
}
#define INF 1LL << 60

int main() {
  ll mod = 1e9 + 7;
  int N, M;
  cin >> N >> M;
  vector<ll> a(M), dp(N + 2);
  REP(i, M) cin >> a[i];
  dp[0] = 0;
  dp[1] = 1;
  int cur_a_idx = 0;
  for (int i = 2; i <= N + 1; i++) {
    if (i - 1 == a[cur_a_idx]) {
      cur_a_idx++;
      dp[i] = 0;
    } else {
      dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    }
  }

  cout << dp[N + 1] << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

template <typename T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}
template <typename T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

int in() {
  int x;
  scanf("%d", &x);
  return x;
}
ll lin() {
  ll x;
  scanf("%lld", &x);
  return x;
}
#define INF 1LL << 60

int main() {
  ll mod = 1e9 + 7;
  int N, M;
  cin >> N >> M;
  vector<ll> a(M), dp(N + 2);
  REP(i, M) cin >> a[i];
  dp[0] = 0;
  dp[1] = 1;
  int cur_a_idx = 0;
  for (int i = 2; i <= N + 1; i++) {
    if (cur_a_idx < M && i - 1 == a[cur_a_idx]) {
      cur_a_idx++;
      dp[i] = 0;
    } else {
      dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    }
  }

  cout << dp[N + 1] << endl;

  return 0;
}
Problem p03013 (C++)

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> a(m), dp(n + 10, 0);
  for (int i = 0; i < m; i++)
    cin >> a[i]; // hole
  dp[0] = 1;
  int j = 0; // next hole
  if (a[0] != 1) {
    dp[1] = 1;
  } else {
    dp[1] = 0;
    j++;
  }
  for (int i = 2; i <= n; i++) {
    if (i != a[j]) {
      dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
    } else {
      dp[i] = 0;
      j++;
    }
  }
  cout << dp[n] << endl;
  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> dp(n + 1);
  vector<int> a(n + 1);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  dp[0] = 1;
  int j = 0; // next hole
  if (a[0] != 1) {
    dp[1] = 1;
  } else {
    dp[1] = 0;
    j++;
  }
  for (int i = 2; i <= n; i++) {
    if (i != a[j]) {
      dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
    } else {
      dp[i] = 0;
      j++;
    }
  }
  cout << dp[n] << endl;
  return 0;
}
Problem p03013 (C++)

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

typedef long long ll;
const ll INF = 1LL << 60, MOD = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define m_p make_pair

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

  ll n, m;
  cin >> n >> m;
  vector<bool> ok(m, false);
  vector<ll> dp(n + 1, 0);
  rep(i, m) {
    ll a;
    cin >> a;
    ok[a] = true;
  }
  dp[0] = 1;
  REP(i, 1, n + 1) {
    if (ok[i])
      continue;
    if (i == 1)
      dp[i] = dp[i - 1];
    else
      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;

typedef long long ll;
const ll INF = 1LL << 60, MOD = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define m_p make_pair

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

  ll n, m;
  cin >> n >> m;
  vector<bool> ok(n + 1, false);
  vector<ll> dp(n + 1, 0);
  rep(i, m) {
    ll a;
    cin >> a;
    ok[a] = true;
  }
  dp[0] = 1;
  REP(i, 1, n + 1) {
    if (ok[i])
      continue;
    if (i == 1)
      dp[i] = dp[i - 1];
    else
      dp[i] = dp[i - 1] + dp[i - 2];
    dp[i] %= MOD;
  }
  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++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
typedef long long ll;

int n;
bool M[11111] = {};
ll dp[11111] = {};
ll cnt = 0;

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


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 - 1; i >= 0; i--)
using namespace std;
typedef long long ll;

int n;
bool M[101010] = {};
ll dp[101010] = {};
ll cnt = 0;

int main() {
  int m;
  cin >> n >> m;
  int a;
  M[n + 1] = 1;
  rep(i, m) {
    cin >> a;
    M[a] = 1;
  }
  dp[0] = 1;
  dp[1] = !M[1];
  rep(i, n - 1) {
    if (!M[i + 2])
      dp[i + 2] = 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>
using namespace std;
#define int long long
const int mod = 1e9 + 7;

signed main() {
  int n, k;
  cin >> n >> k;
  vector<int> oks(n + 1, true);
  int a;
  cin >> a;
  oks[a] = false;
  vector<int> dp(n + 1);
  dp[0] = 1;
  for (int now = 0; now < n; now++) {
    for (int next = now + 1; next <= min(n, now + 2); next++) {
      if (oks[next]) {
        dp[next] += dp[now];
        dp[next] %= mod;
      }
    }
  }
  cout << dp[n] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7;

signed main() {
  int n, k;
  cin >> n >> k;
  vector<int> oks(n + 1, true);
  for (int i = 0; i < k; i++) {
    int a;
    cin >> a;
    oks[a] = false;
  }
  vector<int> dp(n + 1);
  dp[0] = 1;
  for (int now = 0; now < n; now++) {
    for (int next = now + 1; next <= min(n, now + 2); next++) {
      if (oks[next]) {
        dp[next] += dp[now];
        dp[next] %= mod;
      }
    }
  }
  cout << dp[n] << endl;
}
Problem p03013 (C++)

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

int main() {
  long n, m, j = 0;
  cin >> n >> m;
  vector<long> a(m);
  vector<long> dp(n + 1);
  for (int i = 0; i < m; i++)
    cin >> a.at(i);
  dp.at(0) = 1;
  for (int i = 1; i <= n; i++) {
    if (a.at(j) == i) {
      j++;
      if (j == m)
        j--;
    } else {
      if (i != 1)
        dp.at(i) += dp.at(i - 2);
      dp.at(i) += dp.at(i - 1);
      dp.at(i) = dp.at(i) % 1000000007;
    };
  };
  cout << dp.at(n) << endl;
}

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

int main() {
  long n, m, j = 0;
  cin >> n >> m;
  vector<long> a(101000);
  vector<long> dp(n + 1);
  for (int i = 0; i < m; i++)
    cin >> a.at(i);
  dp.at(0) = 1;
  for (int i = 1; i <= n; i++) {
    if (a.at(j) == i) {
      j++;
      if (j == m)
        j--;
    } else {
      if (i != 1)
        dp.at(i) += dp.at(i - 2);
      dp.at(i) += dp.at(i - 1);
      dp.at(i) = dp.at(i) % 1000000007;
    };
  };
  cout << dp.at(n) << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define vec vector<ll>
#define ms multiset<ll>
#define f(i, x, n) for (int i = x; i < n; i++)
#define int long long
#define mod 1000000007
#define endl "\n"
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int bk[1000000], fr[1000000];
int32_t main() {
  fastio();
  int n, m;
  cin >> n >> m;
  int a[m];
  f(i, 0, m) {
    cin >> a[i];
    bk[a[i]] = 1;
  }
  int fg = 0;
  f(i, 1, n) {
    if (a[i] == a[i - 1] + 1)
      fg = 1;
  }
  if (fg == 1) {
    cout << 0;
    return 0;
  }
  fr[0] = 1;
  for (int i = 0; i <= n - 1; i++) {
    if (bk[i] == 1)
      continue;
    if (bk[i + 1] == 0)
      fr[i + 1] = (fr[i + 1] + fr[i]) % mod;
    if (bk[i + 2] == 0)
      fr[i + 2] = (fr[i + 2] + fr[i]) % mod;
  }
  cout << fr[n];
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define vec vector<ll>
#define ms multiset<ll>
#define f(i, x, n) for (int i = x; i < n; i++)
#define int long long
#define mod 1000000007
#define endl "\n"
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int bk[1000000], fr[1000000];
int32_t main() {
  fastio();
  int n, m;
  cin >> n >> m;
  int a[m];
  f(i, 0, m) {
    cin >> a[i];
    bk[a[i]] = 1;
  }
  int fg = 0;
  f(i, 1, m) {
    if (a[i] == a[i - 1] + 1)
      fg = 1;
  }
  if (fg == 1) {
    cout << 0;
    return 0;
  }
  fr[0] = 1;
  for (int i = 0; i <= n - 1; i++) {
    if (bk[i] == 1)
      continue;
    if (bk[i + 1] == 0)
      fr[i + 1] = (fr[i + 1] + fr[i]) % mod;
    if (bk[i + 2] == 0)
      fr[i + 2] = (fr[i + 2] + fr[i]) % mod;
  }
  cout << fr[n];
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long int n, m, b[10001], s[10001], now = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < m; i++) {
    if (b[i] + 1 == b[i + 1]) {
      cout << "0" << endl;
      return 0;
    }
  }
  s[0] = 1;
  if (b[now] == 1) {
    s[1] = 0;
    now++;
  } else {
    s[1] = 1;
  }
  if (b[now] == 2) {
    s[2] = 0;
    now++;
  } else {
    s[2] = s[1] + 1;
  }
  for (int i = 3; i <= n; i++) {
    if (i == b[now]) {
      now++;
      s[i] = 0;
      // cout << i <<"is 0" << endl;
      continue;
    }
    s[i] = (s[i - 1] + s[i - 2]) % 1000000007;
    if (s[i] / 1000000007 && s[i - 1] / 1000000007) {
      s[i] %= 1000000007;
      s[i - 1] %= 1000000007;
    }
  }
  // for(int i=0;i<n;i++){
  //     cout << s[i] << " ";
  // }
  // cout << endl;
  cout << s[n] % 1000000007 << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long int n, m, b[200000], s[200002], now = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < m; i++) {
    if (b[i] + 1 == b[i + 1]) {
      cout << "0" << endl;
      return 0;
    }
  }
  s[0] = 1;
  if (b[now] == 1) {
    s[1] = 0;
    now++;
  } else {
    s[1] = 1;
  }
  if (b[now] == 2) {
    s[2] = 0;
    now++;
  } else {
    s[2] = s[1] + 1;
  }
  for (int i = 3; i <= n; i++) {
    if (i == b[now]) {
      now++;
      s[i] = 0;
      // cout << i <<"is 0" << endl;
      continue;
    }
    s[i] = (s[i - 1] + s[i - 2]) % 1000000007;
    if (s[i] / 1000000007 && s[i - 1] / 1000000007) {
      s[i] %= 1000000007;
      s[i - 1] %= 1000000007;
    }
  }
  // for(int i=0;i<n;i++){
  //     cout << s[i] << " ";
  // }
  // cout << endl;
  cout << s[n] % 1000000007 << endl;
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set                                                            \
  tree<int, null_type, less<int>, rb_tree_tag,                                 \
       tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

void solve() {
  int n, m;
  cin >> n >> m;

  vector<bool> vis(n + 1);
  for (int i = 0; i < m; i++) {
    int tp;
    cin >> tp;
    vis[tp] = true;
  }
  vector<int> dp(n + 1);
  dp[0] = 1;
  for (int i = 0; i <= n; i++) {
    if (vis[i])
      continue;
    dp[i + 1] += dp[i];
    dp[i + 2] += dp[i];
    dp[i + 1] %= MOD;
    dp[i + 2] %= MOD;
  }
  cout << dp[n];
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int t = 1;
  //    cin >> t;

  while (t--)
    solve();
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set                                                            \
  tree<int, null_type, less<int>, rb_tree_tag,                                 \
       tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

void solve() {
  int n, m;
  cin >> n >> m;

  vector<bool> vis(n + 1);
  for (int i = 0; i < m; i++) {
    int tp;
    cin >> tp;
    vis[tp] = true;
  }
  vector<int> dp(n + 1);
  dp[0] = 1;
  for (int i = 0; i <= n; i++) {
    if (vis[i])
      continue;
    if (i + 1 <= n)
      dp[i + 1] += dp[i];
    if (i + 2 <= n)
      dp[i + 2] += dp[i];
    if (i + 1 <= n)

      dp[i + 1] %= MOD;
    if (i + 2 <= n)

      dp[i + 2] %= MOD;
  }
  cout << dp[n];
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int t = 1;
  //    cin >> t;

  while (t--)
    solve();
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, j, n) for (ll i = j; i < n; i++)
#define all(vec) vec.begin(), vec.end()
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;
}
const ll INF = 1LL << 60;

ll dp[110000];

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) cin >> a[i];
  rep(i, m - 1) {
    if (a[i] + 1 == a[i + 1]) {
      cout << 0 << endl;
      return 0;
    }
  }
  dp[0] = 1;
  int no = 0;
  rep(i, n) {
    if (a[no] == i + 1) {
      dp[i + 2] += dp[i];
      dp[i + 2] %= MOD;
      no++;
      i++;
    } else {
      dp[i + 2] += dp[i];
      dp[i + 2] %= MOD;
      dp[i + 1] += dp[i];
      dp[i + 1] %= MOD;
    }
  }
  cout << dp[n] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, j, n) for (ll i = j; i < n; i++)
#define all(vec) vec.begin(), vec.end()
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;
}
const ll INF = 1LL << 60;

ll dp[110000];

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) cin >> a[i];
  rep(i, m - 1) {
    if (a[i] + 1 == a[i + 1]) {
      cout << 0 << endl;
      return 0;
    }
  }
  dp[0] = 1;
  int no = 0;
  rep(i, n) {
    if (no < m && a[no] == i + 1) {
      dp[i + 2] += dp[i];
      dp[i + 2] %= MOD;
      no++;
      i++;
    } else {
      dp[i + 2] += dp[i];
      dp[i + 2] %= MOD;
      dp[i + 1] += dp[i];
      dp[i + 1] %= MOD;
    }
  }
  cout << dp[n] << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> forbidden(n + 1, false);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    forbidden[a] = true;
  }
  long long mod = 1e9 + 7;
  vector<long long> count(n, 0);
  count[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j <= min(n, i + 2); j++) {
      if (forbidden[j])
        continue;
      count[j] += count[i];
      count[j] %= mod;
    }
  }
  cout << count[n] << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> forbidden(n + 1, false);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    forbidden[a] = true;
  }
  long long mod = 1e9 + 7;
  vector<long long> count(n + 1, 0);
  count[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j <= min(n, i + 2); j++) {
      if (forbidden[j])
        continue;
      count[j] += count[i];
      count[j] %= mod;
    }
  }
  cout << count[n] << endl;
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <vector>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(N, 0);
  for (int i = 0; i < M; i++) {
    int A;
    cin >> A;
    a[A] = 1;
  }
  vector<int> dp(N);
  dp[0] = 1;
  if (a[1] != 0) {
    dp[1] = 0;
  } else {
    dp[1] = 1;
  }
  for (int i = 2; i <= N; i++) {
    if (a[i] == 1) {
      dp[i] = 0;
    } else {
      dp[i] = dp[i - 1] + dp[i - 2];
    }
    dp[i] %= INFI;
    if (dp[i] == 0 && dp[i - 1] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  cout << dp[N] << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <vector>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(N, 0);
  for (int i = 0; i < M; i++) {
    int A;
    cin >> A;
    a[A] = 1;
  }
  vector<int> dp(N + 1);
  dp[0] = 1;
  if (a[1] != 0) {
    dp[1] = 0;
  } else {
    dp[1] = 1;
  }
  for (int i = 2; i <= N; i++) {
    if (a[i] == 1) {
      dp[i] = 0;
    } else {
      dp[i] = dp[i - 1] + dp[i - 2];
    }
    dp[i] %= INFI;
    if (dp[i] == 0 && dp[i - 1] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  cout << dp[N] << endl;
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef unsigned int ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repf(i, n) for (int i = 0; i <= n; i++)
const ll mod = 1000000000 + 7;
typedef pair<ll, ll> P;

ll N, M;
priority_queue<ll, vector<ll>, greater<ll>> A;
ll dp[100010];

int main() {
  cin >> N >> M;
  rep(i, M) {
    ll a;
    cin >> a;
    A.push(a);
  }

  dp[0] = 1;
  dp[1] = 1;
  ll cur;
  ll next = A.top();
  for (int i = 1; i < N; i++) {
    cur = next;
    if (!(A.empty())) {
      next = A.top();
      if (i == next) {
        dp[i] = 0;
        dp[i + 1] = (dp[i] + dp[i - 1]) % mod;
        A.pop();
        continue;
      }
      if (cur + 1 == next) {
        cout << 0 << endl;
      }
    }

    dp[i + 1] = (dp[i] + dp[i - 1]) % mod;
  }

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned int ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repf(i, n) for (int i = 0; i <= n; i++)
const ll mod = 1000000000 + 7;
typedef pair<ll, ll> P;

ll N, M;
priority_queue<ll, vector<ll>, greater<ll>> A;
ll dp[100010];

int main() {
  cin >> N >> M;
  rep(i, M) {
    ll a;
    cin >> a;
    A.push(a);
  }

  dp[0] = 1;
  dp[1] = 1;
  ll cur;
  ll next;
  if (!(A.empty()))
    next = A.top();
  for (int i = 1; i < N; i++) {
    cur = next;
    if (!(A.empty())) {
      next = A.top();
      if (i == next) {
        dp[i] = 0;
        dp[i + 1] = (dp[i] + dp[i - 1]) % mod;
        A.pop();
        continue;
      }
      if (cur + 1 == next) {
        cout << 0 << endl;
      }
    }

    dp[i + 1] = (dp[i] + dp[i - 1]) % mod;
  }

  cout << dp[N] << endl;
}
Problem p03013 (C++)

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

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, m;
  cin >> n >> m;
  vector<bool> arr(n + 1, true);
  int x;

  for (int i = 0; i < m; i++) {
    cin >> x;
    arr[x] = false;
  }
  // if (arr[0] == false)
  // {
  // 	cout << 0;
  // 	return 0;
  // }
  vector<int> dp(n + 1, 0);
  if (arr[0])
    dp[0] = 1;
  if (arr[1] && arr[0])
    dp[1] = 1;

  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= 2; j++) {

      if (arr[i] && arr[i - j])
        dp[i] += dp[i - j];
      dp[i] %= mod;
    }
  }
  // for (int i = 1; i <= n; i++)
  // {
  // 	cout << dp[i] << " ";
  // 	// arr[x] = true;
  // }
  cout << dp[n];
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, m;
  cin >> n >> m;
  vector<bool> arr(n + 1, true);
  int x;

  for (int i = 0; i < m; i++) {
    cin >> x;
    arr[x] = false;
  }
  // if (arr[0] == false)
  // {
  // 	cout << 0;
  // 	return 0;
  // }
  vector<int> dp(n + 1, 0);
  if (arr[0])
    dp[0] = 1;
  if (arr[1] && arr[0])
    dp[1] = 1;

  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= 2; j++) {

      if (arr[i] && arr[i - j])
        dp[i] += dp[i - j];
      dp[i] %= mod;
    }
  }
  // for (int i = 1; i <= n; i++)
  // {
  // 	cout << dp[i] << " ";
  // 	// arr[x] = true;
  // }
  cout << dp[n];
}
Problem p03013 (C++)

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

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

  vector<int> dp(n + 2);
  vector<int> broken(n + 1);

  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    broken[a] = 1;
  }

  const int mod = 1000000007;
  dp[n] = 1;
  for (int i = n - 1; i <= 0; i--) {
    if (broken[i] = 1) {
      continue;
    }
    dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
  }
  cout << dp[0] << endl;
}


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

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

  vector<int> dp(n + 2);
  vector<int> broken(n + 1);

  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    broken[a] = 1;
  }

  const int mod = 1000000007;
  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    if (broken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
  }
  cout << dp[0] << endl;
}
Problem p03013 (C++)

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

using namespace std;

const long long mod = 1000000007;

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

  unordered_set<int> a_i;

  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    a_i.insert(a);
  }

  long long s[10001] = {};
  s[0] = 1;

  for (int i = 1; i <= n; i++) {
    if (a_i.find(i) != a_i.end())
      s[i] = 0;
    else {
      if (i > 1) {
        if (a_i.find(i - 1) != a_i.end())
          s[i] = s[i - 2];
        else
          s[i] = s[i - 1] + s[i - 2];
      } else
        s[i] = s[i - 1];
    }
    s[i] = s[i] % mod;
  }

  cout << s[n] << endl;

  return 0;
}

Fixed submission:
#include <iostream>
#include <unordered_set>

using namespace std;

const long long mod = 1000000007;

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

  unordered_set<int> a_i;

  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    a_i.insert(a);
  }

  long long s[100001] = {};
  s[0] = 1;

  for (int i = 1; i <= n; i++) {
    if (a_i.find(i) != a_i.end())
      s[i] = 0;
    else {
      if (i > 1) {
        if (a_i.find(i - 1) != a_i.end())
          s[i] = s[i - 2];
        else
          s[i] = s[i - 1] + s[i - 2];
      } else
        s[i] = s[i - 1];
    }
    s[i] = s[i] % mod;
  }

  cout << s[n] << endl;

  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);
int64_t mod64 = 1e9 + 7;

template <typename T> T gcd(T a, T b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

template <typename T> T lcm(T a, T b) {
  T g = gcd(a, b);
  return a / g * b;
}

bool check(vector<int> a, int index, int key) {
  if (a[index] >= key)
    return true;
  else
    return false;
}

int lower_bound(vector<int> a, int key) {
  int left = -1, right = a.size();
  while (right - left > 1) {
    int mid = left + (left + right) / 2;
    if (check(a, mid, key))
      right = mid;
    else
      left = mid;
  }
  return right;
}

int main() {

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

  vector<int64_t> fib(N + 10);
  fib[0] = 0;
  fib[1] = 1;
  for (int i = 2; i < fib.size(); i++) {
    fib[i] = fib[i - 1] + fib[i - 2];
    fib[i] %= mod64;
  }

  // error
  for (int i = 0; i < M - 1; i++) {
    if (a[i + 1] - a[i] == 1) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (a[M - 1] == N) {
    cout << 0 << endl;
    return 0;
  }

  int64_t state = 0;
  int64_t ans = 1;
  for (int i = 0; i < M; i++) {

    ans *= fib[a[i] - state];

    state = a[i] + 1;
    ans %= mod64;
  }

  ans *= fib[N + 1 - state];
  ans %= mod64;

  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);
int64_t mod64 = 1e9 + 7;

template <typename T> T gcd(T a, T b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

template <typename T> T lcm(T a, T b) {
  T g = gcd(a, b);
  return a / g * b;
}

bool check(vector<int> a, int index, int key) {
  if (a[index] >= key)
    return true;
  else
    return false;
}

int lower_bound(vector<int> a, int key) {
  int left = -1, right = a.size();
  while (right - left > 1) {
    int mid = left + (left + right) / 2;
    if (check(a, mid, key))
      right = mid;
    else
      left = mid;
  }
  return right;
}

int main() {

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

  vector<int64_t> fib(N + 10);
  fib[0] = 0;
  fib[1] = 1;
  for (int i = 2; i < fib.size(); i++) {
    fib[i] = fib[i - 1] + fib[i - 2];
    fib[i] %= mod64;
  }

  // error
  for (int i = 0; i < M - 1; i++) {
    if (a[i + 1] - a[i] == 1) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (M == 0) {
    cout << fib[N + 1] << endl;
    return 0;
  }

  int64_t state = 0;
  int64_t ans = 1;
  for (int i = 0; i < M; i++) {

    ans *= fib[a[i] - state];

    state = a[i] + 1;
    ans %= mod64;
  }

  ans *= fib[N + 1 - state];
  ans %= mod64;

  cout << ans << endl;

  return 0;
}
Problem p03013 (C++)

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

typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m, false);
  for (int i = 0; i < m; i++) {
    int num;
    cin >> num;
    a[num] = true;
  }
  vector<int> dp(n + 2, 0);
  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[i] << endl;
  }
  cout << dp[0] << endl;
  return 0;
}

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

typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1, false);
  for (int i = 0; i < m; i++) {
    int num;
    cin >> num;
    a[num] = true;
  }
  vector<int> dp(n + 2, 0);
  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[i] << endl;
  }
  cout << dp[0] << endl;
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7, MAX = 1e5;

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);
  dp[0] = 1;
  for (int i = 0; i < m; i++) {
    dp[a[i]] = -1;
  }
  if (a[0] != 1)
    dp[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (dp[i] == -1)
      continue;
    if (dp[i - 1] >= 0)
      dp[i] += dp[i - 1];
    dp[i] %= MOD;
    if (dp[i - 2] >= 0)
      dp[i] += dp[i - 2];
    dp[i] %= MOD;
  }
  cout << dp[n] << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7, MAX = 1e5;

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);
  dp[0] = 1;
  for (int i = 0; i < m; i++) {
    dp[a[i]] = -1;
  }
  if (!a.empty())
    if (a[0] != 1)
      dp[1] = 1;
  if (a.empty())
    dp[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (dp[i] == -1)
      continue;
    if (dp[i - 1] >= 0)
      dp[i] += dp[i - 1];
    dp[i] %= MOD;
    if (dp[i - 2] >= 0)
      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;
typedef long long ll;
const int MOD = 1000000007;
// cout << setprecision(20) <<

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> dp(N + 2);
  dp.assign(N + 1, 0);
  vector<ll> m(M);
  for (int i = 0; i < M; ++i)
    cin >> m[i];
  int idx = 0;

  dp[0] = 1;
  dp[1] = 1;
  if (m[idx] == 1) {
    dp[1] = 0;
    idx++;
  }

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
// cout << setprecision(20) <<

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> dp(N + 2);
  dp.assign(N + 1, 0);
  vector<ll> m(M + 1);
  for (int i = 0; i < M; ++i)
    cin >> m[i];
  int idx = 0;

  dp[0] = 1;
  dp[1] = 1;
  if (m[idx] == 1) {
    dp[1] = 0;
    idx++;
  }

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

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

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

const ll INF = 1LL << 60;

vector<ll> dp(100010, 0);

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (int i = 0; i < M; i++) {
    scanf("%d", &A[i]);
  }
  dp[0] = 1;

  int j = 0;
  for (int i = 1; i <= N; i++) {
    if (i == A[j]) {
      dp[i] = 0;
      j++;
      continue;
    }
    dp[i] += dp[i - 1];
    if (i > 1)
      dp[i] += dp[i - 2];
    dp[i] %= mod;
  }

  cout << dp[N] % mod << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long ll;

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

const ll INF = 1LL << 60;

vector<ll> dp(100010, 0);

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(100010);
  for (int i = 0; i < M; i++) {
    scanf("%d", &A[i]);
  }
  dp[0] = 1;

  int j = 0;
  for (int i = 1; i <= N; i++) {
    if (i == A[j]) {
      dp[i] = 0;
      j++;
      continue;
    }
    dp[i] += dp[i - 1];
    if (i > 1)
      dp[i] += dp[i - 2];
    dp[i] %= mod;
  }

  cout << dp[N] % mod << endl;

  return 0;
}
Problem p03013 (C++)

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

int main() {

  int64_t N, M, step2down = 1, step1down = 1, brokepoint = 0;
  cin >> N >> M;
  vector<int64_t> A(M);
  vector<int64_t> mem(100001, 0);
  for (int i = 0; i < M; i++) {
    cin >> A[i];
    if (i > 0) {
      if (A[i] - A[i - 1] == 1) {
        cout << 0 << endl;
        return 0;
      }
    }
  }

  if (A[0] == 1) {
    mem[1] = 0;
    brokepoint++;
  } else
    mem[1] = 1;
  mem[0] = 1;
  for (int i = 1; i < N; i++) {
    if (A[brokepoint] == i + 1) {
      mem[i + 1] = 0;
      if (brokepoint < M - 1)
        brokepoint++;
    } else
      mem[i + 1] = mem[i] + mem[i - 1];
    mem[i + 1] %= 1000000007;
  }
  cout << mem[N] << endl;
}

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

int main() {

  int64_t N, M, step2down = 1, step1down = 1, brokepoint = 0;
  cin >> N >> M;
  vector<int64_t> A(100000);
  vector<int64_t> mem(100001, 0);
  for (int i = 0; i < M; i++) {
    cin >> A[i];
    if (i > 0) {
      if (A[i] - A[i - 1] == 1) {
        cout << 0 << endl;
        return 0;
      }
    }
  }

  if (A[0] == 1) {
    mem[1] = 0;
    brokepoint++;
  } else
    mem[1] = 1;
  mem[0] = 1;
  for (int i = 1; i < N; i++) {
    if (A[brokepoint] == i + 1) {
      mem[i + 1] = 0;
      if (brokepoint < M - 1)
        brokepoint++;
    } else
      mem[i + 1] = mem[i] + mem[i - 1];
    mem[i + 1] %= 1000000007;
  }
  cout << mem[N] << endl;
}
Problem p03013 (C++)

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

#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

struct edge {
  int to, cost;
};

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> P;

const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);

const int mx4[] = {0, 1, 0, -1};
const int my4[] = {1, 0, -1, 0};
const int mx8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int my8[] = {1, 1, 0, -1, -1, -1, 0, 1};

ll dp[100010];

int main() {
  int n, m;
  cin >> n >> m;
  vi a(m);
  rep(i, m) cin >> a[i];
  dp[0] = 1;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (i == a[cnt]) {
      cnt++;
      continue;
    }
    if (i == 1)
      dp[i] = 1;
    else
      dp[i] = (dp[i - 2] + dp[i - 1]) % MOD;
  }
  cout << dp[n] << endl;
  return 0;
}


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

#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

struct edge {
  int to, cost;
};

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> P;

const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);

const int mx4[] = {0, 1, 0, -1};
const int my4[] = {1, 0, -1, 0};
const int mx8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int my8[] = {1, 1, 0, -1, -1, -1, 0, 1};

ll dp[100010];

int main() {
  int n, m;
  cin >> n >> m;
  vi a(m);
  rep(i, m) cin >> a[i];
  dp[0] = 1;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (cnt < m && i == a[cnt]) {
      cnt++;
      continue;
    }
    if (i == 1)
      dp[i] = 1;
    else
      dp[i] = (dp[i - 2] + dp[i - 1]) % MOD;
  }
  cout << dp[n] << endl;
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _USE_MAT_DEFINES
#include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#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> v(N + 2, 0);
  v[0] = 0;
  v[1] = 1;
  for (int i = 2; i <= N + 1; i++) {
    if (find(a.begin(), a.end(), i - 1) != a.end())
      continue;
    else {
      v[i] = (v[i - 1] + v[i - 2]) % 1000000007;
    }
  }

  cout << v[N + 1] << endl;
}

Fixed submission:
#define _USE_MAT_DEFINES
#include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#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> v(N + 2, 0);
  v[0] = 0;
  v[1] = 1;
  for (int i = 2; i <= N + 1; i++) {
    if (binary_search(a.begin(), a.end(), i - 1))
      continue;
    else {
      v[i] = (v[i - 1] + v[i - 2]) % 1000000007;
    }
  }

  cout << v[N + 1] << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define sz(x) (int)x.size()
#define endl '\n'
#define hell 1000000007
#define N 100001
#define rep(i, a, b) for (int i = a; i < b; i++)
typedef long long ll;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> dp(n + 1), op(m);
  dp[0] = 1;
  for (int &i : op)
    cin >> i;
  int ind = 0;
  for (int i = 1; i <= n; i++) {
    if (i == op[ind]) {
      ind++;
      dp[i] = 0;
    } else {
      dp[i] = dp[i - 1];
      if (i > 1)
        dp[i] += dp[i - 2];
      dp[i] = dp[i] % hell;
    }
  }
  cout << dp[n] << endl;
  return 0;
}


Fixed submission:
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define sz(x) (int)x.size()
#define endl '\n'
#define hell 1000000007
#define N 100001
#define rep(i, a, b) for (int i = a; i < b; i++)
typedef long long ll;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> dp(n + 1), op(m);
  dp[0] = 1;
  for (int &i : op)
    cin >> i;
  int ind = 0;
  for (int i = 1; i <= n; i++) {
    if (ind < m && i == op[ind]) {
      ind++;
      dp[i] = 0;
    } else {
      dp[i] = dp[i - 1];
      if (i > 1)
        dp[i] += dp[i - 2];
      dp[i] = dp[i] % hell;
    }
  }
  cout << dp[n] << endl;
  return 0;
}