Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n); 0<=i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());                   //昇順
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());    //降順
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper); 
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define SetPre(x) setprecision(x)

int main(void){
    //標準入力
    ll N;
    cin >> N;
    VL A(N);
    REP(i,N)
    {
        cin >> A.at(i);
        if( A.at(i) == 1)
        {
            //例外処理
            //数列のどこかに1がある場合、0になる（すべて1の倍数になってしまうため）
            cout << 0 << endl;
            return 0;
        }
    }
    V_SORT_U(A)
    //フラグ初期化
    VI flags(N);
    REP(i,N)
    {
        flags.at(i) = 0;
    }

    //小さい数の倍数になるものを弾いていき、最後まで残る奴が満たす数
    //エラトステネスの篩をやればOK？フラグを別管理する
    //そのままだとTLEするし、WAも出てくる
    //2*10^5個が出てくるので、二重ループだと4*10^10でTLE？
    //Aの成分が10^6の√である10^3までをエラトステネスで解けば十分かも？
    auto itr_over1000 = lower_bound( A.begin(), A.end(), 1000 );
    ll limit = min(N, itr_over1000 - A.begin());
    REP(i,limit)
    {
        //フラグがONしている数列はやる必要が無い
        if(flags.at(i) == 1) continue;

        for(ll j=i+1; j<N; j++)
        {
            if( (A.at(j) % A.at(i)) == 0 )
            {
                //割り切れる場合、フラグをONする
                flags.at(j) = 1;
            }
        }
    }
    
    //フラグが0の数をカウントして出力する
    ll count = 0;
    REP(i,N)
    {
        if( flags.at(i) == 0) count ++;
    }
    
    if( count != 1 )
    {
        cout << count << endl;
    }
    else{
        //1になる場合、i!=jの条件を満たさないので0を出力する
        cout << 0 << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:19: error: no matching function for call to 'min(ll&, __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type)'
   48 |     ll limit = min(N, itr_over1000 - A.begin());
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:48:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type' {aka 'long int'})
   48 |     ll limit = min(N, itr_over1000 - A.begin());
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:48:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   48 |     ll limit = min(N, itr_over1000 - A.begin());
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~