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

#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_CAT_I(x, y) x##y

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end)                                                     \\
  for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end);                          \\
       i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f, c, ...)                                                         \\
  (([&](decltype((c)) cccc) {                                                  \\
    return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__);               \\
  })(c))
struct ProconInit {
  static constexpr int IOS_PREC = 15;
  static constexpr bool AUTOFLUSH = false;
  ProconInit() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(IOS_PREC);
    if (AUTOFLUSH)
      cout << unitbuf;
  }
} PROCON_INIT;

void solve() {
  ll n, m;
  cin >> n >> m;
  vector<ll> h(n);
  FOR(i, 0, n) cin >> h[i];
  vector<ll> a(m), b(m);
  FOR(i, 0, m) {
    cin >> a[i] >> b[i];
    --a[i];
    --b[i];
  }

  vector<int> res(n, 1);
  FOR(i, 0, m) {
    if (h[a[i]] > h[b[i]])
      res[b[i]] = 0;
    if (h[a[i]] < h[b[i]])
      res[a[i]] = 0;
    if (h[a[i]] == h[b[i]]) {
      res[a[i]] = 0;
      res[b[i]] = 0;
    }
  }
  cout << accumulate(res.begin(), res.end(), 0);
}

signed main() {
  solve();
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_CAT_I(x, y) x##y

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end)                                                     \\
  for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end);                          \\
       i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f, c, ...)                                                         \\
  (([&](decltype((c)) cccc) {                                                  \\
    return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__);               \\
  })(c))
struct ProconInit {
  static constexpr int IOS_PREC = 15;
  static constexpr bool AUTOFLUSH = false;
  ProconInit() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(IOS_PREC);
    if (AUTOFLUSH)
      cout << unitbuf;
  }
} PROCON_INIT;

void solve() {
  ll n, m;
  cin >> n >> m;
  vector<ll> h(n);
  FOR(i, 0, n) cin >> h[i];
  vector<ll> a(n), b(n);
  FOR(i, 0, m) {
    cin >> a[i] >> b[i];
    --a[i];
    --b[i];
  }

  vector<int> res(n, 1);
  FOR(i, 0, m) {
    if (h[a[i]] > h[b[i]])
      res[b[i]] = 0;
    if (h[a[i]] < h[b[i]])
      res[a[i]] = 0;
    if (h[a[i]] == h[b[i]]) {
      res[a[i]] = 0;
      res[b[i]] = 0;
    }
  }
  cout << accumulate(res.begin(), res.end(), 0);
}

signed main() {
  solve();
  return 0;
}