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>

#define int long long

#define For(i,a,b) for (int i = a; i <= (b); ++i)
#define For2(i,a,b) for (int i = a; i >= (b); --i)

#define test int _t; cin >> _t; while (_t--)

#define pii pair<int, int>
#define mpii map<int, int>
#define all(a) a.begin(), a.end()
#define pb push_back
#define fi first
#define se second
#define mp make_pair

#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define INF 2147483647
#define EPS 1e-9

#define DEBUG

//#define FILEOPEN

using namespace std;

#ifdef DEBUG

    #define debug(args...)     (Debugger()) , args

    class Debugger {
        public:
        Debugger(const std::string& _separator = " | ") :
        first(true), separator(_separator){}

        template<typename T> Debugger& operator , (const T& v) {
            if(!first) cerr << separator;
            cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() { cerr << endl; }
        
        private:
        bool first;
        string separator;
    };

#else
    #define debug(args...)                
#endif

int power(int x, int n, int p) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = (res * x) % p;
		x = (x * x) % p;
		n /= 2;
	}
	return res;
}

int power(int x, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = (res * x);
		x = (x * x);
		n /= 2;
	}
	return res;
}

bool sv[100005];
vector<int> primes;

void sieve(int n) {
	For(i,1,n) sv[i] = true;
	sv[1] = false;
	For(i,2,n) {
		if (sv[i]) {
			primes.pb(i);
			for (int j = i * i; j <= n; j += i) sv[j] = false; 
		}
	}
}

int Mod(int x, int p) {
	x %= p;
	while (x < 0) x += p;
	return x;
}

pii Hash(int n) {
	int N = n;
	int res = 1, rev = 1;
	for (int p: primes) {
		if (p > cbrt(n)) break;
		int a = 0;
		while (n % p == 0) n /= p, a++;
		res *= power(p, Mod(a, 3));
		if (a % 3 != 0) rev *= power(p, Mod(3 - a, 3));
		if (n == 1) break; 
	}
	if (n > 1e5) res = n, rev = n;
	if (n > 1) {
		if (sqrt(n) == (int)sqrt(n)) res *= n, rev *= (int)sqrt(n);
		else res *= n, rev *= n * n;
	}
	return mp(res, rev);
}

int a[100005];
unordered_map<int, int> f, tmpF, rev;

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	#ifdef FILEOPEN
		freopen("input.in", "r", stdin);
		freopen("input.out", "w", stdout);
	#endif
	int n;
	sieve(100000);
	cin >> n;
	For(i,1,n) {
		cin >> a[i];	
		pii t = Hash(a[i]);
		if (rev.find(t.fi) == rev.end()) rev[t.fi] = t.se;
		f[t.fi]++;
		//debug(t.fi, t.se);
	}
	int cnt = 0;
	tmpF = f;
	for (pii i: tmpF) {
		if (f.find(i.fi) == f.end() || f[i.fi] == 0) continue;
		if (i.fi == 1) {
			cnt++;
			continue;
		}
		if (f.find(rev[i.fi]) == f.end()) {
			cnt += i.se;
			f[i.fi] = 0;
		}
		else {
			cnt += max(f[i.fi], f[rev[i.fi]]);
			f[i.fi] = 0;
			f[rev[i.fi]] = 0;
		}
	}
	cout << cnt << endl;
}