Language: C++

#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 100005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<int>v(n);
    map<int,int>mp;
    ll mx = 0;
    for(auto &i:v){
        cin >> i;
        i >>= 1;
        int k = i;
        mx = max(mx, k);
        for(int j = 2 ; j <= sqrt(k) ; j++){
            if(k % j)continue;
            int cnt = 0;
            while(k % j == 0){
                cnt++;
                k /= j;
            }
            mp[j] = max(mp[j], cnt);
        }
        if(k > 1){
            mp[k] = max(mp[k], 1);
        }
    }
    ll lcm = 1;
    for(auto i:mp){
        while(i.S--){
            lcm *= i.F;
            if(lcm > k){
                cout << 0 << endl;
                exit(0);
            }
        }
    }
    for(auto i:v){
        if((lcm/i)%2==0){
            cout << 0 << endl;
            exit(0);
        }
    }
    k /= lcm;
    ll ans = k + 1 / 2;
    if(mx == lcm){
        ans--;
    }
    cout << ans << '\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:17: error: no matching function for call to 'max(long long int&, int&)'
   27 |         mx = max(mx, k);
      |              ~~~^~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:27:17: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   27 |         mx = max(mx, k);
      |              ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:27:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   27 |         mx = max(mx, k);
      |              ~~~^~~~~~~