Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>
#include <unordered_map>
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else 
    #define dbg(x)
#endif

#define int long long
#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 100010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

unordered_map<vpii, int> cnt;
int ld[MX];

vpii pr(const vpii & a) {
    vpii res = a;
    fi(0, siz(a))
        res[i].second = (3 - a[i].second) % 3;
    return res;
}


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
       
    memset(ld, -1, sizeof(ld));
    vi ps;
    ps.reserve(10000);
    fi(2, MX) {
        if (ld[i] == -1) {
            ld[i] = i;
            ps.pb(i);
        }
        fx(x, ps) {
            if (x > ld[i] || x * i >= MX)
                break;
            ld[x * i] = x;
        }
    }
    int n;
    cin >> n;
    cnt.reserve(n);
    cnt.max_load_factor(0.25);
    int ans = 0;
    fi(0, n) {
        vpii fact;
        int x;
        cin >> x;
        fx(d, ps) { 
            if (d * d > x)
                break;
            if (x % d == 0) {
                fact.pb({d, 0});
                while (x % d == 0) {
                    fact.back().second++;
                    x /= d;
                }
                fact.back().second %= 3;
                if (!fact.back().second)
                    fact.ppb;
            }
        }
        if (x != 1) {
            if (x <= MX)
                fact.pb({x, 1});
            else {
                ++ans;
                continue;
            }
        }
        ++cnt[fact];
    }
    fx(x, cnt) {
        vpii op = pr(x.first);
        //print(x.first);
        //print(op);
        //dbg(x.second);
        if (op == x.first)
            ++ans;
        else {
            int sz1 = x.second;
            auto it = cnt.find(op);
            if (it == cnt.end())
                ans += sz1;
            else {
                int sz2 = it->second;
                if (sz1 > sz2)
                    ans += sz1;
                else if (sz1 == sz2 && x.first < op)
                    ans += sz1;
            }
        }
        //dbg(ans);
    }
    cout << ans << '\n';
}


Compiler output:
a.cc:92:26: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::vector<std::pair<long long int, long long int> >; _Tp = long long int; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _Pred = std::equal_to<std::vector<std::pair<long long int, long long int> > >; _Alloc = std::allocator<std::pair<const std::vector<std::pair<long long int, long long int> >, long long int> >]'
   92 | unordered_map<vpii, int> cnt;
      |                          ^~~
In file included from /usr/include/c++/14/unordered_map:41,
                 from a.cc:22:
/usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::vector<std::pair<long long int, long long int> >; _Tp = long long int; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _Pred = std::equal_to<std::vector<std::pair<long long int, long long int> > >; _Alloc = std::allocator<std::pair<const std::vector<std::pair<long long int, long long int> >, long long int> >]' is implicitly deleted because the default definition would be ill-formed:
  148 |       unordered_map() = default;
      |       ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::vector<std::pair<long long int, long long int> >; _Value = std::pair<const std::vector<std::pair<long long int, long long int> >, long long int>; _Alloc = std::allocator<std::pair<const std::vector<std::pair<long long int, long long int> >, long long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::vector<std::pair<long long int, long long int> > >; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]'
In file included from /usr/include/c++/14/bits/unordered_map.h:33:
/usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::vector<std::pair<long long int, long long int> >; _Value = std::pair<const std::vector<std::pair<long long int, long long int> >, long long int>; _Alloc = std::allocator<std::pair<const std::vector<std::pair<long long int, long long int> >, long long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::vector<std::pair<long long int, long long int> > >; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed:
  539 |       _Hashtable() = default;
      |       ^~~~~~~~~~
/usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::vector<std::pair<long long int, long long int> >; _Value = std::pair<const std::vector<std::pair<long long int, long long int> >, long long int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::vector<std::pair<long long int, long long int> > >; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]'
In file included from /usr/include/c++/14/bits/hashtable.h:35:
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::vector<std::pair<long long int, long long int> >; _Value = std::pair<const std::vector<std::pair<long long int, long long int> >, long long int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::vector<std::pair<long long int, long long int> > >; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed:
 1731 |       _Hashtable_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::vector<std::pair<long long int, long long int> >; _Value = std::pair<const std::vector<std::pair<long long int, long long int> >, long long int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]'
/usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::vector<std::pair<long long int, long long int> > >]':
/usr/include/c++/14/bits/hashtable_policy.h:1328:7:   required from here
 1328 |       _Hash_code_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::vector<std::pair<long long int, long long int> > >::hash()'
 1245 |       _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
      |                                                 ^~~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::vector<std::pair<long long int, long long int> > >::hash()' is implicitly deleted because the default definition would be ill-formed:
  102 |     struct hash : __hash_enum<_Tp>
      |            ^~~~
/usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::vector<std::pair<long long int, long long int> >, false>::__hash_enum()'
/usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::vector<std::pair<long long int, long long int> >; bool <anonymous> = false]'
   83 |       __hash_enum(__hash_enum&&);
      |       ^~~~~~~~~~~
/usr/include/c++/14/bits/functional_hash.h:83:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::vector<std::pair<long long int, long long int> >; bool <anonymous> = false]' is private within this context
  102 |     struct hash : __hash_enum<_Tp>
      |            ^~~~
/usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here
   84 |       ~__hash_enum();
      |       ^
/usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates
 1245 |       _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
      |                                                 ^~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::vector<std::pair<long long int, long long int> >; _Value = std::pair<const std::vector<std::pair<long long int, long long int> >, long long int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed:
 1328 |       _Hash_code_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::vector<std::pair<long long int, long long int> > >, true>::~_Hashtable_ebo_helper()'
/usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::vector<std::pair<long long int, long long int> > >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed:
 1242 |     struct _Hashtable_ebo_helper<_Nm, _Tp, true>
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::vector<std::pair<long long int, long long int> > >::~hash()'
/usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::vector<std::pair<long long int, long long int> > >::~hash()' is implicitly deleted because the default definition would be ill-formed:
  102 |     struct hash : __hash_enum<_Tp>
      |            ^~~~
/usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::vector<std::pair<long long int, long long int> >; bool <anonymous> = false]' is private within this context
/usr/include/c++/1