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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++) //  repマクロ
#define leng(n) (int)(log10(n) + 1)                  //  桁数leng
#define INF 9223372036854775807                      //  巨大数INF
using namespace std;

int f(int n) {
  if (n == 0)
    return 1;
  if (n == 1)
    return 1;
  return f(n - 1) + f(n - 2);
}

signed main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M + 2);
  a[0] = -1;
  rep(i, M) cin >> a[i + 1];
  a[M + 1] = N + 1;

  int ans = 1;

  rep(i, M + 1) {
    if (a[i] + 1 == a[i + 1]) {
      ans = 0;
      break;
    }
    int d = a[i + 1] - a[i] - 2;
    ans = (ans * f(d)) % 1000000007;
  }
  cout << ans % 1000000007 << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++) //  repマクロ
#define leng(n) (int)(log10(n) + 1)                  //  桁数leng
#define INF 9223372036854775807                      //  巨大数INF
using namespace std;

int f(int n) {
  vector<int> vec(n + 3);
  vec[0] = 1;
  vec[1] = 1;
  rep(i, n) vec[i + 2] = (vec[i] + vec[i + 1]) % 1000000007;
  return vec[n];
}

signed main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M + 2);
  a[0] = -1;
  rep(i, M) cin >> a[i + 1];
  a[M + 1] = N + 1;

  int ans = 1;

  rep(i, M + 1) {
    if (a[i] + 1 == a[i + 1]) {
      ans = 0;
      break;
    }
    int d = a[i + 1] - a[i] - 2;
    ans = (ans * f(d)) % 1000000007;
  }
  cout << ans % 1000000007 << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rp(i, s, e) for (int i = (s); i < (e); ++i)

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 10);
  vector<bool> s(m, true);
  vector<long long> dp(n + 10, 0);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    s[a[i]] = false;
  }
  dp[0] = 1;
  if (s[1]) {
    dp[1] = 1;
  } else {
    dp[1] = 0;
  }
  for (int i = 1; i < n + 1; i++) {
    if (s[i + 1]) {
      dp[i + 1] = dp[i] + dp[i - 1];
      dp[i + 1] %= (1000000000 + 7);
    } else {
      dp[i + 1] = 0;
    }
  }
  cout << dp[n] << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rp(i, s, e) for (int i = (s); i < (e); ++i)

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<bool> s(n + 10, true);
  vector<long long> dp(n + 10, 0);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    s[a[i]] = false;
  }
  dp[0] = 1;
  if (s[1]) {
    dp[1] = 1;
  } else {
    dp[1] = 0;
  }
  for (int i = 1; i < n + 1; i++) {
    if (s[i + 1]) {
      dp[i + 1] = dp[i] + dp[i - 1];
      dp[i + 1] %= (1000000000 + 7);
    } else {
      dp[i + 1] = 0;
    }
  }
  cout << dp[n] << endl;
}
Problem p03013 (C++)

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

int main() {
  int mod = 1e9 + 7;
  int N, M;
  cin >> N >> M;

  vector<int> aa(M);
  for (int k = 0; k < M; k++) {
    cin >> aa[k];
  }

  vector<int> ans(N + 1);
  ans[0] = 1;

  for (int k = 1, l = 0; k <= N; k++) {
    if (aa[l] == k) {
      l++;
      continue;
    }
    if (k > 0) {
      ans[k] += ans[k - 1];
    }
    if (k > 1) {
      ans[k] += ans[k - 2];
    }
    ans[k] %= mod;
  }

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

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

int main() {
  int mod = 1e9 + 7;
  int N, M;
  cin >> N >> M;

  vector<int> aa(M);
  for (int k = 0; k < M; k++) {
    cin >> aa[k];
  }

  vector<int> ans(N + 1);
  ans[0] = 1;

  for (int k = 1, l = 0; k <= N; k++) {
    if (l < M && aa[l] == k) {
      l++;
      continue;
    }
    if (k > 0) {
      ans[k] += ans[k - 1];
    }
    if (k > 1) {
      ans[k] += ans[k - 2];
    }
    ans[k] %= mod;
  }

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

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
void add(long long &n, long long m) {
  n += m;
  if (n >= mod) {
    n -= mod;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> dp(n + 1);
  int br[100009] = {0};
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    br[x] = 1;
  }
  dp[0] = 1;
  for (int i = 0; i <= n; ++i) {
    if (br[i] == 1)
      dp[i] = 0;
    for (int j : {1, 2}) {
      if (i + j <= n)
        add(dp[i + j], dp[i]);
    }
  }
  cout << dp[n] << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a) a.begin(), a.end()
#define rep(i, K, N) for (long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(M);
  vector<ll> B(N + 1);

  rep(i, 0, M) cin >> A[i];

  B[0] = 1;
  ll a = 0;
  rep(i, 1, N + 1) {
    if (i == A[a]) {
      B[i] = 0;
      a++;
    } else {
      if (i == 1)
        B[i] = 1;
      else
        B[i] = (B[i - 1] % 1000000007 + B[i - 2] % 1000000007) % 1000000007;
    }
  }

  cout << B[N];
}

Fixed submission:
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a) a.begin(), a.end()
#define rep(i, K, N) for (long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(M);
  vector<ll> B(N + 1);

  rep(i, 0, M) cin >> A[i];

  B[0] = 1;
  ll a = 0;
  if (M == 0)
    A.push_back(-1);
  rep(i, 1, N + 1) {
    if (i == A[a]) {
      B[i] = 0;
      a++;
    } else {
      if (i == 1)
        B[i] = 1;
      else
        B[i] = (B[i - 1] % 1000000007 + B[i - 2] % 1000000007) % 1000000007;
    }
  }

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

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

