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

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

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

using ll = long long;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL << 60;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll ans[200005];
graph g;
vector<ll> v;
vector<ll> x;

void dfs(int s) {
  auto ite = lower_bound(x.begin(), x.end(), v[s]);
  ll n = *ite, p = ite - x.begin();
  x[p] = v[s];
  ans[s] = lower_bound(x.begin(), x.end(), INF) - x.begin();
  for (auto ns : g[s]) {
    if (ans[ns] != 0)
      continue;
    dfs(ns);
  }
  x[p] = n;
}

int main() {
  ll N;
  cin >> N;
  v.resize(N);
  g.resize(N);
  rep(i, N) cin >> v[i];
  rep(i, N - 1) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  x.assign(N + 1, INF);
  dfs(0);
  rep(i, N) printf("%lld\\n", ans[i]);
}

Error: 0

Fixed submission:

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

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

using ll = long long;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL << 60;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll ans[200005];
graph g;
vector<ll> v;

void dfs(int s, vector<ll> x) {
  auto ite = lower_bound(x.begin(), x.end(), v[s]);
  x[ite - x.begin()] = v[s];
  auto A = lower_bound(x.begin(), x.end(), INF);
  ans[s] = A - x.begin();
  for (auto ns : g[s]) {
    if (ans[ns] != 0)
      continue;
    dfs(ns, x);
  }
}

int main() {
  ll N;
  cin >> N;
  v.resize(N);
  g.resize(N);
  rep(i, N) cin >> v[i];
  rep(i, N - 1) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<ll> x(N, INF);
  dfs(0, x);
  rep(i, N) printf("%lld\\n", ans[i]);
}
Problem p02698 (C++) — buggy submission, verdict: Time Limit Exceeded

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

const int INF = 2e9;

void dfs(int x, int bef, int dp[], const int n, const vector<int> &A,
         const vector<vector<int>> &T, int ans[]) {
  int *p = lower_bound(dp, dp + n + 1, A[x]);
  int tmp = *p;
  *p = min(tmp, A[x]);
  ans[x] = lower_bound(dp, dp + n + 1, INF) - dp;

  for (auto t : T[x]) {
    if (t == bef)
      continue;

    dfs(t, x, dp, n, A, T, ans);
  }
  *p = tmp;

  return;
}

int main() {
  int n;
  cin >> n;

  vector<int> A(n);
  for (int i = 0; i < n; i++)
    cin >> A[i];

  vector<vector<int>> T(n);

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    T[u].push_back(v);
    T[v].push_back(u);
  }

  int dp[n + 1];
  fill(dp, dp + n + 1, INF);
  dp[0] = A[0];

  int ans[n];

  dfs(0, -1, dp, n, A, T, ans);

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

  return 0;
}

Error: TLE

Fixed submission:

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

const int INF = 2e9;

void dfs(int x, int bef, int dp[], const int n, const vector<int> A,
         const vector<vector<int>> T, int ans[]) {
  if (ans[x] != -1)
    return;

  int *p = lower_bound(dp, dp + n + 1, A[x]);
  int tmp = *p;
  *p = min(tmp, A[x]);
  ans[x] = lower_bound(dp, dp + n + 1, INF) - dp;

  for (auto t : T[x]) {
    if (t == bef)
      continue;

    dfs(t, x, dp, n, A, T, ans);
  }
  *p = tmp;

  return;
}

