Language: C++

#include<bits/stdc++.h>
using namespace std;

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MOD 1000000007
#define MAX (lli)1e18 

class Graph{
  int V;
  vector<list<p>> adj; 
  const int INF = (int)1e6;

  public: 
  Graph(lli V): adj(V){ 
    this->V = V; 
  } 

  void addEdge(int u, int v, int w){ 
    adj[u].push_back(make_pair(v, w)); 
  } 

  lli edgeNum(){
    lli sum=0;
    rep0(i,V)sum+=adj[i].size();
    return sum;
  }

  bool route(lli from, lli to){//vec[i]==j: j->iっていうもとに戻れる道がある
    vector<lli> vec(V, -1);
    dfs(1,from,vec);
    return vec[to] >= 0;
  }

  void dfs(lli ed, lli num, vector<lli>& vec){
    for(auto e: adj[num]){
      if(vec[e.first] != -1)continue;
      vec[e.first] = num;
      dfs(ed+1, e.first, vec);
    }
  }

  vector<int> bfs(int n){
    queue<int> q;
    vector<int> vec(V,-1);

    q.push(n);
    vec[n]=0;
    while(!q.empty()){
      int p=q.front();
      q.pop();
      for(auto e:adj[p]){
        if(vec[e.first]==-1){
          q.push(e.first);
          vec[e.first] = e.second + vec[p];
        }
      }
    }
    return vec;
  }

  vector<int> shortestPath(int src){ 
    priority_queue< p, vector <p> , greater<p> > pq; 
  
    vector<int> dist(V, INF); 
    pq.push(make_pair(0, src)); 
    dist[src] = 0; 
  
    while (!pq.empty()) { 
        int u = pq.top().second; 
        pq.pop(); 
  
        list<p>::iterator i; 
        for (auto i = adj[u].begin(); i != adj[u].end(); ++i) { 
            int v = i->first; 
            int weight = i->second; 
  
            if (dist[v] > dist[u] + weight) { 
                dist[v] = dist[u] + weight; 
                pq.push(make_pair(dist[v], v)); 
            } 
        } 
    } 
    for(int i=0;i<V;i++)if(dist[i]==INF)dist[i]=-1;
    return dist;
  } 

};

struct UF{
    vector<int> par,size;

    UF(int N) : par(N), size(N, 1){
        rep0(i,N)par[i] = i;
    }

    int root(int x){
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        size[rx] += size[ry];
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int getSize(int x){
        return size[x];
    }
};
struct BIT{
  vector<lli> tab;//bit table
  BIT(int n):tab(n+1){
    rep0(i,n+1)tab[i]=0;
  }

  void add(int p, lli num){
    for(++p;p<tab.size();p+=p&-p)tab[p]+=num;
  }

  lli sum(int p){//from 0 to p
    lli ans=0;
    for(++p;p>0;p-=p&-p)ans+=tab[p];
    return ans;
  }

  void debug(){
    rep0(i,tab.size())cout << tab[i] << ' ';
    cout << endl;
  }
};
 
//pairに関するもの
lli sum(p c){
  return (c.first + c.second);
}
p operator-(const p & l,const p & r) {   
    return {l.first-r.first,l.second-r.second};                                    
}
bool cmpf(const p left, const p right) {
    return left.first < right.first;
}
bool cmps(const p left, const p right) {
    return left.second < right.second;
}
 
lli gcd(lli a, lli b){
    if(a < b)return gcd(b, a);
    lli temp;
    while((temp = a%b)){
        a=b;
        b=temp;
    }
    return b;
}

struct nCr{
  vector<lli> f, rf;
  lli count=0;
  nCr(lli num): f(num), rf(num){
      count = num;
      f[0] = 1;
      rep1(i, num) f[i] = (f[i - 1] * i) % MOD;
      rep0(i, num+1) rf[i] = inv(f[i]);
  }
    
