Language: C++

/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<int, int> P;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<P> VP;
typedef vector<vector<P>> VVP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
long long GCD(long long a, long long b)
{
    if (b == 0)
        return a;
    return GCD(b, a % b);
}
long long LCM(long long a, long long b)
{
    return a * b / GCD(a, b);
}
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}
//a,m=MOD MOD逆元
const int N = pow(10, 6);

vector<bool> isp(N + 1, true);

void sieve()
{
    isp[0] = false;
    isp[1] = false;
    for (int i = 2; pow(i, 2) <= N; i++)
    {
        if (isp[i])
            for (int j = 2; i * j <= N; j++)
                isp[i * j] = false;
    }
} //N以下の整数をふるってくれます]
long long modMult(long long a, long long b, long long m) {
  long long res = 0;
  long long exp = a % m;
  while (b) {
    if (b & 1) {
      res += exp;
      if (res > m) res -= m;
    }
    exp <<= 1;
    if (exp > m) exp -= m;
    b >>= 1;
  }
  return res;
}
long long powMod(long long a, long long b, long long m) {
  long long res = 1;
  long long exp = a % m;
  while (b) {
    if (b & 1) res = modMult(res, exp, m);
    exp = modMult(exp, exp, m);
    b >>= 1;
  }
  return res;
}
//powMod(a,b,MOD)
//O(log(b))?
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    V vec(n);
    rep(i, n) cin >> vec[i];
    map<ll, ll> mp;
    rep(i,n){
        ll temp = vec[i];
      //  cout<<i<<endl;
        rep3(j,2,2*1e3){
            if(temp==1)break;
            ll cnt = 0;
            while(temp%j==0){
                cnt++;
                temp/=j;
            }
            if(mp[j]<cnt){
                mp[j] = cnt;
            }
        }
    }
    if(temp!=1){
        mp[temp]=cnt;
    }
    ll LCMval = 1;
    for (auto itr = mp.begin(); itr != mp.end();itr++){
        LCMval*=powMod(itr->first,itr->second,MOD);
        LCMval%=MOD;
    }
    ll sum = 0;
    rep(i,n){
        ll g = modinv(vec[i], MOD) * LCMval;
        sum += g;
        sum %= MOD;
    }
    cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:162:8: error: 'temp' was not declared in this scope; did you mean 'mp'?
  162 |     if(temp!=1){
      |        ^~~~
      |        mp
a.cc:163:18: error: 'cnt' was not declared in this scope; did you mean 'int'?
  163 |         mp[temp]=cnt;
      |                  ^~~
      |                  int