int main() {
  int n;
  cin >> n;

  vector<int> A(n);
  for (int i = 0; i < n; i++)
    cin >> A[i];
  vector<vector<int>> T(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    T[u].push_back(v);
    T[v].push_back(u);
  }

  int dp[n + 1];
  fill(dp, dp + n + 1, INF);
  dp[0] = A[0];

  int ans[n];
  fill(ans, ans + n, -1);

  dfs(0, -1, dp, n, A, T, ans);

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

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

struct LIS {
  const int INF = 1e9 + 1;
  vector<int> dp;
  int last = 0;
  vector<vector<int>> hist;

  LIS(int N) { dp.assign(N + 1, INF); }
  void add(int a) {
    int pos = lower_bound(dp.begin(), dp.end(), a) - dp.begin();
    hist.push_back({pos, dp[pos], last});
    dp[pos] = a;
    last = max(last, pos);
  }

  int ans() { return last + 1; }

  void rollback() {
    auto v = hist.back();
    hist.pop_back();
    dp[v[0]] = v[1];
    last = v[2];
  }
};

int N;
int val[220000];
int ans[220000];
vector<int> adj[220000];
LIS lis(220000);

void dfs(int nd, int prv = -1) {
  lis.add(val[nd]);
  ans[nd] = lis.ans();
  for (int nxt : adj[nd])
    if (nxt != prv)
      dfs(nxt, nd);
  lis.rollback();
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> val[i];
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(0);
  for (int i = 0; i < N; i++)
    cout << ans[i] << "\\n";
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int N;
vector<int> tmp;
int val[220000];
vector<int> adj[220000];

int t[220000];
void modify(int p, int value) {
  p += N;
  for (t[p] = max(t[p], value); p > 1; p >>= 1)
    t[p >> 1] = max(t[p], t[p ^ 1]);
}
void init(int p, int value) {
  for (t[p += N] = value; p > 1; p >>= 1)
    t[p >> 1] = max(t[p], t[p ^ 1]);
}
int query(int l, int r) {
  int ret = 0;
  for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
    if (l & 1)
      ret = max(ret, t[l++]);
    if (r & 1)
      ret = max(ret, t[--r]);
  }
  return ret;
}

map<pll, int> mp;

int dp[220000];
void dfs(int nd, int prv = -1) {
  //	cout << nd + 1 << ":" << query(0, val[nd]) << '\\n';
  dp[nd] = max(dp[nd], query(0, val[nd]) + 1);
  modify(val[nd], dp[nd]);
  mp[{val[nd], dp[nd]}]++;
  for (int nxt : adj[nd]) {
    if (prv == nxt)
      continue;
    dfs(nxt, nd);
  }
  if (--mp[{val[nd], dp[nd]}] == 0)
    if (query(val[nd], val[nd] + 1) == dp[nd])
      init(val[nd], 0);
  //	cout << nd + 1 << ' ' << val[nd] << ' ' << dp[nd] << '\\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> val[i];
    tmp.push_back(val[i]);
  }
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  sort(tmp.begin(), tmp.end());
  tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());

  for (int i = 0; i < N; i++)
    val[i] = lower_bound(tmp.begin(), tmp.end(), val[i]) - tmp.begin();

  dfs(0);

  for (int i = 0; i < N; i++)
    cout << dp[i] << '\\n';

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

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

typedef long long ll;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
#define f first
#define s second
#define FOR(i, s, e) for (ll i = s; i <= ll(e); ++i)
#define DEC(i, s, e) for (ll i = s; i >= ll(e); --i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i, x) for (auto i : x)
#define mem(x, i) memset(x, i, sizeof x)
#define fast ios_base::sync_with_stdio(false), cin.tie(0)
#define maxn 200001

vi adj[maxn];
int A[maxn];
int N;
vi vect;
int ans[maxn];

void dfs(int x, int p) {
  ans[x] = vect.size();
  // cout<<x<<' ';
  aFOR(i, adj[x]) {
    if (i != p) {

      int idx = -1, val = -1;

      if (vect.empty())
        vect.pb(A[i]);
      else {
        if (A[i] > *(--vect.end()))
          vect.pb(A[i]);
        else {
          idx = lower_bound(all(vect), A[i]) - vect.begin();
          val = vect[lower_bound(all(vect), A[i]) - vect.begin()];
          vect[lower_bound(all(vect), A[i]) - vect.begin()] = A[i];
        }
      }

      dfs(i, x);

      if (idx == -1)
        vect.pop_back();
      else
        vect[idx] = val;
    }
  }
}
int main() {
  fast;

  cin >> N;

  FOR(i, 1, N) cin >> A[i];

  FOR(i, 1, N - 1) {
    int a, b;
    cin >> a >> b;
    adj[a].pb(b);
    adj[b].pb(a);
  }

  vect.pb(A[1]);

  dfs(1, -1);

  FOR(i, 1, N) cout << ans[i] << '\\n';
}


