Language: C++

#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(mp(a,b),c)
#define pii pair<int,int>
#define piii pair<pii,int>
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pbc(x) __builtin_popcount(x)
#define clr(x) memset(x,0,sizeof x)
#define SIZE(x) (int)(x.size())
int mod;
IL ll pls(ll x,ll y){x+=y;return x>=mod?x-mod:x;}
IL ll dec(ll x,ll y){x-=y;return x<0?x+mod:x;}
IL ll mul(ll x,ll y){return (__int128)x*y%mod;}
IL ll mul(ll x,ll y,ll z){return mul(mul(x,y),z);}
IL ll mul(ll x,ll y,ll z,ll p){return mul(mul(x,y),mul(z,p));}
IL void add(int &x,int y){x+=y;x=(x>=mod)?x-mod:x;}
IL ll fpw(ll x,ll y,ll r=1){for(;y;y>>=1,x=mul(x,x))if(y&1)r=mul(r,x);return r;}
IL int inv(int x){return fpw(x,mod-2);}
IL int gi(){int x;int _w=scanf("%d",&x);return x;}
IL void gi(int &x){int _w=scanf("%d",&x);}
IL void write(int x){printf("%d\n",x);}
void chkmax(int &x,int y){x=(x>y)?x:y;}
void chkmin(int &x,int y){x=(x<y)?x:y;}
const int INF=0x3f3f3f3f;
template<typename T>IL void debug(T x){cerr<<x;return;}
/* --------------------------------------------------------------------------------------------------------- */
template<typename T>T read(){
	char ch;T u=0,f=1;
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){u=(u<<1)+(u<<3)+ch-48;ch=getchar();}
	return u*f;
}
namespace Rho{
	const int pri[]={2,3,5,7,11,13,17,19,23,29,31,37};
	IL bool Miller_Rabin(ll n){
		if((nn%6)!=1 && (nn%6)!=5) return false;
		mod=n;
		rep(i,0,8)if(n%pri[i]==0)return n==pri[i];
		ll r,t;
		for(r=n-1,t=0;~r&1;r>>=1,++t);
		rep(i,0,8){
			ll x=fpw(pri[i],r);
			for(int j=0;j<t&&x>1;++j){
				ll y=mul(x,x);
				if(y==1&&x!=n-1)return false;
				x=y;
			}
			if(x!=1)return false;
		}
		return true;
	}
	IL ll gcd(ll x,ll y){return !y?x:gcd(y,x%y);}
	IL ll func(ll x,ll a){return pls(mul(x,x),a);}
	IL ll Find(ll n,ll c){
		ll x=rand()%n+1, y=x, k=2;
		for(int i=1;;i++) {
			x=(mul(x,x)+c)%n;
			ll p=gcd(abs(y-x),n);
			if(p!=1) return p;
			if(i==k) k<<=1, y=x;
		}
	}
	IL void Pollard_Rho(ll n,vector<ll>&D){
		if(n==1||Miller_Rabin(n)){if(n!=1)D.pb(n);return;}
		ll d=n;while(d==n)d=Find(n,rand()%n);
		Pollard_Rho(n/d,D);Pollard_Rho(d,D);
	}
}
const int MOD=998244353998244353LL;
ll MUL(ll x,ll y){return (__int128)x*y%MOD;}
map<ll,int>num,rev,vis;
ll Fpw(ll x,ll y,ll r=1ll){for(;y;y>>=1,x=MUL(x,x))if(y&1)r=MUL(r,x);return r;}
int main(){
	srand(time(NULL));
	int n=gi();
	rep(i,1,n){
		ll ai=read<ll>();
		if(ai==1){rev[1]=1;num[1]++;continue;}
		vector<ll>D;
		Rho::Pollard_Rho(ai,D);
		sort(D.begin(),D.end());
		int l=1,val=D[0];ll X=1,Y=1;
		for(int i=1;i<D.size();++i){
			if(D[i]==val){l++;continue;}
			else {
				X=MUL(X,Fpw(val,l%3));
				Y=MUL(Y,Fpw(val,(3-l%3)%3));
				val=D[i];l=1;
			}
		}if(l){
			X=MUL(X,Fpw(val,l%3));
			Y=MUL(Y,Fpw(val,(3-l%3)%3));
		}rev[X]=Y;rev[Y]=X;num[X]++;
	}
	int ans=0;
	for(auto v:num){
		if(vis[v.fr])continue;
		if(v.fr==1)ans++;
		else ans+=max(v.se,num[rev[v.fr]]),vis[v.fr]=vis[rev[v.fr]]=1;
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'bool Rho::Miller_Rabin(long long int)':
a.cc:45:21: error: 'nn' was not declared in this scope; did you mean 'n'?
   45 |                 if((nn%6)!=1 && (nn%6)!=5) return false;
      |                     ^~
      |                     n
a.cc: At global scope:
a.cc:78:15: warning: overflow in conversion from 'long long int' to 'int' changes value from '998244353998244353' to '1998244353' [-Woverflow]
   78 | const int MOD=998244353998244353LL;
      |               ^~~~~~~~~~~~~~~~~~~~