alexjercan/bugnet huggingface dataset:
Problem p01764 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <stdio.h>
using namespace std;
int b[310];
long long dp[310][310];
int sum[310];
int pow[10];
long long solve(int l, int r) {
  if (l == r)
    return 0;
  if (~dp[l][r])
    return dp[l][r];
  long long ret = 99999999999999LL;
  for (int i = l; i < r; i++) {
    int L = sum[i + 1] - sum[l];
    int R = sum[r + 1] - sum[i + 1];
    int c = 0;
    long long cost = solve(l, i) + solve(i + 1, r);
    while (L + R + c) {
      cost += (L % 10) * (R % 10);
      if (c + L % 10 + R % 10 >= 10) {
        c = 1;
        cost++;
      } else
        c = 0;
      L /= 10;
      R /= 10;
    }
    ret = min(ret, cost);
  }
  return dp[l][r] = ret;
}
int main() {
  int a;
  scanf("%d", &a);
  for (int i = 0; i < a; i++)
    scanf("%d", b + i);
  for (int i = 0; i < a; i++)
    sum[i + 1] = sum[i] + b[i];
  for (int i = 0; i < 310; i++) {
    for (int j = 0; j < 310; j++) {
      dp[i][j] = -1;
    }
  }
  pow[0] = 1;
  for (int i = 1; i < 10; i++)
    pow[i] = pow[i - 1] * 10;
  printf("%lld\\n", solve(0, a - 1));
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <stdio.h>
using namespace std;
int b[310];
long long dp[310][310];
int sum[310];
int pow[10];
long long solve(int l, int r) {
  if (l == r)
    return 0;
  if (~dp[l][r])
    return dp[l][r];
  long long ret = 99999999999999LL;
  for (int i = l; i < r; i++) {
    int L = sum[i + 1] - sum[l];
    int R = sum[r + 1] - sum[i + 1];
    int c = 0;
    long long cost = solve(l, i) + solve(i + 1, r);
    while (L + R + c) {
      cost += (L % 10) * (R % 10);
      if (c + L % 10 + R % 10 >= 10) {
        c = 1;
        cost++;
      }
      L /= 10;
      R /= 10;
    }
    ret = min(ret, cost);
  }
  return dp[l][r] = ret;
}
int main() {
  int a;
  scanf("%d", &a);
  for (int i = 0; i < a; i++)
    scanf("%d", b + i);
  for (int i = 0; i < a; i++)
    sum[i + 1] = sum[i] + b[i];
  for (int i = 0; i < 310; i++) {
    for (int j = 0; j < 310; j++) {
      dp[i][j] = -1;
    }
  }
  pow[0] = 1;
  for (int i = 1; i < 10; i++)
    pow[i] = pow[i - 1] * 10;
  printf("%lld\\n", solve(0, a - 1));
}
Problem p01764 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int comp_time(int x, int y) {
  int c = 0;
  int t = 0;
  while ((x > 0) || (y > 0)) {
    int xi = x % 10;
    int yi = y % 10;
    t += xi * yi + c;
    if (xi + yi + c >= 10)
      c = 1;
    else
      c = 0;
    x = x / 10;
    y = y / 10;
  }
  return t + c;
}

int main() {
  int n;
  int x[300];

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

  // table
  int sum[300][300];
  int time[300][300];

  for (int i = 0; i < n; i++) {
    sum[i][1] = x[i];
    time[i][1] = 0;
  }

  for (int k = 2; k <= n; k++) {
    for (int i = 0; i <= n - k; i++) {
      sum[i][k] = x[i] + sum[i + 1][k - 1];
      int min_time = comp_time(x[i], sum[i + 1][k - 1]) + time[i + 1][k - 1];
      for (int l = 2; l <= k - 1; l++) {
        int r = k - l;
        int t =
            time[i][l] + time[i + l][r] + comp_time(sum[i][l], sum[i + l][r]);
        if (t < min_time)
          min_time = t;
      }
      time[i][k] = min_time;
    }
  }

  // for (int k=1;k<=n;k++)
  // {
  //   for (int i=0; i<=n-k; i++)
  //   {
  //     cout << sum[i][k] << ' ';
  //   }
  //   cout << endl;
  // }
  // cout << endl;

  // for (int k=1;k<=n;k++)
  // {
  //   for (int i=0; i<=n-k; i++)
  //   {
  //     cout << time[i][k] << ' ';
  //   }
  //   cout << endl;
  // }
  // cout << endl;

  cout << time[0][n] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int comp_time(int x, int y) {
  int c = 0;
  int t = 0;

  while ((x > 0) || (y > 0)) {
    int xi = x % 10;
    int yi = y % 10;
    t += xi * yi + c;
    if (xi + yi + c >= 10)
      c = 1;
    else
      c = 0;
    x = x / 10;
    y = y / 10;
  }

  return t;
}

int total_time(int *sum, int *A, const int na) {
  int x[300], y[300];
  if (na == 1) {
    *sum = A[0];
    return 0;
  } else {
    int min_time = 100000000;
    for (int k = 1; k < na; k++) {
      int s1, s2;
      int t1, t2;
      for (int i = 0; i < k; i++)
        x[i] = A[i];
      for (int i = 0; i < na - k; i++)
        y[i] = A[k + i];
      t1 = total_time(&s1, x, k);
      t2 = total_time(&s2, y, na - k);
      *sum = s1 + s2;
      int tm = t1 + t2 + comp_time(s1, s2);
      if (tm < min_time) {
        min_time = tm;
      }
    }
    return min_time;
  }
}

int main() {
  int n;
  int x[300];

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

  int time = 0;
  int sum = 0;

  cout << total_time(&sum, x, n) << endl;
  return 0;
}
Problem p01764 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>

using namespace std;
typedef long long ll;

const int MN = 310;
int data[MN];
int sum[MN];
// sum[i] = [0+1..+i)
ll calc(int l, int r, int m) {
  int s1 = sum[m + 1] - sum[l];
  int s2 = sum[r + 1] - sum[m + 1];
  ll res = 0;
  int c = 0;
  while (s1 || s2) {
    int d1 = s1 % 10;
    int d2 = s2 % 10;
    res += d1 * d2 + c;
    c = (d1 + d2 + c) / 10;
    s1 /= 10;
    s2 /= 10;
  }
  res += c;
  return res;
}

bool used[MN][MN];
ll dp[MN][MN];
ll solve(int l, int r) {
  //  printf("%d %d", l, r);
  if (r == l)
    return 0;
  if (used[l][r])
    return dp[l][r];
  used[l][r] = true;
  ll res = 1LL << 55;
  for (int m = l; m < r; m++) {
    res = min(res, solve(l, m) + solve(m + 1, r) + calc(l, r, m));
    if (!res) {
      //	  printf("%d %d %d", l, r, m);
    }
  }
  return (dp[l][r] = res);
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> data[i];
  }
  sum[0] = 0;
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + data[i];
  }
  cout << solve(0, n - 1) << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>

using namespace std;
typedef long long ll;

const int MN = 310;
int data[MN];
int sum[MN];

ll calc(int l, int r, int m) {
  int s1 = sum[m + 1] - sum[l];
  int s2 = sum[r + 1] - sum[m + 1];
  int res = 0;
  while (s1 && s2) {
    int d1 = s1 % 10;
    int d2 = s2 % 10;
    res += d1 * d2;
    if (d1 + d2 >= 10) {
      res++;
    }
    s1 /= 10;
    s2 /= 10;
  }
  return res;
}

bool used[MN][MN];
ll dp[MN][MN];
ll solve(int l, int r) {
  //  printf("%d %d", l, r);
  if (r == l)
    return 0;
  if (used[l][r])
    return dp[l][r];
  ll res = 1LL << 55;
  for (int m = l; m < r; m++) {
    res = min(res, solve(l, m) + solve(m + 1, r) + calc(l, r, m));
    if (!res) {
      //	  printf("%d %d %d", l, r, m);
    }
  }
  return (dp[l][r] = res);
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> data[i];
  }
  sum[0] = 0;
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + data[i];
  }
  cout << solve(0, n - 1) << endl;
}
Problem p01764 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>