using namespace std;

int main() {
  int n, m;
  long long num = 1e9 + 7;

  cin >> n >> m;
  vector<long long> fib(n);
  vector<bool> is_not_breaked(n, true);
  vector<int> a(m);

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

  if (is_not_breaked[0])
    fib[0] = 1;
  else
    fib[0] = 0;
  if (is_not_breaked[1])
    fib[1] = 1;
  else
    fib[1] = 0;

  for (int i = 2; i <= n; ++i) {
    if (is_not_breaked[i]) {
      fib[i] = fib[i - 1] + fib[i - 2];
      fib[i] %= num;
    } else {
      fib[i] = 0;
    }
  }

  cout << fib[n] % num << endl;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, m;
  long long num = 1e9 + 7;

  cin >> n >> m;
  vector<long long> fib(n + 1);
  vector<bool> is_not_breaked(n, true);
  vector<int> a(m);

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

  if (is_not_breaked[0])
    fib[0] = 1;
  else
    fib[0] = 0;
  if (is_not_breaked[1])
    fib[1] = 1;
  else
    fib[1] = 0;

  for (int i = 2; i <= n; ++i) {
    if (is_not_breaked[i]) {
      fib[i] = fib[i - 1] + fib[i - 2];
      fib[i] %= num;
    } else {
      fib[i] = 0;
    }
  }

  cout << fib[n] % num << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll dp[100005] = {0};
const int mod = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  queue<int> out;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    out.push(a);
  }
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    if (out.front() == i) {
      while (out.front() == i)
        out.pop();
      continue;
    }
    dp[i + 1] += dp[i];
    dp[i + 1] %= mod;
    dp[i + 2] += dp[i];
    dp[i + 2] %= mod;
  }
  cout << dp[n] << endl;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll dp[100005] = {0};
const int mod = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  queue<int> out;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    out.push(a);
  }
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    if (!out.empty()) {
      if (out.front() == i) {
        while (out.front() == i && !out.empty())
          out.pop();
        continue;
      }
    }
    dp[i + 1] += dp[i];
    dp[i + 1] %= mod;
    dp[i + 2] += dp[i];
    dp[i + 2] %= mod;
  }
  cout << dp[n] << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
#define ll long long int
using namespace std;

int main() {
  int n, m, denger_id;
  vector<int> a;
  vector<ll> step;

  cin >> n >> m;
  a.resize(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  step.resize(n + 100);
  for (int i = 0; i < n + 1; i++) {
    step[i] = 0;
  }

  step[0] = 1;
  denger_id = 0;
  if (a[denger_id] == 1) {
    step[1] = 0;
    denger_id++;
  } else {
    step[1] = 1;
  }

  for (int i = 2; i < n + 1; i++) {
    if (i == a[denger_id]) {
      denger_id++;
    } else {
      step[i] = (step[i - 1] + step[i - 2]) % 1000000007;
    }
  }
  cout << step[n] % 1000000007 << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
#define ll long long int
using namespace std;

int main() {
  int n, m, denger_id;
  vector<int> a;
  vector<ll> step;

  cin >> n >> m;
  a.resize(m + 100);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  step.resize(n + 100);
  for (int i = 0; i < n + 1; i++) {
    step[i] = 0;
  }

  step[0] = 1;
  denger_id = 0;
  if (a[denger_id] == 1) {
    step[1] = 0;
    denger_id++;
  } else {
    step[1] = 1;
  }

  for (int i = 2; i < n + 1; i++) {
    if (i == a[denger_id]) {
      denger_id++;
    } else {
      step[i] = (step[i - 1] + step[i - 2]) % 1000000007;
    }
  }
  cout << step[n] % 1000000007 << 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;

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);
  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;
  return 0;
}


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

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);
  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;
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using MIte = multimap<vector<long>, int>::iterator;

const long long mod_const = 1000000007;

