Language: C++

#include <bits/stdc++.h>
using namespace std;
namespace IO
{
    const int __S=(1<<20)+5;char __buf[__S],*__H,*__T;
    inline char getc()
    {
        if(__H==__T) __T=(__H=__buf)+fread(__buf,1,__S,stdin);
        if(__H==__T) return -1;return *__H++;
    }
    template <class __I>inline void read(__I &__x)
    {
        __x=0;int __fg=1;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1,__c=getc();
        while(isdigit(__c)) __x=__x*10+__c-'0',__c=getc();
        __x*=__fg;
    }
    inline void readd(double &__x)
    {
        __x=0;double __fg=1.0;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1.0,__c=getc();
        while(isdigit(__c)) __x=__x*10.0+__c-'0',__c=getc();
        if(__c!='.'){__x=__x*__fg;return;}else while(!isdigit(__c)) __c=getc();
        double __t=1e-1;while(isdigit(__c)) __x=__x+1.0*(__c-'0')*__t,__t=__t*0.1,__c=getc();
        __x=__x*__fg;
    }
    inline void reads(char *__s,int __x)
    {
        char __c=getc();int __tot=__x-1;
        while(__c<'!'||__c>'~') __c=getc();
        while(__c>='!'&&__c<='~') __s[++__tot]=__c,__c=getc();
        __s[++__tot]='\0';
    }
    char __obuf[__S],*__oS=__obuf,*__oT=__oS+__S-1,__c,__qu[55];int __qr;
    inline void flush(){fwrite(__obuf,1,__oS-__obuf,stdout);__oS=__obuf;}
    inline void putc(char __x){*__oS++ =__x;if(__oS==__oT) flush();}
    template <class __I>inline void print(__I __x)
    {
        if(!__x) putc('0');
        if(__x<0) putc('-'),__x=-__x;
        while(__x) __qu[++__qr]=__x%10+'0',__x/=10;
        while(__qr) putc(__qu[__qr--]);
    }
    inline void prints(const char *__s,const int __x)
    {
        int __len=strlen(__s+__x);
        for(int __i=__x;__i<__len+__x;__i++) putc(__s[__i]);
    }
    inline void printd(double __x,int __d)
    {
        long long __t=(long long)floor(__x);print(__t);putc('.');__x-=(double)__t;
        while(__d--)
        {
            double __y=__x*10.0;__x*=10.0;
            int __c=(int)floor(__y);
            putc(__c+'0');__x-=floor(__y);
        }
    }
    inline void el(){putc('\n');}inline void sp(){putc(' ');}
}using namespace IO;
#define ll long long
map<ll,ll>iv,cnt;ll a,p[100005];int n,vis[100005],tot,ans,gg;
int main()
{
    for(int i=2;i<=100000;i++)
    {
        if(!vis[i]) p[++tot]=i;
        for(int j=1;j<=tot&&i*p[j]<=100000;j++){vis[i*p[j]]=1;if(i%p[j]==0) break;}
    }
    read(n);for(int i=1;i<=n;i++)
    {
        read(a);ll t=a,val=1,inv=1;
        for(int j=1;j<=tot&&1ll*p[j]*p[j]*p[j]<=a;j++) if(t%p[j]==0)
        {
            int mi=0;while(t%p[j]==0) t/=p[j],mi++;mi%=3;
            for(int i=1;i<=mi;i++) val*=p[j];for(int i=1;i<=(3-mi)%3;i++) inv*=p[j];
        }
        if(t>1){val*=t;ll sq=sqrt(t);if(sq*sq==t) inv*=sq;else inv*=t*t;}
        if(val==1) gg=1;else cnt[val]++,iv[inv]=val,iv[val]=inv;
    }
    for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
    {
        if(cnt.find(iv[it->first])==cnt.end()) ans+=it->second;
        else ans+=max(it->second,cnt[iv[it->first]]),it->second=0,cnt[iv[it->first]]=0;
    }
    printf("%d\n",ans+gg);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:83:43: error: conversion from '_Rb_tree_iterator<pair<[...],long long int>>' to non-scalar type '_Rb_tree_iterator<pair<[...],int>>' requested
   83 |     for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
      |                                  ~~~~~~~~~^~
a.cc:83:48: 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::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'})
   83 |     for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
      |                                              ~~^~~~~~~~~~~
      |                                              |          |
      |                                              |          _Rb_tree_iterator<pair<[...],long long int>>
      |                                              _Rb_tree_iterator<pair<[...],int>>
In file included from /usr/include/c++/14/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
                 from a.cc:1:
/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:83:58: 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>'
   83 |     for(map<ll,int>::iterator it=cnt.begin();it!=cnt.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:83:58: 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>'
   83 |     for(map<ll,int>::iterator it=cnt.begin();it!=cnt.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:83:58: 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>'
   83 |     for(map<ll,int>::iterator it=cnt.begin();it!=cnt.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:83:58: note:   'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   83 |     for(map<ll,int>::iterator it=cnt.begin();it!=cnt.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:83:58: 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>'
   83 |     for(map<ll,int>::iterator it=cnt.begin();it!=cnt.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:83:58: note:   'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   83 |     for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
      |                                                          ^
/usr/include/c++/14/bits/regex.h:1647:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
 1647 |     operator!=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1647:5: note:   template argument deduction/substitution failed:
a.cc:83:58: 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>'
   83 |     for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
      |                                                          ^
/usr/include/c++/14/bits/regex.h:2213:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator!=(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
 2213 |     operator!=(const match_results<_Bi_iter, _Alloc>& __m1,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2213:5: note:   template argument deduction/substitution failed:
a.cc:83:58: 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::match_results<_BiIter, _Alloc>'
   83 |     for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
      |                                                          ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1052 |     operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1052:5: note:   template argument deduction/substitution failed:
a.cc:83:58: 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::pair<_T1, _T2>'
   83 |     for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
      |                                                          ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  455 |     operator!=(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:455:5: note:   template argument deduction/substitution failed:
a.cc:83:58: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<con