Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <string>
#include <iomanip>
// #include <cmath>
#include <cassert>

using namespace std;

typedef int128_t ll;

const int MAX_SIZE = 4000;
bool isprime[MAX_SIZE];
vector<ll> prime_num;
vector<ll> squered;
vector<ll> cubed;
 
// const ll infty = 10000000010;
 
void init() {
  fill(isprime, isprime+MAX_SIZE, true);
  isprime[0] = isprime[1] = false;
  for (auto i=2; i<MAX_SIZE; i++) {
    if (isprime[i]) {
      ll x = i;
      prime_num.push_back(x);
      squered.push_back(x*x);
      cubed.push_back(x*x*x);
      for (auto j=2; i*j<MAX_SIZE; j++) {
        isprime[i*j] = false;
      }
    }
  }
}
 
bool prime(long long x) { // 2 \leq x \leq MAX_SIZE^2
  if (x < MAX_SIZE) {
    return isprime[x];
  }
  for (auto e : prime_num) {
    if (x%e == 0) return false;
  }
  return true;
}
 
int N;
ll s[100010];
map<ll, int> M;
 
ll conj(ll k) {
  ll l = k;
  ll A = 1;
  ll B = 1;
  for (auto x : prime_num) {
    int t = 0;
    while (l % x == 0) {
      l /= x;
      t++;
    }
    if (t == 1) {
      A *= x;
    } else if (t == 2) {
      B *= x;
    }
  }
  ll red = k / (A * B * B);
  ll sq = sqrt(red);
  long long t = static_cast<long long>(sq);
  t = floor(t);
  // cerr << "red = " << red << " , sq = " << sq << endl;
  if (red == t * t) {
    B *= red;
  } else {
    A *= red;
  }
  return A * A * B;
}
 
int main() {
  init();
  cin >> N;
  int ans = 0;
  for (auto i = 0; i < N; i++) {
    cin >> s[i];
    for (auto x : cubed) {
      while (s[i]%x == 0) s[i] /= x;
    }
    if (M.find(s[i]) == M.end()) {
      M[s[i]] = 1;
    } else {
      M[s[i]]++;
    }
  }
  for (auto x : M) {
    ll k = x.first;
    int num = x.second;
    // cerr << k << " " << num << endl;
    if (k == 1 && num > 0) {
      ans += 1;
      continue;
    }
    ll c = conj(k);
    // cerr << "conj(" << k << ") = " << c << endl;
    if (M.find(c) == M.end()) {
      ans += num;
    } else {
      ans += max(num, M[c]);
      M[k] = 0;
      M[c] = 0;      
    }
  }
  cout << ans << endl;
}

Compiler output:
a.cc:16:9: error: 'int128_t' does not name a type; did you mean 'int8_t'?
   16 | typedef int128_t ll;
      |         ^~~~~~~~
      |         int8_t
a.cc:20:8: error: 'll' was not declared in this scope
   20 | vector<ll> prime_num;
      |        ^~
a.cc:20:10: error: template argument 1 is invalid
   20 | vector<ll> prime_num;
      |          ^
a.cc:20:10: error: template argument 2 is invalid
a.cc:21:8: error: 'll' was not declared in this scope
   21 | vector<ll> squered;
      |        ^~
a.cc:21:10: error: template argument 1 is invalid
   21 | vector<ll> squered;
      |          ^
a.cc:21:10: error: template argument 2 is invalid
a.cc:22:8: error: 'll' was not declared in this scope
   22 | vector<ll> cubed;
      |        ^~
a.cc:22:10: error: template argument 1 is invalid
   22 | vector<ll> cubed;
      |          ^
a.cc:22:10: error: template argument 2 is invalid
a.cc: In function 'void init()':
a.cc:31:7: error: 'll' was not declared in this scope
   31 |       ll x = i;
      |       ^~
a.cc:32:17: error: request for member 'push_back' in 'prime_num', which is of non-class type 'int'
   32 |       prime_num.push_back(x);
      |                 ^~~~~~~~~
a.cc:32:27: error: 'x' was not declared in this scope
   32 |       prime_num.push_back(x);
      |                           ^
a.cc:33:15: error: request for member 'push_back' in 'squered', which is of non-class type 'int'
   33 |       squered.push_back(x*x);
      |               ^~~~~~~~~
a.cc:34:13: error: request for member 'push_back' in 'cubed', which is of non-class type 'int'
   34 |       cubed.push_back(x*x*x);
      |             ^~~~~~~~~
a.cc: In function 'bool prime(long long int)':
a.cc:46:17: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   46 |   for (auto e : prime_num) {
      |                 ^~~~~~~~~
      |                 std::begin
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
a.cc:46:17: error: 'end' was not declared in this scope; did you mean 'std::end'?
   46 |   for (auto e : prime_num) {
      |                 ^~~~~~~~~
      |                 std::end
/usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
a.cc: At global scope:
a.cc:53:1: error: 'll' does not name a type
   53 | ll s[100010];
      | ^~
a.cc:54:5: error: 'll' was not declared in this scope
   54 | map<ll, int> M;
      |     ^~
a.cc:54:12: error: template argument 1 is invalid
   54 | map<ll, int> M;
      |            ^
a.cc:54:12: error: template argument 3 is invalid
a.cc:54:12: error: template argument 4 is invalid
a.cc:56:1: error: 'll' does not name a type
   56 | ll conj(ll k) {
      | ^~
a.cc: In function 'int main()':
a.cc:90:12: error: 's' was not declared in this scope
   90 |     cin >> s[i];
      |            ^
a.cc:91:19: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   91 |     for (auto x : cubed) {
      |                   ^~~~~
      |                   std::begin
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
a.cc:91:19: error: 'end' was not declared in this scope; did you mean 'std::end'?
   91 |     for (auto x : cubed) {
      |                   ^~~~~
      |                   std::end
/usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
a.cc:94:11: error: request for member 'find' in 'M', which is of non-class type 'int'
   94 |     if (M.find(s[i]) == M.end()) {
      |           ^~~~
a.cc:94:27: error: request for member 'end' in 'M', which is of non-class type 'int'
   94 |     if (M.find(s[i]) == M.end()) {
      |                           ^~~
a.cc:100:17: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
  100 |   for (auto x : M) {
      |                 ^
      |                 std::begin
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
a.cc:100:17: error: 'end' was not declared in this scope; did you mean 'std::end'?
  100 |   for (auto x : M) {
      |                 ^
      |                 std::end
/usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
a.cc:101:5: error: 'll' was not declared in this scope
  101 |     ll k = x.first;
      |     ^~
a.cc:104:9: error: 'k' was not declared in this scope
  104 |     if (k == 1 && num > 0) {
      |         ^
a.cc:108:7: error: expected ';' before 'c'
  108 |     ll c = conj(k);
      |       ^~
      |       ;
a.cc:110:11: error: request for member 'find' in 'M', which is of non-class type 'int'
  110 |     if (M.find(c) == M.end()) {
      |           ^~~~
a.cc:110:16: error: 'c' was not declared in this scope
  110 |     if (M.find(c) == M.end()) {
      |                ^
a.cc:110:24: error: request for member 'end' in 'M', which is of non-class type 'int'
  110 |     if (M.find(c) == M.end()) {
      |                        ^~~
a.cc:114:9: error: 'k' was not declared in this scope
  114 |       M[k] = 0;
      |         ^