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

#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define pb push_back
using namespace std;

const int N = 1e6 + 6, mod = 998244353;

ll k = 1e18;

int dig(ll x) {
  if (x == 0)
    return 0;
  int cnt = 0;
  while (x) {
    x /= 10;
    cnt++;
  }
  return cnt;
}

inline void test_case() {
  ll n;
  string s;
  cin >> n >> s;
  ll x = s[0] - '0';
  ll y = (s[2] - '0') * 10 + s[3] - '0';
  n = n * x + n * y / 100;
  cout << n << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int T = 1;
  // cin >> T;
  while (T--) {
    test_case();
  }
}


Error: -8

Fixed submission:

#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define pb push_back
using namespace std;

const int N = 1e6 + 6, mod = 998244353;

ll k = 1e18;

int dig(ll x) {
  int cnt = 0;
  while (x) {
    x /= 10;
    cnt++;
  }
  return cnt;
}

inline void test_case() {
  ll n, m;
  cin >> n;
  ll ans = 1;
  while (n--) {
    ll x;
    cin >> x;
    if (x == 0)
      ans = 0;
    if (ans == -1)
      continue;
    if (ans > k / x + 1) {
      ans = -1;
    } else {
      ans *= x;
      if (ans > k) {
        ans = -1;
      }
    }
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int T = 1;
  // cin >> T;
  while (T--) {
    test_case();
  }
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  long double a, b;
  cin >> a >> b;
  long double ans = a * b;
  cout << (long long)ans;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define ll long long int
#define fo(i, n) for (i = 0; i < n; i++)
#define pb push_back
#define mp make_pair
#define MAXN 1000002
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod = 1e9 + 7;

void solve() {
  long long a;
  string b;
  cin >> a >> b;
  int i = b[0] - '0';
  int v = (b[2] - '0') * 10 + (b[3] - '0');
  long long I = a * i;
  long long Z = a * v;
  string str = to_string(Z);
  string s = "";
  for (int k = 0; k < str.length() - 2; k++)
    s += str[k];
  Z = stoi(s);
  I += Z;
  cout << I;
}

int main() { fastio solve(); }
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a;
  long double b;
  cin >> a >> b;
  cout << (long long)(a * b);
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int a[1000005] = {0}, b[1000005] = {0}, f = 0;
int read(int a[]) {
  int i;
  string s;
  cin >> s;
  a[0] = s.length();
  for (i = 1; i <= a[0]; i++) {
    a[i] = s[a[0] - i] - '0';
  }
}
int main() {
  int i;
  double q;
  read(a);
  cin >> q;
  q *= 100;
  long long n = q;
  a[0] *= 2;
  for (i = 1; i <= a[0]; i++) {
    a[i] *= n;
  }
  for (i = 1; i < a[0]; i++) {
    a[i + 1] += a[i] / 10;
    a[i] %= 10;
  }
  while (a[a[0]] == 0)
    a[0]--;
  for (i = a[0]; i >= 1 + 2; i--) {
    f = 1;
    cout << a[i];
  }
  if (f == 0)
    cout << 0;
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

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

signed main() {
  long long a, ans;
  string b;

  cin >> a;
  cin >> b;

  ans = a * (b[3] - '0') + a * (b[2] - '0') * 10 + a * (b[0] - '0') * 100;
  cout << ans / 100 << endl;

  return (0);
}

Error: -11

Fixed submission:

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

int N = 100, A[100][100], Q = 1000;
long long Sorted_A[10000];
vector<int> x, y, h;

void chackhight();
void sort_A();
int highest(int i, int j);
void subhight(int sub, int i, int j);

signed main() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A[i][j];
    }
  }

  for (int i = 0; i < 1000; i++) {
    chackhight();
  }

  printf("1000\\n");
  for (int i = 0; i < 100; i++) {
    printf("%d %d %d\\n", x[i], y[i], h[i]);
  }
}

