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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int twx = 1000000007;
long long n, m, a, dp[10010];
bool pan[10010];
int main() {
  scanf("%lld %lld", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%lld", &a);
    pan[a] = 1;
  }
  dp[0] = 1;
  for (int i = 1; i <= n; i++)
    if (!pan[i])
      if (i == 1)
        dp[i] = dp[0];
      else
        dp[i] = ((dp[i] + dp[i - 1]) % twx + dp[i - 2]) % twx;
  printf("%d\n", dp[n]);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int twx = 1000000007;
long long n, m, a, dp[100010];
bool pan[100010];
int main() {
  scanf("%lld %lld", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%lld", &a);
    pan[a] = 1;
  }
  dp[0] = 1;
  for (int i = 1; i <= n; i++)
    if (!pan[i])
      if (i == 1)
        dp[i] = dp[0];
      else
        dp[i] = ((dp[i] + dp[i - 1]) % twx + dp[i - 2]) % twx;
  printf("%d\n", dp[n]);
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
  ll a, b, c, h, i, j, k, l, m, n, x, y;
  ll ans = 0;
  string s;
  cin >> n >> m;
  vector<ll> aa(m);
  for (i = 0; i < m; i++)
    cin >> aa[i];
  vector<ll> dp(n);
  dp[0] = 1;
  for (i = 1, a = 0; i <= n; i++) {
    if (a < m)
      if (aa[a] == i) {
        a++;
        continue;
      }
    dp[i] = dp[i - 1];
    if (i > 1)
      dp[i] += dp[i - 2];
    dp[i] %= 1000000007;
  }

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


Fixed submission:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
  ll a, b, c, h, i, j, k, l, m, n, x, y;
  ll ans = 0;
  string s;
  cin >> n >> m;
  vector<ll> aa(m);
  for (i = 0; i < m; i++)
    cin >> aa[i];
  vector<ll> dp(n + 1);
  dp[0] = 1;
  for (i = 1, a = 0; i <= n; i++) {
    if (a < m)
      if (aa[a] == i) {
        a++;
        continue;
      }
    dp[i] = dp[i - 1];
    if (i > 1)
      dp[i] += dp[i - 2];
    dp[i] %= 1000000007;
  }

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

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

typedef long long ll;
#define rep(i, N) for (ll(i) = 0; (i) < (N); (i)++)

const int mod = 1000000007;

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

  rep(i, m) { cin >> a[i]; }

  vector<ll> dp(n + 1);

  dp[0] = 1;
  int itr = 0;
  if (a[0] == 1) {
    dp[1] = 0;
    itr++;
  } else {
    dp[1] = 1;
  }

  for (int i = 2; i <= n; ++i) {
    if (itr < m && i == a[itr]) {
      dp[i] = 0;
      itr++;
    } else {
      dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    }
  }

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

Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;
#define rep(i, N) for (ll(i) = 0; (i) < (N); (i)++)

const int mod = 1000000007;

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

  rep(i, m) { cin >> a[i]; }

  vector<ll> dp(n + 1);

  dp[0] = 1;
  int itr = 0;
  if (m > 0 && a[0] == 1) {
    dp[1] = 0;
    itr++;
  } else {
    dp[1] = 1;
  }

  for (int i = 2; i <= n; ++i) {
    if (itr < m && i == a[itr]) {
      dp[i] = 0;
      itr++;
    } else {
      dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int dp[100000] = {};
long long cnt(int n) {
  if (n == 0 || n == 1)
    return dp[n] = 1;
  if (dp[n] != 0)
    return dp[n];
  else
    return (cnt(n - 1) + cnt(n - 2)) % 1000000007;
}

int main() {
  long long n, m;
  long long a[100010] = {};
  cin >> n >> m;
  a[0] = -1;
  a[m + 1] = n + 1;
  for (long long i = 1; i <= m; i++) {
    cin >> a[i];
  }
  long long ans = 1;
  long long f = 1;
  for (long long i = 0; i <= m; i++) {
    if (a[i + 1] - a[i] == 1)
      f = 0;
    else
      ans = (ans * cnt(a[i + 1] - a[i] - 2)) % 1000000007;
  }
  cout << ans * f << endl;
}

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

int dp[100000] = {};
long long cnt(int n) {
  if (n == 0 || n == 1)
    return dp[n] = 1;
  if (dp[n] != 0)
    return dp[n];
  else
    return dp[n] = (cnt(n - 1) + cnt(n - 2)) % 1000000007;
}

int main() {
  long long n, m;
  long long a[100010] = {};
  cin >> n >> m;
  a[0] = -1;
  a[m + 1] = n + 1;
  for (long long i = 1; i <= m; i++) {
    cin >> a[i];
  }
  long long ans = 1;
  long long f = 1;
  for (long long i = 0; i <= m; i++) {
    if (a[i + 1] - a[i] == 1)
      f = 0;
    else
      ans = (ans * cnt(a[i + 1] - a[i] - 2)) % 1000000007;
  }
  cout << ans * f << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, k, n) for (int i = k; i < n; i++)
#define REPEACH(itr, k) for (auto itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
typedef pair<double, int> P;

int main() {
  int n, m;
  cin >> n >> m;
  int broken;
  int now = 0;
  vector<ll> v(n + 1);
  v[0] = 1;
  v[1] = 1;
  v[2] = 2;
  for (int i = 3; i <= n + 1; i++) {
    v[i] = (v[i - 1] % MOD) + (v[i - 2] % MOD);
  }
  ll ans = 1;
  REP(i, m) {
    cin >> broken;
    if (now == broken) {
      cout << 0 << endl;
      return 0;
    }
    ans *= v[broken - 1 - now];
    ans %= MOD;
    now = broken + 1;
  }
  ans *= v[n - now];
  cout << ans % MOD << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, k, n) for (int i = k; i < n; i++)
#define REPEACH(itr, k) for (auto itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
typedef pair<double, int> P;

int main() {
  int n, m;
  cin >> n >> m;
  int broken;
  int now = 0;
  vector<ll> v(n + 1);
  v[0] = 1;
  v[1] = 1;
  v[2] = 2;
  for (int i = 3; i < n + 1; i++) {
    v[i] = (v[i - 1] % MOD) + (v[i - 2] % MOD);
  }
  ll ans = 1;
  REP(i, m) {
    cin >> broken;
    if (now == broken) {
      cout << 0 << endl;
      return 0;
    }
    ans *= v[broken - 1 - now];
    ans %= MOD;
    now = broken + 1;
  }
  ans *= v[n - now];
  cout << ans % MOD << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define MOD 1000000007

using namespace std;

int main() {
  int n, m, tmp, a[10009], dp[10009];
  cin >> n >> m;
  for (int i = 0; i <= n; i++) {
    a[i] = 0;
    dp[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    cin >> tmp;
    a[tmp] = 1;
  }

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


Fixed submission:
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define MOD 1000000007

using namespace std;

int main() {
  int n, m, tmp, a[100009], dp[100009];
  cin >> n >> m;
  for (int i = 0; i <= n; i++) {
    a[i] = 0;
    dp[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    cin >> tmp;
    a[tmp] = 1;
  }

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

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

using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++) // 0から

typedef long long ll;

ll binary_search(vector<ll> a, ll n, ll key) {
  ll right = n, left = -1;
  ll md = (right + left) / 2;

  while (right - left > 1) {
    if (a[md] <= key) {
      right = md;
    } else {
      left = md;
    }
    md = (right + left) / 2;
  }
  if (left == -1)
    return -1; // 無い場合
  return right;
}

vector<ll> prime;
void Prime(ll n) { // 線形篩,素数列挙
  vector<ll> p(n, 0);
  p[0] = 1;
  p[1] = 1;
  for (ll i = 2; i < n; i++) {
    if (p[i] == 0) {
      prime.push_back(i);
      p[i] = i;
    }
    ll k = prime.size();
    for (ll j = 0; j < k && i * prime[j] < n && prime[j] <= p[i]; j++) {
      p[i * prime[j]] = prime[j];
    }
  }
}

#define MOD ((ll)1e+9 + 7)

// cout<<fixed<<setprecision(10);
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) {
    cin >> a[i];
    if (i != 0) {
    }
  }

  vector<ll> cnt(n + 1, 0);
  cnt[0] = 1;
  int c = 0;
  rep(i, n + 1) {
    cnt[i] %= MOD;
    if (a[c] == i) {
      c++;
      continue;
    }
    if (i + 1 <= n) {
      cnt[i + 1] += cnt[i];
    }
    if (i + 2 <= n) {
      cnt[i + 2] += cnt[i];
    }
  }

  cout << cnt[n] << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++) // 0から

typedef long long ll;

ll binary_search(vector<ll> a, ll n, ll key) {
  ll right = n, left = -1;
  ll md = (right + left) / 2;

  while (right - left > 1) {
    if (a[md] <= key) {
      right = md;
    } else {
      left = md;
    }
    md = (right + left) / 2;
  }
  if (left == -1)
    return -1; // 無い場合
  return right;
}

vector<ll> prime;
void Prime(ll n) { // 線形篩,素数列挙
  vector<ll> p(n, 0);
  p[0] = 1;
  p[1] = 1;
  for (ll i = 2; i < n; i++) {
    if (p[i] == 0) {
      prime.push_back(i);
      p[i] = i;
    }
    ll k = prime.size();
    for (ll j = 0; j < k && i * prime[j] < n && prime[j] <= p[i]; j++) {
      p[i * prime[j]] = prime[j];
    }
  }
}

#define MOD ((ll)1e+9 + 7)

// cout<<fixed<<setprecision(10);
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) {
    cin >> a[i];
    if (i != 0) {
    }
  }

  vector<ll> cnt(n + 1, 0);
  cnt[0] = 1;
  int c = 0;
  rep(i, n + 1) {
    cnt[i] %= MOD;
    if (c < m && a[c] == i) {
      c++;
      continue;
    }
    if (i + 1 <= n) {
      cnt[i + 1] += cnt[i];
    }
    if (i + 2 <= n) {
      cnt[i + 2] += cnt[i];
    }
  }

  cout << cnt[n] << endl;

  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define FAST                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int, int>
#define pdd pair<ld, ld>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack<int>
#define stll stack<ll>
#define mseti multiset<ll>
#define msetd multiset<ll, greater<ll>>
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define stp setprecision(20) // use fixed before stp
#define endl '\n'
int main() {
  FAST
#ifndef ONLINE_JUDGE
      freopen("input.txt", "rt", stdin);
  freopen("output.txt", "wt", stdout);
#endif
  ll n, m;
  cin >> n >> m;
  ll ans[n + 1];
  for (ll i = 0; i <= n; i++) {
    ans[i] = 1;
  }
  ll x;
  for (ll i = 0; i < m; i++) {
    cin >> x;
    ans[x] = 0;
  }
  for (ll i = 2; i <= n; i++) {
    ans[i] *= (ans[i - 1] + ans[i - 2]);
    ans[i] %= mod;
  }
  cout << ans[n];
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define FAST                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int, int>
#define pdd pair<ld, ld>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack<int>
#define stll stack<ll>
#define mseti multiset<ll>
#define msetd multiset<ll, greater<ll>>
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define stp setprecision(20) // use fixed before stp
#define endl '\n'
int main() {
  FAST ll n, m;
  cin >> n >> m;
  ll ans[n + 1];
  for (ll i = 0; i <= n; i++) {
    ans[i] = 1;
  }
  ll x;
  for (ll i = 0; i < m; i++) {
    cin >> x;
    ans[x] = 0;
  }
  for (ll i = 2; i <= n; i++) {
    ans[i] *= (ans[i - 1] + ans[i - 2]);
    ans[i] %= mod;
  }
  cout << ans[n];
}
Problem p03013 (C++)

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

int p = 1000000007;
ll f(ll x) {
  if (x == 0) {
    return 1;
  }
  if (x == 1) {
    return 1;
  }
  ll a = 1, b = 1, c = 0;
  rep(i, x - 1) {
    c = (a + b) % p;
    a = b;
    b = c;
  }
  return c;
}
int main() {
  ll n, m, ans = 1;
  cin >> n >> m;
  vector<ll> v(m);
  rep(i, m) {
    cin >> v[i];
    if (i != 0) {
      if (v[i] == v[i - 1] + 1) {
        ans = 0;
        break;
      }
    }
  }
  if (ans == 0) {
    cout << 0 << endl;
  } else {
    if (v[0] != 1) {
      ans *= f(v[0] - 1) % p;
      ans %= p;
    }
    for (int i = 0; i < m - 1; i++) {
      ans *= f(v[i + 1] - v[i] - 2) % p;
      ans %= p;
    }
    ans *= f(n - 1 - v[m - 1]) % p;
    ans %= p;
    cout << ans << endl;
  }
}


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

int p = 1000000007;
ll f(ll x) {
  if (x == 0) {
    return 1;
  }
  if (x == 1) {
    return 1;
  }
  ll a = 1, b = 1, c = 0;
  rep(i, x - 1) {
    c = (a + b) % p;
    a = b;
    b = c;
  }
  return c;
}
int main() {
  ll n, m, ans = 1;
  cin >> n >> m;
  vector<ll> v(m);
  rep(i, m) {
    cin >> v[i];
    if (i != 0) {
      if (v[i] == v[i - 1] + 1) {
        ans = 0;
        break;
      }
    }
  }
  if (m == 0) {
    cout << f(n);
  } else if (ans == 0) {
    cout << 0 << endl;
  } else {
    if (v[0] != 1) {
      ans *= f(v[0] - 1) % p;
      ans %= p;
    }
    for (int i = 0; i < m - 1; i++) {
      ans *= f(v[i + 1] - v[i] - 2) % p;
      ans %= p;
    }
    ans *= f(n - 1 - v[m - 1]) % p;
    ans %= p;
    cout << ans << endl;
  }
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;

ll GCD(ll x, ll y) {
  if (y == 0)
    return x;
  else
    return GCD(y, x % y);
}

ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }

const int MOD = 1000000007;

// void warshall_floyd(int n){
//     for(int k=0;k<n;k++){
//         for(int i=0;i<n;i++){
//             for(int j=0;j<n;j++){
//                 d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//             }
//         }
//     }
// }
// ll calc_digit(ll N) {
//     ll res = 0;
//     while (N) {
//         ++res;
//         N /= 10;
//     }
//     return res;
// }
// ll sum_digit(ll N) {
//     ll res = 0;
//     while (N) {
//         res += N % 10;
//         N /= 10;
//     }
//     return res;
// }
bool b[10000];

int main() {
  ll n, m;
  cin >> n >> m;
  ll a[n + 1];
  a[0] = 1;
  for (int i = 0; i < m; i++) {
    ll x;
    cin >> x;
    b[x] = true;
  }

  if (!b[1]) {
    a[1] = 1;
  } else {
    a[1] = 0;
  }

  for (int i = 2; i <= n; i++) {
    a[i] = 0;
    if (!b[i]) {
      if (!b[i - 1]) {
        a[i] += a[i - 1];
      }
      if (!b[i - 2]) {
        a[i] += a[i - 2];
      }
    }
    a[i] %= MOD;
  }
  cout << a[n];
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;

ll GCD(ll x, ll y) {
  if (y == 0)
    return x;
  else
    return GCD(y, x % y);
}

ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }

const int MOD = 1000000007;

// void warshall_floyd(int n){
//     for(int k=0;k<n;k++){
//         for(int i=0;i<n;i++){
//             for(int j=0;j<n;j++){
//                 d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//             }
//         }
//     }
// }
// ll calc_digit(ll N) {
//     ll res = 0;
//     while (N) {
//         ++res;
//         N /= 10;
//     }
//     return res;
// }
// ll sum_digit(ll N) {
//     ll res = 0;
//     while (N) {
//         res += N % 10;
//         N /= 10;
//     }
//     return res;
// }
bool b[100000];

int main() {
  ll n, m;
  cin >> n >> m;
  ll a[n + 1];
  a[0] = 1;
  for (int i = 0; i < m; i++) {
    ll x;
    cin >> x;
    b[x] = true;
  }

  if (!b[1]) {
    a[1] = 1;
  } else {
    a[1] = 0;
  }

  for (int i = 2; i <= n; i++) {
    a[i] = 0;
    if (!b[i]) {
      if (!b[i - 1]) {
        a[i] += a[i - 1];
      }
      if (!b[i - 2]) {
        a[i] += a[i - 2];
      }
    }
    a[i] %= MOD;
  }
  cout << a[n];
}
Problem p03013 (C++)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;

/*
 string -> int : stoi(S);
 int -> string : to_string(N);
 Sのn文字以降をm文字取り出す : S.substr(n,m)

 int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
 ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/

int main() {

  ll n, m, count = 0, ans = 0;

  cin >> n;
  cin >> m;
  vector<ll> a(m);
  rep(i, m) { cin >> a[i]; }

  vector<ll> s(n + 1);
  s[0] = 1;
  int l = 0;
  rep2(i, n) {
    if (a[l] == i) {
      s[i] = 0;
      l++;
    } else if (i == 1)
      s[1] = 1;
    else
      s[i] = (s[i - 1] + s[i - 2]) % 1000000007;
  }

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

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;

/*
 string -> int : stoi(S);
 int -> string : to_string(N);
 Sのn文字以降をm文字取り出す : S.substr(n,m)

 int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
 ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/

int main() {

  ll n, m, count = 0, ans = 0;

  cin >> n;
  cin >> m;
  vector<ll> a(m);
  rep(i, m) { cin >> a[i]; }

  vector<ll> s(n + 1);
  s[0] = 1;
  int l = 0;
  rep2(i, n) {
    if (m != 0 && a[l] == i) {
      s[i] = 0;
      l++;
    } else if (i == 1)
      s[1] = 1;
    else
      s[i] = (s[i - 1] + s[i - 2]) % 1000000007;
  }

  cout << s[n] << endl;
}
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;
typedef long long ll;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> broken(M);
  rep(i, M) {
    int w;
    cin >> w;
    broken[w] = 1;
  }
  vector<int> a(N + 2);
  a[N] = 1;
  for (int i = N - 1; i >= 0; i--) {
    if (broken[i]) {
      a[i] = 0;
    } else {
      a[i] = (a[i + 1] + a[i + 2]) % 1000000007;
    }
  }
  int ans = a[0];
  cout << ans << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> broken(N + 1);
  rep(i, M) {
    int w;
    cin >> w;
    broken[w] = 1;
  }
  vector<int> a(N + 2);
  a[N] = 1;
  for (int i = N - 1; i >= 0; i--) {
    if (broken[i]) {
      a[i] = 0;
    } else {
      a[i] = (a[i + 1] + a[i + 2]) % 1000000007;
    }
  }
  int ans = a[0];
  cout << ans << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>   //abs()かfabs()で少数絶対値
#include <cstdlib> //abs()で整数絶対値
#include <iomanip> //stw(数字)で空白による桁揃え
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<bool> oks(M, true);
  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    oks[a] = false;
  }
  vector<long> dp(N + 1);
  dp[0] = 1;
  for (int now = 0; now < N; now++) {
    for (int next = now + 1; next <= min(now + 2, N); next++) {
      if (oks[next] == true) {
        dp[next] += dp[now];
        dp[next] %= 1000000007;
      }
    }
  }
  cout << dp[N] << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>   //abs()かfabs()で少数絶対値
#include <cstdlib> //abs()で整数絶対値
#include <iomanip> //stw(数字)で空白による桁揃え
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<bool> oks(N + 1, true);
  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    oks[a] = false;
  }
  vector<long> dp(N + 1);
  dp[0] = 1;
  for (int now = 0; now < N; now++) {
    for (int next = now + 1; next <= min(now + 2, N); next++) {
      if (oks[next] == true) {
        dp[next] += dp[now];
        dp[next] %= 1000000007;
      }
    }
  }
  cout << dp[N] << endl;
  return 0;
}
Problem p03013 (C++)

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) cin >> a[i];

  // dp[i] : i段目にたどりつくまでの移動法の総数
  vector<int> dp(n + 1);
  dp[0] = 1;
  int j = 0;
  rep(i, n + 1) {
    if (i < 1)
      continue;
    if (a[j] == i) {
      j++;
      continue;
    }
    dp[i] = dp[i - 1];
    if (i > 1)
      dp[i] += dp[i - 2];
    dp[i] %= mod;
  }

  // rep(i,n+1) cout << i << ":" << dp[i] << endl;

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


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) cin >> a[i];

  // dp[i] : i段目にたどりつくまでの移動法の総数
  vector<int> dp(n + 1);
  dp[0] = 1;
  int j = 0;
  rep(i, n + 1) {
    if (i < 1)
      continue;
    if (j < m) {
      if (a[j] == i) {
        j++;
        continue;
      }
    }
    dp[i] = dp[i - 1];
    if (i > 1)
      dp[i] += dp[i - 2];
    dp[i] %= mod;
  }

  // rep(i,n+1) cout << i << ":" << dp[i] << endl;

  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;
#define rep(i, n) for (int i = 0; i < (n); i++)

const int MOD = 1e9 + 7;

int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) cin >> a[i];
  set<int> st;
  rep(i, m) st.insert(a[i]);

  vector<int> dp(n + 1);
  dp[0] = 1;
  rep(i, n) {
    rep(j, 2) {
      int add = j + 1;
      if (st.count(i + add))
        continue;
      (dp[i + add] += dp[i]) %= MOD;
    }
  }
  printf("%d\n", dp[n]);

  return 0;
}


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

const int MOD = 1e9 + 7;

int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) cin >> a[i];
  set<int> st;
  rep(i, m) st.insert(a[i]);

  vector<int> dp(n + 1);
  dp[0] = 1;
  rep(i, n) {
    rep(j, 2) {
      int add = j + 1;
      if (i + add > n)
        continue;
      if (st.count(i + add))
        continue;
      (dp[i + add] += dp[i]) %= MOD;
    }
  }
  printf("%d\n", dp[n]);

  return 0;
}
Problem p03013 (C++)

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

int main() {
  int64_t N, M;
  int64_t mod = 1e9 + 7;
  cin >> N >> M;
  vector<int64_t> a(M);
  for (int64_t i = 0; i < M; i++) {
    cin >> a.at(i);
  }
  vector<int64_t> ans(N + 1, 0);
  ans.at(0) = 1;
  vector<bool> flag(N + 1, true);
  for (int64_t i = 0; i < M; i++) {
    flag.at(a.at(i)) = false;
  }
  if (a.at(0) != 1) {
    ans.at(1) = 1;
  }
  for (int64_t i = 2; i <= N; i++) {
    if (!flag.at(i)) {
      continue;
    }
    ans.at(i) = ans.at(i - 1) + ans.at(i - 2);
    ans.at(i) %= mod;
  }
  cout << ans.at(N) << endl;
  return 0;
}


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

int main() {
  int64_t N, M;
  int64_t mod = 1e9 + 7;
  cin >> N >> M;
  vector<int64_t> a(M);
  for (int64_t i = 0; i < M; i++) {
    cin >> a.at(i);
  }
  vector<int64_t> ans(N + 1, 0);
  ans.at(0) = 1;
  vector<bool> flag(N + 1, true);
  for (int64_t i = 0; i < M; i++) {
    flag.at(a.at(i)) = false;
  }
  if (M > 0) {
    if (a.at(0) != 1) {
      ans.at(1) = 1;
    }
  } else {
    ans.at(1) = 1;
  }
  for (int64_t i = 2; i <= N; i++) {
    if (!flag.at(i)) {
      continue;
    }
    ans.at(i) = ans.at(i - 1) + ans.at(i - 2);
    ans.at(i) %= mod;
  }
  cout << ans.at(N) << endl;
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define INF 1 << 30
#define LINF (ll)1 << 62
#define MAX 510000
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define REP(i, a, b) for (ll i = (a); i < (b); i++)
#define all(x) (x).begin(), (x).end()
#define uni(q) unique(all(q)), q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main() {
  ll n, m;
  cin >> n >> m;
  vl a(m);
  rep(i, m) cin >> a[i];
  reverse(all(a));
  vl dp(n + 1, -1);
  if (!a.empty() && a.back() - 1 == 0) {
    dp[0] = 0;
    a.pop_back();
  }
  if (!a.empty() && a.back() - 1 == 1) {
    dp[1] = 0;
    a.pop_back();
  }
  if (dp[0] != 0)
    dp[0] = 1;
  if (dp[1] != 0)
    dp[1] = dp[0] + 1;
  rep(i, n - 2) {
    if (!a.empty() && a.back() - 1 != i + 2) {
      dp[i + 2] = (dp[i + 1] + dp[i]) % MOD;
      dp[i + 2] %= MOD;
    } else {
      dp[i + 2] = 0;
      a.pop_back();
    }
  }
  // rep(i,n) cout << dp[i] << " ";
  cout << dp[n - 1] << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define INF 1 << 30
#define LINF (ll)1 << 62
#define MAX 510000
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define REP(i, a, b) for (ll i = (a); i < (b); i++)
#define all(x) (x).begin(), (x).end()
#define uni(q) unique(all(q)), q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main() {
  ll n, m;
  cin >> n >> m;
  vl a(m);
  rep(i, m) cin >> a[i];
  reverse(all(a));
  vl dp(n + 1, -1);
  if (!a.empty() && a.back() - 1 == 0) {
    dp[0] = 0;
    a.pop_back();
  }
  if (!a.empty() && a.back() - 1 == 1) {
    dp[1] = 0;
    a.pop_back();
  }
  if (dp[0] != 0)
    dp[0] = 1;
  if (dp[1] != 0)
    dp[1] = dp[0] + 1;
  rep(i, n - 2) {
    if (a.empty() || a.back() - 1 != i + 2) {
      dp[i + 2] = (dp[i + 1] + dp[i]) % MOD;
      dp[i + 2] %= MOD;
    } else {
      dp[i + 2] = 0;
      a.pop_back();
    }
  }
  // rep(i,n) cout << dp[i] << " ";
  cout << dp[n - 1] << endl;
}
Problem p03013 (C++)

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

#define INF 1e18
#define int long long

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

  vector<int> dp(n);
  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 <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> broken(n + 1);
  for (int i = 0; i < m; i++) {
    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 <cmath>
#include <iomanip>
#include <iostream>
#include <istream>
#include <random>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <vector>

using namespace std;
typedef long long ll;
ll sum = 0;

int main() {
  ll N, M;
  ll waru = 1000000007;
  cin >> N >> M;
  vector<ll> a(N + 1, 0);

  ll m = 0;
  for (ll i = 0; i < M; i++) {
    cin >> m;
    a[m] = -1;
  }

  // vector<vector<ll > > dp(N, vector<ll >(N + 1, -1));
  a[0] = 1;

  for (ll i = 0; i < N; i++) {
    if (a[i] == -1) {
      continue;
    }
    if (a[i + 1] != -1) {
      a[i + 1] += a[i];
      a[i + 1] %= waru;
    }
    if (a[i + 2] != -1) {
      a[i + 2] += a[i];
      a[i + 2] %= waru;
    }
  }

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

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <istream>
#include <random>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <vector>

using namespace std;
typedef long long ll;
ll sum = 0;

int main() {
  ll N, M;
  ll waru = 1000000007;
  cin >> N >> M;
  vector<ll> a(N + 2, 0);

  ll m = 0;
  for (ll i = 0; i < M; i++) {
    cin >> m;
    a[m] = -1;
  }

  // vector<vector<ll > > dp(N, vector<ll >(N + 1, -1));
  a[0] = 1;

  for (ll i = 0; i < N; i++) {
    if (a[i] == -1) {
      continue;
    }
    if (a[i + 1] != -1) {
      a[i + 1] += a[i];
      a[i + 1] %= waru;
    }
    if (a[i + 2] != -1) {
      a[i + 2] += a[i];
      a[i + 2] %= waru;
    }
  }

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

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

long long mod = 1000000007;
long long modpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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> sum(2 * n);
  sum[0] = 0;
  sum[1] = sum[2] = 1;
  for (long long i = 3; i < 2 * n; i++) {
    sum[i] = (sum[i - 1] + sum[i - 2]) % mod;
  }
  long long ans = sum[a[0]] % mod;
  // cout << ans << endl;
  for (long long i = 1; i < m; i++) {
    ans = (ans * sum[a[i] - a[i - 1] - 1]) % mod;
  }
  ans = (ans * (sum[n - a[m - 1]])) % mod;
  cout << ans % mod << endl;
  return 0;
}

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

long long mod = 1000000007;
long long modpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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> sum(2 * n);
  sum[0] = 0;
  sum[1] = sum[2] = 1;
  for (long long i = 3; i < 2 * n; i++) {
    sum[i] = (sum[i - 1] + sum[i - 2]) % mod;
  }
  if (m == 0) {
    cout << sum[n + 1] << endl;
    return 0;
  }
  long long ans = sum[a[0]] % mod;
  // cout << ans << endl;
  for (long long i = 1; i < m; i++) {
    ans = (ans * sum[a[i] - a[i - 1] - 1]) % mod;
  }
  ans = (ans * (sum[n - a[m - 1]])) % mod;
  cout << ans % mod << endl;
  return 0;
}
Problem p03013 (C++)

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;

// REPEAT
//------------------------------------------
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, m) RFOR(i, m, 0)

// container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(), (V).end())
#define REV(V) reverse((V).begin(), (V).end())

// constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

// grobal variable
//------------------------------------------

// def function, class
//------------------------------------------

// main
//------------------------------------------
signed main() {
  int N, M;
  cin >> N >> M;
  VI broken(N + 1); // 壊れているブロックのbool表
  REP(i, M) {
    int a = 0;
    cin >> a;
    broken[a] = 1;
  }

  VI dp(N + 1);
  dp[N] = 1;
  dp[N + 1] = 0;

  REP(i, N) {
    if (broken[N - i - 1])
      continue;
    dp[N - i - 1] = (dp[N - i] + dp[N - i + 1]) % MOD;
  }

  cout << dp[0] << endl;

  return 0;
}


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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;

// REPEAT
//------------------------------------------
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, m) RFOR(i, m, 0)

// container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(), (V).end())
#define REV(V) reverse((V).begin(), (V).end())

// constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

// grobal variable
//------------------------------------------

// def function, class
//------------------------------------------

// main
//------------------------------------------
signed main() {
  int N, M;
  cin >> N >> M;
  VI broken(N + 1); // 壊れているブロックのbool表
  REP(i, M) {
    int a = 0;
    cin >> a;
    broken[a] = 1;
  }

  VI dp(N + 10);
  dp[N] = 1;
  dp[N + 1] = 0;

  REP(i, N) {
    if (broken[N - i - 1])
      continue;
    dp[N - i - 1] = (dp[N - i] + dp[N - i + 1]) % 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;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }

int main() {
  ll n, m, p = 1000000007;
  cin >> n >> m;
  vll a(m);
  for (ll i = 0; i < m; i++)
    cin >> a[i];
  vll dp(n + 1);
  dp[0] = 1;
  ll check_next = 0;
  if (a[0] == 1) {
    dp[1] = 0;
    check_next++;
  } else
    dp[1] = 1;
  for (ll i = 2; i <= n; i++) {
    ll is_broken = 0;
    for (ll j = check_next; j < m; j++) {
      if (i == a[j]) {
        is_broken = 1;
        check_next = j + 1;
        break;
      }
      if (i < a[j]) {
        check_next = j;
        break;
      }
    }
    if (is_broken == 0)
      dp[i] = (dp[i - 2] + dp[i - 1]) % p;
    else
      dp[i] = 0;
  }
  cout << dp[n] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }

int main() {
  ll n, m, p = 1000000007;
  cin >> n >> m;
  vll a(m);
  for (ll i = 0; i < m; i++)
    cin >> a[i];
  vll dp(n + 1);
  dp[0] = 1;
  ll check_next = 0;
  if (m > 0 && a[0] == 1) {
    dp[1] = 0;
    check_next++;
  } else
    dp[1] = 1;
  for (ll i = 2; i <= n; i++) {
    ll is_broken = 0;
    for (ll j = check_next; j < m; j++) {
      if (i == a[j]) {
        is_broken = 1;
        check_next = j + 1;
        break;
      }
      if (i < a[j]) {
        check_next = j;
        break;
      }
    }
    if (is_broken == 0)
      dp[i] = (dp[i - 2] + dp[i - 1]) % p;
    else
      dp[i] = 0;
  }
  cout << dp[n] << endl;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <vector>
const int MOD = 1e9 + 7;
typedef long long ll;
using namespace std;

int main() {
  int n, m, temp;
  cin >> n >> m;
  vector<bool> broken(m);
  vector<ll> dp(n + 1);
  for (int i = 0; i < m; i++) {
    cin >> temp;
    broken[temp] = true;
  }
  dp[0] = 1;
  if (!broken[1])
    dp[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!broken[i]) {
      dp[i] = dp[i - 1] + dp[i - 2];
      dp[i] %= MOD;
    }
  }
  cout << dp[n] << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <vector>
const int MOD = 1e9 + 7;
typedef long long ll;
using namespace std;

int main() {
  int n, m, temp;
  cin >> n >> m;
  vector<bool> broken(n + 1);
  vector<ll> dp(n + 1);
  for (int i = 0; i < m; i++) {
    cin >> temp;
    broken[temp] = true;
  }
  dp[0] = 1;
  if (!broken[1])
    dp[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!broken[i]) {
      dp[i] = dp[i - 1] + dp[i - 2];
      dp[i] %= MOD;
    }
  }
  cout << dp[n] << endl;
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

int mod = 1e9 + 7;

ll dp[100005];

ll f(int i) {
  if (i < 0)
    return 0;
  if (dp[i] == -1)
    return 0;
  if (dp[i] != 0)
    return dp[i];
  return dp[i] = (f(i - 1) + f(i - 2)) % mod;
}

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a;
    cin >> a;
    dp[a] = -1;
  }
  dp[0] = 1;
  ll ans = f(n);
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

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

int mod = 1e9 + 7;

ll dp[100005];

ll f(int i) {
  if (i < 0)
    return 0;
  if (dp[i] == -1)
    return 0;
  if (dp[i] != 0)
    return dp[i];
  return dp[i] = (f(i - 1) + f(i - 2)) % mod;
}

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a;
    cin >> a;
    dp[a] = -1;
  }
  dp[0] = 1;
  // ll ans = f(n);
  rep(i, n) {
    if (dp[i] == -1)
      continue;
    if (dp[i + 1] != -1)
      dp[i + 1] = (dp[i + 1] + dp[i]) % mod;
    if (dp[i + 2] != -1)
      dp[i + 2] = (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)++)
const bool debug = false;
#define DEBUG if (debug == true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n, m;
ll mod = 1000000007;
int main(void) {
  cin >> n >> m;
  ll dp[10005] = {};
  rep(i, m) {
    int tmp;
    cin >> tmp;
    dp[tmp] = -1;
  }
  dp[0] = 1;
  rep(i, n) {
    if (dp[i] != -1) {
      if (dp[i + 2] != -1) {
        dp[i + 2] += dp[i];
        dp[i + 2] %= mod;
      }
      if (dp[i + 1] != -1) {
        dp[i + 1] += dp[i];
        dp[i + 1] %= mod;
      }
    }
  }
  cout << dp[n] << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
const bool debug = false;
#define DEBUG if (debug == true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n, m;
ll mod = 1000000007;
int main(void) {
  cin >> n >> m;
  ll dp[100005] = {};
  rep(i, m) {
    int tmp;
    cin >> tmp;
    dp[tmp] = -1;
  }
  dp[0] = 1;
  rep(i, n) {
    if (dp[i] != -1) {
      if (dp[i + 2] != -1) {
        dp[i + 2] += dp[i];
        dp[i + 2] %= mod;
      }
      if (dp[i + 1] != -1) {
        dp[i + 1] += dp[i];
        dp[i + 1] %= mod;
      }
    }
  }
  cout << dp[n] << endl;
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;
template <class T> using V = vector<T>;
template <class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i = k; i < (ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(), v.end()
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;
}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  unordered_set<ll> a;
  REP(i, m) {
    ll _a;
    cin >> _a;
    a.insert(_a);
  }
  vll d(n + 1, 1);
  if (a.find(1) != a.end())
    d[1] = 0;
  rep(i, 2, n + 2) {
    if (a.find(i) != a.end())
      d[i] = 0;
    else
      d[i] = (d[i - 1] + d[i - 2]) % MOD;
  }
  cout << d[n] << '\n';
  return 0;
}


Fixed submission:
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;
template <class T> using V = vector<T>;
template <class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i = k; i < (ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(), v.end()
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;
}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  unordered_set<ll> a;
  REP(i, m) {
    ll _a;
    cin >> _a;
    a.insert(_a);
  }
  vll d(n + 1, 1);
  if (a.find(1) != a.end())
    d[1] = 0;
  rep(i, 2, n + 1) {
    if (a.find(i) != a.end())
      d[i] = 0;
    else
      d[i] = (d[i - 1] + d[i - 2]) % MOD;
  }
  cout << d[n] << '\n';
  return 0;
}
Problem p03013 (C++)

Buggy submission (status: Runtime Error):

#pragma GCC optimize("O3")

#include <bits/stdc++.h>

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9 + 7;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{ ";
  REP(i, vec.size()) { os << vec[i] << " "; }
  os << "}";

  return os;
}

void d_err() { cerr << endl; }

template <typename H, typename... T> void d_err(H h, T... t) {
  cerr << h << " ";
  d_err(t...);
}

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

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

  vi a(M);
  REP(i, M) cin >> a[i];

  ll dp[N + 1];
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  int j = 0;
  REP(i, N + 1) {
    if (a[j] == i) {
      ++j;
      continue;
    }

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

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


Fixed submission:

#pragma GCC optimize("O3")

#include <bits/stdc++.h>

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9 + 7;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{ ";
  REP(i, vec.size()) { os << vec[i] << " "; }
  os << "}";

  return os;
}

void d_err() { cerr << endl; }

template <typename H, typename... T> void d_err(H h, T... t) {
  cerr << h << " ";
  d_err(t...);
}

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

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

  vi a(M);
  REP(i, M) cin >> a[i];

  ll dp[N + 1];
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  int j = 0;
  REP(i, N + 1) {
    if (j < M)
      if (a[j] == i) {
        ++j;
        continue;
      }

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

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