alexjercan/bugnet huggingface dataset:
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n, m, t;
  cin >> n >> m >> t;
  bool l[10010];
  for (int i = 0; i < t; i++) {
    l[i] = true;
  }
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for (int i = a - m; i <= min(t, a + m - 1); i++) {
      l[i] = false;
    }
  }
  int sum = 0;
  for (int i = 0; i < t; i++) {
    if (l[i] == true)
      sum++;
  }
  cout << sum << endl;
  char c;
  cin >> c;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, m, t;
  cin >> n >> m >> t;
  bool l[10010];
  for (int i = 0; i < t; i++) {
    l[i] = true;
  }
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for (int i = a - m; i <= a + m - 1; i++) {
      l[i] = false;
    }
  }
  int sum = 0;
  for (int i = 0; i < t; i++) {
    if (l[i] == true)
      sum++;
  }
  cout << sum << endl;
  char c;
  cin >> c;
}
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;

long long int mod = 1000000007;

int main(void) {

  int n, m, t;
  cin >> n >> m >> t;

  vector<bool> a(10000 + 5, false);
  for (int i = 1; i < n + 1; i++) {
    int tmp;
    cin >> tmp;
    for (int j = max(0, tmp - m); j < min(10005, tmp + m); j++)
      a[j] = true;
  }

  int cnt = 0;
  for (int i = 0; i < t; i++) {
    cnt += a[i];
  }
  cout << t - cnt << endl;

  return 0;
}

//

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;

long long int mod = 1000000007;

int main(void) {

  int n, m, t;
  cin >> n >> m >> t;

  vector<bool> a(10000 + 5, false);
  for (int i = 1; i < n + 1; i++) {
    int tmp;
    cin >> tmp;
    for (int j = tmp - m; j < tmp + m; j++)
      a[j] = true;
  }

  int cnt = 0;
  for (int i = 0; i < t; i++) {
    cnt += a[i];
  }
  cout << t - cnt << endl;

  return 0;
}

//
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REAP(i, a, n) for (int i = (a); i < (n); i++)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(), v.end()
typedef long long ll;

int main() {
  int n, m, t;
  cin >> n >> m >> t;
  int a;
  vector<int> tim(t, 1);
  REP(i, n) {
    cin >> a;
    a--;
    for (int j = a - m + 1; j <= a + m && j < t; j++) {
      tim[j] = 0;
    }
  }
  int sum = 0;
  REP(i, t) { sum += tim[i]; }
  cout << sum << endl;
}


Error: 0

Fixed submission:

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REAP(i, a, n) for (int i = (a); i < (n); i++)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(), v.end()
typedef long long ll;

int main() {
  int n, m, t;
  cin >> n >> m >> t;
  int a;
  vector<int> tim(t, 1);
  REP(i, n) {
    cin >> a;
    a--;
    for (int j = a - m + 1; j <= a + m; j++) {
      tim[j] = 0;
    }
  }
  int sum = 0;
  REP(i, t) { sum += tim[i]; }
  cout << sum << endl;
}
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define INF 999999999
#define mod 1000000007

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define REP(i, a, b) for (int i = (a); i < int(b); i++)
#define all(x) (x).begin(), x.end()
#define pb push_back
#define MOD(x) (x % (mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
bool debug = false;
/*---------------------------------------------------*/

