Language: C++

#include <type_traits>
#include <utility>
#include <cassert>
#include <iostream>
#include <functional>
#include <vector>
#include <string>
#include <algorithm>
namespace loquat {
template <typename T>
static std::pair<T, T> extended_gcd(T a, T b){
	if(b == 0){ return std::pair<T, T>(1, 0); }
	const auto p = extended_gcd(b, a % b);
	return std::pair<T, T>(p.second, p.first - a / b * p.second);
}
}
namespace loquat {
template <int MOD>
class modulus_integer {
public:
	typedef modulus_integer<MOD> self_type;
private:
	int m_value;
	static self_type unsafe_construct(int x) noexcept {
		self_type y;
		y.m_value = x;
		return y;
	}
public:
	modulus_integer() noexcept
		: m_value(0)
	{ }
	modulus_integer(int x) noexcept
		: m_value(x % MOD)
	{
		if(m_value < 0){ m_value += MOD; }
	}
	int operator*() const noexcept { return m_value; }
	self_type operator-(const self_type& x) const noexcept {
		const int y = m_value - x.m_value;
		return unsafe_construct(y < 0 ? y + MOD : y);
	}
	self_type operator*(const self_type& x) const noexcept {
		return unsafe_construct(
			static_cast<long long>(m_value) * x.m_value % MOD);
	}
	self_type operator/(const self_type& x) const {
		return (*this) * self_type(extended_gcd(x.m_value, MOD).first);
	}
};
template <int MOD>
inline std::ostream& operator<<(
	std::ostream& os, const modulus_integer<MOD>& x)
{
	os << *x;
	return os;
}
template <int MOD>
struct identity<std::plus<modulus_integer<MOD>>> {
	static modulus_integer<MOD> value() noexcept {
		return modulus_integer<MOD>(0);
	}
};
template <int MOD>
struct identity<std::multiplies<modulus_integer<MOD>>> {
	static modulus_integer<MOD> value() noexcept {
		return modulus_integer<MOD>(1);
	}
};
}
namespace loquat {
template <int MOD>
inline modulus_integer<MOD> modulus_factorial(int x){
	using mint = modulus_integer<MOD>;
	static std::vector<mint> table(1, mint(1));
	assert(x >= 0);
	while(static_cast<int>(table.size()) <= x){
		const int t = static_cast<int>(table.size());
		table.push_back(table.back() * mint(t));
	}
	return table[x];
}
template <int MOD>
inline modulus_integer<MOD> modulus_inv_factorial(int x){
	using mint = modulus_integer<MOD>;
	static std::vector<mint> table(1, mint(1));
	assert(x >= 0);
	while(static_cast<int>(table.size()) <= x){
		const int t = static_cast<int>(table.size());
		table.push_back(table.back() / mint(t));
	}
	return table[x];
}
template <int MOD>
inline modulus_integer<MOD> modulus_combination(int n, int k){
	if(k < 0 || n < k){ return 0; }
	const auto a = modulus_factorial<MOD>(n);
	const auto b = modulus_inv_factorial<MOD>(n - k);
	const auto c = modulus_inv_factorial<MOD>(k);
	return a * b * c;
}
template <int MOD>
inline modulus_integer<MOD> modulus_multichoose(int n, int k){
	return modulus_combination<MOD>(n + k - 1, k);
}
}
using namespace std;
static const int MOD = 1000000007;
using mint = loquat::modulus_integer<MOD>;
int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n + 1), h(n);
	for(int i = 0; i <= n; ++i){
		cin >> a[i];
		--a[i];
		++h[a[i]];
	}
	int dup = 0;
	for(int i = 0; i < n; ++i){
		if(h[i] == 2){ dup = i; }
	}
	int left = n, right = 0;
	for(int i = 0; i <= n; ++i){
		if(a[i] == dup){
			left = min(left, i);
			right = max(right, i);
		}
	}
	const int mid = n - (left + 1) - (n - right - 1);
	for(int i = 1; i <= n + 1; ++i){
		const mint x =
			loquat::modulus_combination<MOD>(n + 1, i) -
			loquat::modulus_combination<MOD>(n - mid, i - 1);
		cout << x << endl;
	}
	return 0;
}


Compiler output:
a.cc:59:8: error: 'identity' is not a class template
   59 | struct identity<std::plus<modulus_integer<MOD>>> {
      |        ^~~~~~~~
a.cc:65:54: error: type/value mismatch at argument 1 in template parameter list for 'template<int MOD> struct loquat::identity'
   65 | struct identity<std::multiplies<modulus_integer<MOD>>> {
      |                                                      ^
a.cc:65:54: note:   expected a constant of type 'int', got 'std::multiplies<loquat::modulus_integer<MOD> >'