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


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

void show(vector<ll> &vc) {
  for (auto it : vc)
    cout << it << " ";
  cout << endl;
}
#define M 1000009
bool p[M + 2];
vector<ll> prime;
void seive(void) {
  memset(p, 0, sizeof p);
  p[1] = 1;
  p[0] = 1;
  for (int i = 4; i <= M; i += 2) {
    p[i] = 1;
  }

  for (ll i = 3; i * i <= M; i += 2) {
    if (!p[i]) {
      for (ll j = i * i; j <= M; j += 2 * i) {
        p[j] = 1;
      }
    }
  }

  prime.push_back(2);
  for (int i = 3; i <= M; i += 2)
    prime.push_back(i);
}
ll dx[] = {-1, -1, 0, -1, 1, 0, 1, 1};
ll dy[] = {-1, 0, -1, 1, -1, 1, 0, 1};

typedef pair<ll, ll> pii;
#define x first
#define y second

pii extendedEuclid(ll a, ll b) { // returns x, y | ax + by = gcd(a,b)
  if (b == 0)
    return pii(1, 0);
  else {
    pii d = extendedEuclid(b, a % b);
    return pii(d.y, d.x - d.y * (a / b));
  }
}

ll modularInverse(ll a, ll n) {
  pii ret = extendedEuclid(a, n);
  return ((ret.x % n) + n) % n;
}

void solve(ll t) {

  ll n;
  cin >> n;
  ll ans = 0;
  for (int i = 0; prime[i] * prime[i] <= n; i++) {

    ll c = 0;
    while (n % prime[i] == 0) {
      c++;
      n /= prime[i];
    }
    for (ll j = 1; c - j > j; j++) {
      ans++;
      c -= j;
    }
    if (c > 0)
      ans++;
    // cout<<n<<" "<<c<<endl;
  }
  if (n > 1)
    ans++;

  cout << ans << endl;
}

int main() {

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

  seive();

  ll t = 1;
  // cin>>t;
  ll T = t;

  while (t--) {

    solve(T - t);
  }
}


Error: 0

Fixed submission:


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

void show(vector<ll> &vc) {
  for (auto it : vc)
    cout << it << " ";
  cout << endl;
}
#define M 1000000
bool p[M + 2];
vector<ll> prime;
void seive(void) {
  memset(p, 0, sizeof p);
  p[1] = 1;
  p[0] = 1;
  for (int i = 4; i <= M; i += 2) {
    p[i] = 1;
  }

  for (ll i = 3; i * i <= M; i += 2) {
    if (!p[i]) {
      for (ll j = i * i; j <= M; j += 2 * i) {
        p[j] = 1;
      }
    }
  }

  prime.push_back(2);
  for (int i = 3; i <= M; i += 2)
    prime.push_back(i);
}
ll dx[] = {-1, -1, 0, -1, 1, 0, 1, 1};
ll dy[] = {-1, 0, -1, 1, -1, 1, 0, 1};

typedef pair<ll, ll> pii;
#define x first
#define y second

pii extendedEuclid(ll a, ll b) { // returns x, y | ax + by = gcd(a,b)
  if (b == 0)
    return pii(1, 0);
  else {
    pii d = extendedEuclid(b, a % b);
    return pii(d.y, d.x - d.y * (a / b));
  }
}

ll modularInverse(ll a, ll n) {
  pii ret = extendedEuclid(a, n);
  return ((ret.x % n) + n) % n;
}

void solve(ll t) {

  ll n;
  cin >> n;
  ll ans = 0;
  for (int i = 0; prime[i] * prime[i] <= n; i++) {
    ll c = 0;
    while (n % prime[i] == 0) {
      c++;
      n /= prime[i];
    }
    for (ll j = 1; c - j >= j; j++) {
      ans++;
      c -= j;
    }
    if (c > 0)
      ans++;
  }
  if (n > 1)
    ans++;

  cout << ans << endl;
}

