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

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

long long int dp[100005];

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int first, second;
  cin >> first >> second;
  vector<long long int> all(first + 1, 0);
  // vector<long long int>deg(first+1,0);
  for (int i = 1; i <= first; i++) {
    long long int temp;
    cin >> temp;
    //  dp[i]=temp;
    all[i] = temp;
  }

  for (int i = 0; i < second; i++) {
    int first1, second1;
    cin >> first1 >> second1;

    // deg[first1]++;
    // deg[second1]++;

    if (all[first1] <= all[second1])
      dp[first1] = 1;
    if (all[second1] <= all[first1])
      dp[second1] = 1;
  }

  long long int ans = 0;
  for (int i = 1; i <= first; i++) {
    //  cout<<dp[i]<<" "<<deg[i]<<endl;
    if (dp[i] == 0)
      ans++;
  }

  cout << ans << endl;

  return 0;
}

Error: 0

Fixed submission:

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

long long int dp[10005];

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int first, second;
  cin >> first >> second;
  vector<long long int> all(first + 1, 0);
  vector<long long int> deg(first + 1, 0);
  for (int i = 1; i <= first; i++) {
    long long int temp;
    cin >> temp;
    //  dp[i]=temp;
    all[i] = temp;
  }

  for (int i = 0; i < second; i++) {
    int first1, second1;
    cin >> first1 >> second1;

    // deg[first1]++;
    // deg[second1]++;

    if (all[first1] <= all[second1])
      dp[first1] = 1;
    if (all[second1] <= all[first1])
      dp[second1] = 1;
  }

  long long int ans = 0;
  for (int i = 1; i <= first; i++) {
    //  cout<<dp[i]<<" "<<deg[i]<<endl;
    if (dp[i] == 0)
      ans++;
  }

  cout << ans << endl;

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

#include <bits/stdc++.h>

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;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, m, sum = 0;
  cin >> n >> m;
  int h[n + 1], /*海拔*/ 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];
  }
  for (int i = 1; i <= n; i++) {
    int s = 0;
    for (int j = 1; j <= m; j++) {
      if (a[j] == i && h[b[j]] >= h[i])
        s = 1;
      if (b[j] == i && h[a[j]] >= h[i])
        s = 1;
    }
    if (s == 0)
      sum++;
  }
  cout << sum;
  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ll N, M;
  cin >> N >> M;
  ll H[N];
  ll A[M], B[M];
  ll num[N];
  for (ll i = 0; i < N; i++)
    cin >> H[i];
  for (ll i = 0; i < M; i++)
    cin >> A[i] >> B[i];
  for (ll i = 0; i < N; i++)
    num[i] = 1;
  for (ll i = 0; i < M; i++) {
    if (H[A[i] - 1] > H[B[i] - 1]) {
      num[B[i] - 1] = 0;
    } else if (H[A[i] - 1] < H[B[i] - 1]) {
      num[A[i] - 1] = 0;
    } else if (H[A[i] - 1] == H[B[i] - 1]) {
      num[A[i] - 1] = num[B[i] - 1] = 0;
    }
  }
  ll count = 0;
  for (ll i = 0; i < N; i++) {
    if (num[i] == 1) {
      count++;
    }
  }
  cout << count << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  ll N, M;
  cin >> N >> M;
  ll H[N];
  ll A[M], B[M];
  for (ll i = 0; i < N; i++)
    cin >> H[i];
  for (ll i = 0; i < M; i++)
    cin >> A[i] >> B[i];
  ll count = N;
  ll comp;
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < M; j++) {

      if (A[j] == i + 1) {
        comp = B[j];
        if (H[i] <= H[comp - 1]) {
          count--;
          break;
        }
      } else if (B[j] == i + 1) {
        comp = A[j];
        if (H[i] <= H[comp - 1]) {
          count--;
          break;
        }
      }
    }
  }
  cout << count << endl;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
#define x first
#define y second
#define pb push_back
#define endl "\\n"

