Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL

const int mod = 1e9+7;
ll gcd(ll a,ll b){
	if(b==0)
	return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){
            ans = ans*base;
            ans = ans%mod;
        }
        base *= base;base%=mod;
        pow/=2;
    }return ans;
}
ll inv(ll x){
    return expo(x,mod-2);
}

double pi = 3.141592653589793238462643;
double error = 0.0000001;
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
/* -------Template ends here-------- */

const ll M = 2222;
const int M2 = 100011;
const ll lim = 1e12;

vector<ll> cubes , prime;

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


void sieve_type() {
    for (int i = 2; i < M; i++) {
        if (is_p(i)) cubes.push_back(1ll * i * i * i);
    }
    for (int i = 2; i < M2; i++) {
        if (is_p(i)) prime.push_back(i);
    }
}

ll divfac(ll x) {
    for (ll q : cubes) {
        if (q > x)break;
        while (x % q == 0) x /= q;
    }
    return x;
}

ll cal(ll a, ll b) {
    if (lim / b < a) return lim;
    return a * b;
}

ll complement(ll x) {
    ll y = 1;
    for (int p : prime) {
        if (1ll * p * p > x) break;
        if (x % p == 0) {
            if (((x / p) % p) == 0)
                y = mul(y, p), x /= p, x /= p;
            else
                y = mul(y, mul(p, p)), x /= p;
        }
    }
    if (x != 1) y = mul(y, mul(x, x));
    return y;
}
map<ll, int> look;
set<ll> done;
int main() {
    int n;
    scanf("%d", &n);
    sieve_type();

    for (int i = 1 ; i <= n ; i++) {
        ll x;
        scanf("%lld", &x);
        x = divfac(x);
        look[x]++;
    }
    int ans = 0;

    for (auto pr : look) {
        ll x = pr.first;
        int c = pr.second;
        ll y = complement(x);

        if (used.count(x))continue;

        if (x == y) {
            ans++;
            continue;
        }
         if (cnt.count(y)) {
                ans += max(c, divfac[y]);
                done.insert(y);
                done.insert(x);
            } else {
                done.insert(x);
                ans += c;
            }
    }
    printf("%d\n", ans);
}





Compiler output:
a.cc: In function 'long long int complement(long long int)':
a.cc:76:21: error: 'mul' was not declared in this scope; did you mean 'fmul'?
   76 |                 y = mul(y, p), x /= p, x /= p;
      |                     ^~~
      |                     fmul
a.cc:78:28: error: 'mul' was not declared in this scope; did you mean 'fmul'?
   78 |                 y = mul(y, mul(p, p)), x /= p;
      |                            ^~~
      |                            fmul
a.cc:78:21: error: 'mul' was not declared in this scope; did you mean 'fmul'?
   78 |                 y = mul(y, mul(p, p)), x /= p;
      |                     ^~~
      |                     fmul
a.cc:81:28: error: 'mul' was not declared in this scope; did you mean 'fmul'?
   81 |     if (x != 1) y = mul(y, mul(x, x));
      |                            ^~~
      |                            fmul
a.cc:81:21: error: 'mul' was not declared in this scope; did you mean 'fmul'?
   81 |     if (x != 1) y = mul(y, mul(x, x));
      |                     ^~~
      |                     fmul
a.cc: In function 'int main()':
a.cc:104:13: error: 'used' was not declared in this scope
  104 |         if (used.count(x))continue;
      |             ^~~~
a.cc:110:14: error: 'cnt' was not declared in this scope; did you mean 'int'?
  110 |          if (cnt.count(y)) {
      |              ^~~
      |              int
a.cc:111:39: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  111 |                 ans += max(c, divfac[y]);
      |                                       ^
a.cc:111:27: error: no matching function for call to 'max(int&, long long int (&)(long long int))'
  111 |                 ans += max(c, divfac[y]);
      |                        ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:111:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int(long long int)')
  111 |                 ans += max(c, divfac[y]);
      |                        ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:111:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  111 |                 ans += max(c, divfac[y]);
      |                        ~~~^~~~~~~~~~~~~~