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

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

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

  vector<long long> H(N);
  vector<long long> A(M);
  vector<long long> B(M);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }

  vector<long long> cnt_i(N, 0);

  for (int i = 0; i < M; i++) {
    cin >> A.at(i) >> B.at(i);

    if (H.at(A.at(i) - 1) < H.at(B.at(i) - 1)) {
      cnt_i.at(A.at(i) - 1)++;
    } else if (H.at(A.at(i) - 1) > H.at(B.at(i) - 1)) {
      cnt_i.at(B.at(i) - 1)++;
    } else {
      cnt_i.at(A.at(i) - 1)++;
      cnt_i.at(B.at(i) - 1)++;
    }
  }

  long long cnt_ans = 0;

  for (int i = 0; i < N; i++) {
    if (cnt_i.at(i) == 0) {
      cnt_ans++;
    }
  }

  cout << cnt_ans << "\\n";
}

Error: 0

Fixed submission:

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

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

  vector<long long> H(N);
  vector<long long> A(N);
  vector<long long> B(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }

  vector<long long> cnt_i(N, 0);

  for (int i = 0; i < M; i++) {
    cin >> A.at(i) >> B.at(i);

    if (H.at(A.at(i) - 1) < H.at(B.at(i) - 1)) {
      cnt_i.at(A.at(i) - 1)++;
    } else if (H.at(A.at(i) - 1) > H.at(B.at(i) - 1)) {
      cnt_i.at(B.at(i) - 1)++;
    } else {
      cnt_i.at(A.at(i) - 1)++;
      cnt_i.at(B.at(i) - 1)++;
    }
  }

  long long cnt_ans = 0;

  for (int i = 0; i < N; i++) {
    if (cnt_i.at(i) == 0) {
      cnt_ans++;
    }
  }

  cout << cnt_ans << "\\n";
}
Problem p02689 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> ot_h(N);
  vector<int> max_h(N);

  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    ot_h.at(i) = tmp;
  }
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    max_h.at(a - 1) = max(max_h.at(a - 1), ot_h.at(b - 1));
    max_h.at(b - 1) = max(max_h.at(b - 1), ot_h.at(a - 1));
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (max_h.at(i) < ot_h.at(i))
      ans++;
  }

  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> ot_h(N);
  for (int i = 0; i < N; i++) {
    int h;
    cin >> h;
    ot_h.at(i) = h;
  }

  vector<vector<bool>> is_connect(N, vector<bool>(N, false));
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    is_connect.at(a - 1).at(b - 1) = is_connect.at(b - 1).at(a - 1) = true;
  }

  vector<bool> is_good_list(N, true);
  for (int i = 0; i < N; i++) {
    if (!is_good_list.at(i)) {
      continue;
    }

    for (int j = 0; j < N; j++) {
      if (is_connect.at(i).at(j)) {
        if (ot_h.at(i) <= ot_h.at(j)) {
          is_good_list.at(i) = false;
          break;
        } else {
          is_good_list.at(j) = false;
        }
      }
    }
  }

  int c = 0;
  for (auto x : is_good_list) {
    if (x)
      c++;
  }
  cout << c << endl;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

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

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }

  vector<int> max_h(N, 0);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    max_h.at(A - 1) = max(H.at(B - 1), max_h.at(A - 1));
    max_h.at(B - 1) = max(H.at(A - 1), max_h.at(B - 1));
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += (max_h.at(i) < H.at(i));
  }
  cout << ans << endl;
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 32561) >= this->size() (which is 4)


Fixed submission:

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

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }

  vector<int> max_h(N, 0);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A, B;
    max_h.at(A - 1) = max(H.at(B - 1), max_h.at(A - 1));
    max_h.at(B - 1) = max(H.at(A - 1), max_h.at(B - 1));
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += (max_h.at(i) < H.at(i));
  }

  cout << ans << endl;
}
Problem p02689 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _GLIBCXX_DEBUG
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define ll long long
#define all(v) v.begin(), v.end()
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  int ans = 0;

  // グラフ入力受取
  vector<vector<int>> G(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    if (h[a - 1] <= h[b - 1])
      G[a - 1].push_back(b - 1);
    if (h[b - 1] <= h[a - 1])
      G[b - 1].push_back(a - 1);
  }
  rep(i, n) {
    if (G[i].size() == 0)
      ans++;
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#define _GLIBCXX_DEBUG
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define ll long long
#define all(v) v.begin(), v.end()
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  int ans = 0;

  // グラフ入力受取
  vector<vector<int>> G(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    if (find(all(G[a - 1]), b - 1) == G[a - 1].end())
      G[a - 1].push_back(b - 1);
    if (find(all(G[b - 1]), a - 1) == G[b - 1].end())
      G[b - 1].push_back(a - 1);
  }

  // 操作
  rep(i, n) {
    vector<ll> hight(G[i].size());
    rep(j, G[i].size()) hight[j] = h[G[i][j]];
    sort(all(hight));
    if ((G[i].size() > 0) && (hight[G[i].size() - 1] < h[i]))
      ans++;
    if (G[i].size() == 0)
      ans++;
  }
  cout << ans << endl;
}
Problem p02689 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