using namespace std;
const int maxn = 1e6 + 5;
vector<pair<int, int>> adj[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int arr[n + 1];
  for (int i = 1; i <= n; i++)
    cin >> arr[i];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].pb({arr[b], b});
    adj[b].pb({arr[a], a});
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    if (adj[i].size() == 0) {
      ans++;
      continue;
    }
    sort(adj[i].begin(), adj[i].end());
    if (adj[i][adj[i].size() - 1].x < arr[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define x first
#define y second
#define pb push_back
#define endl "\\n"

using namespace std;
const int maxn = 1e6;
vector<pair<int, int>> adj[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int arr[n + 1];
  for (int i = 1; i <= n; i++)
    cin >> arr[i];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].pb({arr[b], b});
    adj[b].pb({arr[a], a});
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    sort(adj[i].begin(), adj[i].end());
    if (adj[i][adj[i].size() - 1].x <= arr[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> h(n);
  rep(i, n) { cin >> h[i]; }
  vector<ll> a(m);
  vector<ll> b(m);
  vector<ll> judge(n);
  rep(i, m) {
    cin >> a[i] >> b[i];
    if (h[a[i] - 1] < h[b[i] - 1]) {
      judge[a[i] - 1] = 1;
    } else if (h[a[i] - 1] > h[b[i] - 1]) {
      judge[b[i] - 1] = 1;
    } else {
      judge[a[i] - 1] = 1;
      judge[b[i] - 1] = 1;
    }
  }
  ll ans = 0;
  rep(i, n) {
    if (judge[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> h(n);
  rep(i, n) { cin >> h[i]; }
  vector<ll> a(n);
  vector<ll> b(m);
  vector<ll> judge(n);
  rep(i, m) {
    cin >> a[i] >> b[i];
    if (h[a[i] - 1] < h[b[i] - 1]) {
      judge[a[i] - 1] = 1;
    } else if (h[a[i] - 1] > h[b[i] - 1]) {
      judge[b[i] - 1] = 1;
    } else {
      judge[a[i] - 1] = 1;
      judge[b[i] - 1] = 1;
    }
  }
  ll ans = 0;
  rep(i, n) {
    if (judge[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<unsigned long long int> h(n);
  for (int i = 0; i < n; i++)
    std::cin >> h[i];
  std::vector<bool> good(n, true);
  for (int i = 0; i < m; i++) {
    int a, b;
    std::cin >> a >> b;
    if (h[b - 1] >= h[a - 1])
      good[a - 1] = false;
    if (h[a - 1] >= h[b - 1])
      good[b - 1] = false;
  }
  int cnt = 0;
  for (int i = 0; i < n; i++)
    if (good[i])
      cnt++;
  std::cout << cnt;
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
#include <vector>

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> h(n);
  for (int i = 0; i < n; i++)
    std::cin >> h[i];
  std::vector<std::vector<int>> mat(n);
  for (int i = 0; i < n; i++)
    mat[i].resize(n, 0);
  for (int i = 0; i < m; i++) {
    int a, b;
    std::cin >> a >> b;
    mat[a - 1][b - 1]++;
    mat[b - 1][a - 1]++;
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    bool p = true;
    for (int j = 0; j < n; j++) {
      if (mat[i][j] == 1 && h[j] >= h[i] || mat[i][j] > 1)
        p = false;
    }
    if (p)
      cnt++;
  }
  std::cout << cnt;
  return 0;
}
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++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

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


Error: 0

Fixed submission:

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

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

#include <bits/stdc++.h>
#define endl '\\n'
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  int m;
  int b, c;
  cin >> n >> m;
  int h[n];
  bool a[n];

  for (int i = 0; i < n; i++) {
    cin >> h[i];
    a[i] = true;
  }
  for (int i = 0; i < m; i++) {
    cin >> b >> c;
    if (h[b - 1] <= h[c - 1])
      a[b - 1] = false;
    if (h[c - 1] <= h[b - 1])
      a[c - 1] = false;
  }

  int count = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == true)
      count++;
  }
  cout << count;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define endl '\\n'
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  int m;
  int b, c;
  int h[n];
  bool a[n];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
    a[i] = true;
  }
  for (int i = 0; i < m; i++) {
    cin >> b >> c;
    if (h[b - 1] <= h[c - 1])
      a[b - 1] = false;
    if (h[c - 1] <= h[b - 1])
      a[c - 1] = false;
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == true)
      count++;
  }
  cout << count;
  return 0;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int h[100005], vis[100005];
int main() {
  int n, m, num = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &h[i]);
  for (int i = 1; i <= m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (h[x] == h[y]) {
      vis[x] = vis[y] = 1;
    } else if (h[x] > h[y])
      vis[y] = 1;
    else
      vis[x] = 1;
  }
  for (int i = 1; i <= n; ++i)
    if (vis[i] == 0)
      num++;
  printf("%d", num);
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int h[100005], vis[100005];
int main() {
  int n, m, num = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    cin >> h[i];
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    if (h[x] == h[y]) {
      vis[x] = vis[y] = 1;
    } else
      vis[min(h[x], h[y])] = 1;
  }
  for (int i = 1; i <= n; ++i)
    if (vis[i] == 0)
      num++;
  cout << num;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>

using namespace std;

int main() {

  long long N, M;
  cin >> N >> M;
  long long H[N + 1];
  int highest[N + 1];
  for (int i = 1; i <= N; i++) {
    highest[i] = 1;
  }
  long long 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];
  }

  for (int i = 1; i <= M; i++) {
    if (H[A[i]] > H[B[i]]) {
      highest[B[i]] = 0;
    } else if (H[A[i]] < H[B[i]]) {
      highest[A[i]] = 0;
    } else {
      highest[A[i]] = 0;
      highest[B[i]] = 0;
    }
  }
  long long ryo = 0;
  for (int i = 1; i <= N; i++) {
    ryo = ryo + highest[i];
  }

  cout << ryo << endl;
}


Error: -11

Fixed submission:

#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>

using namespace std;

int main() {

  long long N, M;
  cin >> N >> M;
  long long H[N];
  int highest[N];
  for (int i = 0; i < N; i++) {
    highest[i] = 1;
  }
  long long A[M], B[M];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  for (int i = 1; i <= M; i++) {
    cin >> A[i] >> B[i];
  }

  for (int i = 0; i < M; i++) {
    if (H[A[i]] > H[B[i]]) {
      highest[B[i]] = 0;
    } else if (H[A[i]] < H[B[i]]) {
      highest[A[i]] = 0;
    } else {
      highest[A[i]] = 0;
      highest[B[i]] = 0;
    }
  }
  long long ryo = 0;
  for (int i = 0; i < N; i++) {
    ryo = ryo + highest[i];
  }

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

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

int main() {
  int N, M;
  cin >> N >> M;
  int H[100010];
  for (int i = 1; i <= N; i++) {
    cin >> H[i];
  }

  bool is_highest[100010];
  for (int i = 0; i < 100010; i++) {
    is_highest[i] = true;
  }
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    if (H[a] <= H[b])
      is_highest[a - 1] = false;
    if (H[b] <= H[a])
      is_highest[b - 1] = false;
  }

  int count = 0;

  for (int i = 0; i < N; i++) {
    if (is_highest[i])
      count++;
  }

  cout << count << endl;
}

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<vector<int>> AB(M, vector<int>(2));
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> AB.at(i).at(j);
    }
  }

  int count = 0;

  // 展望台iについて良い展望台か
  for (int i = 0; i < N; i++) {
    vector<int> connect_viewspot;
    for (int j = 0; j < M; j++) {
      for (int k = 0; k < 2; k++) {
        if (i + 1 == AB.at(j).at(k)) {
          if (k == 0)
            connect_viewspot.push_back(AB.at(j).at(1) - 1);
          if (k == 1)
            connect_viewspot.push_back(AB.at(j).at(0) - 1);
        }
      }
    }

    // 繋がってる中で一番高いか
    bool is_highest = true;
    for (int j = 0; j < connect_viewspot.size(); j++) {
      if (H.at(i) <= H.at(connect_viewspot.at(j))) {
        is_highest = false;
      }
    }

    if (is_highest)
      count++;
  }

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

#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;
  map<int, int> hi;
  for (int i = 1; i <= n; i++) {
    cin >> hi[i];
  }

  vector<bool> hh(n, true);
  rep(j, m) {
    int a, b;
    cin >> a >> b;
    if (hi[a] >= hi[b]) {
      hh[b - 1] = false;
    }
    if (hi[a] <= hi[b]) {
      hh[a - 1] = false;
    }
  }
  int count = 0;
  rep(i, n) {
    if (hh[i]) {
      count++;
    }
  }

  cout << count << endl;
}


