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

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(nullptr);                                                            \\
  cout.tie(nullptr);

void check(vector<ll> &k, vector<string> &pp, ll M) {
  rep(i, M) {
    ll a, b;
    cin >> a >> b;
    if (k.at(a - 1) < k.at(b - 1)) {
      pp.at(a - 1) = "wrong";
    }
    if (k[a - 1] > k[b - 1]) {
      pp.at(b - 1) = "wrong";
    }
    if (k[a - 1] == k[b - 1]) {
      pp.at(a - 1) = "wrong";
      pp.at(b - 1) = "wrong";
    }
  }
}

signed main() {
  IOS;
  ll N, M;
  cin >> N >> M;
  vector<ll> K(N);
  vector<string> A(N, "good");
  rep(i, N) {
    ll c;
    cin >> c;
    K.at(i) = c;
  }
  check(K, A, M);
  ll ans = 0;
  rep(i, N) {
    if (A.at(i) == "good") {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(nullptr);                                                            \\
  cout.tie(nullptr);

void check(vector<ll> &k, vector<string> &pp, ll M) {
  rep(i, M) {
    ll a1, a2;
    cin >> a1 >> a2;
    if (k[a1 - 1] < k[a2 - 1]) {
      pp[a1 - 1] = "wrong";
    }
    if (k[a1 - 1] > k[a2 - 1]) {
      pp[a1 - 2] = "wrong";
    }
    if (k[a1 - 1] == k[a2 - 1]) {
      pp[a1 - 2] = "wrong";
      pp[a1 - 1] = "wrong";
    }
  }
}

signed main() {
  IOS;
  ll N, M;
  cin >> N >> M;
  vector<ll> K(N);
  vector<string> A(N, "good");
  rep(i, N) {
    ll c;
    cin >> c;
    K[i] = c;
  }
  check(K, A, M);
  ll ans = 0;
  rep(i, N) {
    if (A[i] == "good") {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
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: 127
/tmp/1f77ccef-df54-41e0-9592-b99f18f5e494.out: error while loading shared libraries: libc.so.6: failed to map segment from shared object


Fixed submission:

#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <math.h>
using namespace std;
int n, m, h[100005], a, b, cnt;
bool a1[10006][10006];

int main() {
  //	memset(r, 0, sizeof(r));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    a1[1][i] = true;
  for (int i = 1; i <= n; i++)
    scanf("%d", &h[i]); // cin>> h[i];
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a, &b);
    if (h[a] > h[b] && a1[0][a] && a1[0][b]) {
      if (a1[a][b]) {
        a1[0][a] = false;
        a1[0][b] = false;
      } else {

        a1[a][b] = true;
        a1[0][b] = false;
      }
    }
    if (h[a] < h[b] && a1[0][a] && a1[0][b]) {
      if (a1[b][a]) {
        a1[0][b] = false;
        a1[0][a] = false;
      } else {
        a1[b][a] = true;
        a1[0][a] = false;
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    if (a1[0][i] == false)
      continue;
    cnt++;
  }
  printf("%d", cnt);
  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main() {

  int n, m, h[100000], ans = 0;
  bool yokunai[100000] = {};

  vector<pair<int, int>> pairs(200000);

  cin >> n >> m;

  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])
      yokunai[b] = true;
    if (h[b] >= h[a])
      yokunai[a] = true;
  }

  for (int i = 0; i < n; i++) {

    if (yokunai[i] == false)
      ans++;
  }

  cout << ans;
}

Error: TLE

Fixed submission:


#include <bits/stdc++.h>

using namespace std;

int main() {

  int n, m, h[100000];

  vector<pair<int, int>> pairs(200000);

  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    pairs[i] = make_pair(a - 1, b - 1);
    pairs[i + m] = make_pair(b - 1, a - 1);
  }
  sort(pairs.begin(), pairs.begin() + 2 * m - 1);

  int x = 0;
  int ten = 0;
  int ans = 0;
  while (x < 2 * m) {
    bool flag = true;
    while (ten == pairs[x].first) {
      int tai = pairs[x].second;
      if (h[ten] <= h[tai]) {
        flag = false;
      }
      x++;
    }
    if (flag)
      ans++;
    ten++;
  }
  cout << ans;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n; i++)
#define ll long long
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  int n, m;
  cin >> n >> m;
  Graph G(n);
  int h[n];
  rep(i, n) { cin >> h[i]; }
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }
  int ans = 0;
  rep(i, n) {
    int x = 1;
    for (auto itr = G[i].begin(); itr != G[i].end(); ++itr) {
      if (h[i] <= h[*itr]) {
        x = 0;
      }
    }
    ans += x;
  }
  cout << ans;
}


Error: -11

Fixed submission:

#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n; i++)
#define ll long long
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  int n, m;
  cin >> n >> m;
  Graph G;
  int h[n];
  rep(i, n) { cin >> h[i]; }
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
  }
  int ans = 0;
  rep(i, n) {
    int x = 1;
    for (auto itr = G[i].begin(); itr != G[i].end(); itr++) {
      if (h[i] <= h[*itr]) {
        x = 0;
      }
    }
    ans += x;
  }
  cout << ans;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

