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++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

const int MAX_PR = 300010;
// looking for all prime numbers
bool prime[MAX_PR];

map<LL, LL> prsquare;

vector<LL> a;

map<LL, pair<LL, int> > have;

int main() {	
	vector<LL> primes;
	primes.clear();
	SET(prime, 0);
	ffor (i, 2, MAX_PR)
		if (!prime[i]){
	    primes.pb(i);
			for (int j = 2 * i; j < MAX_PR; j += i)
				prime[j] = true;
	  }
	FOR (i, primes.sz)
		prsquare.insert(make_pair(1LL * primes[i] * primes[i], primes[i]));
	
	int n;
	cin >> n;
	FOR (i, n) {
		LL b;
		cin >> b;
		LL comp = 1LL;
		LL newb = 1LL;
		int idx = 0;
		while (primes[idx] <= 3333 && 1LL * primes[idx] * primes[idx] <= b) {
			int cnt = 0;
			while (b % primes[idx] == 0) {
				cnt++;
				b /= primes[idx];
			}
			cnt %= 3;
			FOR (j, cnt)
				newb *= primes[idx];
			FOR (j, (3 - cnt) % 3) {
				if (comp < 100000000000LL)
					comp *= primes[idx];
			}
			idx++;
		}
		newb *= b;
		if (prsquare.find(b) != prsquare.end()) {
			if (comp < 1000000000LL)
				comp *= prsquare[b];
			else
				comp = 100000000000LL;
		}
		else if (b < MAX_PR && prime[b]) {
			FOR (j, 2)
				if (comp < 100000000000LL)
					comp *= b;
		}
		else
			comp = 100000000000LL;
		if (have.find(newb) != have.end()) {
			if (newb != 1) {
				pair<LL, int> pp = have[newb];
				have[newb] = make_pair(pp.first, pp.second + 1);
			}
		}
		else {
			have.insert(make_pair(newb, make_pair(comp, 1)));
			a.pb(newb);
		}
	}
	int cnt = 0;
	FOR (i, a.sz) {
		pair<LL, int> pp = have[a[i]];
		if (!pp.second)
			continue;
		if (have.find(pp.first) != have.end()) {
			pair<LL, int> pp1 = have[pp.first];
			cnt += max(pp.second, pp1.second);
			have[pp.first] = make_pair(pp1.first, 0);
		}
		else
			cnt += pp.second;
	}
	cout << cnt << endl;
	return 0;
}