Error: TLE

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>;

int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> hi;
  for (int i = 1; i <= n; i++) {
    cin >> hi[i];
  }
  vector<P> r(m);
  map<int, int> cntA;
  rep(j, m) {
    int a, b;
    cin >> a >> b;
    cntA[a]++;
    cntA[b]++;
    r[j].first = a;
    r[j].second = b;
  }
  int count = n;
  for (int i = 1; i <= n; i++) {
    if (cntA[i] == 0) {
      continue;
    }
    rep(j, m) {
      if (r[j].first != i && r[j].second != i) {
        continue;
      }
      if (r[j].first == i) {
        if (hi[i] <= hi[r[j].second]) {
          count--;
          break;
        }
      }
      if (r[j].second == i) {
        if (hi[i] <= hi[r[j].first]) {
          count--;
          break;
        }
      }
    }
  }
  cout << count << endl;
}
Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FILL0(x) memset(x, 0, sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

struct edge {
  int from, to;
};
vector<int> G[100010];

int N, M;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);

  cin >> N >> M;

  vector<ll> H(N);
  rep(i, N) { cin >> H[i]; }

  rep(i, M) {
    int a1, a2;
    cin >> a1 >> a2;
    a1--;
    a2--;

    G[a1].push_back(a2);
    G[a2].push_back(a1);
  }
  int ans = 0;
  rep(i, N) {
    if (G[i].size() == 0) {
      ans++;
    }

    rep(j, G[i].size()) {
      if (H[G[i][j]] >= H[i]) {
        break;
      }
      if (j == G[i].size() - 1) {
        ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FILL0(x) memset(x, 0, sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);

  int N, K;
  cin >> N >> K;

  bool used[N];
  FILL0(used);
  rep(i, K) {
    int d;
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a;
      a--;
      used[a] = true;
    }
  }

  int ans = 0;
  rep(i, N) {
    if (!used[i]) {
      ans++;
    }
  }

  cout << ans << endl;

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

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vec(n, 0);
  vector<int> are(n, 0);
  vector<vector<int>> miti(m, vector<int>(2));

  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> miti.at(i).at(j);
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    a = miti.at(i).at(0) - 1;
    b = miti.at(i).at(1) - 1;
    are.at(a) = max(vec.at(b), are.at(a));
    are.at(b) = max(vec.at(a), are.at(b));
  }
  int output = 0;
  for (int i = 0; i < n; i++) {
    if (vec.at(i) > are.at(i)) {
      output++;
    }
  }
  cout << output << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vec(n, 0);
  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    vec.at(i) = h;
  }
  // cout << n <<" " << m << endl;
  // cout << vec.at(2) <<" " <<vec.at(3) << endl;

  vector<vector<int>> miti(m, vector<int>(2, 0));

  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> miti.at(i).at(j);
    }
  }

  // cout << miti.at(1).at(0) << " "<<miti.at(1).at(1) << endl;

  int output = 0;
  for (int i = 0; i < n; i++) {
    int flag = 0;
    // cout << endl<<"塔番号"<<i;
    for (int j = 0; j < m; j++) {
      // cout << "道番号"<<j;
      if ((miti.at(j).at(0) - 1) == i) {
        if (vec.at(miti.at(j).at(1) - 1) >= vec.at(i)) {
          flag++;
        }
      }
      if ((miti.at(j).at(1) - 1) == i) {
        if (vec.at(miti.at(j).at(0) - 1) >= vec.at(i)) {
          flag++;
        }
      }
    }
    if (flag == 0) {
      output++;
    }
  }
  cout << output << 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 < (int)(n); i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(), v.end()