//
//
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(), (x).end()
#define outl(x) cout << x << endl
#define outsp(x) cout << x << " "
typedef long long ll;
typedef pair<int, int> P;

#define MAX_N 100005
int h[MAX_N];
vector<int> edge[MAX_N];

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, n) cin >> h[i];
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  int ans = 0;
  rep(i, n) {
    bool good = true;
    rep(j, edge[i].size()) {
      if (h[i] <= h[edge[i][j]]) {
        good = false;
        break;
      }
    }
    ans += good;
  }
  outl(ans);

  return 0;
}


Error: 0

Fixed submission:

//
//
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(), (x).end()
#define outl(x) cout << x << endl
#define outsp(x) cout << x << " "
typedef long long ll;
typedef pair<int, int> P;

#define MAX_N 10005
int h[MAX_N];
vector<int> edge[MAX_N];

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, n) cin >> h[i];
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  int ans = 0;
  rep(i, n) {
    bool good = true;
    rep(j, edge[i].size()) {
      if (h[i] <= h[edge[i][j]]) {
        good = false;
        break;
      }
    }
    ans += good;
  }
  outl(ans);

  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define MAX_N 100001

int N, M, H[MAX_N], ans = 0;
vector<int> E[MAX_N];

void solve() {
  for (int i = 1; i <= N; i++) {
    bool sw = true;
    set<int> C;
    while (!E[i].empty()) {
      int a = *(E[i].end() - 1);
      E[i].pop_back();
      if (H[i] <= H[a] && C.find(a) == C.end()) {
        sw = false;
        C.insert(a);
      }
    }
    if (sw)
      ans++;
  }
  cout << ans << endl;
}

int main() {
  cin >> N >> M;
  for (int i = 1; i <= N; i++) {
    cin >> H[i];
  }
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  solve();
  return 0;
}

Error: TLE

Fixed submission:

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

#define MAX_N 100001

int N, M, H[MAX_N], ans = 0;
vector<int> E[MAX_N];

void solve() {
  for (int i = 1; i <= N; i++) {
    bool sw = true;
    bool C[MAX_N];
    fill(C, C + MAX_N, true);
    while (!E[i].empty()) {
      int a = *(E[i].end() - 1);
      E[i].pop_back();
      if (H[i] <= H[a] && C[a]) {
        sw = false;
        C[a] = false;
      }
    }
    if (sw)
      ans++;
  }
  cout << ans << endl;
}

int main() {
  cin >> N >> M;
  for (int i = 1; i <= N; i++) {
    cin >> H[i];
  }
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  solve();
  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define INF 10000000
using ll = long long;
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}
template <int id> struct CompTupleBy {
  template <class T> bool operator()(const T &a, const T &b) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> Height;
  Height.push_back(0);
  rep(i, n) {
    ll h;
    cin >> h;
    Height.push_back(h);
  }
  vector<vector<ll>> vec;
  vector<ll> tmp;
  rep(i, n + 1) { vec.push_back(tmp); }
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    bool ok = true;
    ll height = Height[i];
    rep(j, vec[i].size()) {
      if (height <= Height[vec.at(i).at(j)]) {
        ok = false;
      }
    }
    if (ok) {
      ans += 1;
    }
  }
  cout << ans << endl;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define INF 10000000