void chackhight() // h , x , y を求める（1000回呼び出される）
{
  long long temp, sub;
  int i, j;
  sort_A();

  temp = Sorted_A[0];
  j = temp % 100;
  temp = temp / 100;
  i = temp % 100;

  x.push_back(i);
  y.push_back(j);

  sub = highest(i, j);
  h.push_back(sub);

  subhight(sub, i, j);

  return;
}

void sort_A() // Aijの最大値と座標（xi,yi）を求める（Aの順番は保持される）
{
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      Sorted_A[i * N + j] = (long long)((A[i][j] * N) * N + i) * N + j;
    }
  }

  sort(Sorted_A, Sorted_A + 10000, greater<long long>());

  return;
}

int highest(int i, int j) // 削りとれる最大の高さ（hi）を求める
{
  int manhattan, hight, can_sub[101];
  for (int k = 0; k < N; k++) {
    can_sub[k] = 101;
  }

  for (int k = 0; k < N; k++) {
    for (int l = 0; l < N; l++) {
      manhattan = abs(i - k) + abs(j - l);

      can_sub[manhattan] = min(can_sub[manhattan], A[k][l] + manhattan);
    }
  }

  sort(can_sub, can_sub + 101, greater<int>());

  hight = can_sub[0];
  return (hight);
}