ll gcd(ll a, ll b) {
  if (b > a)
    swap(a, 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;
}
ll rep_jijo(ll n, ll x) {
  if (x == 0)
    return 1;
  if (x % 2 == 0) {
    ll t = rep_jijo(n, x / 2);
    return t * t % mod;
  }
  return n * rep_jijo(n, x - 1) % mod;
}
int main() {
  ll n, m;
  cin >> n >> m;
  vector<int> cnt(n);
  vector<int> ten[n];
  int h[n];
  rep(i, n) cin >> h[i];
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    ten[a].push_back(b);
    ten[b].push_back(a);
    cnt[a]++;
    cnt[b]++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    bool flag = true;
    for (int j = 0; j < cnt[i]; j++) {
      ll x = h[i];
      ll y = h[ten[i][j]];
      if (x <= y)
        flag = false;
    }
    if (flag)
      ans++;
  }
  cout << ans << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(), v.end()

ll gcd(ll a, ll b) {
  if (b > a)
    swap(a, 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;
}
ll rep_jijo(ll n, ll x) {
  if (x == 0)
    return 1;
  if (x % 2 == 0) {
    ll t = rep_jijo(n, x / 2);
    return t * t % mod;
  }
  return n * rep_jijo(n, x - 1) % mod;
}
vector<int> ten[11000];
int h[11000];

int main() {
  ll n, m;
  cin >> n >> m;
  vector<int> cnt(n);
  rep(i, n) cin >> h[i];
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    ten[a].push_back(b);
    ten[b].push_back(a);
    cnt[a]++;
    cnt[b]++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    bool flag = true;
    for (int j = 0; j < cnt[i]; j++) {
      ll x = h[i];
      ll y = h[ten[i][j]];
      if (x <= y)
        flag = false;
    }
    if (flag)
      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> adj[N];
  int height[N];
  for (int i = 0; i < N; ++i) {
    cin >> height[i];
  }
  for (int i = 0; i < M; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    bool allHigher = true;
    for (auto &it : adj[i]) {
      allHigher &= height[i] > height[it];
    }
    ans += allHigher;
  }
  cout << ans << '\\n';
  return 0;
}


Error: WA

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  vector<int> adj[N];
  int height[N];
  for (int i = 0; i < N; ++i) {
    cin >> height[i];
  }
  for (int i = 0; i < N - 1; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    bool allHigher = true;
    for (auto &it : adj[i]) {
      allHigher &= height[i] > height[it];
    }
    ans += allHigher;
  }
  cout << ans << '\\n';
  return 0;
}