long long modinv(long long a, long long m = MOD) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
  /*MODの割り算の際に
  a/＝b;
  を
  a *= modinv(b,MOD);
  とする。
      */
}

int const MAXN = 100001;
int N, M;
int H[MAXN];
int A[MAXN], B[MAXN];

bool check[MAXN] = {false};

using Graph = vector<vector<int>>;

int ans = 0;

void search(Graph &G, int from) {
  for (int to : G[from]) {
    if (H[from] > H[to])
      check[to] = true;
    else
      check[from] = true;
  }
  if (!check[from])
    ans++;
  else
    check[from] = true;
  return;
}

int main() {
  Graph G(MAXN);
  cin >> N >> M;

  Rep(i, N) cin >> H[i];
  Rep(i, M) {
    cin >> A[i] >> B[i];
    G[A[i]].push_back(B[i]);
    G[B[i]].push_back(A[i]);
  }

  Rep(i, N) {
    if (!check[i])
      search(G, i);
  }
  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

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

long long modinv(long long a, long long m = MOD) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
  /*MODの割り算の際に
  a/＝b;
  を
  a *= modinv(b,MOD);
  とする。
      */
}

int const MAXN = 100000;
int N, M;
int H[MAXN];
int A[MAXN], B[MAXN];

using Graph = vector<vector<int>>;

int main() {
  Graph G(MAXN + 1);
  cin >> N >> M;
  Rep(i, N) cin >> H[i];
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int count = 0;

  for (int i = 1; i <= N; i++) {
    bool good = true;
    for (int tm : G[i]) {
      if (H[tm] >= H[i])
        good = false;
    }
    if (good)
      count++;
  }

  cout << count << endl;

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

#include <bits/stdc++.h>
#include <string>
#include <unordered_map>
#define ll long long
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const int N = 1e5 + 10;
inline void fastio() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

int h[100010];
int good[100010];
int main() {
  int n, m, a, b, ans = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    cin >> h[i];
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    if (h[a] > h[b])
      good[b] = 1;
    else if (h[a] == h[b])
      good[a] = good[b] = 1;
    else
      good[a] = 1;
  }
  for (int i = 1; i <= n; i++)
    ans += (good[i] == 1) ? 0 : 1;
  cout << ans;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <string>
#include <unordered_map>
#define ll long long
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const int N = 1e5 + 10;
inline void fastio() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

int h[10010];
int good[10010];
int main() {
  int n, m, a, b, ans = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    cin >> h[i];
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    if (h[a] > h[b])
      good[b] = 1;
    else if (h[a] == h[b])
      good[a] = good[b] = 1;
    else
      good[a] = 1;
  }
  for (int i = 1; i <= n; i++)
    ans += (good[i] == 1) ? 0 : 1;
  cout << ans;
  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int n, m;
long long int H[100005];
bool A[100015], B[100015];
int main() {
  scanf("%d%d", &n, &m);
  fill(A, A + n + 4, true);
  for (int i = 1; i <= n; i++)
    scanf("%ld", &H[i]);
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    B[a] = true, B[b] = true;
    if (H[a] > H[b])
      A[b] = false;
    else
      A[a] = false;
    if (H[a] == H[b])
      A[a] = A[b] = false;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (A[i] == true)
      ans++;
  }
  printf("%d\\n", ans);
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int n, m;
int H[10005];
bool A[10015], B[10015];
int main() {
  scanf("%d%d", &n, &m);
  fill(A, A + n + 4, true);
  for (int i = 1; i <= n; i++)
    scanf("%d", &H[i]);
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    B[a] = true, B[b] = true;
    if (H[a] > H[b])
      A[b] = false;
    else
      A[a] = false;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (A[i] == true && B[i] == true)
      ans++;
  }
  printf("%d\\n", ans);
  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Time Limit Exceeded

/*input
4 3
1 2 3 4
1 3
2 3
2 4
*/

#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() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<vector<int>> g(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> cnt(n, 1);
  rep(i, n) for (int to : g[i]) {
    if (h[i] <= h[to])
      cnt[i] = 0;
  }
  int ans = 0;
  rep(i, n) ans += cnt[i];
  cout << ans << endl;
  // rep(i, n) cout << h[i] << endl;
  return 0;
}