void subhight(int sub, int i, int j) // 削る
{
  int manhattan;

  for (int k = 0; k < N; k++) {
    for (int l = 0; l < N; l++) {
      manhattan = abs(i - k) + abs(j - l);
      A[k][l] -= max(sub - manhattan, 0);
    }
  }

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

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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for (uint64_t i = start; i < end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0) {
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) { return (m * n) / gcd(m, n); }

void comb(vector<vector<uint64_t>> &v) {
  for (uint64_t i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (uint64_t k = 1; k < v.size(); k++) {
    for (uint64_t j = 1; j < k; j++) {
      v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
    }
  }
}

bool is_product_overflow(uint64_t a, uint64_t b) {

  uint64_t prod = a * b;

  return (prod / b != a);
}

signed main() {
  uint64_t a;
  double b;
  cin >> a >> b;
  uint64_t b100 = (uint64_t)(b * 100.0 + 0.5);

  cout << a * b100 / 100 << endl;

  return 0;
}

Error: 0

Fixed submission:

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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for (uint64_t i = start; i < end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0) {
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) { return (m * n) / gcd(m, n); }

void comb(vector<vector<uint64_t>> &v) {
  for (uint64_t i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (uint64_t k = 1; k < v.size(); k++) {
    for (uint64_t j = 1; j < k; j++) {
      v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
    }
  }
}

bool is_product_overflow(uint64_t a, uint64_t b) {

  uint64_t prod = a * b;

  return (prod / b != a);
}

signed main() {
  uint64_t a;
  double b;
  cin >> a >> b;
  uint64_t b100 = (uint64_t)(b * 100.0 + 0.5);

  if (!is_product_overflow(a, b100)) {
    cout << a * b100 / 100 << endl;
  } else {
    cout << (uint64_t)(a * b) << endl;
  }

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

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, s, e) for (int i = s; i < e; i++)
#define endl '\\n'
int main() {
  lli A;
  cin >> A;
  double B;
  cin >> B;
  lli res = (A * (lli)(B * 100.0 + 0.5)) / 100;
  cout << res << endl;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, s, e) for (int i = s; i < e; i++)
#define endl '\\n'
int main() {
  int A;
  cin >> A;
  int B_d, B_f;
  scanf("%d.%d", B_d, B_f);
  double res = A * (B_d * 100 + B_f) / 100;
  cout << (int)res << endl;
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

// const ll INF = 1e18L + 5;
// const int INF = 1e9 + 5;
// const double pi = 3.14159265358979323846;

void solve() {
  ll a;
  string b;

  cin >> a >> b;
  string B;
  for (char c : b) {
    if (c != '.')
      B += c;
  }
  int bi = stoi(B);
  cout << (a * bi) / 100 << endl;
}

int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);

  solve();
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

// const ll INF = 1e18L + 5;
// const int INF = 1e9 + 5;
// const double pi = 3.14159265358979323846;

void solve() {
  int n;
  cin >> n;
  vector<ll> v(n);
  rep(i, n) {
    cin >> v[i];
    if (v[i] == 0) {
      cout << 0 << endl;
      return;
    }
  }
  ll ans = v[0];
  rep2(i, 1, n) {
    if (ans > 1e18L || ans > INT64_MAX / v[i]) {
      cout << -1 << endl;
      return;
    }
    ans *= v[i];
  }
  cout << ans << endl;
}

int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);

  solve();
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

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

typedef long long ll;
#define sc scanf
#define pf printf
#define pb push_back

int main() {
  //    ll nm, nd;
  //    double nx, np, ans;
  //    sc("%lld%llf", &nm, &nx);
  //    np = nx*100;
  //    nd = np;
  //    ans = (nm*nd)/100;
  //   /// cout<<nm<<" "<<np<<endl;
  //    cout<<(ll)ans<<endl;

  ll A, B;
  cin >> A >> B;
  char C;
  cin >> C;
  int D;
  cin >> D;
  B *= 100;
  B += D;
  ll X = A * B;
  X /= 100;
  cout << X << endl;

  return 0;
}


Error: WA

Fixed submission:

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

typedef long long ll;
#define sc scanf
#define pf printf
#define pb push_back

int main() {
  double nm, np;
  sc("%llf%llf", &nm, &np);
  ll ans = (nm * np);
  cout << ans << endl;

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

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\\n'
#define pb push_back
#define PI 3.14159265
int M = 998244353;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long double a;
  long double b;
  cin >> a >> b;
  long double ans = a * b;
  int x = ans;
  cout << x;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\\n'
#define pb push_back
#define PI 3.14159265
int M = 998244353;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  bool check = 0;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] == 0)
      check = 1;
  }
  if (check)
    cout << "0";
  else {
    int ans = 1e18;
    for (int i = 0; i < n; ++i) {
      ans /= a[i];
      if (ans < 1) {
        cout << "-1";
        exit(0);
      }
    }
    if (ans < 1) {
      cout << "-1";
      exit(0);
    }
    cout << ans;
  }
}
Problem p02659 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (ll i = a; i < ll(b); i++)
#define repr(i, a, b) for (ll i = a; i >= ll(b); i--)
#define endl "\\n"
#define ALL(x) x.begin(), x.end()
#define ALLR(x) x.rbegin(), x.rend()
#define INF 1e9
#define DEBUG(x) cout << "debug: " << x << endl

#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