int main() {
  int n, m, t;
  int a;
  int time[20005];
  rep(i, 20005) time[i] = 0;
  cin >> n >> m >> t;
  rep(i, n) {
    cin >> a;
    time[a - m] += 1;
    time[a + m] -= 1;
  }
  for (int i = 1; i <= t; i++)
    time[i] += time[i - 1];
  int ans = 0;
  for (int i = 0; i < t; i++)
    if (time[i] == 0)
      ans++;
  cout << ans << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define INF 999999999
#define mod 1000000007

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define REP(i, a, b) for (int i = (a); i < int(b); i++)
#define all(x) (x).begin(), x.end()
#define pb push_back
#define MOD(x) (x % (mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
bool debug = false;
/*---------------------------------------------------*/

int main() {
  int n, m, t;
  int a;
  int time[10005];
  rep(i, 10005) time[i] = 0;
  cin >> n >> m >> t;
  rep(i, n) {
    cin >> a;
    time[a - m] += 1;
    time[a + m] -= 1;
  }
  for (int i = 1; i <= t; i++)
    time[i] += time[i - 1];
  int ans = 0;
  for (int i = 0; i < t; i++)
    if (time[i] == 0)
      ans++;
  cout << ans << endl;

  return 0;
}
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int a[100000], n, m, t, p;
int main() {
  cin >> n >> m >> t;
  for (int i = 0; i < n; i++) {
    cin >> p;
    a[p - m]++;
    a[p + m]--;
  }
  for (int i = 1; i < t; i++)
    a[i] += a[i - 1];
  int cnt = 0;
  for (int i = 0; i < t; i++) {
    if (a[i] == 0)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int a[10000], n, m, t, p;
int main() {
  cin >> n >> m >> t;
  for (int i = 0; i < n; i++) {
    cin >> p;
    a[p - m]++;
    a[p + m]--;
  }
  for (int i = 1; i < t; i++)
    a[i] += a[i - 1];
  int cnt = 0;
  for (int i = 0; i < t; i++) {
    if (a[i] == 0)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p01840 (C++) — buggy submission, verdict: 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, t, a;
  cin >> n >> m >> t;
  vector<int> used(1000000, 0);
  rep(i, n) {
    cin >> a;
    used[a] = 1;
    rep(i, m) {
      used[a + i + 1] = 1;
      used[a - i - 1] = 1;
    }
  }
  int cnt = 0;
  rep(i, t) {
    if (used[i] != used[i + 1])
      cnt++;
  }
  // rep(i,t+10) cout << used[i] << " ";
  // cout << endl;
  cnt /= 2;
  rep(i, t) {
    if (used[i] == 0)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Error: 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, t, a;
  cin >> n >> m >> t;
  vector<int> used(t + 1, 0);
  rep(i, n) {
    cin >> a;
    used[a] = 1;
    rep(i, m) {
      used[a + i + 1] = 1;
      if (a - i - 1 < 0)
        continue;
      used[a - i - 1] = 1;
    }
  }
  int cnt = 0;
  rep(i, t) {
    if (used[i] != used[i + 1])
      cnt++;
  }
  cnt /= 2;
  rep(i, t) {
    if (used[i] == 0)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define REP(i, n, N) for (int i = n; i < N; i++)
#define p(S) cout << S << endl
using namespace std;

int main() {
  int N, M, T;
  cin >> N >> M >> T;
  int t[10001];
  fill(t, t + 10001, 1);
  int let;
  int ans = 0;
  REP(i, 0, N) {
    cin >> let;
    REP(j, let - M + 1, let + M + 1) {
      if (j > 10000)
        break;
      t[j] = 0;
    }
  }
  REP(i, 1, T + 1) { ans += t[i]; }
  p(ans);
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n, N) for (int i = n; i < N; i++)
#define p(S) cout << S << endl
using namespace std;

int main() {
  int N, M, T;
  cin >> N >> M >> T;
  int t[10001];
  fill(t, t + 10001, 1);
  int let;
  int ans = 0;
  REP(i, 0, N) {
    cin >> let;
    REP(j, let - M + 1, let + M + 1) { t[j] = 0; }
  }
  REP(i, 1, T + 1) { ans += t[i]; }
  p(ans);
  return 0;
}
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main(void) {
  int n, m, t;
  int x;
  cin >> n >> m >> t;
  int b[10101] = {};
  for (int i = 0; i < n; i++) {
    cin >> x;
    b[x - m]--;
    if (x + m <= t)
      b[x + m]++;
  }
  int ans = 0;
  if (b[0] == 0)
    ans++;
  for (int i = 1; i < t; i++) {
    b[i] += b[i - 1];
    if (b[i] == 0)
      ans++;
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main(void) {
  int n, m, t;
  int x;
  cin >> n >> m >> t;
  int b[10101] = {};
  for (int i = 0; i < n; i++) {
    cin >> x;
    b[x - m]--;
    b[x + m]++;
  }
  int ans = 0;
  if (b[0] == 0)
    ans++;
  for (int i = 1; i < t; i++) {
    b[i] += b[i - 1];
    if (b[i] == 0)
      ans++;
  }
  cout << ans << endl;
}
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

//
//  main.cpp
//  Delivery to a Luxurious House
//
//  Created by x15071xx on 2017/06/19.
//  Copyright ?? 2017??´ AIT. All rights reserved.
//

#include <iostream>
#include <vector>

using namespace std;
int main(int argc, const char *argv[]) {

  int n, m, t, taroSc[100000] = {0}, time = 0;
  vector<int> cometime;
  cin >> n >> m >> t;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    cometime.push_back(tmp);
  }

  for (int i = 0; i < n; i++) {
    for (int j = cometime[i] - m; j < cometime[i] + m; j++) {
      taroSc[j] = 1;
    }
  }

  for (int i = 0; i < t; i++) {
    if (taroSc[i] == 0) {
      time++;
    }
  }

  cout << time << endl;
  return 0;
}

Error: 0

Fixed submission:

//
//  main.cpp
//  Delivery to a Luxurious House
//
//  Created by x15071xx on 2017/06/19.
//  Copyright ?? 2017??´ AIT. All rights reserved.
//

#include <iostream>
#include <vector>

using namespace std;
int main(int argc, const char *argv[]) {

  int n, m, t, taroSc[10000] = {0}, time = 0;
  vector<int> cometime;
  cin >> n >> m >> t;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    cometime.push_back(tmp);
  }

  for (int i = 0; i < n; i++) {
    for (int j = cometime[i] - m; j < cometime[i] + m; j++) {
      taroSc[j] = 1;
    }
  }

  for (int i = 0; i < t; i++) {
    if (taroSc[i] == 0) {
      time++;
    }
  }

  cout << time << endl;
  return 0;
}
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define T 100005
#define N 105
using namespace std;
int n, m, t, a[N], A[T], ans;

int main() {
  cin >> n >> m >> t;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    A[a[i] - m]++;
    A[a[i] + m + 1]--;
  }
  for (int i = 1; i <= t; i++)
    A[i] += A[i - 1];
  int f = 0;
  for (int i = 0; i <= t; i++) {
    if (!A[i])
      ans++;
    else if (i && f && !A[i - 1])
      ans++;
    if (A[i])
      f = 1;
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define T 10010
#define N 105
using namespace std;
int n, m, t, a[N], A[T], ans;

int main() {
  cin >> n >> m >> t;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] - m < 0)
      while (1)
        ;
    A[a[i] - m]++;
    A[a[i] + m + 1]--;
  }
  for (int i = 1; i <= t; i++)
    A[i] += A[i - 1];
  int f = 0;
  for (int i = 0; i <= t; i++) {
    if (!A[i])
      ans++;
    else if (i && f && !A[i - 1])
      ans++;
    if (A[i])
      f = 1;
  }
  cout << ans << endl;
  return 0;
}
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <cstring>

bool tbl[50000];

int main(void) {
  memset(tbl, 0, sizeof(tbl));
  int n, m, t;
  int a;
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    a--;
    for (int j = 0; j < m; j++)
      tbl[a - j] = tbl[a + j] = true;
    tbl[a + m] = true;
  }
  int res = 0;
  for (int i = 0; i < t; i++)
    res += !tbl[i];
  printf("%d\\n", res);
  return 0;
}

Error: -11

Fixed submission:

#include <cstdio>
#include <cstring>

bool tbl[50000];

int main(void) {
  while (1) {
    memset(tbl, 0, sizeof(tbl));
    int n, m, t;
    int a;
    scanf("%d%d%d", &n, &m, &t);
    if (!n)
      break;
    for (int i = 0; i < n; i++) {
      scanf("%d", &a);
      a--;
      for (int j = 0; j < m; j++)
        tbl[a - j] = tbl[a + j] = true;
      tbl[a + m] = true;
    }
    int res = 0;
    for (int i = 0; i < t; i++)
      res += !tbl[i];
    printf("%d\\n", res);
  }
  return 0;
}
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#define ll long long
using namespace std;
int main() {
  int n, m, t, a;
  int time[10100];
  memset(time, 0, sizeof(time));
  cin >> n >> m >> t;
  REP(i, n) {
    cin >> a;
    time[a - m]++;
    time[min(a + m, 10010)]--;
  }
  REP(i, t) time[i + 1] += time[i];
  int ans = 0;
  REP(i, t) if (time[i] == 0) ans++;
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#define ll long long
using namespace std;
int main() {
  int n, m, t, a;
  int time[10100];
  memset(time, 0, sizeof(time));
  cin >> n >> m >> t;
  REP(i, n) {
    cin >> a;
    time[a - m]++;
    time[a + m]--;
  }
  REP(i, t) time[i + 1] += time[i];
  int ans = 0;
  REP(i, t) if (time[i] == 0) ans++;
  cout << ans << endl;
}
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {

  int N, M, T, t[100];
  int imos[30000] = {0};
  cin >> N >> M >> T;
  for (int i = 0; i < N; i++) {
    int t;
    cin >> t;
    imos[t - M]++, imos[t + M]--;
  }
  for (int i = 1; i <= T; i++) {
    imos[i] += imos[i - 1];
  }

  int cnt = 0;
  for (int i = 0; i < T; i++) {
    if (!imos[i])
      cnt++;
  }
  cout << cnt << endl;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main() {

  int N, M, T, t[100];
  int imos[10001] = {0};
  cin >> N >> M >> T;
  for (int i = 0; i < N; i++) {
    int t;
    cin >> t;
    imos[t - M]++, imos[t + M]--;
  }
  for (int i = 1; i <= T; i++) {
    imos[i] += imos[i - 1];
  }

  int cnt = 0;
  for (int i = 0; i < T; i++) {
    if (!imos[i])
      cnt++;
  }
  cout << cnt << endl;
}
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, N) for (int i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define EQV(a, b) (EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int T[20100];
int n, m, t;

int main() {
  cin >> n >> m >> t;
  rep(i, n) {
    int tt;
    cin >> tt;
    T[tt - m]++;
    T[tt + m]--;
  }
  rep(i, t) { T[i + 1] += T[i]; }
  int ans = 0;
  rep(i, t) {
    // cout << i << " " << T[i] << endl;
    ans += (T[i] == 0);
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, N) for (int i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define EQV(a, b) (EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int T[10100];
int n, m, t;

int main() {
  cin >> n >> m >> t;
  rep(i, n) {
    int tt;
    cin >> tt;
    T[tt - m]++;
    T[tt + m]--;
  }
  rep(i, t) { T[i + 1] += T[i]; }
  int ans = 0;
  rep(i, t) {
    // cout << i << " " << T[i] << endl;
    ans += (T[i] == 0);
  }
  cout << ans << endl;
}
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

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

signed main() {
  bool a[30000]{};
  int b, c, d;
  cin >> b >> c >> d;
  for (int e = 0; e < b; e++) {
    int f;
    cin >> f;
    for (int g = f - c; g < f + c; g++) {
      a[g] = true;
    }
  }
  int s = 0;
  for (int h = 0; h < d; h++) {
    if (!a[h])
      s++;
  }
  cout << s << endl;
}

Error: 0

Fixed submission:

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

signed main() {
  bool a[10001]{};
  int b, c, d;
  cin >> b >> c >> d;
  for (int e = 0; e < b; e++) {
    int f;
    cin >> f;
    for (int g = f - c; g < f + c; g++) {
      a[g] = true;
    }
  }
  int s = 0;
  for (int h = 0; h < d; h++) {
    if (!a[h])
      s++;
  }
  cout << s << endl;
}
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <vector>
#define all(c) ((c).begin(), (c).end())
#define rall(c) ((c).rbegin(), (c).rend())
#define ll long long
#define fi first
#define se second
#define inf (999999999)
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n, m, t;
int a[110];

int main() {
  cin >> n >> m >> t;
  bool b[20100];
  for (int i = 0; i < t; i++)
    b[i] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = a[i] - m; j <= a[i] + m - 1; j++) {
      b[j] = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < t; i++) {
    if (b[i] == 0)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <vector>
#define all(c) ((c).begin(), (c).end())
#define rall(c) ((c).rbegin(), (c).rend())
#define ll long long
#define fi first
#define se second
#define inf (999999999)
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n, m, t;
int a[110];

int main() {
  cin >> n >> m >> t;
  bool b[10000];
  for (int i = 0; i < t; i++)
    b[i] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = a[i] - m; j <= a[i] + m - 1; j++) {
      b[j] = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < t; i++) {
    if (b[i] == 0)
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, m, t;
  cin >> n >> m >> t;
  int s[114514] = {};
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    s[a - m + 1]++;
    s[a + m + 1]--;
  }

  for (int i = 1; i < 11450; i++) {
    s[i] += s[i - 1];
  }

  int ans = 0;
  for (int i = 1; i <= t; i++) {
    if (!s[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  int n, m, t;
  cin >> n >> m >> t;
  int s[11451] = {};
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    s[a - m + 1]++;
    s[a + m + 1]--;
  }

  for (int i = 1; i < 11450; i++) {
    s[i] += s[i - 1];
  }

  int ans = 0;
  for (int i = 1; i <= t; i++) {
    if (!s[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p01840 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, m, t;
  cin >> n >> m >> t;
  t++;
  vector<bool> v(t);
  for (int i = 0; i < t; i++)
    v[i] = false;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    v[a] = true;
  }
  int count = 0;
  for (int i = 0; i < t; i++) {
    if (v[i])
      count = m + 1;
    else
      count = max(count - 1, 0);
    if (count)
      v[i] = true;
  }
  count = 0;
  for (int i = t - 1; i >= 0; i--) {
    if (v[i])
      count = m + 1;
    else
      count = max(count - 1, 0);
    if (count)
      v[i] = true;
  }
  int ans = 0;
  for (int i = 0; i < t - 1; i++) {
    if (!v[i] || !v[i + 1]) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, m, t;
  t++;
  vector<bool> v(t);
  for (int i = 0; i < t; i++)
    v[i] = false;
  cin >> n >> m >> t;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    v[a] = true;
  }
  int count = 0;
  for (int i = 0; i <= t; i++) {
    if (v[i])
      count = m + 1;
    else
      count = max(count - 1, 0);
    if (count)
      v[i] = true;
  }
  count = 0;
  for (int i = t - 1; i >= 0; i--) {
    if (v[i])
      count = m + 1;
    else
      count = max(count - 1, 0);
    if (count)
      v[i] = true;
  }
  int ans = 0;
  for (int i = 0; i < t; i++) {
    if (!v[i] || !v[i + 1]) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}