Language: C++

#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

#define F first 
#define S second 
#define MAX 10000003 
using namespace std; 
  
typedef long long ll; 
const int mod = 1000000007; 
  
ll prime[MAX]; 
map<ll, ll> max_map; 
  
// Function to return a^n 
ll power(ll a, ll n) 
{ 
    if (n == 0) 
        return 1; 
    int p = power(a, n / 2) % mod; 
    p = (p * p) % mod; 
    if (n & 1) 
        p = (p * a) % mod; 
    return p; 
}

void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (ll i = 2; i < MAX; i++) { 
        if (prime[i] == 0) { 
            for (ll j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
}

ll lcmModuloM(const ll* ar, ll n) 
{ 
  
    for (ll i = 0; i < n; i++) { 
        ll num = ar[i]; 
        map<ll, ll> temp; 
  
        // Temp stores mapping of prime factor to 
        // its power for the current element 
        while (num > 1) { 
  
            // Factor is the smallest prime factor of num 
            ll factor = prime[num]; 
  
            // Increase count of factor in temp 
            temp[factor]++; 
  
            // Reduce num by its prime factor 
            num /= factor; 
        } 
  
        for (auto it : temp) { 
  
            // Store the highest power of every prime 
            // found till now in a new map max_map 
            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    }
    ll ans = 1; 
  
    for (auto it : max_map) { 
  
        // LCM is product of primes to their highest powers modulo M 
        ans = (ans * power(it.F, it.S)) % mod; 
    } 
  
    return ans; 
}
ll powMod(ll x, ll n) {
  if (n == 0) return 1;
  ll r = powMod(x, n / 2);
  if (n % 2 == 0) return (r * r) % MOD;
  return (r * r % MOD) * x % MOD;
}

int main(void) {

  int n;
  cin >> n;

  ll a[10001];
  rep(i, n) cin >> a[i];

  ll lcm = lcmModuloM(a, n);
  ll ans = 0;
  rep(i, n) {
    ans += lcm * powMod(a[i], MOD - 2);
    ans %= MOD;
  }
  cout << ans << endl;
}
  


Compiler output:
a.cc:33:1: error: 'map' does not name a type
   33 | map<ll, ll> max_map;
      | ^~~
a.cc: In function 'll lcmModuloM(const ll*, ll)':
a.cc:67:9: error: 'map' was not declared in this scope
   67 |         map<ll, ll> temp;
      |         ^~~
a.cc:17:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
   16 | #include <set>
  +++ |+#include <map>
   17 | #define rep(i, n) for (int i = 0; i < int(n); i++)
a.cc:67:15: error: expected primary-expression before ',' token
   67 |         map<ll, ll> temp;
      |               ^
a.cc:67:19: error: expected primary-expression before '>' token
   67 |         map<ll, ll> temp;
      |                   ^
a.cc:67:21: error: 'temp' was not declared in this scope; did you mean 'tm'?
   67 |         map<ll, ll> temp;
      |                     ^~~~
      |                     tm
a.cc:87:13: error: 'max_map' was not declared in this scope
   87 |             max_map[it.first] = max(max_map[it.first], it.second);
      |             ^~~~~~~
a.cc:92:20: error: 'max_map' was not declared in this scope
   92 |     for (auto it : max_map) {
      |                    ^~~~~~~