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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  ll N, M;
  ll A[111111], B[111111], H[111111];
  cin >> N >> M;
  ll i;

  for (i = 1; i <= N; i++)
    cin >> H[i];
  for (i = 1; i <= M; i++)
    cin >> A[i] >> B[i];

  int x[111111]; // 1なら良い展望台、最初は全部1
  for (i = 1; i <= N; i++)
    x[i] = 1;

  for (i = 1; i <= M; i++) {
    if (H[A[i]] < H[B[i]])
      x[A[i]] = 0;
    else if (H[A[i]] > H[B[i]])
      x[B[i]] = 0;
    else if (H[A[i]] == H[B[i]]) {
      x[A[i]] = 0;
      x[B[i]] = 0;
    }
  }
  ll sum = 0;
  for (i = 1; i <= N; i++)
    sum += x[i];
  cout << sum << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  int N, M;
  int A[111111], B[111111], H[111111];
  cin >> N >> M;
  int i;

  for (i = 0; i <= M - 1; i++)
    cin >> A[i] >> B[i];

  int x[111111]; // 1なら良い展望台、最初は全部1
  for (i = 0; i <= N - 1; i++)
    x[i] = 1;

  for (i = 0; i <= M - 1; i++) {
    if (H[A[i]] <= H[B[i]])
      x[A[i]] = 0;
    else
      x[B[i]] = 0;
  }
  int sum = 0;
  for (i = 0; i <= N - 1; i++)
    sum += x[i];
  cout << sum << endl;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long int
#define N 100010
using namespace std;
int main() {
  ll n, m, h[N], ma[N];
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
    ma[i] = 0;
  }
  ll a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    ma[a] = max(ma[a], h[b]);
    ma[b] = max(ma[b], h[a]);
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += h[i] > ma[i];
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int
#define N 10010
using namespace std;
int main() {
  ll n, m, h[N], ma[N];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
    ma[i] = 0;
  }
  ll a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    ma[a] = max(ma[a], h[b]);
    ma[b] = max(ma[b], h[a]);
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += h[i] > ma[i];
  }
  cout << ans << endl;
  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>

// std::vector<int> count(N, 0);

template <typename T> struct edge {
  T src;
  T dst;
};

template <typename T> class graph {
public:
  graph() = default;

  void emplace_edge(const edge<T> &edge) {
    edges_[edge.src].emplace_back(edge.dst);
    edges_[edge.dst].emplace_back(edge.src);
  }

  std::vector<T> get_connected_vertices(const T &vertex) {
    return edges_[vertex];
  }

private:
  std::map<T, std::vector<T>> edges_;
};

template <typename T> T read_cin() {
  T input;
  std::cin >> input;
  return input;
}

int main(void) try {
  const int N = read_cin<int>();
  const int M = read_cin<int>();
  std::vector<int> H(N);
  for (int i = 0; i < N; i++) {
    H[i] = read_cin<int>();
  }

  graph<int> graph;
  for (int i = 0; i < M; i++) {
    graph.emplace_edge({read_cin<int>() - 1, read_cin<int>() - 1});
  }

  unsigned int good_count = 0;

  for (int i = 0; i < N; i++) {
    const std::vector<int> vertices = graph.get_connected_vertices(i);
    const int base_height = H[i];
    bool bad = false;
    for (const int &vertex : vertices) {
      const int height = H[vertex];
      if (base_height <= height) {
        bad = true;
        break;
      }
    }
    if (!bad) {
      ++good_count;
    }
  }

  std::cout << good_count << std::endl;
} catch (const std::exception &e) {
  std::cout << e.what();
  return EXIT_FAILURE;
} catch (...) {
  return EXIT_FAILURE;
}

Error: TLE

Fixed submission:

#include <cstdlib>
#include <iostream>
#include <vector>

// std::vector<int> count(N, 0);

template <typename T> struct edge {
  T src;
  T dst;
};

template <typename T> class graph {
public:
  graph() = default;

  void emplace_edge(const edge<T> &edge) { edges_.emplace_back(edge); }

  std::vector<T> get_connected_vertices(const T &vertex) {
    std::vector<T> vertices;
    for (const struct edge<T> edge : edges_) {
      if (edge.src == vertex) {
        vertices.emplace_back(edge.dst);
      }
      if (edge.dst == vertex) {
        vertices.emplace_back(edge.src);
      }
    }
    return vertices;
  }

private:
  std::vector<struct edge<T>> edges_;
};