int main() {

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

  seive();

  ll t = 1;
  // cin>>t;
  ll T = t;

  while (t--) {

    solve(T - t);
  }
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <numeric>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
int MOD = 998244353;
const int mxN = 40 + 9;

ll ar[mxN];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  vector<ll> divisor;
  for (ll i = 1; i <= sqrtl(N); i++) {
    if (N % i == 0) {
      if (N / i == i)
        divisor.push_back(i);
      else {
        divisor.push_back(i);
        divisor.push_back(N / i);
      }
    }
  }
  sort(divisor.begin(), divisor.end());
  vector<ll> pow;
  for (auto &i : divisor) {
    if (i != 1) {
      ll cnt = 0;
      while (N % i == 0) {
        N /= i;
        ++cnt;
      }
      if (cnt != 0)
        pow.push_back(cnt);
    }
  }
  /*for(auto &c: pow) cout << c << " ";
  cout << endl;*/
  ll ans = 0;
  ar[1] = 1;
  for (ll i = 2; i <= 40; i++)
    ar[i] = ar[i - 1] + i;
  for (auto c : pow) {
    int L = 1;
    int R = 40;
    int tmpans = 1;
    while (L <= R) {
      int mid = (R + L) / 2;
      // cout << "mid = " << mid  << " " << ar[mid] << endl;
      if (ar[mid] == c) {
        tmpans = mid;
        break;
      } else if (ar[mid] > c)
        R = mid - 1;
      else if (ar[mid] < c) {
        tmpans = mid;
        L = mid + 1;
      }
    }
    // cout << tmpans << " ";
    ans += tmpans;
  }
  cout << ans;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <numeric>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
int MOD = 998244353;
const int mxN = 40 + 9;

int ar[mxN];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  vector<int> divisor;
  for (int i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {
      if (N / i == i)
        divisor.push_back(i);
      else {
        divisor.push_back(i);
        divisor.push_back(N / i);
      }
    }
  }
  sort(divisor.begin(), divisor.end());
  vector<int> pow;
  for (auto &i : divisor) {
    if (i != 1) {
      int cnt = 0;
      while (N % i == 0) {
        N /= i;
        ++cnt;
      }
      if (cnt != 0)
        pow.push_back(cnt);
    }
  }
  /*for(auto &c: pow) cout << c << " ";
  cout << endl;*/
  int ans = 0;
  ar[1] = 1;
  for (int i = 2; i <= 40; i++)
    ar[i] = ar[i - 1] + i;
  for (auto c : pow) {
    int L = 1;
    int R = 40;
    int tmpans = 1;
    while (L <= R) {
      int mid = (R + L) / 2;
      // cout << "mid = " << mid  << " " << ar[mid] << endl;
      if (ar[mid] == c) {
        tmpans = mid;
        break;
      } else if (ar[mid] > c)
        R = mid - 1;
      else if (ar[mid] < c) {
        tmpans = mid;
        L = mid + 1;
      }
    }
    // cout << tmpans << " ";
    ans += tmpans;
  }
  cout << ans;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

long long gcd(long long a, long long b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

vector<bool> isNotPrime(1100000);
int solve(long long N) {
  long long current = 2;
  int ans = 0;
  while (current * current <= N) {
    int count = 0;
    while (N % current == 0) {
      N /= current;
      count++;
    }
    int c = 1;
    while (c <= count) {
      ans++;
      count -= c;
      c++;
    }
    while (true) {
      current++;
      if (!isNotPrime[current]) {
        break;
      }
    }
  }

  if (current <= N) {
    ans += 1;
  }
  return ans;
}

int main() {
  //    cout << fixed << setprecision(10);

  for (int i = 2; i < 1100000; i++) {
    if (isNotPrime[i] == false) {
      for (int j = i + i; j < 1100000; j += i) {
        isNotPrime[j] = true;
      }
    }
  }

  long long N;
  cin >> N;

  cout << solve(N);

  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

long long gcd(long long a, long long b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

int main() {
  //    cout << fixed << setprecision(10);
  long long N;
  cin >> N;
  int current = 2;
  int ans = 0;
  vector<bool> isNotPrime(1100000);
  for (int i = 2; i < 1100000; i++) {
    if (isNotPrime[i] == false) {
      for (int j = i; j < 1100000; j += i) {
        isNotPrime[j] = true;
      }
    }
  }
  while (current * current <= N) {
    int count = 0;
    while (N % current == 0) {
      N /= current;
      count++;
    }
    int c = 1;
    while (c <= count) {
      ans++;
      count -= c;
      c++;
    }
    while (true) {
      current++;
      if (isNotPrime[current]) {
        break;
      }
    }
  }

  if (current <= N) {
    ans += 1;
  }
  cout << ans;

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

#include <bits/stdc++.h>
using namespace std;
map<long long, long long> divide(long long n) { // 素因数分解
  map<long long, long long> res;
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}
int main() {
  long long N;
  cin >> N;
  map<long long, long long> m;
  m = divide(N);
  vector<long long> vec(1000010);
  vec[0] = 0;
  for (long long i = 1; i < 1000010; i++) {
    vec[i] += i + vec[i - 1];
  }
  long long ans = 0;
  for (auto u : m) {
    int ind = lower_bound(vec.begin(), vec.end(), u.second) - vec.begin();
    if (vec[ind] != u.second)
      ind--;
    ans += ind;
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
map<long long, long long> divide(long long n) { // 素因数分解
  map<long long, long long> 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;
}
int main() {
  long long N;
  cin >> N;
  map<long long, long long> m;
  m = divide(N);
  long long ans = 0;
  for (auto u : m) {
    int i = 1;
    while (u.second >= i) {
      ans += 1;
      u.second -= i;
      i++;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define endl '\\n'
// pair<int, int> *p=new pair<int, int>[n];
// std::vector<pair<int,int>> vp;
// v.push_back(make_pair(x,y))
// pair<int, int> p[1000001];
// string *s=new string [n];
// int freq[e];
// freq[a[i]-'a']++; freq[a[i]]++;
using namespace std;
ll n, t, m, c1, c2, c, x, y, sum, mn = 999999999, avg, pos, dif, j, dis, mx, xi,
                                  yi, q;
vector<ll> v;
set<int> s;
map<string, ll> mp;
bool PE(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0)
      return false;
  return true;
}
bool PR(string s) {
  int n = s.length();
  for (int i = 0; i < n / 2; i++)
    if (s[i] != s[n - i - 1])
      return false;
  return true;
}

int main(void) {
  SpeeD ll n;
  cin >> n;
  c = 0;
  while (n % 2 == 0) {
    n /= 2;
    c++;
  }
  // cout<<c;

  ll dif = (-1 + sqrt(1 + 8 * c)) / 2;

  for (ll i = 3; i * i <= n; i++) {
    c1 = 0;
    while (n % i == 0) {
      c1++, n /= i;
    }

    dif += (-1 + sqrt(1 + 8 * c1)) / 2;
  }
  // cout<<n;
  if (n > 2)
    dif++;

  cout << dif;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define endl '\\n'
// pair<int, int> *p=new pair<int, int>[n];
// std::vector<pair<int,int>> vp;
// v.push_back(make_pair(x,y))
// pair<int, int> p[1000001];
// string *s=new string [n];
// int freq[e];
// freq[a[i]-'a']++; freq[a[i]]++;
using namespace std;
ll n, t, m, c1, c2, c, x, y, sum, mn = 999999999, avg, pos, dif, j, dis, mx, xi,
                                  yi, q;
vector<ll> v;
set<int> s;
map<string, ll> mp;
bool PE(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0)
      return false;
  return true;
}
bool PR(string s) {
  int n = s.length();
  for (int i = 0; i < n / 2; i++)
    if (s[i] != s[n - i - 1])
      return false;
  return true;
}

int main(void) {
  SpeeD ll n;
  cin >> n;
  c = 0;
  while (n % 2 == 0) {
    n /= 2;
    c++;
  }
  // cout<<c;

  ll dif = (-1 + sqrt(1 + 8 * c)) / 2;

  for (int i = 3; i * i <= n; i++) {
    c1 = 0;
    while (n % i == 0) {
      c1++, n /= i;
    }

    dif += (-1 + sqrt(1 + 8 * c1)) / 2;
  }
  // cout<<n;
  if (n > 2)
    dif++;

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

#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define endl '\\n'
// pair<int, int> *p=new pair<int, int>[n];
// std::vector<pair<int,int>> vp;
// v.push_back(make_pair(x,y))
// pair<int, int> p[1000001];
// string *s=new string [n];
// int freq[e];
// freq[a[i]-'a']++; freq[a[i]]++;
using namespace std;
ll n, t, m, c1, c2, c, x, y, sum, mn = 999999999, avg, pos, dif, j, dis, mx, xi,
                                  yi, q;
vector<ll> v;
set<int> s;
map<string, ll> mp;
bool PE(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0)
      return false;
  return true;
}
bool PR(string s) {
  int n = s.length();
  for (int i = 0; i < n / 2; i++)
    if (s[i] != s[n - i - 1])
      return false;
  return true;
}

int main(void) {
  SpeeD ll n;
  cin >> n;
  c = 0;

  for (ll i = 2; i <= sqrtl(n); i++) {
    c1 = 0;
    while (n % i == 0) {
      c1++, n /= i;
    }
    c += (-1 + sqrt(1 + 8 * c1)) / 2;
  }
  // cout<<n;
  if (n > 2)
    c++;

  cout << c;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define endl '\\n'
// pair<int, int> *p=new pair<int, int>[n];
// std::vector<pair<int,int>> vp;
// v.push_back(make_pair(x,y))
// pair<int, int> p[1000001];
// string *s=new string [n];
// int freq[e];
// freq[a[i]-'a']++; freq[a[i]]++;
using namespace std;
ll n, t, m, c1, c2, c, x, y, sum, mn = 999999999, avg, pos, dif, j, dis, mx, xi,
                                  yi, q;
vector<ll> v;
set<int> s;
map<string, ll> mp;
bool PE(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0)
      return false;
  return true;
}
bool PR(string s) {
  int n = s.length();
  for (int i = 0; i < n / 2; i++)
    if (s[i] != s[n - i - 1])
      return false;
  return true;
}

int main(void) {
  SpeeD ll n;
  cin >> n;
  c = 0;
  while (n % 2 == 0) {
    n /= 2;
    c++;
  }
  // cout<<c;
  ll dif = (-1 + sqrt(1 + 8 * c)) / 2;

  for (int i = 3; i * i <= n; i += 2) {
    c1 = 0;
    while (n % i == 0) {
      c1++, n /= i;
    }

    dif += (-1 + sqrt(1 + 8 * c1)) / 2;
  }
  // cout<<n;
  if (n > 2)
    dif++;

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

#include <cmath>
#include <iostream>
#include <map>
using namespace std;

int main() {
  long long N;
  cin >> N;
  map<long long, int> ps;
  for (long long i = 2; i * i <= N; ++i) {
    while ((N % i == 0)) {
      ++ps[i];
      N /= i;
    }
  }
  if (N != 1)
    ++ps[N];
  int ans = 0, counter, j;
  //  for(auto itr=ps.begin();itr!=ps.end();++itr)
  //    cout << itr->first << "**" << itr->second << endl;
  for (auto itr = ps.begin(); itr != ps.end(); ++itr) {
    counter = itr->second;
    j = 1;
    while (counter - j >= 0) {
      counter -= j;
      ++j;
      ++ans;
    }
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#include <map>
using namespace std;

int main() {
  long long N;
  cin >> N;
  map<int, int> ps;
  for (int i = 2; i * i <= N; ++i) {
    while ((N % i == 0)) {
      ++ps[i];
      N /= i;
    }
  }
  if (N != 1)
    ++ps[N];
  int ans = 0, counter, j;
  for (auto itr = ps.begin(); itr != ps.end(); ++itr) {
    counter = itr->second;
    j = 1;
    while (counter - j >= 0) {
      counter -= j;
      ++j;
      ++ans;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  long long N;
  cin >> N;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  long long p = 2;
  long long N0 = N;
  vector<long long> e;
  while ((p * p <= N0)) {
    int tmp = 0;
    while (N % p == 0) {
      tmp++;
      N /= p;
      if (N % p != 0) {
        e.push_back(tmp);
      }
    }

    p++;
  }

  int Np = e.size();
  int No = 0;
  if (N > 1) {
    No++;
  }
  for (int i = 0; i < Np; i++) {
    int tmp = 0;
    for (int j = 1; j <= e[i]; j++) {
      if (tmp + j > e[i])
        break;
      tmp += j;
      No++;
    }
  }
  cout << No << endl;

  return 0;
}


Error: TLE

Fixed submission:

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

int main(void) {
  long long N;
  cin >> N;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  long long p = 2;
  vector<long long> e;
  while (N > 1) {
    int tmp = 0;
    while (N % p == 0) {
      tmp++;
      N /= p;
      if (N % p != 0) {
        e.push_back(tmp);
      }
    }
    p++;
  }

  int Np = e.size();

  int No = 0;
  for (int i = 0; i < Np; i++) {
    int tmp = 0;
    for (int j = 1; j <= e[i]; j++) {
      tmp += j;
      No++;
      if (tmp > e[i]) {
        No--;
        break;
      }
    }
  }
  cout << No << endl;

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

#include <cmath>
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;

int main() {
  long long n;
  long long p;
  unordered_map<long long, long long> primes;

  cin >> n;

  p = 2LL;

  while (p * p <= n) {
    while (n % p == 0) {
      n /= p;
      ++primes[p];
    }
    ++p;
  }

  if (n > 1) {
    ++primes[n];
  }

  long long sum = 0;

  for (const auto &prime : primes) {
    long long j;
    for (j = 1; j <= prime.second; ++j) {
      if (j * (j + 1LL) / 2LL > prime.second) {
        break;
      }
    }

    --j;

    sum += j;
  }

  cout << sum << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;

int main() {
  long long n;
  long long p;
  unordered_map<long long, long long> primes;

  cin >> n;

  p = 2;

  while (n > 1) {
    while (n % p == 0) {
      n /= p;
      ++primes[p];
    }
    ++p;
  }

  long long sum = 0LL;

  for (const auto &prime : primes) {
    int j;
    for (j = 1; j <= prime.second; ++j) {
      if (j * (j + 1LL) / 2LL > prime.second) {
        break;
      }
    }

    --j;

    sum += j;
  }

  cout << sum << endl;

  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++)
#define rep2(i, a, n) for (int i = a; i < n; i++)
#define been(ix) (ix).begin(), (ix).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001;
typedef pair<int, int> P;
#define foreach(ix, i) for (auto &(ix) : (i))
typedef long double ld;
const int mod = 1000000007;
const double PI = acos(-1);

int main() {
  ll n, m;
  bool prime = true;
  cin >> n;

  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 0;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;

    prime = false;
    ll expo = 0;
    while (n % i == 0) {
      n /= i;
      expo++;
    }
    ll j = 1;
    while (expo >= j * (j + 1) / 2)
      j++;
    ans += j - 1;
  }
  if (n != 1)
    ans += 1;
  if (prime)
    ans = 1;
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = a; i < n; i++)
#define been(ix) (ix).begin(), (ix).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001;
typedef pair<int, int> P;
#define foreach(ix, i) for (auto &(ix) : (i))
typedef long double ld;
const int mod = 1000000007;
const double PI = acos(-1);
vector<int> Eratosthenes(const int N) {
  std::vector<bool> is_prime(N + 1);
  for (int i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  std::vector<int> P;
  for (int i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}
bool prime(ll num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false; // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      // 素数ではない
      return false;
    }
  }

  // 素数である
  return true;
}
int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (prime(n)) {
    cout << 1 << endl;
    return 0;
  }
  ll now = n;
  ll ans = 0;
  ll a = sqrt(n) + 2;
  ll x = 2;
  while (x <= now) {
    if (now % x == 0) {
      ans++;
      now /= x;
    }
    x *= 2;
  }
  for (int i = 3; i <= now; i += 2) {
    if (i == 0)
      continue;
    if (prime(i)) {
      ll cnt = i;
      while (cnt <= now) {
        if (now % cnt == 0) {
          ans++;
          now /= cnt;
        }
        cnt *= i;
      }
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  long long n;
  cin >> n;
  if (n == 1) {
    cout << "0\\n";
    return 0;
  }

  long long temp = n;
  map<long long, int> pw;
  int res = 0;
  for (long long i = 2; i * i <= n; i++) {
    long long cur = i;
    int cn = 1;
    while (temp % cur == 0) {
      temp /= cur;
      pw[i] += cn;
      cn++;
      cur *= i;
    }
    while (temp % i == 0)
      temp /= i;
  }
  bool prime = temp > 1;
  for (long long i = 2; i * i <= temp; i++) {
    if (temp % i == 0) {
      prime = false;
      break;
    }
  }
  if (prime)
    pw[temp]++;
  for (auto &p : pw) {
    int cn = (int)((-1.0 + sqrt(1.0 + 8.0 * p.second)) / 2.0);
    res += cn;
    /*int cn = 1;
    while (p.second - cn >= 0) {
            res++;
            p.second -= cn;
            cn++;
    }*/
  }

  cout << res << '\\n';

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  long long n;
  cin >> n;
  if (n == 1) {
    cout << "0\\n";
    return 0;
  }
  bool prime = true;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      prime = false;
      break;
    }
  }
  if (prime) {
    cout << "1\\n";
    return 0;
  }

  long long temp = n;
  unordered_map<long long, int> pw;
  int res = 0;
  for (long long i = 2; i <= temp; i++) {
    long long cur = i;
    int cn = 1;
    while (temp % cur == 0) {
      temp /= cur;
      pw[i] += cn;
      cn++;
      cur *= i;
      res++;
    }
    while (temp % i == 0)
      temp /= i;
  }

  cout << res << '\\n';

  return 0;
}