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 int M = 100001;

vector<ll> prime;
bool isP[M];

void sieve(){
    isP[1] = 1;
    for(int i = 2 ; i < M ; i++){
        if(isP[i]) continue;
        prime.push_back(i);
        for(ll j = i * 1LL * i ; j < M ; j += i){
            isP[j] = 1;
        }
    }
}

ll fin(ll x){
    ll res = x;
    for(int i = 0 ; i < prime.size() ; i++){
        ll ex = prime[i] * prime[i] * prime[i];
        if(ex > res) break;
        while(res%ex == 0) res /= ex;
    }
    return res;
}

ll complement(ll x){
    ll res = 1;
    for(int i = 0 ; i < prime.size() ; i++){
        if(prime[i] * prime[i] > x) break;
        ll ex = prime[i];
        if(x%ex == 0){
            x/=ex;
            if(x%ex == 0){
                x/=ex;
                res *= ex;
            }
            else{
                res *= ex;
                res *= ex;
            }
        }
    }
    if(x > 1){
        res *= x;
        res *= x;
    }
    return res;
}

unordered_map<ll , int> divfac;
unordered_set<ll> done;

int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);


    sieve();
    int n;
    si(n);
    for(int i = 1 ;  i <= n ; i++){
        ll el;
        sll(el);
        ll ex = fin(el);
        //cout<<el <<"   "<<ex<<endl;
        divfac[ex]++;
    }
    map<ll , int> :: iterator it;

    int ans = 0;

    for(it = divfac.begin() ; it != divfac.end() ; it++){
        ll el = it->first;
        int times = it->second;

        if(el == 1){
            ans++;
            continue;
        }

        ll c_el = complement(el);

        if(done.count(el)) continue;

        ans += max(times , divfac[c_el]);
        done.insert(el);
        done.insert(c_el);
    }
    printf("%d\n" , ans);
















}














Compiler output:
a.cc: In function 'int main()':
a.cc:106:27: error: no match for 'operator=' (operand types are 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} and 'std::unordered_map<long long int, int>::iterator' {aka 'std::__detail::_Insert_base<long long int, std::pair<const long long int, int>, std::allocator<std::pair<const long long int, int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'})
  106 |     for(it = divfac.begin() ; it != divfac.end() ; it++){
      |                           ^
In file included from /usr/include/c++/14/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_tree.h:252:12: note: candidate: 'constexpr std::_Rb_tree_iterator<std::pair<const long long int, int> >& std::_Rb_tree_iterator<std::pair<const long long int, int> >::operator=(const std::_Rb_tree_iterator<std::pair<const long long int, int> >&)'
  252 |     struct _Rb_tree_iterator
      |            ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:252:12: note:   no known conversion for argument 1 from 'std::unordered_map<long long int, int>::iterator' {aka 'std::__detail::_Insert_base<long long int, std::pair<const long long int, int>, std::allocator<std::pair<const long long int, int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'} to 'const std::_Rb_tree_iterator<std::pair<const long long int, int> >&'
/usr/include/c++/14/bits/stl_tree.h:252:12: note: candidate: 'constexpr std::_Rb_tree_iterator<std::pair<const long long int, int> >& std::_Rb_tree_iterator<std::pair<const long long int, int> >::operator=(std::_Rb_tree_iterator<std::pair<const long long int, int> >&&)'
/usr/include/c++/14/bits/stl_tree.h:252:12: note:   no known conversion for argument 1 from 'std::unordered_map<long long int, int>::iterator' {aka 'std::__detail::_Insert_base<long long int, std::pair<const long long int, int>, std::allocator<std::pair<const long long int, int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'} to 'std::_Rb_tree_iterator<std::pair<const long long int, int> >&&'
a.cc:106:34: error: no match for 'operator!=' (operand types are 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} and 'std::unordered_map<long long int, int>::iterator' {aka 'std::__detail::_Insert_base<long long int, std::pair<const long long int, int>, std::allocator<std::pair<const long long int, int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'})
  106 |     for(it = divfac.begin() ; it != divfac.end() ; it++){
      |                               ~~ ^~ ~~~~~~~~~~~~
      |                               |               |
      |                               |               std::unordered_map<long long int, int>::iterator {aka std::__detail::_Insert_base<long long int, std::pair<const long long int, int>, std::allocator<std::pair<const long long int, int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator}
      |                               std::map<long long int, int>::iterator {aka std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator}
In file included from /usr/include/c++/14/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181:
/usr/include/c++/14/bits/regex.h:1132:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
 1132 |     operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1132:5: note:   template argument deduction/substitution failed:
a.cc:106:48: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  106 |     for(it = divfac.begin() ; it != divfac.end() ; it++){
      |                                                ^
/usr/include/c++/14/bits/regex.h:1212:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
 1212 |     operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1212:5: note:   template argument deduction/substitution failed:
a.cc:106:48: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
  106 |     for(it = divfac.begin() ; it != divfac.end() ; it++){
      |                                                ^
/usr/include/c++/14/bits/regex.h:1305:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
 1305 |     operator!=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1305:5: note:   template argument deduction/substitution failed:
a.cc:106:48: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  106 |     for(it = divfac.begin() ; it != divfac.end() ; it++){
      |                                                ^
/usr/include/c++/14/bits/regex.h:1379:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
 1379 |     operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1379:5: note:   template argument deduction/substitution failed:
a.cc:106:48: note:   'std::unordered_map<long long int, int>::iterator' {aka 'std::__detail::_Insert_base<long long int, std::pair<const long long int, int>, std::allocator<std::pair<const long long int, int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  106 |     for(it = divfac.begin() ; it != divfac.end() ; it++){
      |                                                ^
/usr/include/c++/14/bits/regex.h:1473:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
 1473 |     operator!=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1473:5: note:   template argument deduction/substitution failed:
a.cc:106:48: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  106 |     for(it = divfac.begin() ; it != divfac.end() ; it++){
      |                                                ^
/usr/include/c++/14/bits/regex.h:1547:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
 1547 |     operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1547:5: note:   template argument deduction/substitution failed:
a.cc:106:48: note:   'std::unordered_map<long long int, int>::iterator' {aka 'std::__detail::_Insert_base<long long int, std::pair<const long long int, int>, std::allocator<std::pair<const long long int, int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'} is not derived from