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

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

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

typedef long long ll;

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> 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;
}

int main() {
  ll N;
  ll ans = 0;
  cin >> N;
  map<ll, ll> prime = prime_factor(N);
  for (auto p : prime) {
    ll max_e = p.second;
    int e = 1;
    int cnt = 0;
    while (max_e >= e) {
      cnt++;
      max_e -= e;
      e++;
    }
    ans += cnt;
  }
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

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

typedef long long ll;

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> 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() {
  ll N;
  ll ans = 0;
  cin >> N;
  map<ll, ll> prime = prime_factor(N);
  for (auto p : prime) {
    ll max_e = p.second;
    int e = 1;
    int cnt = 0;
    while (max_e >= e) {
      cnt++;
      max_e -= e;
      e++;
    }
    ans += cnt;
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue                                                                   \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define rep(i, a, n) for (int i = a; i < n; ++i)
typedef vector<int> vi;
typedef long long ll;
const int mod = 1e9 + 7;

const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
vector<ll> q;

ll getAns(ll m) {
  ll x = 0;
  auto it = upper_bound(all(q), m) - q.begin() - 1;
  return it;
}

void solve() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 0; i <= 8; i++) {
    q.pb(((i + 1) * i) / 2);
  }
  for (ll i = 2; i * i <= n; i++) {
    ll cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    ans += getAns(cnt);
  }
  if (n > 1)
    ans++;
  cout << ans;
}

int main() {
  Blue;
  int test = 1;
  // cin>>test;
  while (test--)
    solve();
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue                                                                   \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define rep(i, a, n) for (int i = a; i < n; ++i)
typedef vector<int> vi;
typedef long long ll;
const int mod = 1e9 + 7;

const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
vector<ll> q;

ll getAns(ll m) {
  ll x = 0;
  auto it = upper_bound(all(q), m) - q.begin() - 1;
  return it;
}

void solve() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 0; i <= 8; i++) {
    q.pb(((i + 1) * i) / 2);
  }
  for (ll i = 2; i * i <= n; i++) {
    ll cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    ll j = 0;
    for (; j <= 8;) {
      if ((j * (j + 1)) <= cnt)
        j++;
    }
    j--;
    ans += j;
  }
  if (n > 1)
    ans++;
  cout << ans;
}

