Language: C++

#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
#pragma GCC optimize(3)
#define ll long long
#define int long long
#define ljc 998244353
using namespace std;
inline ll read(){
	ll x=0,f=1;char ch=getchar();
	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)){x=x*10ll+ch-'0';ch=getchar();}
	return x*f;
}
inline ll fast_pow(ll a,ll b,ll p){
    ll t=1;a%=p;
    while (b){
        if (b&1) t=t*a%p;
        b>>=1;a=a*a%p;
    }
    return t;
}
int A[101010][2];
int p[101010],tot,n,a[101010];
bool vis[101010];
map<int,int> cac,rev;
signed main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=2;i<=100000;i++){
		if (!vis[i]) p[++tot]=i;
		for (int j=1;j<=tot;j++){
			if (1ll*p[j]*i>100000) break;
			vis[p[j]*i]=1;
			if (i%p[j]==0) break;
		}
	}	
	ll _=0;
  	int all=0,flag=0;
  	sort(a+1,a+1+n);
	for (int i=1;i<=n;i++){
		int tmp=a[i];
		for (int j=1;p[j]*p[j]<=tmp&&j<=tot;j++,all++){
			if (tmp==1) break;
          if (all>600000000){
          	flag=1;break;
          }
			if (tmp%p[j]==0){
				for (;tmp%p[j]==0&&tmp;tmp/=p[j]);
			}
		}
      if (flag==1) break;
	}
  all=0;
	for (int i=1;i<=n;i++){
		int tmp=a[i];
		for (int j=1;p[j]*p[j]<=tmp&&j<=tot;j++,all++){
          if (flag&&all>1000000){
          		all-=50;break;
          }
			if (tmp==1) break;
			if (tmp%p[j]==0){
				int cnt=0;
				for (;tmp%p[j]==0&&tmp;tmp/=p[j],cnt++);
				cnt%=3;
				if (A[i][0]) A[i][0]*=(cnt>0?p[j]:1)*(cnt>1?p[j]:1);
				else A[i][0]=(cnt>0?p[j]:0)*(cnt>1?p[j]:1);
				cnt=3-cnt;cnt%=3;
				if (A[i][1]) A[i][1]*=(cnt>0?p[j]:1)*(cnt>1?p[j]:1);
				else A[i][1]=(cnt>0?p[j]:0)*(cnt>1?p[j]:1);
			}
		}
		if (tmp>1&&tmp<=100000){
			if (A[i][0]) A[i][0]*=tmp;
			else A[i][0]=tmp;
			if (A[i][1]) A[i][1]*=tmp*tmp;
			else A[i][1]=tmp*tmp;
		}
		if (tmp>100000){
			_++;
		}else{
			cac[A[i][0]]++;
			rev[A[i][0]]=A[i][1];
			rev[A[i][1]]=A[i][0];		
		}
	}
	for (auto j:cac){
		if (j.first&&j.second){
			_+=max(j.second,cac[rev[j.first]]);	
			cac[rev[j.first]]=0;
		}
	}
	cout<<_+(cac[0]>0);
	return 0;
}


Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:6:
/usr/include/c++/14/bits/allocator.h: In destructor '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> > >::_Rb_tree_impl<std::less<long long int>, true>::~_Rb_tree_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::_Rb_tree_node<std::pair<const long long int, long long int> >]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_tree.h:658:16: note: called from here
  658 |         struct _Rb_tree_impl
      |                ^~~~~~~~~~~~~