Error: TLE

Fixed submission:

/*input
33
*/

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

ll pow(ll a) { return a * a * a * a * a; }

bool C(ll a, ll b, ll x) { return a - pow(b) >= x; }

bool D(ll a, ll b, ll x) { return a - pow(b) == x; }

int main() {
  ll X;
  cin >> X;
  rep(i, 1001001) {
    ll a = pow(i);
    ll lb = -100101, ub = 100101;
    while (lb < ub) {
      ll mid = (lb + ub) / 2;
      if (C(a, mid, X))
        lb = mid;
      else
        ub = mid;
    }
    if (D(a, ub, X)) {
      cout << i << " " << ub << endl;
      break;
    }
  }
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
using namespace std;
#define N 100010

int main() {
  int n, m, h[N], ma[N];
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
    ma[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    ma[a] = max(ma[a], h[b]);
    ma[b] = max(ma[b], h[a]);
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += h[i] > ma[i];
  }
  cout << ans << endl;
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 18446744073709551615) >= this->size() (which is 4)


Fixed submission:

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

  vector<ll> high(n);
  rep(i, n) cin >> high.at(i);
  int cnt = 0;

  for (ll i = 0; i < n; i++) {
    bool gd = true;

    for (ll j = 0; j < m; j++) {

      ll a, b;
      cin >> a >> b;
      a--;
      b--;

      if (a == i) {
        if (high.at(i) <= high.at(b))
          gd = false;
      }
      if (b == i) {
        if (high.at(i) <= high.at(a))
          gd = false;
      }
    }
    if (gd == true)
      cnt++;
  }
  cout << cnt << endl;
}
Problem p02689 (C++) — buggy submission, verdict: 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>;

// #define N 100010

// int main(){
//     int n, m, h[N], ma[N];
//     cin >> n >> m;
//     rep(i,n){
//         cin >> h[i];
//         ma[i] = 0;
//     }
//     rep(i,m){
//         int a, b;
//         cin >> a >> b;
//         ma[a-1] = max(ma[a-1], h[b-1]);
//         ma[b-1] = max(ma[b-1], h[a-1]);
//     }
//     int ans = 0;
//     rep(i,n) {
//         if(h[i] > ma[i]) ans++;
//     }
//     cout << ans << endl;
//     return 0;
// }

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  vector<bool> ok(n, true);
  rep(i, n) cin >> h[i];
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (h[a] <= h[b])
      ok[a] = false;
    if (h[b] <= h[a])
      ok[b] = false;
  }
  int ans = 0;
  rep(i, n) if (ok[i]) ans++;
  cout << ans << 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;
using ll = long long;
using P = pair<int, int>;

// #define N 100010

// int main(){
//     int n, m, h[N], ma[N];
//     cin >> n >> m;
//     rep(i,n){
//         cin >> h[i];
//         ma[i] = 0;
//     }
//     rep(i,m){
//         int a, b;
//         cin >> a >> b;
//         ma[a-1] = max(ma[a-1], h[b-1]);
//         ma[b-1] = max(ma[b-1], h[a-1]);
//     }
//     int ans = 0;
//     rep(i,n) {
//         if(h[i] > ma[i]) ans++;
//     }
//     cout << ans << endl;
//     return 0;
// }

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  vector<bool> ok(n, true);
  rep(i, m) cin >> h[i];
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    if (h[a - 1] <= h[b - 1])
      ok[a - 1] = false;
    if (h[b - 1] <= h[a - 1])
      ok[b - 1] = false;
  }
  int ans = 0;
  rep(i, n) if (ok[i]) ans++;
  cout << ans << endl;
  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  vector<bool> ok(n, true);
  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (h.at(a) <= h.at(b))
      ok.at(a) = false;
    if (h.at(b) <= h.at(a))
      ok.at(b) = false;
  }
  int ans = 0;
  for (bool f : ok) {
    if (f)
      ans++;
  }
  cout << ans;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }

  vector<int> a(m);
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> a.at(i) >> b.at(i);
    a.at(i)--;
    b.at(i)--;
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a.at(j) == i) {
        if (h.at(b.at(j)) >= h.at(i)) {
          goto SKIP;
        }
      } else if (b.at(j) == i) {
        if (h.at(a.at(j)) >= h.at(i)) {
          goto SKIP;
        }
      }
    }
    ans++;
  SKIP:;
  }
  cout << ans;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define F first
#define S second
#define ld long double
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define vi vector<ll>
#define all(v) (v).begin(), (v).end()
const int inf = 1e9 + 10;