template <typename T> T read_cin() {
  T input;
  std::cin >> input;
  return input;
}

int main(void) try {
  const int N = read_cin<int>();
  const int M = read_cin<int>();
  std::vector<int> H(N);
  for (int i = 0; i < N; i++) {
    H[i] = read_cin<int>();
  }

  graph<int> graph;
  for (int i = 0; i < M; i++) {
    graph.emplace_edge({read_cin<int>() - 1, read_cin<int>() - 1});
  }

  unsigned int good_count = 0;

  for (int i = 0; i < N; i++) {
    const std::vector<int> vertices = graph.get_connected_vertices(i);
    const int base_height = H[i];
    bool bad = false;
    for (const int &vertex : vertices) {
      const int height = H[vertex];
      if (base_height <= height) {
        bad = true;
        break;
      }
    }
    if (!bad) {
      ++good_count;
    }
  }

  std::cout << good_count << std::endl;
} catch (const std::exception &e) {
  std::cout << e.what();
  return EXIT_FAILURE;
} catch (...) {
  return EXIT_FAILURE;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂

                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ

 */
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T, typename cmp=less<T>> using oset =tree<T, null_type,
// cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define mod 1000000007
#define inf 100000000000000000
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(), _x.end()
#define f first
#define s second
#define pb push_back
void mahakal() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif
}
vector<ll> adj[100011];
vector<bool> visited(100000);
ll arr[100011];
ll n, m;
ll solve() {
  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    bool flag = 1;
    for (auto v : adj[i]) {
      if (arr[i] <= arr[v])
        flag = 0;
    }
    if (flag) {
      // cerr<<i<<endl;
      ans++;
    }
  }
  return ans;
}

int main() {
  // mahakal(),fast;

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

  for (ll i = 0, a, b; i < m; i++) {
    cin >> a >> b;
    adj[a].pb(b);
    adj[b].pb(a);
  }

  ll ans = solve();
  cout << ans << endl;

  return 0;
}

Error: 0

Fixed submission:

/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂

                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ

 */
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T, typename cmp=less<T>> using oset =tree<T, null_type,
// cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define mod 1000000007
#define inf 100000000000000000
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(), _x.end()
#define f first
#define s second
#define pb push_back
void mahakal() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif
}
vector<ll> adj[100001];
vector<bool> visited(100000);
ll arr[100000];
ll n, m;
ll solve() {
  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    bool flag = 1;
    for (auto v : adj[i]) {
      if (arr[i] <= arr[v])
        flag = 0;
    }
    if (flag) {
      // cerr<<i<<endl;
      ans++;
    }
  }
  return ans;
}

int main() {
  // mahakal(),fast;

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

  for (ll i = 0, a, b; i < m; i++) {
    cin >> a >> b;
    adj[a].pb(b);
    adj[b].pb(a);
  }

  ll ans = solve();
  cout << ans << endl;

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

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

int main() {

  int n, m;
  cin >> n >> m;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x -= 1;
    y -= 1;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int maxa = -1;
    for (int j = 0; j < g[i].size(); j++) {
      maxa = max(maxa, arr[g[i][j]]);
    }
    if (maxa < arr[i])
      ans += 1;
  }
  cout << ans << endl;

  return 0;
}


Error: -11

Fixed submission:

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

int main() {

  int n, m;
  cin >> n >> m;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x -= 1;
    y -= 1;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int maxa = -1;
    for (int j = 0; j < g[i].size(); i++) {
      maxa = max(maxa, arr[g[i][j]]);
    }
    if (maxa < arr[i])
      ans += 1;
  }
  cout << ans << endl;

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

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> tenbou(N, 0);
  vector<int> t_check(N, 1);
  for (int i = 0; i < N; i++) {
    int a = 0;
    cin >> a;
    tenbou[i] = a;
  }
  for (int j = 0; j < M; j++) {
    int b, c;
    cin >> b >> c;
    if (tenbou[b - 1] >= tenbou[c - 1]) {
      t_check[c - 1] = 0;
      // tenbou[c-1]=tenbou[b-1];
    }
    if (tenbou[c - 1] >= tenbou[b - 1]) {
      t_check[b - 1] = 0;
      // tenbou[b-1]=tenbou[c-1];
    }
  }

  /* for(int j=0;j<N;j++){
   cout<<t_check[j]<<" ";
   }*/
  int count = accumulate(t_check.begin(), t_check.end(), 0);
  cout << count << endl;
}

Error: 0