  lli inv(lli x) {
      lli res = 1;
      lli k = MOD - 2;
      lli y = x;
      while (k) {
          if (k & 1) res = (res * y) % MOD;
          y = (y * y) % MOD;
          k /= 2;
      }
      return res;
  }
  lli C(lli n, lli k) {
      if(k > n || k<0)return 0;
      lli a = f[n];
      lli b = rf[n-k];
      lli c = rf[k];
   
      lli bc = (b * c) % MOD;
      return (a * bc) % MOD;
  }
};

int main(){
  lli n;
  cin >> n;
  vector<lli> a(n);
  vector<map<lli,lli>> mp(n);
  map<lli,lli> mx;
  rep0(i,n){
    cin >> a[i];
    for(int j=2;j*j<=a[i];j++){
      while(a[i]%j==0){
        mp[i][j]++;
        a[i]/=j;
      }
    }
    if(a[i] > 1)mp[i][a[i]]++;
    for(auto e:mp[i]){
      mx[e.first] = max(mx[e.first], e.second);
    }
  }
  lli ans = 0;
  rep0(i,n){
    lli tp=1;
    for(auto e:mx){
      rep0(j,e.second - mp[i][e.first]){
        tp*=e.first;
        tp%=MOD;
      }
    }
    ans+=tp;
    ans%=MOD;
  }
  cout << ans;

}


Compiler output:
a.cc:15:15: error: 'p' was not declared in this scope
   15 |   vector<list<p>> adj;
      |               ^
a.cc:15:15: error: template argument 1 is invalid
a.cc:15:15: error: template argument 2 is invalid
a.cc:15:16: error: template argument 1 is invalid
   15 |   vector<list<p>> adj;
      |                ^~
a.cc:15:16: error: template argument 2 is invalid
a.cc: In member function 'void Graph::addEdge(int, int, int)':
a.cc:24:8: error: invalid types 'int[int]' for array subscript
   24 |     adj[u].push_back(make_pair(v, w));
      |        ^
a.cc: In member function 'long long int Graph::edgeNum()':
a.cc:29:22: error: invalid types 'int[int]' for array subscript
   29 |     rep0(i,V)sum+=adj[i].size();
      |                      ^
a.cc: In member function 'void Graph::dfs(long long int, long long int, std::vector<long long int>&)':
a.cc:40:20: error: invalid types 'int[long long int]' for array subscript
   40 |     for(auto e: adj[num]){
      |                    ^
a.cc: In member function 'std::vector<int> Graph::bfs(int)':
a.cc:56:21: error: invalid types 'int[int]' for array subscript
   56 |       for(auto e:adj[p]){
      |                     ^
a.cc: In member function 'std::vector<int> Graph::shortestPath(int)':
a.cc:67:21: error: 'p' was not declared in this scope
   67 |     priority_queue< p, vector <p> , greater<p> > pq;
      |                     ^
a.cc:67:33: error: template argument 2 is invalid
   67 |     priority_queue< p, vector <p> , greater<p> > pq;
      |                                 ^
a.cc:67:48: error: template argument 1 is invalid
   67 |     priority_queue< p, vector <p> , greater<p> > pq;
      |                                                ^
a.cc:67:48: error: template argument 2 is invalid
a.cc:67:48: error: template argument 3 is invalid
a.cc:70:8: error: request for member 'push' in 'pq', which is of non-class type 'int'
   70 |     pq.push(make_pair(0, src));
      |        ^~~~
a.cc:73:16: error: request for member 'empty' in 'pq', which is of non-class type 'int'
   73 |     while (!pq.empty()) {
      |                ^~~~~
a.cc:74:20: error: request for member 'top' in 'pq', which is of non-class type 'int'
   74 |         int u = pq.top().second;
      |                    ^~~
a.cc:75:12: error: request for member 'pop' in 'pq', which is of non-class type 'int'
   75 |         pq.pop();
      |            ^~~
a.cc:77:15: error: template argument 2 is invalid
   77 |         list<p>::iterator i;
      |               ^
a.cc:77:27: error: expected initializer before 'i'
   77 |         list<p>::iterator i;
      |                           ^
a.cc:78:26: error: invalid types 'int[int]' for array subscript
   78 |         for (auto i = adj[u].begin(); i != adj[u].end(); ++i) {
      |                          ^
a.cc:78:47: error: invalid types 'int[int]' for array subscript
   78 |         for (auto i = adj[u].begin(); i != adj[u].end(); ++i) {
      |                                               ^
a.cc:84:20: error: request for member 'push' in 'pq', which is of non-class type 'int'
   84 |                 pq.push(make_pair(dist[v], v));
      |                    ^~~~
a.cc: At global scope:
a.cc:147:9: error: 'p' was not declared in this scope
  147 | lli sum(p c){
      |         ^
a.cc:150:1: error: 'p' does not name a type
  150 | p operator-(const p & l,const p & r) {
      | ^
a.cc:153:17: error: 'p' does not name a type
  153 | bool cmpf(const p left, const p right) {
      |                 ^
a.cc:153:31: error: 'p' does not name a type
  153 | bool cmpf(const p left, const p right) {
      |                               ^
a.cc: In function 'bool cmpf(int, int)':
a.cc:154:17: error: request for member 'first' in 'left', which is of non-class type 'const int'
  154 |     return left.first < right.first;
      |                 ^~~~~
a.cc:154:31: error: request for member 'first' in 'right', which is of non-class type 'const int'
  154 |     return left.first < right.first;
      |                               ^~~~~
a.cc: At global scope:
a.cc:156:17: error: 'p' does not name a type
  156 | bool cmps(const p left, const p right) {
      |                 ^
a.cc:156:31: error: 'p' does not name a type
  156 | bool cmps(const p left, const p right) {
      |                               ^
a.cc: In function 'bool cmps(int, int)':
a.cc:157:17: error: request for member 'second' in 'left', which is of non-class type 'const int'
  157 |     return left.second < right.second;
      |                 ^~~~~~
a.cc:157:32: error: request for member 'second' in 'right', which is of non-class type 'const int'
  157 |     return left.second < right.second;
      |                                ^~~~~~