Error: TLE

Fixed submission:

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

typedef long long ll;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
#define f first
#define s second
#define FOR(i, s, e) for (ll i = s; i <= ll(e); ++i)
#define DEC(i, s, e) for (ll i = s; i >= ll(e); --i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i, x) for (auto i : x)
#define mem(x, i) memset(x, i, sizeof x)
#define fast ios_base::sync_with_stdio(false), cin.tie(0)
#define maxn 200001

vi adj[maxn];
int A[maxn];
int N;
vi vect;
int ans[maxn];

void dfs(int x, int p) {
  ans[x] = vect.size();
  // cout<<x<<' ';
  aFOR(i, adj[x]) {
    if (i != p) {
      vi prev_vect = vect;

      if (vect.empty())
        vect.pb(A[i]);
      else {
        if (A[i] > *(--vect.end()))
          vect.pb(A[i]);
        else
          vect[lower_bound(all(vect), A[i]) - vect.begin()] = A[i];
      }

      dfs(i, x);

      vect = prev_vect;
    }
  }
}
int main() {
  fast;

  cin >> N;

  FOR(i, 1, N) cin >> A[i];

  FOR(i, 1, N - 1) {
    int a, b;
    cin >> a >> b;
    adj[a].pb(b);
    adj[b].pb(a);
  }

  vect.pb(A[1]);

  dfs(1, -1);

  FOR(i, 1, N) cout << ans[i] << '\\n';
}
Problem p02698 (C++) — buggy submission, verdict: Runtime Error

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

#define int long long

const int N = 2e5 + 5;
int a[N];
vector<int> g[N];
int n;
int ans[N];
vector<int> d;
void dfs(int k, int par) {
  ans[k] = d.size();
  for (auto &it : g[k]) {
    int temp;
    if (it == par)
      continue;
    bool flag = 1;
    auto itr = lower_bound(d.begin(), d.end(), a[it]);
    int idx = itr - d.begin();
    if (itr == d.end())
      d.push_back(a[it]);
    else {
      flag = 0;
      temp = *itr;
      *itr = a[it];
    }
    dfs(it, k);
    if (flag)
      d.pop_back();
    else
      d[idx] = temp;
  }
}

void solve(int tt) {
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  d.push_back(a[1]);
  dfs(1, 0);
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
}

int32_t main() {
  int t = 1;
  // cin>>t;
  for (int i = 1; i <= t; i++)
    solve(i);
}

Error: 0

Fixed submission:

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

#define int long long

const int N = 2e5 + 5;
int a[N];
vector<int> g[N];
int n;
int ans[N];
vector<int> d;
void dfs(int k, int par) {
  ans[k] = d.size();
  for (auto &it : g[k]) {
    int temp;
    if (it == par)
      continue;
    bool flag = 1;
    auto itr = upper_bound(d.begin(), d.end(), a[it]);
    if (itr == d.end())
      d.push_back(a[it]);
    else {
      flag = 0;
      temp = *itr;
      *itr = a[it];
    }
    dfs(it, k);
    if (flag)
      d.pop_back();
    else
      *itr = temp;
  }
}

void solve(int tt) {
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  d.push_back(a[1]);
  dfs(1, 0);
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
}

int32_t main() {
  int t = 1;
  // cin>>t;
  for (int i = 1; i <= t; i++)
    solve(i);
}
Problem p02699 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <stdlib.h>

int main() {
  int S, W;
  scanf("%d%d", &S, &W);
  if (W >= S) {
    printf("unsafe");
  } else {
    printf("safe");
  }
  // printf("羊の数は%d、オオカミの数は%d",S,W);
}


Error: -11

Fixed submission:

#include <cstdio>
#include <stdlib.h>

int main(int argc, char *argv[]) {
  int S;
  int W;
  S = atoi(argv[1]);
  W = atoi(argv[2]);
  if (W >= S) {
    printf("unsafe");
  } else {
    printf("safe");
  }
  // printf("羊の数は%d、オオカミの数は%d",S,W);
}
Problem p02699 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int S, W;
  cin >> S >> W;
  if (S <= W) {
    cout << "unsafe" << endl;
  } else
    cout << "safe" << endl;
}