Fixed submission:

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> tenbou(N, 0);
  vector<int> t_check(N, 1);
  for (int i = 0; i < M; i++) {
    int a = 0;
    cin >> a;
    tenbou[i] = a;
  }
  for (int j = 0; j < M; j++) {
    int b, c;
    cin >> b >> c;
    if (tenbou[b - 1] >= tenbou[c - 1]) {
      t_check[c - 1] = 0;
      // tenbou[c-1]=tenbou[b-1];
    } else if (tenbou[c - 1] >= tenbou[b - 1]) {
      t_check[b - 1] = 0;
      // tenbou[b-1]=tenbou[c-1];
    }
  }

  /* for(int j=0;j<N;j++){
   cout<<t_check[j]<<" ";
   }*/
  int count = accumulate(t_check.begin(), t_check.end(), 0);
  cout << count << endl;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

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

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

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
bool t[10001];

int main() {
  i64 n, m;
  cin >> n >> m;
  vector<i64> h(n);
  for (i64 i = 0; i < n; i++)
    cin >> h[i];
  for (i64 i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (h[a - 1] < h[b - 1])
      t[a - 1] = true;
    else if (h[a - 1] > h[b - 1])
      t[b - 1] = true;
    else {
      t[a] = true;
      t[b] = true;
    }
  }
  i64 ans = 0;
  for (i64 i = 0; i < n; i++) {
    if (t[i] == false)
      ans++;
  }
  cout << ans << endl;

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

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (road.at(i).size() == 0) {
      ans++;
    }
    for (int j = 0; j < road.at(i).size(); j++) {
      if (highten.at(i) <= highten.at(road.at(i).at(j) - 1)) {
        break;
      }
      if (j == road.at(i).size() - 1) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> highten(n);
  for (int i = 0; i < n; i++) {
    cin >> highten.at(i);
  }
  vector<vector<int>> road(n, vector<int>(0));
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    road.at(a - 1).push_back(b);
    road.at(b - 1).push_back(a);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < road.at(i).size(); j++) {
      if (highten.at(i) <= highten.at(road.at(i).at(j))) {
        break;
      }
      if (j == road.at(i).size() - 1) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
Problem p02689 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <cstdint> // int64_t, int*_t
#include <cstdio>  // printf
#include <deque>   // deque
#include <iomanip>
#include <iostream>      // cout, endl, cin
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector

using namespace std;
using ll = long long;

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

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

#include <iostream>

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

  vector<ll> H(N + 1);
  vector<ll> A(M), B(M);

  for (ll i = 1; i <= N; ++i)
    cin >> H[i];

  for (ll i = 0; i < M; ++i)
    cin >> A[i] >> B[i];

  deque<ll> C;

  rep(i, M) {
    if (H[A[i]] < H[B[i]]) {
      C.push_front(A[i]);
    } else if (H[A[i]] > H[B[i]]) {
      C.push_front(B[i]);
    } else {
      C.push_front(A[i]);
      C.push_front(B[i]);
    }
  }

  sort(C.begin(), C.end());
  C.erase(unique(C.begin(), C.end()), C.end());

  ll s = C.size();

  cout << N - s << endl;
}

Error: TLE

Fixed submission:

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <cstdint> // int64_t, int*_t
#include <cstdio>  // printf
#include <deque>   // deque
#include <iomanip>
#include <iostream>      // cout, endl, cin
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector

using namespace std;
using ll = long long;

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

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

#include <iostream>

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

  vector<int> H(N + 1);
  vector<int> A(M + 1), B(M + 1);

  for (int i = 1; i <= N; ++i)
    cin >> H[i];

  for (int i = 1; i <= M; ++i)
    cin >> A[i] >> B[i];

  int k = 0;

  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= M; ++j) {
      if (A[j] == i) {
        if (H[A[j]] <= H[B[j]]) {
          goto xyz;
        }
      }
      if (B[j] == i) {
        if (H[B[j]] <= H[A[j]]) {
          goto xyz;
        }
      }
    }
    ++k;
  xyz:;
  }

  cout << k << endl;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, d, sum, temp, c;
  cin >> n >> m;
  vector<long long int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  vector<int> b(n, 1);
  while (m--) {
    cin >> c >> d;
    if (a[c - 1] <= a[d - 1])
      b[c - 1] = 0;
    if (a[d - 1] <= a[c - 1])
      b[d - 1] = 0;
  }
  sum = 0;
  for (int i = 0; i < n; i++) {
    if (b[i]) {
      // cout<<i+1<<endl;
      sum++;
    }
  }
  cout << sum << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, d, sum, temp, c;
  cin >> n >> m;
  vector<long long int> a(n);
  vector<vector<int>> p(n, vector<int>(n, 0));
  for (int i = 0; i < n; i++)
    cin >> a[i];
  vector<int> b(n, 1);
  while (m--) {
    cin >> c >> d;
    if (a[c - 1] <= a[d - 1])
      b[c - 1] = 0;
    if (a[d - 1] <= a[c - 1])
      b[d - 1] = 0;
  }
  sum = 0;
  for (int i = 0; i < n; i++) {
    if (b[i]) {
      // cout<<i+1<<endl;
      sum++;
    }
  }
  cout << sum << endl;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> adj(n);
  ll h[n];
  for (ll i = 0; i < n; i++)
    cin >> h[i];
  for (ll i = 0; i < m; i++) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    if (adj[i].size() == 0) {
      ans++;
      continue;
    }
    ll maxi = 0;
    for (auto j : adj[i]) {
      maxi = max(maxi, h[j]);
    }
    if (h[i] > maxi)
      ans++;
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> adj(n);
  ll h[n];
  for (ll i = 0; i < n; i++)
    cin >> h[i];
  for (ll i = 0; i < m; i++) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    if (adj[i].size() == 0) {
      ans++;
      break;
    }
    ll maxi = 0;
    for (auto j : adj[i]) {
      maxi = max(maxi, h[j]);
    }
    if (h[i] == h[maxi])
      ans++;
  }
  cout << ans + 1 << endl;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define exrep(i, a, b) for (long long i = a; i <= b; i++)
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll>> vvl;
typedef vector<vector<P>> vvp;
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 = 1e9 + 7;
const ll INF = 1e18;
const int MAX = 510000;
const double pi = acos(-1);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

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


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define exrep(i, a, b) for (long long i = a; i <= b; i++)
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll>> vvl;
typedef vector<vector<P>> vvp;
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 = 1e9 + 7;
const ll INF = 1e18;
const int MAX = 510000;
const double pi = acos(-1);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

  ll n, m;
  cin >> n >> m;
  vector<ll> h(n);
  vector<bool> ok(n, true);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    if (h[a] <= h[b])
      ok[a] = false;
    if (h[b] <= h[a])
      ok[b] = false;
  }
  ll cnt = 0;
  rep(i, n) {
    if (ok[i])
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<long long> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  vector<vector<long long>> A(M, vector<long long>(2));
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> A.at(i).at(j);
    }
  }
  vector<long long> B(2 * M);
  for (int i = 0; i < 2 * M; i++) {
    B.at(i) = -1;
  }
  int s = 0;
  for (int i = 0; i < M; i++) {
    if (H.at(A.at(i).at(0) - 1) < H.at(A.at(i).at(1) - 1)) {
      B.at(i) = A.at(i).at(0) - 1;
    } else if (H.at(A.at(i).at(0) - 1) == H.at(A.at(i).at(1) - 1)) {
      B.at(i) = A.at(i).at(0) - 1;
      B.at(2 * M - 1 - s) = A.at(i).at(1) - 1;
      s++;
    } else {
      B.at(i) = A.at(i).at(1) - 1;
    }
  }
  for (long long x : B) {
    if (x == -1) {
      continue;
    } else {
      H.at(x) = 0;
    }
  }
  int ans = 0;
  for (long long x : H) {
    if (x != 0) {
      ans++;
    }
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<long long> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  vector<vector<long long>> A(M, vector<long long>(2));
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> A.at(i).at(j);
    }
  }
  vector<long long> B(2 * M);
  for (int i = 0; i < M; i++) {
    if (H.at(A.at(i).at(0) - 1) < H.at(A.at(i).at(1) - 1)) {
      B.at(i) = A.at(i).at(0) - 1;
    } else if (H.at(A.at(i).at(0) - 1) == H.at(A.at(i).at(1) - 1)) {
      B.at(i) = A.at(i).at(0) - 1;
      B.at(2 * M - i) = A.at(i).at(1) - 1;
    } else {
      B.at(i) = A.at(i).at(1) - 1;
    }
  }
  for (long long x : B) {
    H.at(x) = 0;
  }
  int ans = 0;
  for (long long x : H) {
    if (x != 0) {
      ans++;
    }
  }
  cout << ans << endl;
}