Language: C++

#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ll MAX_N = 1 << 17;
ll nn, dat[2 * MAX_N - 1]; //セグメント木を持つグローバル配列
void init(ll n_) { //初期化
	nn = 1; //簡単のため、要素数を2のべき乗に
	while (nn < n_)nn *= 2;
	//全ての値をINT_MAXに
	for (int i = 0; i < 2 * nn - 1; i++) dat[i] = INT_MAX;
}
void update(ll k, ll a) { //k番目の値(0-indexed)をaに変更
	k += nn - 1; dat[k] = a; //葉の節点
	while (k > 0) { //登りながら更新
		k = (k - 1) / 2;
		if (dat[k * 2 + 2] == INT_MAX) { dat[k] = dat[k * 2 + 1]; }
		else if (dat[k * 2 + 1] == INT_MAX) { dat[k] = dat[k * 2 + 2]; }
		else { dat[k] = dat[k * 2 + 1] * dat[k * 2 + 2] % mod; }
	}
}
//[a, b)の最小値を求める
//kは節点の番号、l, rはその節点が[l, r)に対応づいていることを表す。
//したがって外からはquery(a, b, 0, 0, nn)として呼ぶ。
ll query(ll a, ll b, ll k, ll l, ll r) {
	if (r <= a || b <= l) { return INT_MAX; }
	if (a <= l && r <= b) { return dat[k]; }
	else {
		int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		if (vr == INT_MAX) { return vl; }
		if (vl == INT_MAX) { return vr; }
		return vl * vr % mod;
	}
}
ll res[1234567];
void prime_factor(ll n) {
	vector<ll> kari(1234567);
	for (int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			kari[i]++; res[i] = max(res[i], kari[i]);
			n /= i;
		}
	}
	if (n != 1) { res[n] = max(kari[n] + 1, res[n]); }
}
vector<ll> s(ll num) {
	vector<ll>res;
	for (int i = 2; i <= num; i++) { // 他の素数で割っていく
		while (num % i == 0) {
			res.push_back(i);
			num /= i;
		}
	}
	return res;
}
ll aa[12345678], cost[12345678];
signed main() {
	ll n, m, a = 0, x = 0, y = 0, ans = 0; cin >> n;
	vector<ll> v;
	for (int h = 0; h < n; h++) {
		cin >> aa[h]; prime_factor(aa[h]);
	}
	for (int h = 1; h <= 1000000; h++) {
		if (res[h] != 0) {
			cost[h] = v.size();
			for (int i = 0; i < res[h]; i++) {
				v.push_back(h);
			}
		}
	}
	init(v.size());
	for (int h = 0; h < v.size(); h++) {
		update(h, v[h]);
	}
	for (int h = 0; h < n; h++) {
		int z = 0, cnt = 1; vector<ll>uio(12345678);
		for (int i = 0; i < s(aa[h]).size(); i++) {
			if (query(z, cost[s(aa[h])[i]] + uio[s(aa[h])[i]], 0, 0, nn) != INT_MAX) {
				cnt *= query(z, cost[s(aa[h])[i]] + uio[s(aa[h])[i]], 0, 0, nn);
				cnt %= mod;
			}
			uio[s(aa[h])[i]]++; z = cost[s(aa[h])[i]] + uio[s(aa[h])[i]];
		}
		//cout << s(aa[h]).size() << ' ' << z << endl;
		if (query(z, v.size(), 0, 0, nn) != INT_MAX) {
			cnt *= query(z, v.size(), 0, 0, nn);
		}
		//cout << cnt << endl;
		ans += cnt; ans %= mod;
	}
	while (ans < 0) { ans += mod; }
	cout << ans % mod << endl;
	return 0;
}

Compiler output:
a.cc: In function 'void init(ll)':
a.cc:26:55: error: 'INT_MAX' was not declared in this scope
   26 |         for (int i = 0; i < 2 * nn - 1; i++) dat[i] = INT_MAX;
      |                                                       ^~~~~~~
a.cc:15:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   14 | #include<functional>
  +++ |+#include <climits>
   15 | //#include<bits/stdc++.h>
a.cc: In function 'void update(ll, ll)':
a.cc:32:39: error: 'INT_MAX' was not declared in this scope
   32 |                 if (dat[k * 2 + 2] == INT_MAX) { dat[k] = dat[k * 2 + 1]; }
      |                                       ^~~~~~~
a.cc:32:39: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc: In function 'll query(ll, ll, ll, ll, ll)':
a.cc:41:40: error: 'INT_MAX' was not declared in this scope
   41 |         if (r <= a || b <= l) { return INT_MAX; }
      |                                        ^~~~~~~
a.cc:41:40: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:46:27: error: 'INT_MAX' was not declared in this scope
   46 |                 if (vr == INT_MAX) { return vl; }
      |                           ^~~~~~~
a.cc:46:27: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:47:27: error: 'INT_MAX' was not declared in this scope
   47 |                 if (vl == INT_MAX) { return vr; }
      |                           ^~~~~~~
a.cc:47:27: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc: In function 'int main()':
a.cc:94:89: error: 'INT_MAX' was not declared in this scope
   94 |                         if (query(z, cost[s(aa[h])[i]] + uio[s(aa[h])[i]], 0, 0, nn) != INT_MAX) {
      |                                                                                         ^~~~~~~
a.cc:94:89: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:101:53: error: 'INT_MAX' was not declared in this scope
  101 |                 if (query(z, v.size(), 0, 0, nn) != INT_MAX) {
      |                                                     ^~~~~~~
a.cc:101:53: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'