Language: C++

#include <algorithm>
#include <iostream>
#include <numeric>
#include <type_traits>
#include <vector>
using namespace std;

template <class M, class N>
common_type_t<M, N> gcd(M a, N b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

template <class M, class N>
common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

int main(int argc, const char *argv[]) {
  using ll = long long;
  int n, m;
  cin >> n >> m;
  m *= 2;

  vector<ll> va(n);
  for (auto &a : va) {
    cin >> a;
  }

  ll v_lcm = accumulate(va.begin(), va.end(), 1ll,
                        [](auto acc, auto cur) { return lcm(acc, cur); });
  bool lcm_is_csm = all_of(va.begin(), va.end(), [&](auto a) {
    a % v_lcm == 0 && a / v_lcm % 2 == 1;
  });

  ll ans = 0;
  for (ll i = lcm_is_csm ? 1 : 2; i <= m; i += v_lcm * 2) {
    ans++;
  }

  cout << ans << "\n";
  return 0;
}

Compiler output:
a.cc: In instantiation of 'main(int, const char**)::<lambda(auto:1, auto:2)> [with auto:1 = long long int; auto:2 = long long int]':
/usr/include/c++/14/bits/stl_numeric.h:169:22:   required from '_Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation) [with _InputIterator = __gnu_cxx::__normal_iterator<long long int*, vector<long long int> >; _Tp = long long int; _BinaryOperation = main(int, const char**)::<lambda(auto:1, auto:2)>]'
  169 |         __init = __binary_op(_GLIBCXX_MOVE_IF_20(__init), *__first);
      |                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:33:24:   required from here
   33 |   ll v_lcm = accumulate(va.begin(), va.end(), 1ll,
      |              ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
   34 |                         [](auto acc, auto cur) { return lcm(acc, cur); });
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:34:60: error: call of overloaded 'lcm(long long int&, long long int&)' is ambiguous
   34 |                         [](auto acc, auto cur) { return lcm(acc, cur); });
      |                                                         ~~~^~~~~~~~~~
a.cc:18:21: note: candidate: 'std::common_type_t<_Mn, _Nn> lcm(M, N) [with M = long long int; N = long long int; std::common_type_t<_Mn, _Nn> = long long int]'
   18 | common_type_t<M, N> lcm(M a, N b) {
      |                     ^~~
In file included from a.cc:3:
/usr/include/c++/14/numeric:188:5: note: candidate: 'constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn) [with _Mn = long long int; _Nn = long long int; common_type_t<_Mn, _Nn> = long long int]'
  188 |     lcm(_Mn __m, _Nn __n) noexcept
      |     ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/algorithm:60,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_negate<_Predicate>::operator()(_Iterator) [with _Iterator = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _Predicate = main(int, const char**)::<lambda(auto:3)>]':
/usr/include/c++/14/bits/stl_algobase.h:2107:14:   required from '_RandomAccessIterator std::__find_if(_RandomAccessIterator, _RandomAccessIterator, _Predicate, random_access_iterator_tag) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<long long int*, vector<long long int> >; _Predicate = __gnu_cxx::__ops::_Iter_negate<main(int, const char**)::<lambda(auto:3)> >]'
 2107 |           if (__pred(__first))
      |               ~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:112:28:   required from '_InputIterator std::__find_if_not(_InputIterator, _InputIterator, _Predicate) [with _InputIterator = __gnu_cxx::__normal_iterator<long long int*, vector<long long int> >; _Predicate = __gnu_cxx::__ops::_Iter_pred<main(int, const char**)::<lambda(auto:3)> >]'
  112 |       return std::__find_if(__first, __last,
      |              ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
  113 |                             __gnu_cxx::__ops::__negate(__pred),
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  114 |                             std::__iterator_category(__first));
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:471:32:   required from '_IIter std::find_if_not(_IIter, _IIter, _Predicate) [with _IIter = __gnu_cxx::__normal_iterator<long long int*, vector<long long int> >; _Predicate = main(int, const char**)::<lambda(auto:3)>]'
  471 |       return std::__find_if_not(__first, __last,
      |              ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
  472 |                                 __gnu_cxx::__ops::__pred_iter(__pred));
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:411:40:   required from 'bool std::all_of(_IIter, _IIter, _Predicate) [with _IIter = __gnu_cxx::__normal_iterator<long long int*, vector<long long int> >; _Predicate = main(int, const char**)::<lambda(auto:3)>]'
  411 |     { return __last == std::find_if_not(__first, __last, __pred); }
      |                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:35:27:   required from here
   35 |   bool lcm_is_csm = all_of(va.begin(), va.end(), [&](auto a) {
      |                     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   36 |     a % v_lcm == 0 && a / v_lcm % 2 == 1;
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   37 |   });
      |   ~~                       
/usr/include/c++/14/bits/predefined_ops.h:395:31: error: void value not ignored as it ought to be
  395 |         { return !bool(_M_pred(*__it)); }
      |                        ~~~~~~~^~~~~~~