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# (Mono 4.6.2.0) (judge verdict: Time Limit Exceeded)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

class HashMap<K, V> : Dictionary<K, V>
{
    new public V this[K i]
    {
        get
        {
            V v;
            return TryGetValue(i, out v) ? v : base[i] = default(V);
        }
        set { base[i] = value; }
    }
}

public class Program
{
    private int N;
    private long[] S;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        S = new long[N];
        for (int i = 0; i < N; i++)
        {
            S[i] = sc.NextLong();
        }

        var c = new HashMap<BigInteger, int>();
        var p = new HashMap<BigInteger, BigInteger>();
        int ans = 0;
        foreach (long l in S)
        {
            long tmpl = l;
            BigInteger norm = 1;
            BigInteger pair = 1;

            for (long i = 2; i * i <= tmpl; i++)
            {
                if (tmpl % i == 0)
                {
                    int cnt = 0;
                    while (tmpl % i == 0)
                    {
                        cnt++;
                        tmpl /= i;
                    }

                    if (cnt % 3 == 1)
                    {
                        norm *= i;
                        pair *= i * i;
                    }
                    else if (cnt % 3 == 2)
                    {
                        norm *= i * i;
                        pair *= i;
                    }
                }
            }

            norm *= tmpl;
            pair *= (BigInteger) tmpl * tmpl;


            if (norm == 1)
            {
                ans = 1;
            }
            else
            {
                c[norm]++;
                p[norm] = pair;
            }

            // Console.WriteLine($"{l} {norm}");
        }
        
        var keys = c.Keys.ToArray();
        foreach (BigInteger bigInteger in keys)
        {
            
            // Console.WriteLine($"{bigInteger}:{c[bigInteger]} {p[bigInteger]}:{c[p[bigInteger]]}");
            ans += Math.Max(c[bigInteger], c[p[bigInteger]]);
            c[bigInteger] = 0;
            c[p[bigInteger]] = 0;
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}