Language: C++

# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define step(n) rep(_, n)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define Unique(a) a.erase(unique(ALL(a)), a.end())
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LLONG_MAX)
# define LINT_MIN (LLONG_MIN)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr Type Square(Type x) { return x * x; }
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
#define Cin(Type, ...) Type __VA_ARGS__; _cin(__VA_ARGS__)
#define Cinv(Type, xs, n) vector<Type> xs(n); rep(i, n) cin >> xs[i]
#define Cinv2(Type, xs, ys, n) vector<Type> xs(n), ys(n); rep(i, n) cin >> xs[i] >> ys[i]
#define Cinv3(Type, xs, ys, zs, n) vector<Type> xs(n), ys(n), zs(n); rep(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinvv(Type, xs, h, w) vector<vector<Type>> xs(h, vector<int>(w)); rep(i, h) rep(j, w) cin >> xs[i][j]
void Print() { cout << endl; }
template <class Head, class... Tail> void Print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; Print(forward<Tail>(tail)...); }
template <class Type> void Print(vector<Type> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class Type> void Print(vector<vector<Type>> &df) { for (auto& vec : df) { Print(vec); } }
void Debug() { cerr << endl; }
template <class Head, class... Tail> void Debug(Head&& head, Tail&&... tail) { cerr << head; if (sizeof...(tail) != 0) cerr << " "; Debug(forward<Tail>(tail)...); }
template <class Type> void Debug(vector<Type> &vec) { for (auto& a : vec) { cerr << a; if (&a != &vec.back()) cerr << " "; } cerr << endl; }
template <class Type> void Debug(vector<vector<Type>> &df) { for (auto& vec : df) { Debug(vec); } }

vector<lint> divisor(lint n) {
    vector<lint> ret;
    for (lint i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n and i != 1) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int mp[1000010];
int main()
{
    Cin(lint, N);
    Cinv(lint, A, N);
    set<lint, lint> s;
    for (auto& it : A)
    {
        s.insert(it);
        mp[it]++;
    }

    sort(RALL(A));
    Debug(A);

    vector<vector<lint>> divss(N);
    rep (i, N)
    {
        divss[i] = divisor(A[i]);
    }
    Debug("//////");
    Debug(divss[0]);
    Debug("//////");

    lint cnt = 0;
    rep (i, N)
    {
        bool ok = true;
        rep (k, len(divss[i]))  // 自分自身は除く
        {
            if ((s.find(divss[i][k]) != s.end()) or (mp[A[i]] > 1)) 
            {
                ok = false;
                break;
            }
        }

        if (ok)
        {
            cnt++;
        }
    }

    Print(cnt);

    return 0;
}



Compiler output:
In file included from /usr/include/c++/14/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::iterator]':
/usr/include/c++/14/bits/stl_set.h:797:25:   required from 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::find(const key_type&) [with _Key = long long int; _Compare = long long int; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::const_iterator; key_type = long long int]'
  797 |       { return _M_t.find(__x); }
      |                ~~~~~~~~~^~~~~
a.cc:87:24:   required from here
   87 |             if ((s.find(divss[i][k]) != s.end()) or (mp[A[i]] > 1))
      |                  ~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:2532:40: error: expression cannot be used as a function
 2532 |               || _M_impl._M_key_compare(__k,
      |                  ~~~~~~~~~~~~~~~~~~~~~~^~~~~
 2533 |                                         _S_key(__j._M_node))) ? end() : __j;
      |                                         ~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>; key_type = long long int]':
/usr/include/c++/14/bits/stl_tree.h:2169:4:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = const long long int&; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>]'
 2169 |         = _M_get_insert_unique_pos(_KeyOfValue()(__v));
      |           ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:514:25:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = long long int; _Compare = long long int; _Alloc = std::allocator<long long int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<long long int>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::rebind<long long int>; typename _Alloc::value_type = long long int; value_type = long long int]'
  514 |           _M_t._M_insert_unique(__x);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc:65:17:   required from here
   65 |         s.insert(it);
      |         ~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_tree.h:2116:42: error: expression cannot be used as a function
 2116 |           __comp = _M_impl._M_key_compare(__k, _S_key(__x));
      |                    ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:2127:33: error: expression cannot be used as a function
 2127 |       if (_M_impl._M_key_compare(_S_key(__j._M_node), __k))
      |           ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_(_Base_ptr, _Base_ptr, _Arg&&, _NodeGen&) [with _Arg = const long long int&; _NodeGen = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::_Alloc_node; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::iterator; _Base_ptr = std::_Rb_tree_node_base*]':
/usr/include/c++/14/bits/stl_tree.h:2174:26:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = const long long int&; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>]'
 2174 |           return _Res(_M_insert_(__res.first, __res.second,
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
 2175 |                                  _GLIBCXX_FORWARD(_Arg, __v), __an),
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:514:25:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = long long int; _Compare = long long int; _Alloc = std::allocator<long long int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<long long int>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::rebind<long long int>; typename _Alloc::value_type = long long int; value_type = long long int]'
  514 |           _M_t._M_insert_unique(__x);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc:65:17:   required from here
   65 |         s.insert(it);
      |         ~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_tree.h:1824:56: error: expression cannot be used as a function
 1824 |                               || _M_impl._M_key_compare(_KeyOfValue()(__v),
      |                                  ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
 1825 |                                                         _S_key(__p)));
      |                                                         ~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_lower_bound(_Link_type, _Base_ptr, const _Key&) [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::iterator; _Link_type = std::_Rb_tree_node<long long int>*; _Base_ptr = std::_Rb_tree_node_base*]':
/usr/include/c++/14/bits/stl_tree.h:2530:36:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::iterator]'
 2530 |       iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);
      |                      ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:797:25:   required from 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::find(const key_type&) [with _Key = long long int; _Compare = long long int; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::const_iterator; key_type = long long int]'
  797 |       { return _M_t.find(__x); }
      |                ~~~~~~~~~^~~~~
a.cc:87:24:   required from here
   87 |             if ((s.find(divss[i][k]) != s.end()) or (mp[A[i]] > 1))
      |                  ~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1948:36: error: expression cannot be used as a function
 1948 |         if (!_M_impl._M_key_compare(_S_key(__x), __k))
      |              ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(_Const_Link_type) [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>; _Const_Link_type = const std::_Rb_tree_node<long long int>*]':
/usr/include/c++/14/bits/stl_tree.h:2116:47:   required from 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>; key_type = long long int]'
 2116 |           __comp = _M_impl._M_key_compare(__k, _