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 <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

int nextInt()
{
    int y = 0;
    char c = getchar();
    while ('0' <= c && c <= '9')
    {
        y = 10 * y + c - '0';
        c = getchar();
    }
    return y;
}

long long max(long long a, long long b)
{
    if (a > b) return a;
    return b;
}

long long min(long long a, long long b)
{
    if (a < b) return a;
    return b;
}

unsigned long long n;
unsigned long long a[500000];
unsigned long long b[500000];
unsigned long long k[500000];

const unsigned long long INF = 1e10;

map<pair<unsigned long long, unsigned long long>, int> c;

unsigned long long Msqrt(unsigned long long r)
{
    unsigned long long f = sqrt(r);
    while (f * f < r) f++;
    while (f * f > r) f--;
    if (f * f == r) return f;
    return -1;
}

signed main()
{
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> k[i];
        for (ll j = 2; j * j * j <= INF; j++)
        {
            while (k[i] % (j * j * j) == 0)
            {
                k[i] /= j * j * j;
            }
        }
        a[i] = k[i];
    }
    for (int i = 0; i < n; i++)
    {
        unsigned long long simmetrical = 1;
        for (ll j = 2; j * j * j <= INF; j++)
        {
            int cnt = 0;
            while (a[i] % j == 0)
            {
                cnt++;
                a[i] /= j;
            }
            if (cnt == 1)
            {
                simmetrical *= j * j;
                if (simmetrical > INF) simmetrical = INF + 1;
            }
            if (cnt == 2)
            {
                simmetrical *= j;
                if (simmetrical > INF) simmetrical = INF + 1;
            }
        }
        c[{k[i], a[i]}]++;
        b[i] = simmetrical;
    }
    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (Msqrt(a[i]) != -1)
        {
            unsigned long long s = Msqrt(a[i]);
            if (k[i] == 1 && b[i] == 1 && c[{k[i], b[i]}]) ans ++;
            else ans += max(c[{k[i], a[i]}], c[{b[i], s}]);
            //if (k[i] == b[i] && a[i] == s) cout << 1 << endl;
            //else cout << max(c[{k[i], a[i]}], c[{b[i], s}]) << endl;
            //cout << "(" << k[i] << ", " << a[i] << ") - (" << b[i] << ", " << s << ") " << endl;
            c[{k[i], a[i]}] = 0;
            c[{b[i], s}] = 0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        ans += c[{k[i], a[i]}];
        c[{k[i], a[i]}] = 0;
    }
    cout << ans;
}