// i段目までの行き方
long long Pattern(int i, const vector<int> &vA) {
  if (i == 0) {
    return 1;
  } else if (i == 1) {
    return 1;
  } else {
    long long a = 0;
    long long b = 0;
    if (vA[i - 2] == 0)
      a = 1;
    if (vA[i - 1] == 0)
      b = 1;
    return ((a * Pattern(i - 2, vA) + b * Pattern(i - 1, vA)) % mod_const);
  }
}

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> vA(N + 1, 0);
  for (int i = 0; i != M; ++i) {
    int w = 0;
    cin >> w;
    vA[w] = 1;
    if (w >= 1) {
      if (vA[w - 1] == 1) {
        cout << "0" << endl;
        return 0;
      }
    }
  }

  vector<long long> vPattern(N + 1, 0);
  vPattern[0] = 1;
  vPattern[1] = 1;
  int i = 2;
  while (1) {
    long long a = 0;
    long long b = 0;
    if (vA[i - 2] == 0)
      a = 1;
    if (vA[i - 1] == 0)
      b = 1;
    if (vA[i] == 0) {
      vPattern[i] = (a * vPattern[i - 2] + b * vPattern[i - 1]) % mod_const;
    } else {
      vPattern[i] = 0;
    }
    i++;
    if (i == N + 1) {
      break;
    }
  }

  cout << vPattern[N] << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using MIte = multimap<vector<long>, int>::iterator;

const long long mod_const = 1000000007;

// i段目までの行き方
long long Pattern(int i, const vector<int> &vA) {
  if (i == 0) {
    return 1;
  } else if (i == 1) {
    return 1;
  } else {
    long long a = 0;
    long long b = 0;
    if (vA[i - 2] == 0)
      a = 1;
    if (vA[i - 1] == 0)
      b = 1;
    return ((a * Pattern(i - 2, vA) + b * Pattern(i - 1, vA)) % mod_const);
  }
}

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> vA(N + 1, 0);
  for (int i = 0; i != M; ++i) {
    int w = 0;
    cin >> w;
    vA[w] = 1;
    if (w >= 1) {
      if (vA[w - 1] == 1) {
        cout << "0" << endl;
        return 0;
      }
    }
  }

  vector<long long> vPattern(N + 1, 0);
  vPattern[0] = 1;
  vPattern[1] = 1;
  int i = 2;
  if (N >= 2) {
    while (1) {
      long long a = 0;
      long long b = 0;
      if (vA[i - 2] == 0)
        a = 1;
      if (vA[i - 1] == 0)
        b = 1;
      if (vA[i] == 0) {
        vPattern[i] = (a * vPattern[i - 2] + b * vPattern[i - 1]) % mod_const;
      } else {
        vPattern[i] = 0;
      }
      i++;
      if (i == N + 1) {
        break;
      }
    }
  }

  cout << vPattern[N] << endl;

  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll n, m, a, dp[100010];
string s[2010];
bool ju[2010];

ll pow(ll x, ll y) {
  if (y == 0)
    return 1;
  if (y % 2) {
    return pow(x, y - 1) * x % mod;
  } else {
    ll yyy = pow(x, y / 2);
    return yyy * yyy % mod;
  }
}

ll div(ll x) { return pow(x, mod - 2); }

int main(void) {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a;
    ju[a] = true;
  }
  dp[0] = 1;
  if (!ju[1]) {
    dp[1] = 1;
  }
  for (int i = 2; i <= n; i++) {
    if (!ju[i]) {
      dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    }
  }
  cout << dp[n] << endl;
  int www;
  cin >> www;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll n, m, a, dp[100010];
string s[2010];
bool ju[100010];

ll pow(ll x, ll y) {
  if (y == 0)
    return 1;
  if (y % 2) {
    return pow(x, y - 1) * x % mod;
  } else {
    ll yyy = pow(x, y / 2);
    return yyy * yyy % mod;
  }
}

ll div(ll x) { return pow(x, mod - 2); }

int main(void) {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a;
    ju[a] = true;
  }
  dp[0] = 1;
  if (!ju[1]) {
    dp[1] = 1;
  }
  for (int i = 2; i <= n; i++) {
    if (!ju[i]) {
      dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    }
  }
  cout << dp[n] << endl;
  int www;
  cin >> www;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), rend()
#define PB pushback
#define SORT(c) sort((c).begin(), (c).end())

const LL INF = 1LL << 60;

// priority_queue<int> p;

int i, j, k, tmp, ans, cnt, N, M;
string s;

// scanf("%d",&N);

// printf("%d", ans);

// cout <<  << endl;

