Language: C++

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
long long modpow(long long a, long long b, long long m){
  long long ans = 1;
  while (b > 0){
    if (b % 2 == 1){
      ans *= a;
      ans %= m;
    }
    a *= a;
    a %= m;
    b /= 2;
  }
  return ans;
}
map<long long, long long> mp;
long long modinv(long long a, long long m){
  if (mp.count(a)){
    return mp[a];
  } else {
    long long ans = modpow(a, m - 2, m);
    mp[a] = ans;
    return ans;
  }
}
vector<complex<long double>> fft(vector<complex<long double>> A, bool inv){
	int N = A.size();
	int M = 0;
	for (int i = 1; i < N; i *= 2){
		M++;
	}
	for (int i = 0; i < N; i++){
		int j = 0;
		for (int k = 0; k < M; k++){
			if ((i >> k) & 1){
				j |= 1 << (M - 1 - k);
			}
		}
		if (i < j){
			swap(A[i], A[j]);
		}
	}
	for (int i = 1; i < N; i *= 2){
		for (int j = 0; j < i; j++){
			complex<long double> z = polar((long double) 1, (2 * PI) / (i * 2) * j * (inv ? -1 : 1));
			for (int k = 0; k < N; k += i * 2){
				complex<long double> s = A[j + k];
				complex<long double> t = A[j + k + i] * z;
				A[j + k] = s + t;
				A[j + k + i] = s - t;
			}
		}
	}
	if (inv){
		for (int i = 0; i < N; i++){
			A[i] /= N;
		}
	}
	return A;
}
vector<long long> convolution(vector<long long> A, vector<long long> B){
	int deg = A.size() + B.size() - 1;
	int N = 1;
	while (N < deg){
		N *= 2;
	}
	vector<complex<long double>> A2(N);
	for (int i = 0; i < A.size(); i++){
		A2[i] = A[i];
	}
	while (A2.size() < N){
		A2.push_back(0);
	}
	vector<complex<long double>> B2(N);
	for (int i = 0; i < B.size(); i++){
		B2[i] = B[i];
	}
	while (B2.size() < N){
		B2.push_back(0);
	}
	vector<complex<long double>> a = fft(A2, false);
	vector<complex<long double>> b = fft(B2, false);
	vector<complex<long double>> c(N);
	for (int i = 0; i < N; i++){
		c[i] = a[i] * b[i];
	}
	c = fft(c, true);
	vector<long long> ans(deg);
	for (int i = 0; i < deg; i++){
		ans[i] = (long long)(c[i].real() + 0.5);
	}
	return ans;
}
int main(){
  int p;
  cin >> p;
  vector<int> a(p);
  for (int i = 0; i < p; i++){
    cin >> a[i];
  }
  vector<vector<long long>> L(p);
  L[0] = vector<long long>(1, 1);
  for (int i = 0; i < p - 1; i++){
    L[i + 1] = vector<long long>(i + 2, 0);
    for (int j = 0; j <= i; j++){
      L[i + 1][j] -= L[i][j] * i % p;
      L[i + 1][j + 1] += L[i][j];
    }
    for (int j = 0; j <= i + 1; j++){
      L[i + 1][j] += p;
      L[i + 1][j] %= p;
    }
  }
  vector<vector<long long>> R(p);
  R[p - 1] = vector<long long>(1, 1);
  for (int i = p - 2; i >= 0; i--){
    R[i] = vector<long long>(p - i, 0);
    for (int j = 0; j < p - 1 - i; j++){
      R[i][j] -= R[i + 1][j] * (i + 1) % p;
      R[i][j + 1] += R[i + 1][j];
    }
    for (int j = 0; j < p - i; j++){
      R[i][j] += p;
      R[i][j] %= p;
    }
  }
  vector<long long> ans(p, 0);
  for (int i = 0; i < p; i++){
    if (a[i] == 1){
      vector<long long> tmp = convolution(L[i], R[i]);
      long long use = 1;
      for (int j = 0; j < p; j++){
        if (j != i){
          use *= (i - j + p) % p;
          use %= p;
        }
      }
      int coef = modinv(use, p);
      for (int j = 0; j < p; j++){
        ans[j] += tmp[j] % p * coef;
        ans[j] %= p;
      }
    }
  }
  for (int i = 0; i < p; i++){
    cout << ans[i];
    if (i < p - 1){
      cout << ' ';
    }
  }
  cout << endl;
}

Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:5:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::_Rb_tree_impl<std::less<long long int>, true>::~_Rb_tree_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::_Rb_tree_node<std::pair<const long long int, long long int> >]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_tree.h:658:16: note: called from here
  658 |         struct _Rb_tree_impl
      |                ^~~~~~~~~~~~~