mp::cpp_int A, B, ans;
string b;
int main() {
  cin >> A >> b;
  b.erase(b.length() - 3, 1);
  string str = to_string(stoi(b));
  B.assign(str);
  ans = (A * B) / 100;
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (ll i = a; i < ll(b); i++)
#define repr(i, a, b) for (ll i = a; i >= ll(b); i--)
#define endl "\\n"
#define ALL(x) x.begin(), x.end()
#define ALLR(x) x.rbegin(), x.rend()
#define INF 1e9
#define DEBUG(x) cout << "debug: " << x << endl

#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

mp::cpp_int A, ans;
string sb;
int main() {
  cin >> A >> sb;
  sb.erase(sb.length() - 3, 1);
  mp::cpp_int B(sb);
  ans = (A * B) / 100;
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define ll long long

using namespace std;

ll p;

ll calc(ll n) {
  ll res = (1 + n) * n / 2;
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  freopen("input.txt", "r", stdin);
#endif

  ll ans = 0;
  cin >> p;
  vector<pair<int, int>> pref;
  for (ll i = 2; i * i <= p; ++i) {
    if (p % i == 0) {
      int cnt = 0;
      while (p % i == 0) {
        p /= i;
        ++cnt;
      }
      pref.push_back(make_pair(i, cnt));
      ll l = 1, r = 10, res;
      while (l <= r) {
        ll mid = (l + r) >> 1;
        if (calc(mid) <= cnt) {
          res = mid;
          l = mid + 1;
        } else {
          r = mid - 1;
        }
      }
      ans += res;
    }
  }
  if (p > 1) {
    pref.push_back(make_pair(p, 1));
    ++ans;
  }
  cout << ans << '\\n';

#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\\n";
#endif
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define ll long long

using namespace std;

ll p;

ll calc(ll n) {
  ll res = (1 + n) * n / 2;
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  freopen("input.txt", "r", stdin);
#endif

  ll ans = 0;
  cin >> p;
  vector<pair<int, int>> pref;
  for (int i = 2; i * i <= p; ++i) {
    if (p % i == 0) {
      int cnt = 0;
      while (p % i == 0) {
        p /= i;
        ++cnt;
      }
      pref.push_back(make_pair(i, cnt));
      ll l = 1, r = 10, res;
      while (l <= r) {
        ll mid = (l + r) >> 1;
        if (calc(mid) <= cnt) {
          res = mid;
          l = mid + 1;
        } else {
          r = mid - 1;
        }
      }
      ans += res;
    }
  }
  if (p > 1) {
    pref.push_back(make_pair(p, 1));
    ++ans;
  }
  cout << ans << '\\n';

#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\\n";
#endif
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

bool isPrime(ll x) {
  ll i;
  if (x < 2)
    return 0;
  else if (x == 2)
    return 1;
  if (x % 2 == 0)
    return 0;
  for (i = 3; i * i <= x; i += 2)
    if (x % i == 0)
      return 0;
  return 1;
}

int main() {
  ll ans = 0;
  ll n;
  cin >> n;
  ll k = n;
  queue<int> p;
  for (ll i = 2; i * i <= k; i++) {
    int g = 0, top = 1;
    while (n % i == 0) {
      n /= i;
      g++;
      if (g == top) {
        ans++;
        top++;
        g = 0;
      }
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

bool isPrime(ll x) {
  ll i;
  if (x < 2)
    return 0;
  else if (x == 2)
    return 1;
  if (x % 2 == 0)
    return 0;
  for (i = 3; i * i <= x; i += 2)
    if (x % i == 0)
      return 0;
  return 1;
}

int main() {
  ll ans = 0;
  ll n;
  cin >> n;
  ll k = n;
  if (isPrime(n)) {
    cout << 1 << endl;
    return 0;
  }
  queue<int> p;
  for (int i = 2; i * i <= k; i++) {
    int g = 0;
    while (n % i == 0) {
      n /= i;
      g++;
    }
    if (g != 0) {
      p.push(g);
    };
    if (n == 1)
      break;
  }

  while (!p.empty()) {
    int f = p.front();
    p.pop();
    for (int i = 1; i < 10; i++) {
      if (f >= i) {
        f -= i;
        ans++;
      } else {
        continue;
      }
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  bool prime = true;
  long long int N, n, k, count = 0, ans = 0, sum;
  cin >> N;
  n = N;
  for (long long int i = 2; i * i <= n; i++) {
    if (N % i == 0) {
      k = N / i;
      prime = false;
      count = 0;
      while (N % i == 0) {
        count++;
        N /= i;
      }
      for (int j = 1;; j++) {
        count -= j;
        if (count >= 0)
          ans++;
        else
          break;
      }
    }
  }
  if (N != 1)
    ans++;
  if (n == 1)
    cout << 0;
  else if (prime)
    cout << 1;
  else
    cout << ans;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  bool prime = true;
  long long int N, n, k, count = 0, ans = 0, sum;
  cin >> N;
  n = N;
  for (long long int i = 2; i * i <= n; i++) {
    if (N % i == 0) {
      k = N / i;
      prime = false;
      count = 0;
      while (N % i == 0) {
        count++;
        N /= i;
      }
      for (int j = 1;; j++) {
        count -= j;
        if (count >= 0)
          ans++;
        else
          break;
      }
      bool flag = true;
      for (int j = 2; j * j <= k; j++) {
        if (k % j == 0)
          flag = false;
      }
      if (flag) {
        count = 0;
        while (N % k == 0) {
          count++;
          N /= k;
        }
        for (int j = 1;; j++) {
          count -= j;
          if (count >= 0)
            ans++;
          else
            break;
        }
      }
    }
  }
  if (n == 1)
    cout << 0;
  else if (prime)
    cout << 1;
  else
    cout << ans;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

bool hantei(long long x) {
  for (long long i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return 0;
  }
  return x > 1;
}

int main() {
  ll n;
  cin >> n;
  map<ll, ll> m;
  if (hantei(n)) {
    cout << 1 << endl;
    return 0;
  } else if (n == 1) {
    cout << 0 << endl;
    return 0;
  } else {
    ll b{2};
    while (1) {
      if (n % b == 0) {
        m[b]++;
        n /= b;
        if (n == 1)
          break;
        if (hantei(n)) {
          m[n]++;
          break;
        }
      } else
        b++;
    }
  }
  vector<ll> a(10);
  for (int i = 1; i < 10; i++) {
    a.at(i) = a.at(i - 1) + i;
  }
  ll ans{};
  for (auto i : m) {
    ll e = i.second;
    auto it = upper_bound(a.begin(), a.end(), e);
    ans += it - a.begin() - 1;
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

bool hantei(long long x) {
  for (long long i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return 0;
  }
  return x > 1;
}

int main() {
  ll n;
  cin >> n;
  map<ll, ll> m;
  if (hantei(n)) {
    cout << 1 << endl;
    return 0;
  } else if (n == 1) {
    cout << 0 << endl;
    return 0;
  } else {
    ll b{2};
    while (1) {
      if (hantei(n)) {
        m[n]++;
        break;
      }
      if (n % b == 0) {
        m[b]++;
        n /= b;
        if (n == 1)
          break;
      } else
        b++;
    }
  }
  vector<ll> a(10);
  for (int i = 1; i < 10; i++) {
    a.at(i) = a.at(i - 1) + i;
  }
  ll ans{};
  for (auto i : m) {
    ll e = i.second;
    auto it = upper_bound(a.begin(), a.end(), e);
    ans += it - a.begin() - 1;
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
namespace prime {
bool is_prime(ll n) {
  if (n < 2)
    return false;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}
vector<ll> divisors(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i)
        res.push_back(n / i);
    }
  }
  return res;
}
map<ll, int> prime_factors(ll n) {
  map<ll, int> res;
  if (n < 2)
    return res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n > 1)
    res[n] = 1;
  return res;
}
}; // namespace prime

void answer() {
  ll N;
  cin >> N;
  map<ll, int> factors = prime::prime_factors(N);
  ll ans = 0;
  for (auto &pr : factors) {
    int i = 1;
    while (pr.second >= i) {
      pr.second -= i;
      ans++;
      i++;
    }
  }
  cout << ans << "\\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
namespace prime {
bool is_prime(ll n) {
  if (n < 2)
    return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}
vector<ll> divisors(ll n) {
  vector<ll> res;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i)
        res.push_back(n / i);
    }
  }
  return res;
}
map<ll, int> prime_factors(ll n) {
  map<ll, int> res;
  if (n < 2)
    return res;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n > 1)
    res[n] = 1;
  return res;
}
}; // namespace prime

void answer() {
  ll N;
  cin >> N;
  map<ll, int> factors = prime::prime_factors(N);
  ll ans = 0;
  for (auto &pr : factors) {
    int i = 1;
    while (pr.second >= i) {
      pr.second -= i;
      ans++;
      i++;
    }
  }
  cout << ans << "\\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}