void solve() {
  ll n, m;
  cin >> n >> m;
  vi a(n, 0), h(n, 0);
  for (int i = 0; i < n; i++)
    cin >> h[i];
  for (int i = 0; i < m; i++) {
    ll x, y;
    cin >> x >> y;
    x--;
    y--;
    a[x] = max(a[x], h[y]);
    a[y] = max(a[y], h[x]);
  }
  ll ans = 0;
  for (int i = 0; i < n; i++)
    ans += h[i] > a[i];
  cout << ans;
}

int main() {

  FASTIO;

  cout << fixed << setprecision(25);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define F first
#define S second
#define ld long double
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define vi vector<ll>
#define all(v) (v).begin(), (v).end()
const int inf = 1e9 + 10;

void solve() {
  ll n, m;
  cin >> n >> m;
  vi a(n, 0), h(n, 0);
  for (int i = 0; i < n; i++)
    cin >> h[i];
  for (int i = 0; i < m; i++) {
    ll x, y;
    cin >> x >> y;
    a[x] = max(a[x], h[y]);
    a[y] = max(a[y], h[x]);
  }
  ll ans = 0;
  for (int i = 0; i < n; i++)
    ans += h[i] > a[i];
  cout << ans;
}

int main() {

  FASTIO;

  cout << fixed << setprecision(25);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef long long ll;

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

  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  vector<bool> ok(n);
  for (int i = 0; i < n; i++)
    ok[i] = true;
  for (int i = 0; i < n; i++)
    cin >> h[i];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (h[a] <= h[b])
      ok[a] = false;
    if (h[b] <= h[a])
      ok[b] = false;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (ok[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

typedef long long ll;

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

  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  set<pair<int, int>> st;
  for (int i = 0; i < n; i++)
    cin >> h[i];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    st.emplace(a, b);
    st.emplace(b, a);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    bool ok = true;
    for (int j = 0; j < n; j++) {
      if (i != j && st.count({i, j})) {
        if (h[i] <= h[j]) {
          ok = false;
          break;
        }
      }
    }
    if (ok)
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int a[200001], b[200001];
int n, m;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    b[x] = max(b[x], a[y]);
    b[y] = max(b[y], a[x]);
  }
  int s = 0;
  for (int i = 1; i <= n; ++i)
    if (a[i] > b[i])
      s++;
  cout << s;
}


Error: 127
/tmp/32bc5d28-3850-463b-bf5b-20c2d7d5bf86.out: error while loading shared libraries: libc.so.6: failed to map segment from shared object


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
bool t[10000 + 1][10000 + 1];
int main() {
  int n, m;
  cin >> n >> m;
  long long a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      t[i][j] = false;
    }
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    t[x][y] = true;
    t[y][x] = true;
  }
  int s = 0;
  for (int i = 1; i <= n; i++) {
    int f = 0;
    for (int j = 1; j <= n; j++) {
      if (t[i][j] && a[i] <= a[j])
        f = 1;
    }
    if (f == 0)
      s++;
  }
  cout << s;
  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#define ll long long
using namespace std;

int main() {
  ll n, m, h[100100], a[100100], b[100100];
  cin >> n >> m;

  for (ll i = 1; i <= n; ++i)
    cin >> h[i];

  for (ll i = 1; i <= m; ++i)
    cin >> a[i] >> b[i];

  ll better[100100] = {0};
  for (ll i = 1; i <= m; ++i) {
    if (h[a[i]] <= h[b[i]])
      better[a[i]] = b[i];

    if (h[b[i]] <= h[a[i]])
      better[b[i]] = a[i];
  }

  ll cnt = 0;
  for (ll i = 1; i <= n; ++i) {
    if (!better[i])
      ++cnt;
    // cout << better[i] << endl;
  }

  cout << cnt << endl;
}


Error: 0

Fixed submission:

#include <iostream>
#define ll long long
using namespace std;

int main() {
  ll n, m, h[10100], a[10100], b[10100];
  cin >> n >> m;

  for (ll i = 1; i <= n; ++i)
    cin >> h[i];

  for (ll i = 1; i <= m; ++i)
    cin >> a[i] >> b[i];

  ll better[10100] = {0};
  for (ll i = 1; i <= m; ++i) {
    if (h[a[i]] <= h[b[i]])
      better[a[i]] = b[i];

    if (h[b[i]] <= h[a[i]])
      better[b[i]] = a[i];
  }

  ll cnt = 0;
  for (ll i = 1; i <= n; ++i) {
    if (!better[i])
      ++cnt;
    // cout << better[i] << endl;
  }

  cout << cnt << endl;
}