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 <bits/stdc++.h>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

const int MAX = 100010;
bool isprime[MAX];
int N;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  vector<LL> primes;
  fill(isprime, isprime+MAX, true);
  isprime[0] = isprime[1] = false;
  for(int i=2;i*i<=MAX;++i){
	if(isprime[i]){
	  primes.PB(i);
	  for(int j=i+i;j<MAX;j+=i)
		isprime[j] = false;
	}
  }
  
  cin >> N;
  map<LL,int> xs;
  map<LL,LL> cs;
  REP(i,N){
	LL x; cin >> x;
	LL tmp = 1;
	for(int j=0;j<SZ(primes);++j){
	  if(primes[j] > x) break;
	  if(x % primes[j] != 0) continue;
	  LL p = primes[j] * primes[j] * primes[j];
	  while(x % p == 0)
		x /= p;

	  if(x % (primes[j]*primes[j]) == 0)
		tmp *= primes[j];
	  else if(x % primes[j] == 0)
		tmp *= primes[j] * primes[j];
	}
	xs[x]++;
	cs[x] = tmp;
  }


  int ans = 0;
  set<LL> vis;
  for(auto& p: xs){
	if(vis.count(p.FF)) continue;
	if(p.FF == 1){
	  ++ans;
	  continue;
	}
	
	LL c = cs[p.FF];
	ans += max(p.SS, xs[c]);
	vis.insert(p.FF);
	vis.insert(c);
  }
  
  cout << ans << endl;
  
  return 0;
}