Language: C++

#include <bits/stdc++.h>

using namespace std;

using ll = int_fast64_t;
constexpr ll llmax = INT_FAST64_MAX; // std::numeric_limits<int_fast64_t>::max()
constexpr ll llmin = INT_FAST64_MIN; // std::numeric_limits<int_fast64_t>::min()
using ull = uint_fast64_t;
constexpr ull ullmax = UINT_FAST64_MAX; // std::numeric_limits<uint_fast64_t>::max()

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

constexpr uint mod = 1000000007;

// modをとった和を返す
inline
uint modPlus(uint a, uint b){return (a + b) % mod;}

// modをとった差を返す
inline
uint modMinus(uint a, uint b){return (mod + a - b) % mod;}

// modをとった積を返す
inline
uint modMultiple(uint a, uint b){return (static_cast<long long>(a) * b) % mod;}

// 階乗数n!を最初に計算して、呼ばれた時に返す
class Factorial {
    std::vector<uint> table;
public:
    Factorial(uint max) : table(max) // max:テーブルのサイズ
    {
        if (max == 0) return;
        table[0] = 1;
        for (uint i = 1; i < max; ++i){
            table[i] = modMultiple(table[i - 1], i + 1);
        }
    }

    uint operator () (int n)
    {
        if (n < 0) return 0;
        if (n == 0) return 1;
        return table[n - 1];
    }
};


class PowerN {
    std::vector<uint> table;
public:
    PowerN(uint N, uint max) // max:使いたい引数nの最大
    {
        if (max == 0) return;
        table.resize(static_cast<uint>(floor(log2f(max))) + 1);
        table[0] = N;
        for (uint i = 1; i < table.size(); ++i){
            table[i] = modMultiple(table[i - 1], table[i - 1]); // N ^ (2 ^ i)
        }
    }

    int operator () (int n)
    {
        if (n < 0) return 0;
        if (n == 0) return 1;
        int result = 1;
        for (int i = 0; n; ++i, n >>= 1){
            if (!(n & 1)) continue;
            result = modMultiple(result, table[i]);
        }
        return result;
    }
};

int main()
{
    scanInt(N);
    scanInt(X);
    scanVecInt(S, N);
    sort(S.begin(), S.end());
    Factorial fact(N);
    PowerN pow2(2, N);
    // for (auto& s : S){
    //     cout << s << endl;
    // }
    unordered_map<int, int> dp;
    dp.emplace(X, 1);
    REP(n, N){
        // unordered_map<int, int> dp_next = dp;
        for (auto& x : dp){
            const int nextX = x.first % S[n];
            dp_next[nextX] = modPlus(dp_next[nextX], x.second);
        }
        dp.swap(dp_next);
    }
    int result = 0;
    for (auto& x : dp){
        result = modPlus(result, modMultiple(x.first, x.second));
    }
    cout << result << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:99:13: error: 'dp_next' was not declared in this scope
   99 |             dp_next[nextX] = modPlus(dp_next[nextX], x.second);
      |             ^~~~~~~
a.cc:101:17: error: 'dp_next' was not declared in this scope
  101 |         dp.swap(dp_next);
      |                 ^~~~~~~