using ll = long long;
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}
template <int id> struct CompTupleBy {
  template <class T> bool operator()(const T &a, const T &b) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> Height;
  Height.push_back(0);
  rep(i, n) {
    ll h;
    cin >> h;
    Height.push_back(h);
  }
  vector<vector<ll>> vec;
  vector<ll> tmp;
  rep(i, m + 1) { vec.push_back(tmp); }
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  int ans = 0;
  for (ll i = 1; i <= n; i++) {
    bool ok = true;
    ll height = Height[i];
    rep(j, vec[i].size()) {
      if (height <= Height[vec[i][j]]) {
        ok = false;
      }
    }
    if (ok) {
      ans += 1;
    }
  }
  cout << ans << endl;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

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

ll n, m, a, b, ans = 0;

int main() {
  cin >> n >> m;
  vector<ll> h(n);
  vector<int> good(n, 1);

  REP(i, n) { cin >> h[i]; }

  REP(i, m) {
    cin >> a >> b;
    if (h[a - 1] <= h[b - 1]) {
      good[a - 1] = 0;
    }
    if (h[a - 1] >= h[b - 1]) {
      good[b - 1] = 0;
    }
  }

  ans = accumulate(good.begin(), good.end(), 0);

  cout << ans << endl;
}

Error: 0

Fixed submission:

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

ll n, m, a, b, ans = 0;

int main() {
  cin >> n >> m;
  vector<ll> h(n);
  int adj[n + 1][n + 1];

  REP(i, n) {
    cin >> h[i];
    REP(j, n) { adj[i][j] = 0; }
  }

  REP(i, m) {
    cin >> a >> b;
    adj[a - 1][b - 1] = 1;
    adj[b - 1][a - 1] = 1;
  }

  // いい展望台かチェック
  REP(i, n) {
    REP(j, n) {
      if (adj[i][j] == 1) {
        if (h[i] <= h[j]) {
          break;
        }
      }
      if (j == n - 1) {
        ans += 1;
      }
    }
  }

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>
#include <vector>
#define INF 1000000000
using namespace std;
vector<int> adj[100001];
int h[100001], n, good, m, a, b, tim = 0;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    cin >> h[i];
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    good = 1;
    for (auto x : adj[i])
      if (h[i] <= h[x])
        good = 0;
    tim = tim + good;
  }
  cout << tim;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>
#include <vector>
#define INF 1000000000
using namespace std;
vector<int> adj[10001];
int h[10001], n, good, m, a, b, tim = 0, gone[10001];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    cin >> h[i];
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    good = 1;
    if (gone[i])
      good = 0;
    else
      for (int x = 0; x < adj[i].size(); x++) {
        if (h[i] <= h[adj[i][x]])
          good = 0;
        else
          gone[x] = 1;
      }
    tim = tim + good;
  }
  cout << tim;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;