Error: WA

Fixed submission:

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

int main() {
  int N;
  vector<string> S(11);
  cin >> N;
  for (int i = 0; i < 11; i++) {
    S.at(i);
  }
  int count = N;
  sort(S.begin(), S.end());

  for (int i = 0; i < N - 1; i++) {

    if (S.at(i) == S.at(i + 1))
      count--;
  }
  cout << count << endl;
}
Problem p02699 (C++) — buggy submission, verdict: Runtime Error

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

int s, w;
void input() { cin >> s >> w; }

void solve() {
  if (w >= s)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;
}

int main() {
  cin.tie();
  ios::sync_with_stdio(false);
  input();
  solve();
  return 0;
}

Error: 0

Fixed submission:

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

int s, w;
int input() { cin >> s >> w; }

int solve() {
  if (w >= s)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;
}

int main() {
  cin.tie();
  ios::sync_with_stdio(false);
  input();
  solve();
  return 0;
}
Problem p02699 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main(void) {
  int s, w;

  cin >> s >> w;

  if ((s > 0 && s <= 100) && (w > 0 && w <= 100)) {
    if (s <= w) {
      cout << "unsafe" << endl;
    } else {
      cout << "safe" << endl;
    }
  }

  return 0;
}

Error: 255

Fixed submission:

#include <iostream>

using namespace std;

int main(void) {
  int a, b, c, d;
  cin.exceptions(ios::failbit);

  try {
    cin >> a >> b >> c >> d;
  } catch (...) {
    return -1;
  }

  if ((a < 0 && a <= 100) && (b < 0 && b <= 100) && (c < 0 && c <= 100) &&
      (d < 0 && d <= 100)) {
    while (a > 0 || b > 0) {
      a -= d;
      c -= b;
    }

    if (a <= 0) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
  return 0;
}
Problem p02699 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Map = map<string, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF = 1LL << 60;
ll MOD = 1000000007;

int main() {
  ll S;
  cin >> S;
  ll W;
  cin >> W;
  for (ll i = 0; i < 1000000000; i++) {
    swap(S, W);
  }
  if (S <= W)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Map = map<string, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF = 1LL << 60;
ll MOD = 1000000007;

int main() {
  ll S;
  cin >> S;
  ll W;
  cin >> W;
  for (ll i = 0; i < 10000000000; i++) {
    swap(S, W);
  }
  if (S <= W)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;
  return 0;
}
Problem p02699 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int s, w;
  cin >> s >> w;
  cout << (w >= s ? "unsafe" : "safe") << endl;

  return 0;
}


Error: TLE

Fixed submission:

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

using ll = long long;
const int SIZE = 1e5;

int ary[SIZE];

const int MOD = 2019;
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    ary[i] = s[i] - '0';
  }
  ll res = 0;
  int n = s.size();
  for (int i = 0; i < SIZE; i++) {
    int sum = 0;
    for (int j = i; j < SIZE; j++) {
      sum *= 10;
      sum += ary[j];
      sum %= MOD;
      res += ll(sum == 0);
    }
  }
  res -= ll(SIZE - n) * (SIZE - n + 1) / 2;
  int tmp = 1;
  int sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    sum += ary[i] * tmp;
    tmp *= 10;
    tmp %= MOD;
    sum %= MOD;
    if (sum == 0)
      res -= SIZE - n;
  }
  cout << res << endl;
  return 0;
}
Problem p02700 (C++) — buggy submission, verdict: Time Limit Exceeded

/*
---------author:O7Oo7oO7O-------------
*/

#include <bits/stdc++.h>

#define IOS                                                                    \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

using namespace std;

using ll = long long int;

int main() {
  IOS

      int a,
      b, c, d;
  cin >> a >> b >> c >> d;
  while (1) {
    if (c <= 0) {
      cout << "Yes\\n";
      break;
    }
    if (a <= 0) {
      cout << "No\\n";
      break;
    }
    c -= b;
    a -= d;
  }

  return 0;
}


Error: TLE

Fixed submission:

/*
---------author:O7Oo7oO7O-------------
*/