using namespace std;

class range {
private:
  struct Iterator {
    int val;
    int operator*() { return val; }
    bool operator!=(Iterator &itr) { return val < itr.val; }
    void operator++() { ++val; }
  };
  Iterator i, n;

public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator &begin() { return i; }
  Iterator &end() { return n; }
};

template <class T> T at(vector<T> v, int i) {
  return v[(i % (int)v.size() + v.size()) % v.size()];
}

pair<long long, long long> mem[310][310];
long long a[310];

pair<long long, long long> solve(long long s, long long t) {
  if (mem[s][t].first != -1)
    return mem[s][t];
  if (s == t - 1)
    return mem[s][t] = make_pair(0, a[s]);
  long long res = 1e9;
  long long sum = -1;
  for (long long i : range(s + 1, t)) {
    auto p1 = solve(s, i);
    auto p2 = solve(i, t);
    long long k1 = p1.second, k2 = p2.second, c = 0, r = 0;
    sum = k1 + k2;
    while (k1 || k2) {
      r += (k1 % 10) * (k2 % 10) + c;
      if (k1 % 10 + k2 % 10 + c >= 10)
        c = 1;
      else
        c = 0;
      k1 /= 10;
      k2 /= 10;
    }
    res = min(res, p1.first + p2.first + r + c);
  }
  return mem[s][t] = make_pair(res, sum);
}

