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

#include <bits/stdc++.h>
#define mod 1000000009
#define int long long
#define garou                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
using namespace std;
int pow(int p, int r) {
  int ans = 1;
  while (r > 0) {
    if (r & 1) {
      ans = ((ans % mod) * (p % mod)) % mod;
    }
    r = r >> 1;
    p = ((p % mod) * (p % mod)) % mod;
  }
  return ans;
}
int arr[100000];
vector<int> v;
signed main() {
  garou;
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    for (int j = 1; j <= cnt; j++) {
      cnt -= j;
      ans++;
    }
  }
  if (n > 1)
    ans++;
  cout << ans;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define mod 1000000009
#define int long long
#define garou                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
using namespace std;
int pow(int p, int r) {
  int ans = 1;
  while (r > 0) {
    if (r & 1) {
      ans = ((ans % mod) * (p % mod)) % mod;
    }
    r = r >> 1;
    p = ((p % mod) * (p % mod)) % mod;
  }
  return ans;
}
int arr[100000];
vector<int> v;
signed main() {
  garou;
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 2; i * i <= n; i++) {
    if (arr[i] == 0) {
      v.push_back(i);
      for (int j = i * i; j <= n; j += i)
        arr[j] = 1;
    }
  }
  int m = v.size();
  for (int i = 0; i < m; i++) {
    int a = v[i];
    while (n % a == 0) {
      ans++;
      n /= a;
      a *= v[i];
    }
  }
  cout << ans;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

#define oo 0xffffff
#define endl '\\n'
int ten = 10;
using namespace std;

char s[1000001];