int main() {
  Blue;
  int test = 1;
  // cin>>test;
  while (test--)
    solve();
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

/*
  Reference:-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int, int>
#define all(vec) vec.begin(), vec.end()
ll mod = 1000000007;
const int N = 2e5 + 5;
ll power(ll n, ll k) {
  ll ans = 1;
  while (k) {
    if (k & 1)
      ans = (ans * n) % mod;
    k /= 2;
    n = (n * n) % mod;
  }
  // ans=(ans-1+mod)%mod;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll a;
  cin >> a;
  ll ans = 0;
  ll n = a;
  for (ll i = 2; i * i <= a; i++) {
    if (n % i == 0) {
      ll co = 0;
      while (n % i == 0) {
        n /= i;
        co++;
      }
      // cout<<i<<" "<<co<<" ";
      ll sum = 1, num = 1;
      while (sum <= co) {
        sum = (num * (num + 1)) / 2;
        num++;
      }
      // cout<<num<<endl;
      ans += num - 2;
    }
  }
  if (n > 1)
    ans++;
  cout << ans;

  return 0;
}


Error: TLE

Fixed submission:

/*
  Reference:-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int, int>
#define all(vec) vec.begin(), vec.end()
ll mod = 1000000007;
const int N = 2e5 + 5;
ll power(ll n, ll k) {
  ll ans = 1;
  while (k) {
    if (k & 1)
      ans = (ans * n) % mod;
    k /= 2;
    n = (n * n) % mod;
  }
  // ans=(ans-1+mod)%mod;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll a;
  cin >> a;
  ll ans = 0;
  ll n = a;
  for (int i = 2; i * i <= a; i++) {
    if (n % i == 0) {
      ll co = 0;
      while (n % i == 0) {
        n /= i;
        co++;
      }
      // cout<<i<<" "<<co<<" ";
      ll sum = 1, num = 1;
      while (sum <= co) {
        sum = (num * (num + 1)) / 2;
        num++;
      }
      // cout<<num<<endl;
      ans += num - 2;
    }
  }
  if (n > 1)
    ans++;
  cout << ans;

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

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

bool prime(ll x) {
  if (x == 1)
    return false;
  for (ll i = 2; i <= pow(x, 0.5); i++) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int main() {
  ll n, ans = 0;
  cin >> n;
  if (prime(n))
    ans = 1;
  else {
    ll m = pow(n, 0.5);
    for (ll i = 2; i <= m; i++) {
      ll c = 0;
      while (true) {
        if (n % i != 0) {
          break;
        }
        n /= i;
        c++;
      }

      ll k = 1;
      while (true) {
        if (c >= k) {
          c -= k;
          ans++;
        } else {
          break;
        }
        k++;
      }
      // if(prime(n)){ans++;break;}
    }
    if (n != 1)
      ans++;
  }
  cout << ans;
}


Error: TLE

Fixed submission:

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

bool prime(ll x) {
  if (x == 1)
    return false;
  for (ll i = 2; i <= pow(x, 0.5); i++) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int main() {
  ll n, ans = 0;
  cin >> n;
  if (prime(n))
    ans = 1;

  for (ll i = 2; i <= n; i++) {
    ll c = 0;
    while (true) {
      if (n % i != 0) {
        break;
      }
      n /= i;
      c++;
    }
    // if(c>0){cout<<i<<" "<<c<<" ";}
    ll k = 1;
    while (true) {
      if (c >= k) {
        c -= k;
        ans++;
      } else {
        break;
      }
      k++;
    }
    // if(n!=1)cout<<n<<" "<<k<<"    ";
  }

  cout << ans;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T> T lcm(T a, T b) { return a / __gcd(a, b) * b; }

int main() {
  ll n, ans = 0;
  cin >> n;
  ll n_tmp = n;
  bool is_prime = true;
  for (ll i = 2; i * i <= n_tmp; i++) {
    ll tmp = i;
    while (n % tmp == 0) {
      n /= tmp;
      tmp *= i;
      ans++;
    }
    while (n % i == 0) {
      n /= i;
    }
  }
  if (n <= 1)
    is_prime = false;
  cout << ans + is_prime << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T> T lcm(T a, T b) { return a / __gcd(a, b) * b; }

int main() {
  ll n, ans = 0;
  cin >> n;
  ll tmp_n = sqrt(n + .1);
  vector<bool> a(n + 10, false);
  for (int i = 2; i <= tmp_n; i++) {
    if (n % i != 0)
      continue;
    // cout << n << " " << i << endl;
    n /= i;
    a[i] = true;
    ans++;
  }
  if (n > 1 && a[n] == false)
    ans++;
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int a[100000];
int main() {
  long long n, ba = 0, bz;
  cin >> n;
  for (long long t = 2; t * t <= n; t++) {
    if (n % t == 0) {
      while (n % t == 0) {
        // cout<<t<<" ";
        a[ba]++;
        n /= t;
      }
      ba++;
    }
  }
  if (n != 1) {
    ba++;
    a[ba - 1] = 1;
    // cout<<n<<" ";
  }
  // cout<<ba<<endl;
  bz = ba;
  for (int t = 0; t < bz; t++) {
    int l = 0;
    while (a[t] >= 0) {
      // cout<<"l="<<l<<" t="<<t<<" a[t]="<<a[t]<<" ";
      l++;
      a[t] -= l;
    }
    ba += l - 2;
    // cout<<"ba="<<ba<<endl;
  }
  cout << ba;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int a[100000];
int main() {
  long long n, ba = 0, bz;
  cin >> n;
  for (long long t = 2; t <= n; t++) {
    if (n % t == 0) {
      while (n % t == 0) {
        // cout<<t<<" ";
        a[ba]++;
        n /= t;
      }
      ba++;
    }
  }
  // cout<<ba<<endl;
  bz = ba;
  for (int t = 0; t < bz; t++) {
    int l = 0;
    while (a[t] >= 0) {
      // cout<<"l="<<l<<" t="<<t<<" a[t]="<<a[t]<<" ";
      l++;
      a[t] -= l;
    }
    ba += l - 2;
    // cout<<"ba="<<ba<<endl;
  }
  cout << ba;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <cmath>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>

#include <algorithm>
#include <queue>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
  long long n;
  cin >> n;
  long long p = 2;
  long long ans = 0;
  long long count = 1;
  long long now = 0;
  while (n > 1) {
    if (n % p == 0) {
      n /= p;
      now++;
      if (count == now) {
        ans++;
        now = 0;
        count++;
      }
    } else {
      if (p == 2) {
        p = 3;
      } else {
        p += 2;
      }
      if (p * p > n) {
        ans++;
        break;
      }
      count = 1;
      now = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <cmath>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>

#include <algorithm>
#include <queue>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
  long long n;
  cin >> n;
  long long p = 2;
  long long ans = 0;
  long long count = 1;
  long long now = 0;
  while (n > 1) {
    if (n % p == 0) {
      n /= p;
      now++;
      if (count == now) {
        ans++;
        now = 0;
        count++;
      }
    } else {
      if (p == 2) {
        p = 3;
      } else {
        p += 2;
      }
      count = 1;
      now = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  ll n;
  cin >> n;
  ll m = n;
  vector<pair<ll, int>> fs;
  for (ll i = 2; i * i <= m; i++) {
    int x = 0;
    while (n % i == 0) {
      n /= i;
      x++;
    }

    fs.emplace_back(i, x);
  }
  if (n != 1)
    fs.emplace_back(n, 1);

  int ans = 0;
  for (auto p : fs) {
    int x = p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

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

bool IsPrime(int 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;
  ll x = n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  for (int i = 2; i <= sqrt(x); i++) {
    if (!IsPrime(i))
      continue;
    if (n % i == 0) {
      for (int j = i; n % j == 0; j *= j) {
        n /= j;
        ans++;
      }
    }
  }

  if (ans == 0)
    cout << 1 << endl;
  else
    cout << ans << endl;

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// int gcd(int a,int b)
// {
// 	if(b==0)
// 	return a;

// 	return gcd(b,a%b);
// }
ll power(ll x, ll y) {
  ll res = 1;
  x = x;
  while (y > 0) {
    if (y & 1)
      res = (res * x);

    y = y >> 1;
    x = (x * x);
  }
  return res;
}

int main() {
  // your code goes here
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  ll N = n;
  vector<pair<ll, ll>> v;
  ll c = 0;
  while (n % 2 == 0) {
    n = n / 2;
    c++;
  }
  if (c != 0)
    v.push_back({2, c});
  for (ll i = 3; i <= sqrt(n); i += 2) {
    if (n % i == 0) {
      c = 0;
      while (n % i == 0) {
        n = n / i;
        c++;
      }
      v.push_back({i, c});
    }
  }
  if (n != 1)
    v.push_back({n, 1});

  ll ans = 0;
  for (ll i = 0; i < (int)v.size(); i++) {
    for (ll p = 1; p <= v[i].second; p++) {
      ll z = power(v[i].first, p);
      if (N % z == 0) {
        N = N / z;
        ans++;
      }
    }
    if (N == 1)
      break;
  }
  cout << ans;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// int gcd(int a,int b)
// {
// 	if(b==0)
// 	return a;

// 	return gcd(b,a%b);
// }
int power(ll x, ll y) {
  int res = 1;
  x = x;
  while (y > 0) {
    if (y & 1)
      res = (res * x);

    y = y >> 1;
    x = (x * x);
  }
  return res;
}

int main() {
  // your code goes here
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  ll N = n;
  vector<pair<ll, ll>> v;
  ll c = 0;
  while (n % 2 == 0) {
    n = n / 2;
    c++;
  }
  if (c != 0)
    v.push_back({2, c});
  for (ll i = 3; i <= sqrt(n); i += 2) {
    if (n % i == 0) {
      c = 0;
      while (n % i == 0) {
        n = n / i;
        c++;
      }
      v.push_back({i, c});
    }
  }
  if (n != 1)
    v.push_back({n, 1});

  ll ans = 0;
  for (ll i = 0; i < (int)v.size(); i++) {
    for (ll p = 1; p <= v[i].second; p++) {
      ll z = power(v[i].first, p);
      if (N % z == 0) {
        N = N / z;
        ans++;
      }
      // else
      // {
      // 	break;
      // // }
    }
    if (N == 1)
      break;
  }
  cout << ans;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tii;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)

int main() {
  ll N;
  cin >> N;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll n = N;
  ll ans = 0;
  for (ll i = 2; i * i <= N; i++) {
    ll x = i;
    while (n % x == 0) {
      ans++;
      n /= x;
      x *= i;
    }
    while (n % i == 0) {
      n /= i;
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 999999999
#define rep(i, n) for (int i = 0; i < n; i++)
const ll MOD = 1000000007;
ll cnt = 0, ans = 0;
const int MAX = 510000;

int main() {
  ll n;
  cin >> n;
  ans = 0;
  for (int i = 2; i * i <= n; i++) {
    ll x = i;
    while (n % x == 0) {
      ans++;
      n /= x;
      x *= i;
    }
    while (n % i == 0) {
      n /= i;
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ll n;
  cin >> n;
  vector<int> a(1000000, 0);
  ll now = 2;
  ll n0 = n;
  while (now * now <= n0) {
    while (n % now == 0) {
      a[now - 1]++;
      n /= now;
    }
    now++;
  }

  // cout << a[0] << endl;
  // cout << a[1] << endl;
  // cout << a[2] << endl;
  // cout << a[3] << endl;
  // cout << a[4] << endl;

  ll ans = 0;
  if (n != 1)
    ans++;
  rep(i, 1000000) {
    int e = 1;
    while (a[i] >= e) {
      a[i] -= e;
      e++;
      ans++;
    }
  }

  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

ll x[10000000];

int main() {
  vector<int> z(0);
  rep(i, 30) {
    rep(j, i + 1) { z.push_back(i); }
  }
  ll n;
  cin >> n;
  ll sq = 0;
  while (sq * sq <= n) {
    sq++;
  }
  vector<bool> p(sq, 1);

  for (int i = 0; i * i <= n; i++) {
    if (p[i]) {
      for (int j = 0; i * (j + 2) < n; j++) {
        p[i * (j + 2)] = 0;
      }
    }
  }

  // if(n==1){
  //     cout << 0 << endl;
  //     return 0;
  // }
  int k = 1;
  ll a = p[k];
  while (n >= a * a) {
    if (n % a == 0) {
      x[a]++;
      n /= a;
    } else {
      k++;
      a = p[k];
    }
  }
  x[n]++;
  int ans = 0;
  rep2(i, a + 2) {
    if (i == 1)
      continue;
    ans += z[x[i]];
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define rep(i, n) for (int i = 0; i < (n); i++)
const int INF = 1001001001;
const ll BIG = 1000000007;
const double PI = 3.141592653589793;

int main() {
  ll n;
  cin >> n;
  map<ll, ll> primes;
  for (ll p = 2; p * p <= n; p++) {
    int k = 0;
    while (n % p == 0) {
      n /= p;
      k++;
    }
    if (k > 0) {
      primes[p] = k;
    }
  }
  if (n > 1) {
    primes[n] = 1;
  }
  /*
  for(auto& prime : primes){
      cout << prime.first << " " << prime.second << endl;
  }
  */
  int ans = 0;
  for (auto prime : primes) {
    int i = 1;
    while (1) {
      if (((i + 2) * (i + 1)) > 2 * prime.second) {
        break;
      }
      i++;
    }
    // cout << i << endl;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

#define rep(i, n) for (int i = 0; i < (n); i++)
const int INF = 1001001001;
const ll BIG = 1000000007;
const double PI = 3.141592653589793;

int main() {
  ll n;
  cin >> n;
  map<int, int> primes;
  for (int p = 2; p * p <= n; p++) {
    int k = 0;
    while (n % p == 0) {
      n /= p;
      k++;
    }
    if (k > 0) {
      primes[p] = k;
    }
  }
  if (n > 1) {
    primes[n] = 1;
  }
  /*
  for(auto& prime : primes){
      cout << prime.first << " " << prime.second << endl;
  }
  */
  int ans = 0;
  for (auto prime : primes) {
    int i = 1;
    while (1) {
      if (((i + 2) * (i + 1)) > 2 * prime.second) {
        break;
      }
      i++;
    }
    // cout << i << endl;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

vector<pair<long long, long long>> pf(long long N) {
  vector<pair<long long, long long>> v;
  for (long long i = 2; i * i <= N; i++) {
    if (N % i != 0)
      continue;
    long long counter = 0;
    while (N % i == 0) {
      counter++;
      N /= i;
    }
    v.push_back(make_pair(i, counter));
  }
  if (N != 1)
    v.push_back(make_pair(N, 1));
  return v;
}

long long find(long long n) {
  // long long ans;
  // long long sum = 0;
  long long l = 1;
  long long r = n;
  while (r - l > 1) {
    long long c = (l + r) / 2;
    if (c * (c + 1) / 2 <= n)
      l = c;
    else
      r = c;
  }
  return l;
  // for(int i =1; i <= n + 1000; i++){
  //     sum += i;
  //     if(sum > n) {
  //         ans = i - 1;
  //         break;
  //     }
  // }
}

int main() {
  long long N;
  cin >> N;
  // cout << find(N) << endl;
  vector<pair<long long, long long>> v = pf(N);
  long long ans = 0;
  for (int i = 0; i < v.size(); i++) {
    ans += find(v.at(i).second);
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

vector<pair<long long, long long>> pf(long long N) {
  vector<pair<long long, long long>> v;
  for (int i = 2; i * i <= N; i++) {
    if (N % i != 0)
      continue;
    long long counter = 0;
    while (N % i == 0) {
      counter++;
      N /= i;
    }
    v.push_back(make_pair(i, counter));
  }
  if (N != 1)
    v.push_back(make_pair(N, 1));
  return v;
}

long long find(long long n) {
  // long long ans;
  // long long sum = 0;
  long long l = 1;
  long long r = n;
  while (r - l > 1) {
    long long c = (l + r) / 2;
    if (c * (c + 1) / 2 <= n)
      l = c;
    else
      r = c;
  }
  return l;
  // for(int i =1; i <= n + 1000; i++){
  //     sum += i;
  //     if(sum > n) {
  //         ans = i - 1;
  //         break;
  //     }
  // }
}

int main() {
  long long N;
  cin >> N;
  // cout << find(N) << endl;
  vector<pair<long long, long long>> v = pf(N);
  long long ans = 0;
  for (int i = 0; i < v.size(); i++) {
    ans += find(v.at(i).second);
  }
  cout << ans << endl;
}