Language: C++

#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);
const long MOD = 1000000007;

long power(long a, long b, long MOD){
	if(b == 0){
		return 1;
	}else if(b % 2 == 1){
		return a % MOD * power(a, b-1, MOD) % MOD;
	}else{
		long r = power(a, b/2, MOD);
		return r * r % MOD;
	}
}

long modinv(long x){
    return power(x, MOD-2, MOD);
}

//gcd
long gcd(long num1, long num2){
	if(num2 > num1){
		std::swap(num1, num2);
	}
	if(num2 == 0){
		return num1;
	}else{
		return gcd(num2, num1 % num2);
	}
}

long lcm(std::vector<long> x){
    #error むり。
}

long n;
long a[1005];

typedef long long ll;
const int mod = 1000000007;
const long MAX = 200000;

int prime[MAX];
std::unordered_map<int, int> max_map;

// Function to return a^n
int power(int a, int 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;
}

// Function to find the smallest prime factors
// of numbers upto MAX
void sieve()
{
    prime[0] = prime[1] = 1;
    for (int i = 2; i < MAX; i++) {
        if (prime[i] == 0) {
            for (int j = i * 2; j < MAX; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
            prime[i] = i;
        }
    }
}

// Function to return the LCM modulo M
ll lcmModuloM(const int* ar, int n)
{

    for (int i = 0; i < n; i++) {
        int num = ar[i];
        std::unordered_map<int, int> 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
            int 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;
}

int main(){
    sieve();
    scanf("%ld", &n);
    for(int i = 0; i < n; i++){
        scanf("%ld", a+i);
    }
    long l = lcmModuloM(a, n);
    long ans = 0;
    for(int i = 0; i < n; i++){
        long res = l * modinv(a[i]) % MOD;
        //*
        printf("%d\n", i);
        printf("  a = %ld\n", a[i]);
        printf("  inv = %ld\n", modinv(a[i]));
        printf("  a * inv = %ld\n", a[i] * modinv(a[i]) % MOD);
        printf("  %ld\n", res);
        printf("  %ld\n", a[(i+1)%3] * a[(i+2)%3] % MOD);
        //*/
        ans += res;
        ans %= MOD;
    }
    printf("%ld\n", ans);
}


Compiler output:
a.cc:54:12: error: extended character 。 is not valid in an identifier
   54 |     #error むり。
      |            ^
a.cc:54:6: error: #error \U00003080\U0000308a\U00003002
   54 |     #error むり。
      |      ^~~~~
a.cc: In function 'long int lcm(std::vector<long int>)':
a.cc:55:1: warning: no return statement in function returning non-void [-Wreturn-type]
   55 | }
      | ^
a.cc: At global scope:
a.cc:65:6: error: 'unordered_map' in namespace 'std' does not name a template type
   65 | std::unordered_map<int, int> max_map;
      |      ^~~~~~~~~~~~~
a.cc:21:1: note: 'std::unordered_map' is defined in header '<unordered_map>'; this is probably fixable by adding '#include <unordered_map>'
   20 | #include <complex>
  +++ |+#include <unordered_map>
   21 | 
a.cc: In function 'll lcmModuloM(const int*, int)':
a.cc:102:14: error: 'unordered_map' is not a member of 'std'
  102 |         std::unordered_map<int, int> temp;
      |              ^~~~~~~~~~~~~
a.cc:102:14: note: 'std::unordered_map' is defined in header '<unordered_map>'; this is probably fixable by adding '#include <unordered_map>'
a.cc:102:28: error: expected primary-expression before 'int'
  102 |         std::unordered_map<int, int> temp;
      |                            ^~~
a.cc:112:13: error: 'temp' was not declared in this scope; did you mean 'tm'?
  112 |             temp[factor]++;
      |             ^~~~
      |             tm
a.cc:118:24: error: 'temp' was not declared in this scope; did you mean 'tm'?
  118 |         for (auto it : temp) {
      |                        ^~~~
      |                        tm
a.cc:122:13: error: 'max_map' was not declared in this scope
  122 |             max_map[it.first] = max(max_map[it.first], it.second);
      |             ^~~~~~~
a.cc:122:33: error: 'max' was not declared in this scope; did you mean 'std::max'?
  122 |             max_map[it.first] = max(max_map[it.first], it.second);
      |                                 ^~~
      |                                 std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:12:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:128:20: error: 'max_map' was not declared in this scope
  128 |     for (auto it : max_map) {
      |                    ^~~~~~~
a.cc: In function 'int main()':
a.cc:143:25: error: cannot convert 'long int*' to 'const int*'
  143 |     long l = lcmModuloM(a, n);
      |                         ^
      |                         |
      |                         long int*
a.cc:97:26: note:   initializing argument 1 of 'll lcmModuloM(const int*, int)'
   97 | ll lcmModuloM(const int* ar, int n)
      |               ~~~~~~~~~~~^~