Language: C++

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
using namespace std;

void _DEBUG() {
    #ifndef _DEBUG
    freopen("input.in", "r", stdin);
    #endif
}

array<bool, static_cast<int>(2 * 1e5 + 1)> ref {};
unordered_map<int, int> freq {};

void Sieve(const vector<int> &arr) {
    for (int i {}; i < static_cast<int>(arr.size()); ++i) {
        if (ref.at(arr.at(i))) {
            for (int j {i+1}; j < static_cast<int>(arr.size()); ++j)
                if (!(arr.at(j)%arr.at(i)))
                    ref.at(arr.at(j)) = false;
        }
        if (freq.at(arr.at(i)) > 1) ref.at(arr.at(i)) = false;
    }
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // _DEBUG();

    ref.fill(true);

    int n {};
    cin >> n;
    vector<int> arr (n);
    for (int i {}; i < n; ++i) {
        cin >> arr.at(i);
        freq[arr.at(i)]++;
    }
    sort(arr.begin(), arr.end());

    Sieve(arr);

    int ans {};
    for (auto const &val: arr) {
        if (ref.at(val))
            ++ans;
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void Sieve(const std::vector<int>&)':
a.cc:19:13: error: reference to 'ref' is ambiguous
   19 |         if (ref.at(arr.at(i))) {
      |             ^~~
In file included from /usr/include/c++/14/string:52,
                 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/refwrap.h:445:5: note: candidates are: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(reference_wrapper<_Tp>)'
  445 |     ref(reference_wrapper<_Tp> __t) noexcept
      |     ^~~
/usr/include/c++/14/bits/refwrap.h:436:10: note:                 'template<class _Tp> void std::ref(const _Tp&&)'
  436 |     void ref(const _Tp&&) = delete;
      |          ^~~
/usr/include/c++/14/bits/refwrap.h:425:5: note:                 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)'
  425 |     ref(_Tp& __t) noexcept
      |     ^~~
a.cc:14:44: note:                 'std::array<bool, 200001> ref'
   14 | array<bool, static_cast<int>(2 * 1e5 + 1)> ref {};
      |                                            ^~~
a.cc:22:21: error: reference to 'ref' is ambiguous
   22 |                     ref.at(arr.at(j)) = false;
      |                     ^~~
/usr/include/c++/14/bits/refwrap.h:445:5: note: candidates are: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(reference_wrapper<_Tp>)'
  445 |     ref(reference_wrapper<_Tp> __t) noexcept
      |     ^~~
/usr/include/c++/14/bits/refwrap.h:436:10: note:                 'template<class _Tp> void std::ref(const _Tp&&)'
  436 |     void ref(const _Tp&&) = delete;
      |          ^~~
/usr/include/c++/14/bits/refwrap.h:425:5: note:                 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)'
  425 |     ref(_Tp& __t) noexcept
      |     ^~~
a.cc:14:44: note:                 'std::array<bool, 200001> ref'
   14 | array<bool, static_cast<int>(2 * 1e5 + 1)> ref {};
      |                                            ^~~
a.cc:24:37: error: reference to 'ref' is ambiguous
   24 |         if (freq.at(arr.at(i)) > 1) ref.at(arr.at(i)) = false;
      |                                     ^~~
/usr/include/c++/14/bits/refwrap.h:445:5: note: candidates are: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(reference_wrapper<_Tp>)'
  445 |     ref(reference_wrapper<_Tp> __t) noexcept
      |     ^~~
/usr/include/c++/14/bits/refwrap.h:436:10: note:                 'template<class _Tp> void std::ref(const _Tp&&)'
  436 |     void ref(const _Tp&&) = delete;
      |          ^~~
/usr/include/c++/14/bits/refwrap.h:425:5: note:                 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)'
  425 |     ref(_Tp& __t) noexcept
      |     ^~~
a.cc:14:44: note:                 'std::array<bool, 200001> ref'
   14 | array<bool, static_cast<int>(2 * 1e5 + 1)> ref {};
      |                                            ^~~
a.cc: In function 'int main()':
a.cc:33:5: error: reference to 'ref' is ambiguous
   33 |     ref.fill(true);
      |     ^~~
/usr/include/c++/14/bits/refwrap.h:445:5: note: candidates are: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(reference_wrapper<_Tp>)'
  445 |     ref(reference_wrapper<_Tp> __t) noexcept
      |     ^~~
/usr/include/c++/14/bits/refwrap.h:436:10: note:                 'template<class _Tp> void std::ref(const _Tp&&)'
  436 |     void ref(const _Tp&&) = delete;
      |          ^~~
/usr/include/c++/14/bits/refwrap.h:425:5: note:                 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)'
  425 |     ref(_Tp& __t) noexcept
      |     ^~~
a.cc:14:44: note:                 'std::array<bool, 200001> ref'
   14 | array<bool, static_cast<int>(2 * 1e5 + 1)> ref {};
      |                                            ^~~
a.cc:48:13: error: reference to 'ref' is ambiguous
   48 |         if (ref.at(val))
      |             ^~~
/usr/include/c++/14/bits/refwrap.h:445:5: note: candidates are: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(reference_wrapper<_Tp>)'
  445 |     ref(reference_wrapper<_Tp> __t) noexcept
      |     ^~~
/usr/include/c++/14/bits/refwrap.h:436:10: note:                 'template<class _Tp> void std::ref(const _Tp&&)'
  436 |     void ref(const _Tp&&) = delete;
      |          ^~~
/usr/include/c++/14/bits/refwrap.h:425:5: note:                 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)'
  425 |     ref(_Tp& __t) noexcept
      |     ^~~
a.cc:14:44: note:                 'std::array<bool, 200001> ref'
   14 | array<bool, static_cast<int>(2 * 1e5 + 1)> ref {};
      |                                            ^~~