Language: C++

#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

struct RuntimeModint {
  static int MOD;

  long long val;
  constexpr RuntimeModint(long long v = 0) noexcept : val(v% MOD) {
    if (val < 0) val += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr RuntimeModint operator - () const noexcept {
    return val ? MOD - val : 0;
  }
  constexpr RuntimeModint operator + (const RuntimeModint& r) const noexcept { return RuntimeModint(*this) += r; }
  constexpr RuntimeModint operator - (const RuntimeModint& r) const noexcept { return RuntimeModint(*this) -= r; }
  constexpr RuntimeModint operator * (const RuntimeModint& r) const noexcept { return RuntimeModint(*this) *= r; }
  constexpr RuntimeModint& operator += (const RuntimeModint& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr RuntimeModint& operator -= (const RuntimeModint& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr RuntimeModint& operator *= (const RuntimeModint& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr bool operator == (const RuntimeModint& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator != (const RuntimeModint& r) const noexcept {
    return this->val != r.val;
  }
  friend ostream& operator << (ostream& os, const RuntimeModint& x) noexcept {
    return os << x.val;
  }
  friend istream& operator >> (istream& is, RuntimeModint& x) noexcept {
    return is >> x.val;
  }

  constexpr RuntimeModint pow(long long n) const noexcept {
    if (!n) return 1;
    auto t = pow(n >> 1);
    t *= t;
    if (n & 1) t *= *this;
    return t;
  }
  friend constexpr RuntimeModint modpow(const RuntimeModint& a, long long n) noexcept {
    return a.pow(n);
  }

  friend constexpr RuntimeModint Ncr(RuntimeModint a, int n) {
    RuntimeModint p = 1, q = 1;

    while (n > 0) {
      p *= a;
      a -= 1;
      q *= n--;
    }

    return p / q;
  }

  // for prime mod
  constexpr RuntimeModint& operator /= (const RuntimeModint& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr RuntimeModint operator / (const RuntimeModint& r) const noexcept { return RuntimeModint(*this) /= r; }
};
int RuntimeModint::MOD;
using rmint = RuntimeModint;

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  // b[0] + b[1]x + b[2]x^2 + ... + b[p-1]x^(p-1)

  int p;
  cin >> p;

  rmint::MOD = p;

  vector<rmint> as(p);
  F0R(i, p) {
    cin >> as[i];
  }

  vector<vector<rmint>> xs(p, vector<rmint>(p));
  F0R(i, p) {
    int x = 1;
    F0R(j, p) {
      xs[i][j] = x;
      x = (x * i) % p;
    }
  }

  auto print = [&](){
    F0R(i, p) {
      F0R(j, p) {
        cout << xs[i][j] << ' ';
      }
      cout << " = " << as[i];
      cout << newl;
    }
    cout << newl;
  };
  //print();
  
  // 掃き出し法
  F0R(i, p) {
    // i番目の要素が0じゃない式をi番目に持ってくる
    if (xs[i][i] == 0) {
      FOR(j, i + 1, p) {
        if (xs[j][i].val) {
          
          // swap i, j
          xs.insert(xs.begin() + i, *xs.erase(xs.begin() + j));
          as.insert(as.begin() + i, *as.erase(as.begin() + j));
          break;
        }
      }
    }
    assert(xs[i][i]);

    if (xs[i][i].val > 1) {
      auto q = xs[i][i];
      F0R(j, p) {
        xs[i][j] /= q;
      }
      as[i] /= q;
    }

    F0R(j, p) {
      if (j == i) continue;
      if (!xs[j][i].val) continue;
      auto a = xs[j][i];
      F0R(k, p) {
        xs[j][k] -= xs[i][k] * a;
      }
      as[j] -= as[i] * a;
    }
    //print();
  }
  //print();

  F0R(i, p) {
    cout << as[i] << ' ';
  }
}
#endif


Compiler output:
a.cc: In constructor 'constexpr RuntimeModint::RuntimeModint(long long int)':
a.cc:44:62: warning: the value of 'RuntimeModint::MOD' is not usable in a constant expression [-Winvalid-constexpr]
   44 |   constexpr RuntimeModint(long long v = 0) noexcept : val(v% MOD) {
      |                                                              ^~~
a.cc:41:14: note: 'int RuntimeModint::MOD' is not const
   41 |   static int MOD;
      |              ^~~
a.cc: In member function 'constexpr int RuntimeModint::getmod()':
a.cc:47:35: warning: the value of 'RuntimeModint::MOD' is not usable in a constant expression [-Winvalid-constexpr]
   47 |   constexpr int getmod() { return MOD; }
      |                                   ^~~
a.cc:41:14: note: 'int RuntimeModint::MOD' is not const
   41 |   static int MOD;
      |              ^~~
a.cc: In member function 'constexpr RuntimeModint& RuntimeModint::operator+=(const RuntimeModint&)':
a.cc:56:16: warning: the value of 'RuntimeModint::MOD' is not usable in a constant expression [-Winvalid-constexpr]
   56 |     if (val >= MOD) val -= MOD;
      |                ^~~
a.cc:41:14: note: 'int RuntimeModint::MOD' is not const
   41 |   static int MOD;
      |              ^~~
a.cc: In member function 'constexpr RuntimeModint& RuntimeModint::operator*=(const RuntimeModint&)':
a.cc:65:25: warning: the value of 'RuntimeModint::MOD' is not usable in a constant expression [-Winvalid-constexpr]
   65 |     val = val * r.val % MOD;
      |                         ^~~
a.cc:41:14: note: 'int RuntimeModint::MOD' is not const
   41 |   static int MOD;
      |              ^~~
a.cc: In member function 'constexpr RuntimeModint& RuntimeModint::operator/=(const RuntimeModint&)':
a.cc:106:30: warning: the value of 'RuntimeModint::MOD' is not usable in a constant expression [-Winvalid-constexpr]
  106 |     long long a = r.val, b = MOD, u = 1, v = 0;
      |                              ^~~
a.cc:41:14: note: 'int RuntimeModint::MOD' is not const
   41 |   static int MOD;
      |              ^~~
In file included from /usr/include/c++/14/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:106,
                 from a.cc:3:
a.cc: In function 'int main()':
a.cc:173:5: error: invalid 'static_cast' from type '__gnu_cxx::__alloc_traits<std::allocator<RuntimeModint>, RuntimeModint>::value_type' {aka 'RuntimeModint'} to type 'bool'
  173 |     assert(xs[i][i]);
      |     ^~~~~~