int main() {
  long long n;
  cin >> n;
  for (long long i : range(n))
    cin >> a[i];
  for (long long i : range(310))
    for (long long j : range(310))
      mem[i][j].first = -1;
  cout << solve(0, n).first << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

class range {
private:
  struct Iterator {
    int val;
    int operator*() { return val; }
    bool operator!=(Iterator &itr) { return val < itr.val; }
    void operator++() { ++val; }
  };
  Iterator i, n;

public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator &begin() { return i; }
  Iterator &end() { return n; }
};

template <class T> T at(vector<T> v, int i) {
  return v[(i % (int)v.size() + v.size()) % v.size()];
}

int mem[300][300], a[300];

pair<int, int> solve(int s, int t) {
  if (s == t - 1)
    return make_pair(0, a[s]);
  int res = 1e9;
  int sum = -1;
  for (int i : range(s + 1, t)) {
    auto p1 = solve(s, i);
    auto p2 = solve(i, t);
    sum = p1.second + p2.second;
    int k1 = p1.second, k2 = p2.second, c = 0, r = 0;
    while (k1 || k2) {
      r += k1 % 10 * k2 % 10 + c;
      if (k1 % 10 + k2 % 10 + c >= 10)
        c = 1;
      else
        c = 0;
      k1 /= 10;
      k2 /= 10;
    }
    res = min(res, p1.first + p2.first + r);
  }
  return make_pair(res, sum);
}

int main() {
  int n;
  cin >> n;
  for (int i : range(n))
    cin >> a[i];
  cout << solve(0, n).first << endl;
}
Problem p01766 (C++) — buggy submission, verdict: Runtime Error

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

#define EPS 1e-3
#define INF (1 << 29)
#define equals(a, b) (fabs(a - b) < EPS)

struct Country {
  int f, a, x, y, i;
  Country() {}
  Country(int f, int a, int x, int y, int i) : f(f), a(a), x(x), y(y), i(i) {}
};

double get_distance(double x1, double y1, double x2, double y2) {
  return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}

int main() {
  int N, f, a, t, x, y;
  std::cin >> N;
  std::vector<Country> country[2];
  for (int i = 0; i < N; i++) {
    std::cin >> f >> a >> t >> x >> y;
    country[t].push_back(Country(f, a, x, y, i));
  }

  double max_dist[2], min_time[2];
  for (int i = 0; i < 2; i++) {
    size_t size = country[i].size();
    max_dist[i] = -1;
    min_time[i] = INF;
    if (size > 1) {
      for (size_t j = 0; j < size - 1; j++) {
        Country c1 = country[i][j], c2 = country[i][j + 1];
        if (c1.a == c2.a || c2.i - c1.i != 1) {
          continue;
        }
        double ndist = get_distance(c1.x, c1.y, c2.x, c2.y);
        double ntime = (c2.f - c1.f) / 60.0;
        if (ndist > max_dist[i]) {
          max_dist[i] = ndist;
          min_time[i] = ntime;
        } else if (equals(ndist, max_dist[i])) {
          if (ntime < min_time[i]) {
            min_time[i] = ntime;
          }
        }
      }
    }
    if (max_dist[i] == -1) {
      std::cout << -1 << " " << -1 << std::endl;
    } else {
      printf("%.10f %.10f\\n", max_dist[i], min_time[i]);
    }
  }
  return 0;
}

Error: WA

Fixed submission:

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

#define EPS 1e-7
#define INF (1 << 29)
#define equals(a, b) (fabs(a - b) < EPS)

struct Country {
  int f, a, x, y;
  Country() {}
  Country(int f, int a, int x, int y) : f(f), a(a), x(x), y(y) {}
};

double get_distance(double x1, double y1, double x2, double y2) {
  return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}

int main() {
  int N, f, a, t, x, y;
  std::cin >> N;
  std::vector<Country> country[2];
  for (int i = 0; i < N; i++) {
    std::cin >> f >> a >> t >> x >> y;
    country[t].push_back(Country(f, a, x, y));
  }

  double max_dist[2], min_time[2];
  for (int i = 0; i < 2; i++) {
    size_t size = country[i].size();
    max_dist[i] = -1;
    min_time[i] = INF;
    for (size_t j = 0; j < size - 1; j++) {
      Country c1 = country[i][j], c2 = country[i][j + 1];
      if (c1.a == c2.a) {
        continue;
      }
      double ndist = get_distance(c1.x, c1.y, c2.x, c2.y);
      double ntime = (c2.f - c1.f) / 60.0;
      if (ndist > max_dist[i] + EPS) {
        max_dist[i] = ndist;
        min_time[i] = ntime;
      } else if (equals(ndist, max_dist[i])) {
        if (ntime < min_time[i] + EPS) {
          min_time[i] = ntime;
        }
      }
    }

    if (max_dist[i] == -1) {
      std::cout << -1 << " " << -1 << std::endl;
    } else {
      printf("%.10f %.10f\\n", max_dist[i], min_time[i]);
    }
  }
  return 0;
}
Problem p01767 (C++) — buggy submission, verdict: Runtime Error

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

typedef long long ll;
typedef vector<int> vec;

const int MAX = 1111111;

int main() {
  int N;
  cin >> N;
  vec A(N);
  for (auto &i : A)
    cin >> i;

  int M;
  cin >> M;
  vec B(M);
  vector<ll> C(M);
  for (auto &i : B)
    cin >> i;
  for (auto &i : C)
    cin >> i;

  vector<ll> V(MAX);
  for (int i = 0; i < N; i++) {
    V[A[i]]++;
  }
  V[0] = 0;
  for (int i = 1; i < MAX; i++) {
    V[i] = V[i] * i + V[i - 1];
  }
  for (int i = 0; i < M; i++) {
    if (V[B[i]] >= C[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

typedef long long ll;
typedef vector<int> vec;

int main() {
  int N;
  cin >> N;
  vec A(N);
  int SUM = 0;
  for (auto &i : A)
    cin >> i, SUM += i;

  int M;
  cin >> M;
  vec B(M), C(M);
  for (auto &i : B)
    cin >> i;
  for (auto &i : C)
    cin >> i;

  vector<ll> V(SUM + 1);
  for (int i = 0; i < N; i++) {
    V[A[i]]++;
  }
  for (int i = 1; i <= SUM; i++) {
    V[i] = V[i] * i + V[i - 1];
  }
  for (int i = 0; i < M; i++) {
    if (SUM >= B[i] && V[B[i]] >= C[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

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

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
#define shosu(x) fixed << setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int, P> pip;
typedef vector<pip> vip;
const int inf = (1 << 31) - 1;
const double pi = acos(-1);

int N, M;
vector<ll> a, b, c, dp;
ll tmp = 0;

int main() {
  cin >> N;
  a = vector<ll>(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
  cin >> M;
  b = vector<ll>(M);
  c = vector<ll>(M);
  for (int i = 0; i < M; i++) {
    cin >> b[i];
    tmp = max(tmp, b[i]);
  }
  dp = vector<ll>(tmp + 1);
  for (int i = 0; i < M; i++)
    cin >> c[i];
  sort(a.begin(), a.end());
  for (int i = 1; i <= tmp; i++) {
    dp[i] = dp[i - 1] + i * (upper_bound(a.begin(), a.end(), i) -
                             lower_bound(a.begin(), a.end(), i));
  }
  for (int i = 0; i < M; i++) {
    if (dp[b[i]] >= c[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
#define shosu(x) fixed << setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int, P> pip;
typedef vector<pip> vip;
const int inf = (1 << 31) - 1;
const double pi = acos(-1);

int N, M, tmp = 0;
vi a, b, c, dp;

int sum(int x) {
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (x < a[i])
      break;
    ans += a[i];
  }
  return ans;
}

int main() {
  cin >> N;
  a = vi(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
  cin >> M;
  b = vi(M);
  c = vi(M);
  for (int i = 0; i < M; i++) {
    cin >> b[i];
    tmp = max(tmp, b[i]);
  }
  dp = vi(tmp);
  for (int i = 0; i < M; i++)
    cin >> c[i];
  sort(a.begin(), a.end());
  for (int i = 1; i <= tmp; i++) {
    dp[i] = dp[i - 1] + i * (upper_bound(a.begin(), a.end(), i) -
                             lower_bound(a.begin(), a.end(), i));
  }
  for (int i = 0; i < M; i++) {
    if (dp[b[i]] >= c[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
Problem p01767 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

#define MAX 1000001
typedef long long ll;

int main() {
  ll N, M, a;
  vector<ll> d(MAX, 0), e(MAX + 1, 0);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a;
    d[a]++;
  }
  for (int i = 0; i < MAX; i++) {
    d[i] *= (ll)i;
  }
  for (int i = 0; i < MAX; i++) {
    e[i + 1] = e[i] + d[i + 1];
  }
  cin >> M;
  vector<ll> b(M);
  for (int i = 0; i < M; i++) {
    cin >> a;
    b[i] = e[a];
  }
  for (int i = 0; i < M; i++) {
    cin >> a;
    cout << (b[i] >= a ? "Yes" : "No") << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define MAX 300001
typedef long long ll;

int main() {
  ll N, M, a;
  vector<ll> d(MAX, 0), e(MAX + 1, 0);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a;
    d[a]++;
  }
  for (int i = 0; i < MAX; i++) {
    d[i] *= (ll)i;
  }
  for (int i = 0; i < MAX; i++) {
    e[i + 1] = e[i] + d[i + 1];
  }
  cin >> M;
  vector<ll> b(M);
  for (int i = 0; i < M; i++) {
    cin >> a;
    b[i] = e[a];
  }
  for (int i = 0; i < M; i++) {
    cin >> a;
    cout << (b[i] >= a ? "Yes" : "No") << endl;
  }
  return 0;
}
Problem p01767 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, b) FOR(i, 0, b)
#define PB push_back
#define BE(c) c.begin(), c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef vector<ut> VI;
const int SIZE = 1 + 1e+6;
LL getly[SIZE];
VI nums;
LL b[SIZE];
int main() {
  LL N, M, a, c;
  cin >> N;
  REP(i, N) {
    scanf("%lld", &a);
    nums.PB(a);
  }
  sort(BE(nums));
  int now = 0;
  while (now != nums.size() && nums[now] == 0)
    now++;
  FOR(i, 1, SIZE) {
    getly[i] = getly[i - 1];
    while (now != nums.size() && nums[now] == i) {
      getly[i] += (LL)i;
      now++;
    }
  }
  cin >> M;
  REP(i, M)
  scanf("%lld", &b[i]);
  REP(i, M) {
    scanf("%lld", &c);
    if (getly[b[i]] >= c)
      printf("Yes\\n");
    else
      printf("No\\n");
  }
}

Error: MLE

Fixed submission:

#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, b) FOR(i, 0, b)
#define PB push_back
#define BE(c) c.begin(), c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef vector<ut> VI;
const int SIZE = 1 + 1e+7;
LL getly[SIZE];
VI nums;
LL b[SIZE];
int main() {
  LL N, M, a, c;
  cin >> N;
  REP(i, N) {
    scanf("%lld", &a);
    nums.PB(a);
  }
  sort(BE(nums));
  int now = 0;
  while (now != nums.size() && nums[now] == 0)
    now++;
  FOR(i, 1, SIZE) {
    getly[i] = getly[i - 1];
    while (now != nums.size() && nums[now] == i) {
      getly[i] += (LL)i;
      now++;
    }
  }
  cin >> M;
  REP(i, M)
  scanf("%lld", &b[i]);
  REP(i, M) {
    scanf("%lld", &c);
    if (getly[b[i]] >= c)
      printf("Yes\\n");
    else
      printf("No\\n");
  }
}
Problem p01767 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

#include <cstdio>
#include <queue>
inline ll getLL() {
  ll s;
  scanf("%lld", &s);
  return s;
}
inline int getInt() {
  int s;
  scanf("%d", &s);
  return s;
}

#include <set>

using namespace std;

int main() {
  const int n = getInt();
  vector<ll> a(n);
  REP(i, n) a[i] = getLL();
  sort(a.begin(), a.end());
  vector<ll> as(n);
  as[0] = a[0];
  REP(i, n - 1) as[i + 1] = as[i] + a[i + 1];

  const int m = getInt();
  vector<ll> b(m);
  vector<ll> c(m);
  REP(i, m) b[i] = getLL();
  REP(i, m) c[i] = getLL();

  REP(i, m) {
    const int idx = lower_bound(a.begin(), a.end(), b[i] + 1) - a.begin();
    const ll g = idx == 0 ? 0 : as[idx - 1];
    puts(c[i] <= g ? "Yes" : "No");
  }

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

#include <cstdio>
#include <queue>
inline ll getLL() {
  ll s;
  scanf("%lld", &s);
  return s;
}
inline int getInt() {
  int s;
  scanf("%d", &s);
  return s;
}

#include <set>

using namespace std;

int main() {
  const int n = getInt();
  vector<ll> a(n);
  REP(i, n) a[i] = getLL();
  sort(a.begin(), a.end());
  vector<ll> as(n);
  as[0] = a[0];
  REP(i, n - 1) as[i + 1] = as[i] + a[i + 1];

  const int m = getInt();
  vector<ll> b(n);
  vector<ll> c(n);
  REP(i, m) b[i] = getLL();
  REP(i, m) c[i] = getLL();

  REP(i, m) {
    const int idx = lower_bound(a.begin(), a.end(), b[i] + 1) - a.begin();
    const ll g = idx == 0 ? 0 : as[idx - 1];
    puts(c[i] <= g ? "Yes" : "No");
  }

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

#include <bits/stdc++.h>

using namespace std;

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

const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int dy[] = {0, 1, 0, -1};
int dx[] = {1, 0, -1, 0};

int main(void) {
  int N;
  cin >> N;
  vector<ll> a(N);
  vector<ll> p(1000001);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    p[a[i]]++;
  }
  for (int i = 0; i <= 1000000; i++)
    p[i] *= i;
  for (int i = 0; i < 1000000; i++) {
    p[i + 1] += p[i];
  }

  int M;
  cin >> M;
  vector<ll> b(M), c(M);
  for (int i = 0; i < M; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> c[i];
  }

  for (int i = 0; i < M; i++) {
    if (p[b[i]] >= c[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

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

const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int dy[] = {0, 1, 0, -1};
int dx[] = {1, 0, -1, 0};

int main(void) {
  int N;
  cin >> N;
  vector<ll> a(N);
  vector<ll> p(300001);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    p[a[i]]++;
  }
  for (int i = 0; i <= 300000; i++)
    p[i] *= i;
  for (int i = 0; i < 300000; i++) {
    p[i + 1] += p[i];
  }

  int M;
  cin >> M;
  vector<ll> b(M), c(M);
  for (int i = 0; i < M; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> c[i];
  }

  for (int i = 0; i < M; i++) {
    if (p[b[i]] >= c[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}