int main() {
  long long int t, n, i, j, m, res1;
  cin >> n;
  if (n == 1) {
    cout << "0";
    return 0;
  }
  long long int res = sqrt(n);
  int cnt = 0;
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      j = i;
      while (n % j == 0) {
        n /= j;
        j *= i;
        cnt++;
      }
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  if (n > 1)
    cnt++;
  cout << cnt;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<ll>
#define vpi vector<pair<ll, ll>>
#define mpi map<ll, ll>
#define si set<ll>
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define reP(i, a, n) for (ll i = a; i <= n; i++)
#define YES cout << "YES\\n";
#define NO cout << "NO\\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define st string
#define sz size()
#define case(i, n) Case << " " << i << ": " << n << endl;
#define tc                                                                     \\
  ll t;                                                                        \\
  cin >> t;                                                                    \\
  while (t--)
ll sum(ll x) {
  for (ll i = 1; i <= 64; i++) {
    if (i * (i + 1) / 2 > x)
      return i - 1;
  }
}
int main() {
  ll n;
  cin >> n;
  bool pri[n + 1];

  ll m = 10000007;
  memset(pri, true, sizeof(pri));
  for (ll i = 2; i * i <= m; i++) {
    if (pri[i]) {
      for (ll j = i * i; j <= n; j += i) {
        pri[j] = false;
      }
    }
  }
  ll j = 0, ara[10000007], b[10000007];
  for (ll i = 2; i <= m; i++) {
    if (pri[i])
      ara[j++] = i;
  }
  // for(ll i=0;i<j;i++)
  //{
  // cout<<ara[i]<<" ";
  //}
  // cout<<endl;
  ll cnt = 0, ans = 0;
  j = 0;
  for (ll i = 0; ara[i] * ara[i] <= n; i++) {
    if (n % ara[i] == 0) {
      cnt = 0;
      while (n % ara[i] == 0) {
        n /= ara[i];
        cnt++;
      }
      // cout<<n<<endl;
      // cout<<cnt<<endl;
      b[j++] = cnt;
    }
  }
  if (n > 1)
    b[j++] = 1;
  for (ll i = 0; i < j; i++) {
    ans += sum(b[i]);
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second
#define pb push_back
#define all(x) x.begin(), x.end()
#define inputSpeed() ios_base::sync_with_stdio(0), cin.tie(0)

#define MAXN (ll)(1e6 + 10)
// only one prime factor will be larger than 10^6
// Also, there are at most 40 prime factors.
bool composite[MAXN];
vector<pii> prime_factorise(ll N) {
  vector<pii> prime_factors;
  for (ll i = 2; i < MAXN; i++) {
    if (!composite[i]) {
      // Found prime
      ll power = 0;
      while (N % (ll)i == 0) {
        N /= (ll)i;
        power++;
      }
      if (power) {
        prime_factors.pb({i, power});
      }
      // Update rest
      for (ll j = i * i; j <= MAXN; j += i) {
        composite[j] = true;
      }
    }
  }
  if (N > 1) {
    prime_factors.pb({N, 1});
  }
  return prime_factors;
}

int main() {
  inputSpeed();

  ll N;
  cin >> N;
  vector<pii> prime_factors = prime_factorise(N);

  // printf("N = 1\\n");
  // for (auto f : prime_factors) {
  // 	printf("* %d ^ %d\\n", f.x, f.y);
  // }

  int ans = 0;
  for (auto f : prime_factors) {
    // find out which triangular number it is
    for (int j = 1; j < 100; j++) {
      if (f.y - j >= 0) {
        f.y -= j;
        ans++;
      }
    }
  }
  printf("%d\\n", ans);
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second
#define pb push_back
#define all(x) x.begin(), x.end()
#define inputSpeed() ios_base::sync_with_stdio(0), cin.tie(0)

#define MAXN (ll)(1e6 + 10)
// only one prime factor will be larger than 10^6
// Also, there are at most 40 prime factors.
bool composite[MAXN];
vector<pii> prime_factorise(ll N) {
  vector<pii> prime_factors;
  for (ll i = 2; i <= MAXN; i++) {
    if (!composite[i]) {
      // Found prime
      ll power = 0;
      while (N % (ll)i == 0) {
        N /= (ll)i;
        power++;
      }
      if (power) {
        prime_factors.pb({i, power});
      }
      // Update rest
      for (ll j = i * i; j <= MAXN; j += i) {
        composite[j] = true;
      }
    }
  }
  if (N > 1) {
    prime_factors.pb({N, 1});
  }
  return prime_factors;
}

int main() {
  inputSpeed();

  ll N;
  cin >> N;
  vector<pii> prime_factors = prime_factorise(N);

  // printf("N = 1\\n");
  // for (auto f : prime_factors) {
  // 	printf("* %d ^ %d\\n", f.x, f.y);
  // }

  int ans = 0;
  for (auto f : prime_factors) {
    // find out which triangular number it is
    for (int j = 1; j < 100; j++) {
      if (f.y - j >= 0) {
        f.y -= j;
        ans++;
      }
    }
  }
  printf("%d\\n", ans);
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  uint64_t n;
  cin >> n;
  uint64_t ans = 0;
  vector<uint64_t> primes;

  for (uint64_t i = 2; i <= 1'000'000; i++) {
    bool f = true;
    for (uint64_t p : primes) {
      if (p * p > i)
        break;
      if (i % p == 0) {
        f = false;
        break;
      }
    }
    if (f) {
      primes.push_back(i);
    }
  }

  for (uint64_t p : primes) {
    if (p * p > n)
      break;
    for (uint64_t x = p; x <= n; x *= p) {
      if (n % x == 0) {
        n /= x;
        ans++;
      }
    }
    while (n % p == 0) {
      n /= p;
    }
  }

  if (n > 1)
    ans++;
  cout << ans << endl;
}


Error: 0

Fixed submission:

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

int main() {
  uint64_t n;
  cin >> n;
  uint64_t ans = 0;
  vector<bool> d(1'000'001, true);

  for (uint64_t i = 2; i <= 1'000'000; i++) {
    if (i * i > n)
      break;
    if (n % i == 0) {
      d[i] = false;
      n /= i;
      ans++;
    }
  }

  if (n > 1 && d[n])
    ans++;
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long ans = 0;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    long long num = 0;
    while (n % i == 0) {
      n /= i;
      num++;
    }
    for (long long j = 1;; j++) {
      if (num >= j) {
        num -= j;
        ans++;
      } else
        break;
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define ret return
#define all(vl) vl.begin(), vl.end()
#define sor sort
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll>::iterator itll;
typedef long double ld;
typedef map<ll, ll> mapll;
bool zhi[1000001];
vector<long long> vl;
long long n;
int main() {
  zhi[0] = zhi[1] = 1;
  cin >> n;
  for (int i = 2; i < 1000001; i++) {
    if (!zhi[i])
      vl.pb(i);
    for (int j = i * i; j < 1000001; j += i)
      zhi[j] = 1;
  }
  long long cnt = 0, cop = n;
  bool isok = false;
  int sz = vl.size();
  for (int i = 0; i < sz; i++) {
    long long cc = 0;
    while (cop % vl[i] == 0) {
      cc++;
      cop /= vl[i];
    }
    long long cn = 1, ccn = 0;
    while (cc >= cn) {
      cc -= cn;
      ccn++;
      cn++;
    }
    cnt += ccn;
  }
  if (cop > 1)
    cnt++;
  cout << cnt << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M
//--------------- O ---------------↓--------------//
// コンパイル
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
//
//
//
//
//
//
//
//------------↑------------- M -------------- E ---------------- M
//--------------- O ---------------↑--------------//

int main(void) {

  ll N;
  cin >> N;

  ll ans = 0;
  for (ll i = 2; i * i <= N; ++i) {

    int e = 0;
    while (N % i == 0) {
      ++e;
      N /= i;
    }

    int k = 0;
    while (k * (k + 1) / 2 <= e)
      ++k;
    if (k * (k + 1) / 2 > e)
      --k;

    ans += k;
  }

  if (N != 1) {
    ++ans;
  }

  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M
//--------------- O ---------------↓--------------//
// コンパイル
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
//
//
//
//
//
//
//
//------------↑------------- M -------------- E ---------------- M
//--------------- O ---------------↑--------------//

int main(void) {

  ll N;
  cin >> N;

  ll ans = 0;
  for (int i = 2; i * i <= N; ++i) {

    int e = 0;
    while (N % i == 0) {
      ++e;
      N /= i;
    }

    int k = 0;
    while (k * (k + 1) / 2 <= e)
      ++k;
    if (k * (k + 1) / 2 > e)
      --k;

    ans += k;
  }

  if (N != 1) {
    ++ans;
  }

  cout << ans << endl;

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }

// 素数判定
// #include <cmath>
bool is_prime(long long n) {
  if (n == 1)
    return false;
  if (n == 2)
    return true;
  if (n % 2 == 0)
    return false;
  ll m = sqrt(n);
  for (long long i = 3; i <= m; i += 2) {
    if (n % i == 0)
      return false;
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // const ll p = 1e9 + 7;
  // const ll p = 998244353;

  ll n;
  cin >> n;

  unordered_map<ll, ll> mp;
  if (n % 2 == 0) {
    ll cnt = 0;
    while (n % 2 == 0) {
      n /= 2;
      cnt++;
    }
    mp[2] += cnt;
  }
  for (ll i = 3; i <= n; i += 2) {
    if (i % (ll)1e6 == 1) {
      if (is_prime(n)) {
        mp[n]++;
        break;
      }
    }
    if (n % i)
      continue;
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    mp[i] += cnt;
  }

  ll ans = 0;
  for (auto i : mp) {
    ll x = i.second, y = 1;
    while (x >= y) {
      ans++;
      x -= y;
      y++;
    }
  }

  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }

// 素数判定
// #include <cmath>
bool is_prime(long long n) {
  if (n == 1)
    return false;
  if (n == 2)
    return true;
  if (n % 2 == 0)
    return false;
  ll m = sqrt(n);
  for (long long i = 3; i <= m; i += 2) {
    if (n % i == 0)
      return false;
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // const ll p = 1e9 + 7;
  const ll p = 998244353;

  ll n;
  cin >> n;

  unordered_map<ll, ll> mp;
  if (n % 2 == 0) {
    ll cnt = 0;
    while (n % 2 == 0) {
      n /= 2;
      cnt++;
    }
    mp[2] += cnt;
  }
  for (ll i = 3; i <= n; i += 2) {
    if (is_prime(n)) {
      mp[n]++;
      break;
    }
    if (n % i)
      continue;
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    mp[i] += cnt;
  }

  ll ans = 0;
  for (auto i : mp) {
    ll x = i.second, y = 1;
    while (x >= y) {
      ans++;
      x -= y;
      y++;
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
typedef pair<ll, ll> pll;
const ll MAX = 100000000;
int main() {

  ll n;

  cin >> n;

  vector<pll> v;

  ll cnt = 0;

  while (n % 2 == 0) {
    n /= 2;
    cnt++;
  }
  if (cnt)
    v.eb(2, cnt);

  cnt = 0;

  for (ll i = 3; i * i <= n; i += 2) {
    cnt = 0;

    while (n % i == 0) {
      n /= i;
      cnt++;
    }

    v.eb(i, cnt);
  }
  if (n > 1)
    v.eb(n, 1);

  ll ans = 0;

  for (auto x : v) {
    ll j = 2;

    for (ll i = 1; i <= x.se;) {
      ans++;
      i += j;
      j++;
    }
  }

  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define eb emplace_back
const ll MAX = 1000000000000;

int main() {
  ll n;

  cin >> n;
  ll ans = 0;

  for (ll i = 2; i <= 2; i++) {

    ll cnt = 0, ne = 1;

    while (n % i == 0) {
      cnt++;
      n /= i;
      if (cnt == ne) {
        ans++;
        ne++;
        cnt = 0;
      }
    }
    if (cnt != 0) {
      ans++;
      cnt = 0;
    }
  }

  for (ll i = 3; i * i <= MAX; i + 2) {

    ll cnt = 0, ne = 1;

    while (n % i == 0) {
      cnt++;
      n /= i;
      if (cnt == ne) {
        ans++;
        ne++;
        cnt = 0;
      }
    }
    if (cnt != 0) {
      ans++;
      cnt = 0;
    }
  }

  // cout<<n<<endl;
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  long long int n, i, j, k = 0, z = 0;
  cin >> n;
  if (n % 2 == 0) {
    z = 0;
    while (n % 2 == 0) {
      n /= 2;
      z++;
    }
    k += floor((sqrt(1.0 + 8 * z) - 1) / 2);
  }
  for (i = 3; i * i <= n; i += 2) {
    if (n % i == 0) {
      z = 0;
      while (n % i == 0) {
        n /= i;
        z++;
      }
      k += floor((sqrt(1.0 + 8 * z) - 1) / 2);
    }
  }
  if (n > 1)
    k++;
  cout << k << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  long long int n, i, j, k = 0, z = 0;
  cin >> n;
  for (i = 2; i <= n; i++) {
    if (n % i == 0) {
      z = 0;
      while (n % i == 0) {
        n /= i;
        z++;
      }
      k += floor((sqrt(1.0 + 8 * z) - 1) / 2);
    }
  }
  cout << k << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
#define endl "\\n"
#define vi vector<int>
#define F(i, n) for (ll i = 0; i < (ll)n; i++)
#define pb push_back
#define print(x) cout << x << endl;
#define print_array(arr)                                                       \\
  F(i, arr.size()) { cout << arr[i] << "-"; }                                  \\
  cout << endl;
#define print_line                                                             \\
  F(i, 60) { cout << "--"; }                                                   \\
  cout << endl;
const int mod = 1e9 + 7;
using namespace std;

void pre() {}
void solve() {
  ll n;
  cin >> n;
  ll lim = sqrt(n) + 1;
  int values[10] = {0, 1, 3, 6, 10, 15, 21, 28, 36, 45};
  vector<int> bases(lim, 0);
  ll temp = n;
  int ans = 0;
  while (temp > 1) {
    bool isprime = true;
    for (ll i = 2; i <= sqrt(temp); ++i) {
      if (temp % i == 0) {
        bases[i]++;
        temp /= i;
        isprime = false;
        break;
      }
    }
    if (isprime) {
      if (temp >= lim) {
        ans = 1;
        break;
      }
      bases[temp]++;
      temp = 1;
      break;
    }
  }
  // F(i, lim){
  // 	cout << bases[i] << " ";
  // }
  // print("")
  F(i, lim) {
    if (bases[i] > 0) {
      F(j, 10) {
        if (bases[i] >= values[9 - j]) {
          ans += 9 - j;
          break;
        }
      }
    }
  }
  print(ans)
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define endl "\\n"
#define vi vector<int>
#define F(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define print(x) cout << x << endl;
#define print_array(arr)                                                       \\
  F(i, arr.size()) { cout << arr[i] << "-"; }                                  \\
  cout << endl;
#define print_line                                                             \\
  F(i, 60) { cout << "--"; }                                                   \\
  cout << endl;
const int mod = 1e9 + 7;
using namespace std;

void pre() {}
void solve() {
  ll n;
  cin >> n;
  int lim = sqrt(n) + 1;
  int values[10] = {0, 1, 3, 6, 10, 15, 21, 28, 36, 45};
  vector<int> bases(lim, 0);
  ll temp = n;
  while (temp > 1) {
    bool isprime = true;
    for (int i = 2; i <= sqrt(temp); ++i) {
      if (temp % i == 0) {
        bases[i]++;
        temp /= i;
        isprime = false;
        break;
      }
    }
    if (isprime) {
      bases[temp]++;
      temp = 1;
    }
  }
  // F(i, lim){
  // 	cout << bases[i] << " ";
  // }
  // print("")
  int ans = 0;
  F(i, lim) {
    if (bases[i] > 0) {
      F(j, 10) {
        if (bases[i] >= values[9 - j]) {
          ans += 9 - j;
          break;
        }
      }
    }
  }
  print(ans)
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

/* 	* In the name of GOD
 * Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long

bool is_prime(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int32_t main() {
  int n;
  cin >> n;
  if (n == 1)
    return cout << 0, 0;
  if (is_prime(n))
    return cout << 1, 0;
  int x = n;
  int ans = 0;
  map<int, int> mp;
  for (int i = 2; i * i <= n; i++) {
    if (x == 1)
      break;
    if (x % i == 0) {
      while (x % i == 0)
        mp[i]++, x /= i;
    }
    if (x == 1)
      break;
    int y = n / i;
    if (x % y == 0) {
      if (!is_prime(y))
        continue;
      while (x % y == 0)
        mp[y]++, x /= y;
    }
  }
  for (auto g : mp) {
    //		cout << g.F << ' ' << g.S << endl;
    int y = max(0ll, (ll)(sqrt(g.S * 2)) - 5);
    int an;
    for (int i = y; i < y + 10; i++) {
      if ((i * (i + 1)) / 2 <= g.S)
        an = i;
    }
    ans += an;
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

/* 	* In the name of GOD
 * Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long

bool is_prime(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int32_t main() {
  int n;
  cin >> n;
  if (n == 1)
    return cout << 0, 0;
  if (is_prime(n))
    return cout << 1, 0;
  int x = n;
  int ans = 0;
  map<int, int> mp;
  for (int i = 2; i <= n; i++) {
    if (x == 1)
      break;
    if (!is_prime(i))
      continue;
    if (x % i == 0) {
      while (x % i == 0)
        mp[i]++, x /= i;
    }
  }
  for (auto g : mp) {
    //		cout << g.F << ' ' << g.S << endl;
    int y = max(0ll, (ll)(sqrt(g.S * 2)) - 50);
    int an;
    for (int i = y; i < y + 100; i++) {
      if ((i * (i + 1)) / 2 <= g.S)
        an = i;
    }
    ans += an;
  }
  cout << ans << endl;
}