Problem:
Score : 1100 points

Problem Statement

Snuke got positive integers s_1,...,s_N from his mother, as a birthday present. There may be duplicate elements.

He will circle some of these N integers. Since he dislikes cubic numbers, he wants to ensure that if both s_i and s_j (i ≠ j) are circled, the product s_is_j is not cubic. For example, when s_1=1,s_2=1,s_3=2,s_4=4, it is not possible to circle both s_1 and s_2 at the same time. It is not possible to circle both s_3 and s_4 at the same time, either.

Find the maximum number of integers that Snuke can circle.

Constraints

1 ≦ N ≦ 10^5

1 ≦ s_i ≦ 10^{10}

All input values are integers.

Input

The input is given from Standard Input in the following format:

N
s_1
:
s_N

Output

Print the maximum number of integers that Snuke can circle.

Sample Input 1

8
1
2
3
4
5
6
7
8

Sample Output 1

6

Snuke can circle 1,2,3,5,6,7.

Sample Input 2

6
2
4
8
16
32
64

Sample Output 2

3

Sample Input 3

10
1
10
100
1000000007
10000000000
1000000009
999999999
999
999
999

Sample Output 3

9

Solution in C++ (GCC 9.2.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>

using namespace std;

const long long maxn = 100010;
bitset<maxn> ciur;
long long prime[maxn];
unordered_map < long long, long long> cl;
unordered_map < long long, long long> invers;

pair <long long, long long> create(long long numar)
{
	long long ans=1;
	long long inv=1;
	long double logInv = 0;
	bool ok = true;
	for(int i=1;i<=prime[0]&&1ll*prime[i]*prime[i]<=numar&&numar>1;i++)
	{
		if(numar%prime[i]==0)
		{
			int power=0;
			while(numar%prime[i]==0)
			{
				power++;
				numar/=prime[i];
			}
			power=power%3;
			if(power==0) continue;
			if(power==1) {
				ans=ans*prime[i];
				if (ok) {
					inv = inv * prime[i] * prime[i];
					logInv += log2(prime[i] * prime[i]);
					if (logInv > 33.5) ok = false;
				}
			}
			else if(power==2) {
				ans=ans*(prime[i]*prime[i]);
				if (ok) {
					inv = inv * prime[i];
					logInv += log2(prime[i]);
					if (logInv > 33.5) ok = false;
				}
			}
		}
	}
	ans=ans*numar;
	inv = inv * numar * numar;
	logInv += log2(numar * numar);
	if (logInv > 33.5) ok = false;
	if (ok)
		return {ans, inv};
	return {ans, -1};
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	for(int i=2;i<=100000;i++)
	{
		if (ciur[i]==0)
		{
			ciur[i]=1;
			for (int j = i+i;j<=100000;j+=i)
				ciur[j] = 1;
			prime[++prime[0]]=i;
		}
	}
    int n;
    long long s=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        long long x;
        cin>>x;
        auto info = create(x);
        cl[info.first]++;
		invers[info.first] = info.second;
    }
	cl[-1] = -1;
	s = min(1ll, cl[1]);
    for(auto &x : cl)
    {
		if(x.first == 1) continue;
        if(x.second>0)
        {
            long long j=invers[x.first];
			if (x.first <= j || j == -1) {
           		if(cl[x.first]>cl[j]) s+=cl[x.first];
				else s+=cl[j];
			}
        }
    }
    cout<<s<<"\n";
	return 0;
}