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

#include <bits/stdc++.h>

#define N_Max 200001
#define A_Max 1000001
using namespace std;
const long long INF = 1LL << 60;

int main(void) {
  long long k, n;
  long long res = 0;
  long long flg, tmp;
  long long i, j;
  long pn2[1000001] = {};
  long pn[10000000] = {};
  long c_pn = 0;

  cin >> n;

  for (i = 2; i < 1000000; i++) {
    if (pn2[i] == 0) {
      for (j = i + i; j < 1000000; j += i) {
        pn2[j] = 1;
      }
    }
  }
  for (i = 2; i < 1000000; i++) {
    if (pn2[i] == 0) {
      pn[c_pn] = i;
      // cout<<pn[c_pn]<<endl;
      c_pn++;
    }
  }

  // cout<<c_pn<<endl;

  for (i = 0; pn[i] <= n && i < c_pn; i++) {
    tmp = 0;
    do {
      if (n % pn[i] == 0) {
        tmp++;
        n = n / pn[i];
      } else {
        break;
      }
    } while (1);
    if (tmp != 0) {
      // cout<<pn[i]<<" "<<tmp<<" "<<n<<endl;
      // cout<<(pow(2.0*double(tmp)+0.25,0.5)-0.5)<<endl;
      res += long(pow(2 * tmp + 0.25, 0.5) - 0.5);
    }
  }
  // cout<<res<<" "<<n<<endl;
  if (n != 1) {
    res++;
  }
  cout << res << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define N_Max 200001
#define A_Max 1000001
using namespace std;
const long long INF = 1LL << 60;

int main(void) {
  long long k, n;
  long long res = 0;
  long long flg, tmp;
  long long i, j;
  long pn[10000000] = {};
  long c_pn = 1;

  cin >> n;
  pn[0] = 2;
  for (i = 3; i < 1000000;) {
    flg = 0;
    for (j = 0; j < c_pn; j++) {
      if (i % pn[j] == 0) {
        flg = 1;
        break;
      }
    }
    if (flg == 0) {
      pn[c_pn] = i;
      c_pn++;
      // cout<<i<<endl;
    }
    i += 2;

    flg = 0;
    for (j = 0; j < c_pn; j++) {
      if (i % pn[j] == 0) {
        flg = 1;
        break;
      }
    }
    if (flg == 0) {
      pn[c_pn] = i;
      c_pn++;
      // cout<<i<<endl;
    }
    i += 4;
  }
  // cout<<c_pn<<endl;

  for (i = 0; pn[i] <= n && i < c_pn; i++) {
    tmp = 0;
    do {
      if (n % pn[i] == 0) {
        tmp++;
        n = n / pn[i];
      } else {
        break;
      }
    } while (1);
    if (tmp != 0) {
      // cout<<pn[i]<<" "<<tmp<<" "<<n<<endl;
      // cout<<pow(2.0*double(tmp)-0.25,0.5)<<endl;
      res += long(pow(2 * tmp - 0.25, 0.5));
    }
  }

  if (n != 1) {
    res++;
  }

  cout << res << endl;

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

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

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  for (auto p : prime_factor(N)) {
    ll x = p.second;
    ll i = 1;
    while (x >= i) {
      x -= i;
      i++;
      ans++;
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  for (auto p : prime_factor(N)) {
    ll x = p.second;
    ll i = 1;
    while (x >= i) {
      x -= i;
      i++;
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  long long N;
  cin >> N;
  long long p = 2;
  long long count = 0;
  while (p * p <= N) {
    if (N % p != 0) {
      p++;
      continue;
    }

    long long z = p;
    while (N % z == 0) {
      N /= z;
      z *= p;
      count++;
    }

    while (N % p == 0)
      N /= p;
  }

  if (N != 1)
    count += 1;
  cout << count << endl;
}

Error: TLE

Fixed submission:

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

int main(void) {
  long long N;
  cin >> N;
  long long p = 2;
  long long count = 0;
  while (p * p <= N) {
    while (N % p != 0)
      p++;

    long long z = p;
    while (N % z == 0) {
      N /= z;
      z *= p;
      count++;
    }

    while (N % p == 0)
      N /= p;
  }

  if (N != 1)
    count += 1;
  cout << count << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1000000007;
const ll mod = 1000000007;
const double PI = 3.14159265358979323846;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

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

int cans(bool f) {
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

vector<pair<long long, long long>> prime_factorization(ll N) {
  vector<pair<long long, long long>> res;
  for (ll i = 2; i * i <= N; i++) {
    if (N % i != 0)
      continue;
    int ex = 0; // represent exponetial part
    while (N % i == 0) {
      ex++;
      N /= i;
    }
    res.push_back({i, ex});
  }
  if (N != 1) {
    res.push_back({N, 1});
  }
  return res;
}

int main() {
  long long N;
  cin >> N;
  auto pf = prime_factorization(N);
  long long res = 0;
  for (auto p : pf) {
    long long e = p.second;
    long long tmp = 0, cur = 1;
    while (e >= cur)
      e -= cur++, ++tmp;
    res += tmp;
  }
  cout << res << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1000000007;
const ll mod = 1000000007;
const double PI = 3.14159265358979323846;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

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

int cans(bool f) {
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

vector<pair<long long, long long>> prime_factorization(ll N) {
  vector<pair<long long, long long>> res;
  for (int i = 2; i * i <= N; i++) {
    if (N % i != 0)
      continue;
    int ex = 0; // represent exponetial part
    while (N % i == 0) {
      ex++;
      N /= i;
    }
    res.push_back({i, ex});
  }
  if (N != 1) {
    res.push_back({N, 1});
  }

  return res;
}

int main() {
  long long N;
  cin >> N;
  auto pf = prime_factorization(N);
  long long res = 0;
  for (auto p : pf) {
    long long e = p.second;
    long long tmp = 0, cur = 1;
    while (e >= cur)
      e -= cur++, ++tmp;
    res += tmp;
  }
  cout << res << endl;
}
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 namespace std;
#define pri(str) cout << str << endl
using ll = long long;
using P = pair<int, int>;

const ll MX = 1e18;
const long double PI = acos(-1);

vector<pair<ll, int>> divisor(ll n) {
  vector<pair<ll, int>> ret;
  for (ll i = 2; i * i <= n; ++i) {
    int x = 0;
    while (n % i == 0) {
      n /= i;
      ++x;
    }
    ret.emplace_back(i, x);
  }
  if (n != 1)
    ret.emplace_back(n, 1);
  return ret;
}

int main() {
  ll n;
  cin >> n;
  auto fs = divisor(n);

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


Error: TLE

Fixed submission:

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

const ll MX = 1e18;
const long double PI = acos(-1);

vector<pair<ll, int>> divisor(ll n) {
  vector<pair<ll, int>> ret;
  for (ll i = 1; i * i <= n; ++i) {
    int x = 0;
    while (n % i == 0) {
      n /= i;
      ++x;
    }
    ret.emplace_back(i, x);
  }
  if (n != 1)
    ret.emplace_back(n, 1);
  return ret;
}

int main() {
  ll n;
  cin >> n;
  auto fs = divisor(n);

  int ans = 0;
  for (auto a : fs) {
    int x = a.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      ++b;
      ++ans;
    }
  }
  pri(ans);
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

typedef pair<ll, ll> Pair;
int main() {

  ll N;

  cin >> N;

  vector<Pair> fs;

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

    ll cnt = 0;

    while (N % i == 0) {
      N /= i;
      ++cnt;
    }
    fs.emplace_back(i, cnt);
  }

  if (N != 1)
    fs.emplace_back(N, 1);

  ll ans = 0;

  for (Pair p : fs) {

    ll cnt = p.second;
    ll x = 1;
    while (x <= cnt) {
      cnt -= x;
      ++ans;
      ++x;
    }
  }

  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

typedef pair<ll, ll> Pair;
int main() {

  ll N;

  cin >> N;

  vector<Pair> fs;

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

    ll cnt = 0;

    while (N % i == 0) {
      N /= i;
      ++cnt;
    }
    fs.emplace_back(i, cnt);
  }

  if (N != 1)
    fs.emplace_back(N, 1);

  ll ans = 0;

  for (Pair p : fs) {

    ll cnt = p.second;
    ll x = 1;
    while (cnt != 0) {
      cnt -= x;
      ++ans;
      ++x;
    }
  }

  cout << ans << endl;

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  int ans = 0;
  for (ll i = 2; i * i <= n; i++)
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0)
        n /= i, cnt++;
      for (int j = 1; j <= cnt; j++) {
        cnt -= j;
        ans++;
      }
    }
  if (n != 1)
    ans++;
  printf("%d\\n", ans);
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);

map<ll, ll> primeFactors(ll n) {
  map<ll, ll> pf;
  while (n % 2 == 0) {
    n /= 2;
    pf[2]++;
  }
  for (int i = 3; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) {
        n /= i;
        pf[i]++;
      }
    }
  }
  if (n > 2)
    pf[n]++;
  return pf;
}
int main() {
  FAST ll n;
  cin >> n;
  ll sum[30];
  sum[0] = 1;
  for (int i = 1; i < 30; i++) {
    sum[i] = sum[i - 1] + i + 1;
  }
  map<ll, ll> p = primeFactors(n);
  ll ans = 0;
  for (auto it = p.begin(); it != p.end(); it++) {
    ll x = it->second;
    ans += (upper_bound(sum, sum + 30, x) - sum);
  }
  cout << ans;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long n;
  cin >> n;
  long long k = 2;
  int s = 0;
  while (k * k <= n) {
    if (n % k == 0) {
      int x = 0;
      while (n % k == 0) {
        x += 1;
        n = n / k;
      }
      int i = 1;
      while (x >= (i + 2) * (i + 1) / 2)
        i += 1;
      // cout << k << " " << i << endl;
      s += i;
    }
    k += 1;
  }
  if (n > 1)
    s += 1;
  cout << s;
}


Error: TLE

Fixed submission:

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

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

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

int main() {
  ll n;

  cin >> n;

  ll ans = 0;

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

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

    for (ll j = 1; j <= 100; j++) {
      if (e < j)
        break;
      e = e - j;
      ans++;
    }
  }

  if (n > 1)
    ans++;

  cout << ans << "\\n";

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

const ll maxn = 1e6 + 1;

// vector <ll> primes;
set<ll> primes;

void ESieve(ll n) {
  vector<bool> sieve(n + 1, true);

  sieve[0] = sieve[1] = false;

  for (ll i = 2; i <= n; i++) {
    if (sieve[i]) {
      // primes.push_back(i);
      primes.insert(i);

      for (ll j = i * i; j <= n; j += i) {
        sieve[j] = false;
      }
    }
  }
}

bool is_prime(ll n) {
  if (n < 2)
    return false;

  if (primes.count(n))
    return true;

  for (ll p : primes) {
    if (n % p == 0)
      return false;

    if (p * p > n)
      break;
  }

  return true;
}

bool is_prime_power(ll n) {
  if (is_prime(n))
    return true;

  for (ll p : primes) {
    if (n % p)
      continue;

    while (n % p == 0) {
      n = n / p;
    }

    if (n == 1)
      return true;
    else
      return false;
  }

  return true;
}

int main() {
  ll n;

  ESieve(maxn);

  cin >> n;

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

  if (is_prime(n)) {
    cout << 1 << "\\n";
  }

  ll ans = 0;

  for (ll z = 2; z <= n; z++) {
    if (is_prime_power(z)) {
      if (n % z == 0) {
        // cout << n << " " << z << "\\n";
        ans++;
        n = n / z;
      }
    }
  }

  cout << ans << "\\n";

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

#include <bits/stdc++.h>
using namespace std;
long long A;
int res = 0, ans[1000004];
int main() {
  cin >> A;
  ans[1] = 1;
  for (int i = 1; i <= 1e6; i++) {
    ans[i] = max(ans[i], ans[i - 1]);
    if (i + ans[i] + 1 <= 1e6)
      ans[i + ans[i] + 1] = ans[i] + 1;
  }
  for (int i = 2; 1ll * i * i <= A; i++) {
    int cnt = 0;
    while (A % i == 0)
      cnt++, A /= i;
    res += ans[cnt];
  }
  if (A > 1) {
    res++;
  }
  cout << res;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
long long A;
int res = 0, ans[1000004];
int main() {
  cin >> A;
  ans[1] = 1;
  for (int i = 1; i <= 1e6; i++) {
    ans[i] = max(ans[i], ans[i - 1]);
    if (i + ans[i] + 1 <= 1e6)
      ans[i + ans[i] + 1] = ans[i] + 1;
  }
  for (int i = 2; i * i <= A; i++) {
    int cnt = 0;
    while (A % i == 0)
      cnt++, A /= i;
    res += ans[cnt];
  }
  if (A > 1) {
    res++;
  }
  cout << res;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1000000007;
const ll mod = 1000000007;
const double PI = 3.14159265358979323846;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

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

int cans(bool f) {
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

vector<pair<long long, long long>> prime_factorization(ll N) {
  vector<pair<long long, long long>> res;
  for (ll p = 2; p * p <= N; p++) {
    if (N % p != 0)
      continue;
    int ex = 0; // exponetial part
    while (N % p == 0) {
      ex++;
      N /= p;
    }
    res.push_back({p, ex});
  }
  if (N != 1) {
    res.push_back({N, 1});
  }
  return res;
}
int main() {
  ll N;
  cin >> N;
  vector<pair<ll, ll>> a;
  a = prime_factorization(N);

  ll ans = 0;
  for (auto it : a) {
    ll num = it.second;
    ll cnt = 1;
    ll tmp = 0;
    while (num >= cnt) {
      num -= cnt;
      cnt++;
      tmp++;
    }
    ans += tmp;
  }

  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1000000007;
const ll mod = 1000000007;
const double PI = 3.14159265358979323846;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

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

int cans(bool f) {
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

vector<pair<long long, long long>> prime_factorization(ll N) {
  vector<pair<long long, long long>> res;
  for (int p = 2; p * p <= N; p++) {
    if (N % p != 0)
      continue;
    int ex = 0; // exponetial part
    while (N % p == 0) {
      ex++;
      N /= p;
    }
    res.push_back({p, ex});
  }
  if (N != 1) {
    res.push_back({N, 1});
  }
  return res;
}
int main() {
  ll N;
  cin >> N;
  vector<pair<ll, ll>> a;
  a = prime_factorization(N);

  ll ans = 0;
  for (auto it : a) {
    ll num = it.second;
    ll cnt = 1;
    ll tmp = 0;
    while (num >= cnt) {
      num -= cnt;
      cnt++;
      tmp++;
    }
    ans += tmp;
  }

  cout << ans << 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)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using G = vector<vector<int>>;

int main() {
  ll n;
  cin >> n;

  ll num = n;
  int ans = 0;

  for (ll i = 2; i * i < n; i++) {
    int keta = 1, count = 0;
    while (num % i == 0) {
      count++;
      if (keta == count) {
        ans++;
        count = 0;
        keta++;
      }
      num /= i;
    }
  }
  if (num != 1ll)
    ans++;

  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  ll n;
  cin >> n;

  ll num = n;
  int ans = 0;
  ll root = (ll)sqrt(n);
  ll i = 2, max = root;
  while (i <= max) {
    int keta = 1, count = 0;
    while (num % i == 0) {
      if (ans == 0)
        max = n;
      max /= i;
      count++;
      if (keta == count) {
        ans++;
        count = 0;
        keta++;
      }
      num /= i;
    }
    i++;
  }
  if (num == n && num != 1ll)
    ans++;

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

#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;
using ull = unsigned long long;
ll amari = 1000000007;
#define rep(n, x)                                                              \\
  for (ll i = 0; i < n; i++)                                                   \\
    cin >> x[i];
#define forr(a, b)                                                             \\
  for (ll i = a; i < b; i++)                                                   \\
    ;
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (0 < n) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll gcd(ll x, ll y) {
  if (x % y == 0)
    return y;
  else
    return gcd(y, x % y);
}
// 1or素数だと１を返す
ll prime(ll x) {
  for (ll i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return 0;
  }
  return 1;
}

int main() {
  ll n;
  cin >> n;
  ll k = n;
  ll x = sqrt(n);
  vector<ll> a(x + 10, 0);

  for (ll i = 2; i < x + 5; i++) {
    while (k % i == 0) {
      a[i]++;
      k /= i;
    }
  }

  ll ans = 0;
  ll y = 0;
  for (ll i = 0; i < x + 5; i++) {
    if (a[i] != 0) {
      y = 0;
      while (y * (y + 1) <= 2 * a[i]) {
        y++;
      }
      y--;
      ans += y;
    }
  }
  if (k != 1)
    ans++;
  cout << ans << "\\n";

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;
using ull = unsigned long long;
ll amari = 1000000007;
#define rep(n, x)                                                              \\
  for (ll i = 0; i < n; i++)                                                   \\
    cin >> x[i];
#define forr(a, b)                                                             \\
  for (ll i = a; i < b; i++)                                                   \\
    ;
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (0 < n) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll gcd(ll x, ll y) {
  if (x % y == 0)
    return y;
  else
    return gcd(y, x % y);
}
// 1or素数だと１を返す
ll prime(ll x) {
  for (ll i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return 0;
  }
  return 1;
}

int main() {
  ll n;
  cin >> n;
  ll k = n;
  ll x = sqrt(n);
  vector<ll> a(x, 0);
  ll i = 2;
  ll aa = 0;
  while (k != 1) {
    if (k % i == 0) {
      a[aa] += 1;
      k /= i;
    } else {
      i++;
      if (a[aa] != 0)
        aa++;
    }
  }
  ll ans = 0;
  ll y = 0;
  for (ll i = 0; i < x; i++) {
    y = 0;
    while (y * (y + 1) <= 2 * a[i]) {
      y++;
    }
    y--;
    if (a[i] != 0) {
      ans += y;
    }
  }

  cout << ans << "\\n";

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

#include <iostream>
#include <map>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    for (ll j = 1;; j++) {
      if (cnt >= j) {
        cnt -= j;
        ans++;
      } else
        break;
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <map>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  int ans = 0;
  for (int i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    for (ll j = 1;; j++) {
      if (cnt >= j) {
        cnt -= j;
        ans++;
      } else
        break;
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}