int main(void) {
  vector<LL> A;
  vector<int> a;
  cnt = 0;
  scanf("%d %d", &N, &M);
  REP(i, M) {
    scanf("%d", &tmp);
    a.push_back(tmp);
  }
  REP(i, N + 1) { A.push_back(0); }
  tmp = 0;
  A.at(0) = 1;
  if (a.at(cnt) != 1) {
    A.at(1) = 1;

  } else {
    cnt++;
  }

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

    if (a.size() > cnt && i == a.at(cnt)) {
      cnt++;
      A.at(i) = 0;
    } else {
      A.at(i) = (A.at(i - 1) + A.at(i - 2)) % 1000000007LL;
      if (A.at(i) == 0) {
        printf("0\n");
        return 0;
      }
    }
  }

  printf("%lld", A.at(N) % 1000000007);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <array>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), rend()
#define PB pushback
#define SORT(c) sort((c).begin(), (c).end())

const LL INF = 1LL << 60;

// priority_queue<int> p;

int i, j, k, tmp, ans, cnt, N, M;
string s;

// scanf("%d",&N);

// printf("%d", ans);

// cout <<  << endl;

int main(void) {
  vector<LL> A;
  vector<int> a;
  cnt = 0;
  scanf("%d %d", &N, &M);
  if (M == 0) {
    a.push_back(0);
  }
  REP(i, M) {
    scanf("%d", &tmp);
    a.push_back(tmp);
  }
  REP(i, N + 1) { A.push_back(0); }
  tmp = 0;
  A.at(0) = 1;
  if (a.at(cnt) != 1) {
    A.at(1) = 1;

  } else {
    cnt++;
  }

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

    if (a.size() > cnt && i == a.at(cnt)) {
      cnt++;
      A.at(i) = 0;
    } else {
      A.at(i) = (A.at(i - 1) + A.at(i - 2)) % 1000000007LL;
      if (A.at(i) == 0) {
        printf("0\n");
        return 0;
      }
    }
  }

  printf("%lld", A.at(N) % 1000000007);
  return 0;
}
Problem p03013 (C++)

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

int main(void) {
  int n, m;
  std::cin >> n >> m;

  std::vector<int> broken(n + 1);
  for (int i = 0; i < n; i++) {
    int a;
    std::cin >> a;
    broken.at(a) = 1;
  }

  std::vector<int> dp(n + 2);
  const int mod = 1000000007;
  dp.at(n) = 1;

  for (int i = n - 1; i >= 0; i--) {
    if (broken.at(i)) {
      dp.at(i) = 0;
      continue;
    }
    dp.at(i) = (dp.at(i + 1) + dp.at(i + 2)) % mod;
  }
  std::cout << dp.at(0) << std::endl;
  return 0;
}

Fixed submission:
#include <cstdio>
#include <iostream>
#include <vector>

int main(void) {
  int n, m;
  std::cin >> n >> m;

  std::vector<int> broken(n + 1);
  for (int i = 0; i < m; i++) {
    int a;
    std::cin >> a;
    broken.at(a) = 1;
  }

  std::vector<int> dp(n + 2);
  const int mod = 1000000007;
  dp.at(n) = 1;

  for (int i = n - 1; i >= 0; i--) {
    if (broken.at(i)) {
      dp.at(i) = 0;
      continue;
    }
    dp.at(i) = (dp.at(i + 1) + dp.at(i + 2)) % mod;
  }
  std::cout << dp.at(0) << std::endl;
  return 0;
}
Problem p03013 (C++)

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

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> broken(n + 1);
  for (int i = 0; i < n + 1; i++) {
    int a;
    std::cin >> a;
    broken[a] = 1;
  }

  std::vector<int> dp(n + 2);
  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;
  }
  std::cout << dp[0] << std::endl;
  return 0;
}


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

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> broken(n + 1);
  for (int i = 0; i < m; i++) {
    int a;
    std::cin >> a;
    broken[a] = 1;
  }

  std::vector<int> dp(n + 2);
  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;
  }
  std::cout << dp[0] << std::endl;
  return 0;
}
Problem p03013 (C++)

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

int main(void) {
  i64 n, m;
  cin >> n >> m;
  vector<bool> a(m, false);
  vector<i64> dp(n + 1, 0);
  for (i64 i = 0; i < m; i++) {
    i64 x;
    cin >> x;
    a[x] = true;
  }
  dp[0] = 1;
  for (i64 i = 1; i <= n; i++) {
    if (!a[i - 1]) {
      dp[i] += dp[i - 1];
      dp[i] %= MOD;
    }
    if (i != 1 && !a[i - 2]) {
      dp[i] += dp[i - 2];
      dp[i] %= MOD;
    }
  }
  cout << dp[n] << endl;
}

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

