Language: C++

#include <bits/stdc++.h>

using namespace std;
using ll = long long ll;

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

bool is_prime(ll n) {
    ll k = pow(n, 0.5) + 1;
    for (ll i = 2; i < k; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

ll total_gcd(vector<ll> A) {
    ll ans = A[0];
    for (ll a : A) {
        ans = gcd(ans, a);
    }
    return ans;
}

int main() {
    ll N;
    cin >> N;
    ll prime_index = -1;
    ll prime_count = 0;
    vector<ll> A = vector<ll>();
    for (ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        A.emplace_back(a);
        if (is_prime(a)) {
            prime_count += 1;
            prime_index = i;
        }
    }
    if (prime_count == 0) {
        ll g = total_gcd(A);
        prime_index = -1;
        prime_count = 0;
        for (ll i = 0; i < N; i++) {
            A[i] /= g;
            if (is_prime(A[i])) {
                prime_count += 1;
                prime_index = i;
            }
        }
        if (prime_count != 1) {
            cout << g << endl;
        } else {
            A.erase(A.begin() + prime_index);
            cout << total_gcd(A) * g << endl;
        }
    } else if (prime_count >= 2) {
        cout << 1 << endl;
    } else {
        A.erase(A.begin() + prime_index);
        cout << total_gcd(A) << endl;
    }

    return 0;
}

Compiler output:
a.cc:4:21: error: expected ';' before 'll'
    4 | using ll = long long ll;
      |                     ^~~
      |                     ;
a.cc:6:1: error: 'll' does not name a type
    6 | ll gcd(ll a, ll b) {
      | ^~
a.cc:13:15: error: 'll' was not declared in this scope
   13 | bool is_prime(ll n) {
      |               ^~
a.cc:23:1: error: 'll' does not name a type
   23 | ll total_gcd(vector<ll> A) {
      | ^~
a.cc: In function 'int main()':
a.cc:32:5: error: 'll' was not declared in this scope
   32 |     ll N;
      |     ^~
a.cc:33:12: error: 'N' was not declared in this scope
   33 |     cin >> N;
      |            ^
a.cc:34:7: error: expected ';' before 'prime_index'
   34 |     ll prime_index = -1;
      |       ^~~~~~~~~~~~
      |       ;
a.cc:35:7: error: expected ';' before 'prime_count'
   35 |     ll prime_count = 0;
      |       ^~~~~~~~~~~~
      |       ;
a.cc:36:14: error: template argument 2 is invalid
   36 |     vector<ll> A = vector<ll>();
      |              ^
a.cc:36:29: error: template argument 2 is invalid
   36 |     vector<ll> A = vector<ll>();
      |                             ^
a.cc:37:12: error: expected ';' before 'i'
   37 |     for (ll i = 0; i < N; i++) {
      |            ^~
      |            ;
a.cc:37:20: error: 'i' was not declared in this scope
   37 |     for (ll i = 0; i < N; i++) {
      |                    ^
a.cc:38:11: error: expected ';' before 'a'
   38 |         ll a;
      |           ^~
      |           ;
a.cc:39:16: error: 'a' was not declared in this scope
   39 |         cin >> a;
      |                ^
a.cc:40:11: error: request for member 'emplace_back' in 'A', which is of non-class type 'int'
   40 |         A.emplace_back(a);
      |           ^~~~~~~~~~~~
a.cc:41:21: error: 'is_prime' cannot be used as a function
   41 |         if (is_prime(a)) {
      |             ~~~~~~~~^~~
a.cc:42:13: error: 'prime_count' was not declared in this scope
   42 |             prime_count += 1;
      |             ^~~~~~~~~~~
a.cc:43:13: error: 'prime_index' was not declared in this scope
   43 |             prime_index = i;
      |             ^~~~~~~~~~~
a.cc:46:9: error: 'prime_count' was not declared in this scope
   46 |     if (prime_count == 0) {
      |         ^~~~~~~~~~~
a.cc:47:11: error: expected ';' before 'g'
   47 |         ll g = total_gcd(A);
      |           ^~
      |           ;
a.cc:48:9: error: 'prime_index' was not declared in this scope
   48 |         prime_index = -1;
      |         ^~~~~~~~~~~
a.cc:50:16: error: expected ';' before 'i'
   50 |         for (ll i = 0; i < N; i++) {
      |                ^~
      |                ;
a.cc:50:24: error: 'i' was not declared in this scope
   50 |         for (ll i = 0; i < N; i++) {
      |                        ^
a.cc:51:21: error: 'g' was not declared in this scope
   51 |             A[i] /= g;
      |                     ^
a.cc:52:30: error: 'is_prime' cannot be used as a function
   52 |             if (is_prime(A[i])) {
      |                              ^
a.cc:58:21: error: 'g' was not declared in this scope
   58 |             cout << g << endl;
      |                     ^
a.cc:60:15: error: request for member 'erase' in 'A', which is of non-class type 'int'
   60 |             A.erase(A.begin() + prime_index);
      |               ^~~~~
a.cc:60:23: error: request for member 'begin' in 'A', which is of non-class type 'int'
   60 |             A.erase(A.begin() + prime_index);
      |                       ^~~~~
a.cc:61:21: error: 'total_gcd' was not declared in this scope
   61 |             cout << total_gcd(A) * g << endl;
      |                     ^~~~~~~~~
a.cc:61:36: error: 'g' was not declared in this scope
   61 |             cout << total_gcd(A) * g << endl;
      |                                    ^
a.cc:66:11: error: request for member 'erase' in 'A', which is of non-class type 'int'
   66 |         A.erase(A.begin() + prime_index);
      |           ^~~~~
a.cc:66:19: error: request for member 'begin' in 'A', which is of non-class type 'int'
   66 |         A.erase(A.begin() + prime_index);
      |                   ^~~~~
a.cc:66:29: error: 'prime_index' was not declared in this scope
   66 |         A.erase(A.begin() + prime_index);
      |                             ^~~~~~~~~~~
a.cc:67:17: error: 'total_gcd' was not declared in this scope
   67 |         cout << total_gcd(A) << endl;
      |                 ^~~~~~~~~