int main() {
  int N, M, a, b;
  vector<int> ma(1000000, 0), h(1000000, 0);
  cin >> N >> M;
  for (int i = 1; i <= N; i++) {
    cin >> h[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    ma[a] = max(ma[a], h[b]);
    ma[b] = max(ma[b], h[a]);
  }
  int c = 0;
  for (int i = 1; i <= N; i++) {
    if (ma[i] < h[i])
      c += 1;
  }
  cout << c << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;

int main() {
  int N, M, a, b;
  vector<int> ma(M, 0), h(M, 0);
  cin >> N >> M;
  for (int i = 1; i <= N; i++) {
    cin >> h[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    ma[a] = max(ma[a], h[b]);
    ma[b] = max(ma[b], h[a]);
  }
  int c = 0;
  for (int i = 1; i <= N; i++) {
    if (ma[i] < h[i])
      c += 1;
  }
  cout << c << endl;
  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int h[N];
vector<int> e[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    scanf("%d", h + i);
  for (int i = 1; i <= m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    e[a].push_back(b);
    e[b].push_back(a);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    bool hh = true;
    for (int j = 0; j < int(e[i].size()); ++j) {
      if (h[i] <= h[e[i][j]]) {
        hh = false;
        break;
      }
    }
    if (hh)
      ans++;
  }
  printf("%d\\n", ans);
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int h[10005];
vector<int> e[10005];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    scanf("%d", h + i);
  for (int i = 1; i <= m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    e[a].push_back(b);
    e[b].push_back(a);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    bool hh = true;
    for (int j = 0; j < e[i].size(); ++j) {
      if (h[i] <= h[e[i][j]]) {
        hh = false;
        break;
      }
    }
    if (hh)
      ans++, cout << i << " ";
  }
  cout << ans << endl;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  long long n, m;
  bool check[100001];
  long long H[100001];
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> H[i];
    check[i] = true;
  }
  int A, B;
  for (int i = 0; i < m; i++) {
    cin >> A >> B;
    if (H[A] > H[B]) {
      check[B] = false;
    } else if (H[A] < H[B]) {
      check[A] = false;
    } else {
      check[A] = false;
      check[B] = false;
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (check[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  long long n, m;
  bool check[10001];
  long long H[10001];
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> H[i];
    check[i] = true;
  }
  int A, B;
  for (int i = 0; i < m; i++) {
    cin >> A >> B;
    if (H[A] > H[B]) {
      check[B] = false;
    } else if (H[A] < H[B]) {
      check[A] = false;
    } else {
      check[A] = false;
      check[B] = false;
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (check[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
// NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
// ABC 166, task , 2020/05/03
// ms,
/*
 */

int main(void) {
  int64_t N, M;
  vector<int64_t> height(100000);
  int64_t A, B;
  vector<vector<int64_t>> connect(100000);
  int ans = 0;

  cin >> N >> M;
  for (int64_t i = 0; i < N; i++)
    cin >> height[i];
  for (int64_t i = 0; i < M; i++) {
    cin >> A >> B;
    connect[A - 1].push_back(B - 1);
    connect[B - 1].push_back(A - 1);
  }

  for (int64_t i = 0; i < N; i++) {
    for (size_t j = 0; j < connect[i].size(); j++) {
      // cout <<i <<j <<endl;
      if (height[i] <= height[connect[i][j]])
        goto NEXT_LOOP;
    }
    ans++;
  // cout <<i <<endl;
  NEXT_LOOP:
    continue;
  }

  cout << ans << endl;

  return 0;
}
/*
 */


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
// NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
// ABC 166, task , 2020/05/03
// ms,
/*
 */

int main(void) {
  int64_t N, M;
  vector<int64_t> height(10000);
  int64_t A, B;
  vector<vector<int64_t>> connect(10000);
  int ans = 0;

  cin >> N >> M;
  for (int64_t i = 0; i < N; i++)
    cin >> height[i];
  for (int64_t i = 0; i < M; i++) {
    cin >> A >> B;
    connect[A - 1].push_back(B - 1);
    connect[B - 1].push_back(A - 1);
  }

  for (int64_t i = 0; i < N; i++) {
    for (size_t j = 0; j < connect[i].size(); j++) {
      // cout <<i <<j <<endl;
      if (height[i] <= height[connect[i][j]])
        goto NEXT_LOOP;
    }
    ans++;
  // cout <<i <<endl;
  NEXT_LOOP:
    continue;
  }

  cout << ans << endl;

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

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int h[n];
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  vector<int> G[n];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int ans = 0;
  bool flag = true;
  for (int i = 0; i < n; i++) {
    flag = true;
    for (int j = 0; j < G[i].size(); j++) {
      if (h[i] <= h[G[i][j]]) {
        flag = false;
      }
    }
    if (flag) {
      ans++;
    }
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int h[n];
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int d[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      d[i][j] = 0;
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    d[a][b] = 1;
    d[b][a] = 1;
  }
  int ans = 0;
  bool flag = true;
  for (int i = 0; i < n; i++) {
    flag = true;
    for (int j = 0; j < n; j++) {
      if (d[i][j] == 1) {
        if (h[i] <= h[j]) {
          flag = false;
          break;
        }
      }
    }
    if (flag) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
// int N が既に与えられているとする.

int main() {
  unsigned int N, M;
  cin >> N >> M;
  bool tenbou[N];
  for (unsigned int i = 0; i < N; i++)
    tenbou[i] = true;

  unsigned long long hyoukou[N];
  for (unsigned int i = 0; i < N; ++i) {
    cin >> hyoukou[i];
  }
  for (unsigned int i = 0; i < M; i++) {
    unsigned int A, B;
    cin >> A >> B;
    A -= 1;
    B -= 1;
    if (hyoukou[A] > hyoukou[B]) {
      tenbou[B] = false;
    } else if (hyoukou[A] < hyoukou[B]) {
      tenbou[A] = false;
    } else {
      tenbou[A] = false;
      tenbou[B] = false;
    }
  }
  unsigned int cnt = 0;

  for (unsigned int i = 0; i < N; ++i) {
    if (tenbou[i])
      ++cnt;
  }
  cout << cnt;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
// int N が既に与えられているとする.

int main() {
  unsigned int N, M;
  cin >> N >> M;
  bool tenbou[N][N];
  for (unsigned int i = 0; i < N; i++)
    for (unsigned int j = 0; j < N; j++)
      tenbou[i][j] = false;

  unsigned long long hyoukou[N];
  for (unsigned int i = 0; i < N; ++i) {
    cin >> hyoukou[i];
  }
  for (unsigned int i = 0; i < M; i++) {
    unsigned int A, B;
    cin >> A >> B;
    tenbou[A - 1][B - 1] = true;
    tenbou[B - 1][A - 1] = true;
  }
  unsigned int cnt = 0;

  for (unsigned int i = 0; i < N; ++i) {
    bool good = true;
    for (unsigned int j = 0; j < N; j++) {
      if (i == j)
        continue;
      if (tenbou[i][j]) {
        if (hyoukou[i] <= hyoukou[j])
          good = false;
      }
    }
    if (good)
      ++cnt;
  }
  cout << cnt;
}