Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

// питер паркер эй! люблю мэри джэйн)
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame                                                                \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vlli vector<lli>
#define vulli vector<ulli>
#define vchar vector<char>
#define vstr vector<string>
#define vb vector<bool>
#define fst first
#define sec second
#define srt(a) sort(a.begin(), a.end())
#define vpii vector<pair<int, int>>
#define pii pair<int, int>
#define vplli vector<pair<lli, lli>>
#define vpulli vector<pair<ulli, ulli>>
#define vvi vector<vector<int>>
#define vvpii vector<vector<pair<int, int>>>
#define vvb vector<vector<bool>>
#define fr(i, n) for (int i = 0; i < (n); i++)
#define frbig(i, n) for (lli i = 0; i < (n); i++)
#define fra(i, a, n) for (lli i = a; i < (n); i++)
#define run(c, s) for (auto c : s)
#define read(n)                                                                \\
  int n;                                                                       \\
  cin >> n;
#define read2(x, y)                                                            \\
  int x, y;                                                                    \\
  cin >> x >> y;
#define read2ll(x, y)                                                          \\
  long long int x, y;                                                          \\
  cin >> x >> y;
#define readll(n)                                                              \\
  lli n;                                                                       \\
  cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i, x.size()) cout << x[i] << " ";
using namespace std;
const lli MOD = 1e9 + 7;
int ans = 0;
void lol(lli &n) {
  bool rap = 0;
  for (lli i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      rap = 1;
      int k = 0, a = 1;
      while (n % i == 0) {
        k++;
        n /= i;
      }
      while (k >= a) {
        ans++;
        k -= a;
        a++;
      }
      break;
    }
  }
  if (!rap) {
    ans++;
    n = 1;
  }
}
int main() {
  rapgame readll(n);
  while (n != 1) {
    lol(n);
  }
  cout << ans;
  return 0;
}

Error: TLE

Fixed submission:

// питер паркер эй! люблю мэри джэйн)
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame                                                                \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vlli vector<lli>
#define vulli vector<ulli>
#define vchar vector<char>
#define vstr vector<string>
#define vb vector<bool>
#define fst first
#define sec second
#define srt(a) sort(a.begin(), a.end())
#define vpii vector<pair<int, int>>
#define pii pair<int, int>
#define vplli vector<pair<lli, lli>>
#define vpulli vector<pair<ulli, ulli>>
#define vvi vector<vector<int>>
#define vvpii vector<vector<pair<int, int>>>
#define vvb vector<vector<bool>>
#define fr(i, n) for (int i = 0; i < (n); i++)
#define frbig(i, n) for (lli i = 0; i < (n); i++)
#define fra(i, a, n) for (lli i = a; i < (n); i++)
#define run(c, s) for (auto c : s)
#define read(n)                                                                \\
  int n;                                                                       \\
  cin >> n;
#define read2(x, y)                                                            \\
  int x, y;                                                                    \\
  cin >> x >> y;
#define read2ll(x, y)                                                          \\
  long long int x, y;                                                          \\
  cin >> x >> y;
#define readll(n)                                                              \\
  lli n;                                                                       \\
  cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i, x.size()) cout << x[i] << " ";
using namespace std;
const lli MOD = 1e9 + 7;
int ans = 0;
void lol(lli n) {
  bool rap = 0;
  for (lli i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      rap = 1;
      int k = 0, a = 1;
      while (n % i == 0) {
        k++;
        n /= i;
      }
      while (k >= a) {
        ans++;
        k -= a;
        a++;
      }
    }
    break;
  }
  if (!rap) {
    ans++;
    n = 1;
  }
}
int main() {
  rapgame readll(n);
  while (n != 1) {
    lol(n);
  }
  cout << ans;
  return 0;
}