int main(void) {
  i64 n, m;
  cin >> n >> m;
  vector<bool> a(n, false);
  vector<i64> dp(n + 1, 0);
  for (i64 i = 0; i < m; i++) {
    i64 x;
    cin >> x;
    a[x] = true;
  }
  dp[0] = 1;
  for (i64 i = 1; i <= n; i++) {
    if (!a[i - 1]) {
      dp[i] += dp[i - 1];
      dp[i] %= MOD;
    }
    if (i != 1 && !a[i - 2]) {
      dp[i] += 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;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll, ll>> vp;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
  rep(i, n) {                                                                  \
    ll x;                                                                      \
    cin >> x;                                                                  \
    v.push_back(x);                                                            \
  }
const ll INF = 99999999999999;
const ll MOD = 1000000007;

int main() {
  ll n, m;
  cin >> n >> m;
  vl a;
  inputv(a, m);
  vl s(n + 1, 0);
  s[0] = 1;
  ll point = 0;
  if (a[0] == 1) {
    s[1] = 0;
    point++;
  } else {
    s[1] = 1;
  }
  for (ll i = 2; i <= n; i++) {
    if (a[point] == i) {
      s[i] = 0;
      point++;
    } else {
      s[i] = (s[i - 1] + s[i - 2]) % MOD;
    }
  }
  cout << s[n];
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll, ll>> vp;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
  rep(i, n) {                                                                  \
    ll x;                                                                      \
    cin >> x;                                                                  \
    v.push_back(x);                                                            \
  }
const ll INF = 99999999999999;
const ll MOD = 1000000007;

int main() {
  ll n, m;
  cin >> n >> m;
  vl a;
  inputv(a, m);
  rep(i, 100) { a.push_back(INF); }

  vl s(n + 1, 0);
  s[0] = 1;
  ll point = 0;
  if (a[0] == 1) {
    s[1] = 0;
    point++;
  } else {
    s[1] = 1;
  }
  for (ll i = 2; i <= n; i++) {
    if (a[point] == i) {
      s[i] = 0;
      point++;
    } else {
      s[i] = (s[i - 1] + s[i - 2]) % MOD;
    }
  }
  cout << s[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 PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

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

  int n, m;
  cin >> n >> m;
  vector<int> as(m);
  rep(i, m) cin >> as[i];

  vector<ll> dp(n + 1);
  dp[0] = 1;
  int j = 0;
  rep(i, n) {
    if (i + 1 == as[j]) {
      if (j < m - 1)
        j++;
    } else if (i + 1 <= n)
      dp[i + 1] = (dp[i + 1] + dp[i]) % 1000000007;
    if (i + 2 != as[j] && i + 2 <= n) {
      dp[i + 2] = (dp[i + 2] + dp[i]) % 1000000007;
    }
  }
  cout << dp[n] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

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

  int n, m;
  cin >> n >> m;
  vector<int> as(m);
  rep(i, m) cin >> as[i];
  if (m == 0)
    as.push_back(0);

  vector<ll> dp(n + 1);
  dp[0] = 1;
  int j = 0;
  rep(i, n) {
    if (i + 1 == as[j]) {
      if (j < m - 1)
        j++;
    } else if (i + 1 <= n)
      dp[i + 1] = (dp[i + 1] + dp[i]) % 1000000007;
    if (i + 2 != as[j] && i + 2 <= n) {
      dp[i + 2] = (dp[i + 2] + dp[i]) % 1000000007;
    }
  }
  cout << dp[n] << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define LL long long
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPA(i, n) for (int i = 1; i < (n); ++i)
#define PII pair<int, int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(), (x).end()
#define ctoi(x) (x - 'a')
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a) {
  LL b = MOD, u = 1, v = 0;
  while (b) {
    LL t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0)
    u += MOD;
  return u;
}
int exp(int a, int b) {
  LL res = 1;
  LL sum = a;
  while (b) {
    if (b & 1)
      res = (res * sum) % MOD;
    sum = (sum * sum) % MOD;
    b >>= 1;
  }
  return res;
}

int main() {
  int N;
  cin >> N;
  int M;
  cin >> M;
  vector<int> line(N + 1, 0);
  REP(i, M) {
    int d;
    cin >> d;
    line[d] = -1;
  }
  line[0] = 1;
  REP(i, N) {
    if (line[i] == -1)
      continue;
    if (i + 1 >= line.size() || line[i + 1] == -1)
      ;
    else {
      line[i + 1] = (line[i + 1] + line[i]) % MOD;
    }
    if (line[i + 2] == -1)
      ;
    else {
      line[i + 2] = (line[i + 2] + line[i]) % MOD;
    }
  }
  cout << line.back() << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define LL long long
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPA(i, n) for (int i = 1; i < (n); ++i)
#define PII pair<int, int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(), (x).end()
#define ctoi(x) (x - 'a')
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a) {
  LL b = MOD, u = 1, v = 0;
  while (b) {
    LL t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0)
    u += MOD;
  return u;
}
int exp(int a, int b) {
  LL res = 1;
  LL sum = a;
  while (b) {
    if (b & 1)
      res = (res * sum) % MOD;
    sum = (sum * sum) % MOD;
    b >>= 1;
  }
  return res;
}

int main() {
  int N;
  cin >> N;
  int M;
  cin >> M;
  vector<int> line(N + 1, 0);
  REP(i, M) {
    int d;
    cin >> d;
    line[d] = -1;
  }
  line[0] = 1;
  REP(i, N) {
    if (line[i] == -1)
      continue;
    if (i + 1 >= line.size() || line[i + 1] == -1)
      ;
    else {
      line[i + 1] = (line[i + 1] + line[i]) % MOD;
    }
    if (i + 2 >= line.size() || line[i + 2] == -1)
      ;
    else {
      line[i + 2] = (line[i + 2] + line[i]) % MOD;
    }
  }
  cout << line.back() << 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;
using P = pair<int, int>;

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

  int mod = 1e9 + 7;
  int n, m;
  cin >> n >> m;
  vector<int> v(n + 1, 0), a(m);
  rep(i, m) {
    cin >> a[i];
    if ((a[i] - a[i - 1]) == 1 && i != 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  int j = 0;
  v[0] = 1;
  if (a[j] == 1) {
    v[1] = 0;
    ++j;
  } else
    v[1] = 1;

  int ans = 0;

  for (int i = 2; i <= n; ++i) {
    if (a[j] != i) {
      v[i] = v[i - 1] + v[i - 2];
      v[i] %= mod;
    } else {
      v[i + 1] = v[i - 1];
      ++i;
      ++j;
    }
  }
  cout << v[n];
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  int mod = 1e9 + 7;
  int n, m;
  cin >> n >> m;
  vector<int> v(n + 1, 0), a(m + 1, -1);
  rep(i, m) {
    cin >> a[i];
    if ((a[i] - a[i - 1]) == 1 && i != 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  int j = 0;
  v[0] = 1;
  if (a[j] == 1) {
    v[1] = 0;
    ++j;
  } else
    v[1] = 1;

  int ans = 0;

  for (int i = 2; i <= n; ++i) {
    if (a[j] != i) {
      v[i] = v[i - 1] + v[i - 2];
      v[i] %= mod;
    } else {
      v[i + 1] = v[i - 1];
      ++i;
      ++j;
    }
  }
  cout << v[n];
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <map>
#include <stdio.h>
#include <string>
#include <vector>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(m);
  vector<long long> dp(n + 1, 0);
  for (int i = 0; i < m; i++) {
    cin >> v[i];
  }

  int index = 0;
  dp[0] = 1;
  if (v[index] != 1) {
    dp[1] = 1;
  } else {
    dp[1] = 0;
    index++;
  }

  for (int i = 2; i <= n; i++) {
    if (v[index] == i) {
      dp[i] = 0;
      index++;
    } else {
      dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
    }
  }

  cout << dp[n] << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <map>
#include <stdio.h>
#include <string>
#include <vector>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(m + 1, 0);
  vector<long long> dp(n + 1, 0);
  for (int i = 0; i < m; i++) {
    cin >> v[i];
  }

  int index = 0;
  dp[0] = 1;
  if (v[index] != 1) {
    dp[1] = 1;
  } else {
    dp[1] = 0;
    index++;
  }

  for (int i = 2; i <= n; i++) {
    if (v[index] == i) {
      dp[i] = 0;
      index++;
    } else {
      dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
    }
  }

  cout << dp[n] << endl;

  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type>
#define endl '\n'

#define FOR(i, A, B) for (auto i = (A); i != (B); i++)
#define FORD(i, A, B) for (auto i = (A); i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
};

const int MOD = 1000000007;

int main(int argc, char **argv) {
  io_init();

  // Actual program code starts here.
  int N, M;
  cin >> N >> M;
  VEC(bool) broke(N + 1, false);
  FOR(i, 0, M) {
    int s;
    cin >> s;
    broke[s] = true;
  }

  VEC(int) dp(N, 0);
  FORD(i, N, -1) {
    if (i == N) {
      dp[i] = 1;
      continue;
    }

    if (broke[i])
      continue;

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

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


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type>
#define endl '\n'

#define FOR(i, A, B) for (auto i = (A); i != (B); i++)
#define FORD(i, A, B) for (auto i = (A); i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
};

const int MOD = 1000000007;

int main(int argc, char **argv) {
  io_init();

  // Actual program code starts here.
  int N, M;
  cin >> N >> M;
  VEC(bool) broke(N + 1, false);
  FOR(i, 0, M) {
    int s;
    cin >> s;
    broke[s] = true;
  }

  VEC(int) dp(N + 1, 0);
  FORD(i, N, -1) {
    if (i == N) {
      dp[i] = 1;
      continue;
    }

    if (broke[i])
      continue;

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

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

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

int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(m);
  for (long long i = 0; i < m; i++)
    cin >> a[i];
  vector<long long> ans(n + 1);
  ans[0] = 1;
  long long cnt = 0;
  if (a[0] == 1) {
    ans[1] = 0;
    cnt++;
  } else
    ans[1] = 1;

  for (long long i = 2; i <= n; i++) {
    if (a[cnt] == i) {
      cnt++;
      ans[i] = 0;
    } else
      ans[i] = (ans[i - 1] + ans[i - 2]) % 1000000007;
  }
  cout << ans[n] << endl;
  return 0;
}


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

int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(m + 1);
  for (long long i = 0; i < m; i++)
    cin >> a[i];
  vector<long long> ans(n + 1);
  ans[0] = 1;
  long long cnt = 0;
  if (a[0] == 1) {
    ans[1] = 0;
    cnt++;
  } else
    ans[1] = 1;

  for (long long i = 2; i <= n; i++) {
    if (a[cnt] == i) {
      cnt++;
      ans[i] = 0;
    } else
      ans[i] = (ans[i - 1] + ans[i - 2]) % 1000000007;
  }
  cout << ans[n] << endl;
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  long long mod = 1e9 + 7;
  cin >> n >> m;
  vector<bool> hole(m + 1, 0);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    hole[a] = true;
  }
  vector<long long int> 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 (hole[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;
  long long mod = 1e9 + 7;
  cin >> n >> m;
  vector<bool> hole(n + 1, 0);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    hole[a] = true;
  }
  vector<long long int> 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 (hole[j])
        continue;
      count[j] += count[i];
      count[j] %= mod;
    }
  }
  cout << count[n] << endl;
  return 0;
}
Problem p03013 (Python)

Buggy submission (status: Runtime Error):
def typical_stairs():
    n, m, *dangerous = map(int, open(0).read().split())
    dangerous = set(*dangerous)
    mod = 1000000007
    dp = [0] * (n + 1)
    dp[0] = 1
    if 1 not in dangerous:
        dp[1] = 1
    for i in range(2, n + 1):
        if i not in dangerous:
            dp[i] = (dp[i - 2] + dp[i - 1]) % mod
    print(dp[-1])


if __name__ == "__main__":
    typical_stairs()


Fixed submission:
def typical_stairs():
    n, m, *dangerous = map(int, open(0).read().split())
    dangerous = set(dangerous)
    mod = 1000000007
    dp = [0] * (n + 1)
    dp[0] = 1
    if 1 not in dangerous:
        dp[1] = 1
    for i in range(2, n + 1):
        if i not in dangerous:
            dp[i] = (dp[i - 2] + dp[i - 1]) % mod
    print(dp[-1])


if __name__ == "__main__":
    typical_stairs()
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++)

const ll MAX = 1e6;
const ll MOD = 1e9 + 7;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll COM(ll n, ll k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll mod = 1e9 + 7;
  ll N, M;
  cin >> N >> M;
  vector<ll> a(M);
  rep(i, M) cin >> a[i];

  vector<ll> steps(N + 1, 0);
  rep(i, M - 1) if (a[i] == a[i + 1] - 1) {
    cout << 0 << endl;
    return 0;
  }
  rep(i, M - 1) steps[a[i + 1] - a[i] - 2]++;
  steps[a[0] - 1]++;
  steps[N - a[M - 1] - 1]++;
  COMinit();
  ll ans = 1;
  rep(i, N + 1) {
    if (steps[i] == 0)
      continue;
    ll two_max = i / 2, way = 0;
    rep(two, two_max + 1) {
      ll one = i - 2 * two;
      way += COM(one + two, two);
      way %= mod;
    }
    rep(j, steps[i]) ans = (ans * way) % mod;
  }
  cout << ans << endl;
  return 0;
}


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++)

const ll MAX = 1e6;
const ll MOD = 1e9 + 7;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll COM(ll n, ll k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll mod = 1e9 + 7;
  ll N, M;
  cin >> N >> M;
  vector<ll> a(M);
  rep(i, M) cin >> a[i];

  vector<ll> steps(N + 1, 0);
  rep(i, M - 1) if (a[i] == a[i + 1] - 1) {
    cout << 0 << endl;
    return 0;
  }
  rep(i, M - 1) steps[a[i + 1] - a[i] - 2]++;
  if (M > 0) {
    steps[a[0] - 1]++;
    steps[N - a[M - 1] - 1]++;
  } else {
    steps[N]++;
  }
  COMinit();
  ll ans = 1;
  rep(i, N + 1) {
    if (steps[i] == 0)
      continue;
    ll two_max = i / 2, way = 0;
    rep(two, two_max + 1) {
      ll one = i - 2 * two;
      way += COM(one + two, two);
      way %= mod;
    }
    rep(j, steps[i]) ans = (ans * way) % mod;
  }
  cout << ans << endl;
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
typedef long long ll;
const ll mod = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;

signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> broken(n);
  rep(i, n) {
    int a;
    cin >> a;
    broken[a] = 1; // 1 ~= true
  }

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


Fixed submission:
#include <iostream>
#include <vector>
typedef long long ll;
const ll mod = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;

signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> broken(n);
  rep(i, m) {
    int a;
    cin >> a;
    broken[a] = 1; // 1 ~= true
  }

  vector<int> dp(n + 2);
  dp[n] = 1;
  for (int i = n - 1; i >= 0; --i) {
    if (broken[i]) {
      dp[i] = 0;
      continue;
    } else {
      dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
    }
  }
  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;
using pint = pair<int, int>;
ll mod = 1000000007, mod2 = 998244353;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

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 long long INF = 1LL << 60;
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

bool is_prime[1000010];
int dp[100010];
int ana[100010];
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < m; ++i) {
    cin >> a[i];
    ana[a[i]] = 1;
  }
  dp[0] = 1;
  if (a[0] != 1)
    dp[1] = 1;
  else
    dp[1] = 0;
  for (int i = 2; i <= n; ++i) {
    if (!ana[i - 2]) {
      dp[i] += dp[i - 2];
      dp[i] %= mod;
    }
    if (!ana[i - 1]) {
      dp[i] += dp[i - 1];
      dp[i] %= mod;
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int, int>;
ll mod = 1000000007, mod2 = 998244353;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

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 long long INF = 1LL << 60;
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

bool is_prime[1000010];
int dp[100010];
int ana[100010];
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < m; ++i) {
    cin >> a[i];
    ana[a[i]] = 1;
  }
  dp[0] = 1;
  if (ana[1] != 1)
    dp[1] = 1;
  else
    dp[1] = 0;
  for (int i = 2; i <= n; ++i) {
    if (!ana[i - 2]) {
      dp[i] += dp[i - 2];
      dp[i] %= mod;
    }
    if (!ana[i - 1]) {
      dp[i] += dp[i - 1];
      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 int n, m;
  cin >> n >> m;
  vector<long long int> ans(n + 1);
  vector<int> a(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  int atenji = 0;
  ans[0] = 1;
  if (1 == a[atenji]) {
    ans[1] = 0;
    atenji++;
    atenji = atenji > m - 1 ? atenji - 1 : atenji;
  } else
    ans[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (i == a[atenji]) {
      atenji++;
      atenji = atenji > m - 1 ? atenji - 1 : atenji;
      ans[i] = 0;
      continue;
    } else {
      ans[i] = ans[i - 1] + ans[i - 2];
    }
    ans[i] = ans[i] % 1000000007;
  }
  cout << ans[n] % 1000000007 << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  vector<long long int> ans(n + 1);
  if (m == 0) {
    ans[0] = 1;
    ans[1] = 1;
    for (int i = 2; i <= n; i++) {
      ans[i] = ans[i - 1] + ans[i - 2];
      ans[i] = ans[i] % 1000000007;
    }
    cout << ans[n] % 1000000007 << endl;
    return 0;
  }
  vector<int> a(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  int atenji = 0;
  ans[0] = 1;
  if (1 == a[atenji]) {
    ans[1] = 0;
    atenji++;
    atenji = atenji > m - 1 ? atenji - 1 : atenji;
  } else
    ans[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (i == a[atenji]) {
      atenji++;
      atenji = atenji > m - 1 ? atenji - 1 : atenji;
      ans[i] = 0;
      continue;
    } else {
      ans[i] = ans[i - 1] + ans[i - 2];
    }
    ans[i] = ans[i] % 1000000007;
  }
  cout << ans[n] % 1000000007 << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#define _GLIBCXX_DEBUG
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()

const int mod = 1e9 + 7;

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

  vector<int> dp(N + 1, 0);
  dp[0] = 1;
  if (a[1])
    dp[1] = 1;

  for (int i = 2; i <= N; i++) {
    if (a[i]) {
      dp[i] = dp[i - 1] + dp[i - 2];
      dp[i] %= mod;
    }
  }

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


Fixed submission:
#define _GLIBCXX_DEBUG
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()

const int mod = 1e9 + 7;

int main() {
  int N, M;
  cin >> N >> M;
  vector<bool> a(N + 1, true);
  for (int i = 0; i < M; i++) {
    int t;
    cin >> t;
    a[t] = false;
  }

  vector<int> dp(N + 1, 0);
  dp[0] = 1;
  if (a[1])
    dp[1] = 1;

  for (int i = 2; i <= N; i++) {
    if (a[i]) {
      dp[i] = dp[i - 1] + dp[i - 2];
      dp[i] %= mod;
    }
  }

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