Language: C++

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
ll M, a[100005];
typedef pair<ll, ll> P;

// gcd lcm
ll calc_gcd(ll a, ll b) {
    if (b == 0) return a;
    return calc_gcd(b, a % b);
}

P calc_lcm(ll a, ll b) {
    ll g = calc_gcd(a, b);
    return make_pair(a / g * b, g);
}

int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  cin >> N >> M;
  rep(i, N) cin >> a[i];
  P lg = calc_lcm(a[0], a[1]);
  ll lcm = lg.first; ll gcd = lg.second;

  rep(i, N) {
    P p = calc_lcm(lcm, a[i]);
    lcm = p.first;
    gcd = calc_gcd(p.second, gcd);
  }

  rep(i, N) {
    if ((a[i]/gcd)%2==0) {
      cout << 0 << "\n";
      return 0;
    }
  }

  ll cnt=0;
  ll incr = lcm;
  while(lcm<=2*M) {
    lcm+=2*incr;
    cnt++;
  }
  
  cout << cnt << "\n";
  return 0;
}
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
ll M, a[100005];
typedef pair<ll, ll> P;

// gcd lcm
ll calc_gcd(ll a, ll b) {
    if (b == 0) return a;
    return calc_gcd(b, a % b);
}

P calc_lcm(ll a, ll b) {
    ll g = calc_gcd(a, b);
    return make_pair(a / g * b, g);
}

int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  cin >> N >> M;
  rep(i, N) cin >> a[i];
  P lg = calc_lcm(a[0], a[1]);
  ll lcm = lg.first; ll gcd = lg.second;

  rep(i, N) {
    P p = calc_lcm(lcm, a[i]);
    lcm = p.first;
    gcd = calc_gcd(p.second, gcd);
  }

  rep(i, N) {
    if ((a[i]/gcd)%2==0) {
      cout << 0 << "\n";
      return 0;
    }
  }

  ll cnt=0;
  ll incr = lcm;
  while(lcm<=2*M) {
    lcm+=2*incr;
    cnt++;
  }
  
  cout << cnt << "\n";
  return 0;
}


Compiler output:
a.cc:89:10: error: redefinition of 'const ll MOD'
   89 | const ll MOD = 1e9+7LL;
      |          ^~~
a.cc:20:10: note: 'const ll MOD' previously defined here
   20 | const ll MOD = 1e9+7LL;
      |          ^~~
a.cc:90:11: error: redefinition of 'const int INF'
   90 | const int INF = 2e9;
      |           ^~~
a.cc:21:11: note: 'const int INF' previously defined here
   21 | const int INF = 2e9;
      |           ^~~
a.cc:91:5: error: redefinition of 'int N'
   91 | int N;
      |     ^
a.cc:22:5: note: 'int N' previously declared here
   22 | int N;
      |     ^
a.cc:92:4: error: redefinition of 'll M'
   92 | ll M, a[100005];
      |    ^
a.cc:23:4: note: 'll M' previously declared here
   23 | ll M, a[100005];
      |    ^
a.cc:92:7: error: redefinition of 'll a [100005]'
   92 | ll M, a[100005];
      |       ^
a.cc:23:7: note: 'll a [100005]' previously declared here
   23 | ll M, a[100005];
      |       ^
a.cc:96:4: error: redefinition of 'll calc_gcd(ll, ll)'
   96 | ll calc_gcd(ll a, ll b) {
      |    ^~~~~~~~
a.cc:27:4: note: 'll calc_gcd(ll, ll)' previously defined here
   27 | ll calc_gcd(ll a, ll b) {
      |    ^~~~~~~~
a.cc:101:3: error: redefinition of 'P calc_lcm(ll, ll)'
  101 | P calc_lcm(ll a, ll b) {
      |   ^~~~~~~~
a.cc:32:3: note: 'P calc_lcm(ll, ll)' previously defined here
   32 | P calc_lcm(ll a, ll b) {
      |   ^~~~~~~~
a.cc:106:5: error: redefinition of 'int main()'
  106 | int main() {
      |     ^~~~
a.cc:37:5: note: 'int main()' previously defined here
   37 | int main() {
      |     ^~~~