#include <bits/stdc++.h>

#define IOS                                                                    \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

using namespace std;

using ll = long long int;

int main() {
  IOS

      int a,
      b, c, d;
  cin >> a >> b >> c >> d;
  while (1) {
    if (a <= 0 && c > 0) {
      cout << "No\\n";
      break;
    }
    if (c <= 0 && a > 0) {
      cout << "Yes\\n";
      break;
    }

    c -= b;
    a -= d;
  }

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

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

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  while (1) {
    c -= b;
    if (c <= 0) {
      cout << "Yes";
      return 0;
    }
    a -= d;
    if (a <= 0) {
      cout << "No";
      return 0;
    }
  }
}

Error: TLE

Fixed submission:

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

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  while (1) {
    c -= b;
    if (c == 0) {
      cout << "Yes";
      return 0;
    }
    a -= d;
    if (a == 0) {
      cout << "No";
      return 0;
    }
  }
}
Problem p02700 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, z, w;
  cin >> x >> y >> z >> w;
  while (x > 0 && z > 0) {
    z -= y;
    if (z <= 0) {
      break;
    } else {
      x -= w;
    }
    if (x <= 0) {
      break;
    } else {
      continue;
    }
  }
  if (z <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, z, w;
  cin >> x >> y >> z >> w;
  while (x > 0 && y > 0) {
    z -= y;
    if (z <= 0) {
      cout << "Yes" << endl;
    } else {
      x -= w;
      if (x <= 0) {
        cout << "No" << endl;
      }
    }
  }
}
Problem p02700 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int i = 0;
  while (a > 0 && c > 0) {
    if (i)
      a -= d, i--;
    else
      c -= b, i++;
  }
  if (a > 0)
    cout << "Yes\\n";
  else
    cout << "No\\n";
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  int x = (a + d - 1) / d;
  int y = (c + b - 1) / b;
  x >= y ? (cout << "YES\\n") : (cout << "NO\\n");
}
Problem p02700 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (a > 0) {
    c = c - b;
    if (c <= 0) {
      break;
    }
    a = a - d;
  }
  if (c <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (a > 0 && c > 0) {
    c = c - b;
    while (c > 0) {
      a = a - d;
    }
  }
  if (a < 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}
Problem p02700 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

  int A;
  int B;
  int C;
  int D;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;
  int X;
  if (A % D == 0) {
    X = A / D;
  } else {
    X = (A / D) + 1;
  }
  int Y;
  if (C % B == 0) {
    Y = C / B;
  } else {
    Y = (C / B) + 1;
  }
  if (X < Y) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


Error: -8

Fixed submission:

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

int main() {

  int A;
  int B;
  int C;
  int D;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;
  int a;
  a = A - D;
  int b;
  b = C - B;
  int X;
  if (A % a == 0) {
    X = A / a;
  } else {
    X = (A / a) + 1;
  }
  int Y;
  if (B % b == 0) {
    Y = B / b;
  } else {
    Y = (B / b) + 1;
  }
  if (X <= Y) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}
Problem p02700 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (true) {
    c -= b;
    if (c <= 0) {
      cout << "Yes";
      break;
    }
    a -= d;
    if (a <= 0) {
      cout << "No";
      break;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (true) {
    a -= d;
    if (a <= 0) {
      cout << "No";
    }
    c -= b;
    if (c <= 0) {
      cout << "Yes";
    }
  }
  return 0;
}
Problem p02700 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int X = (A + D - 1) / D;
  int Y = (B + C - 1) / B;
  if (X >= Y)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Error: WA

Fixed submission:

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

int abcd(int A, int B, int C, int D) {
  if ((A - B) > 0 && (C - D) > 0) {
    abcd((A - B), B, (C - D), D);
  } else {
    if ((A - B) > 0)
      return 0;
    else
      return 1;
  }
}

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int i = abcd(A, B, C, D);
  if (i == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p02700 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while (A > 0 && C > 0) {
    C -= B;
    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if (A <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}


Error: TLE

Fixed submission:

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while (A > 0 && C > 0) {
    C - B;
    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }
    A - D;
    if (A <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}