Language: C++

#pragma GCC optimize("Ofast")
#include<vector>
#include<queue>
#include<iostream>
#include<fstream>
#include<string>
#include<cassert>
#include<algorithm>
#include<random>
#include<map>
#include<set>
#include <bitset>
#include<ctime>

using namespace std;

int mod = 998244353;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<char>vc;
typedef vector<string>vs;
typedef vector<vector<int>>vii;
typedef vector<vector<char>>vvc;
typedef vector<vector<ll>>vll;
typedef vector< pair<ll, ll>>vpll;
typedef vector< pair<ld, ld>>vpld;
typedef vector< pair<int, int>>vpi;
typedef pair<ld, ld>pld;
#define mp make_pair
#define pb push_back

 int mod = 1000000007;
int sum(int a, int b)
{
	int c = a + b;
	if (c >= mod)
	{
		c -= mod;
	}
	return c;
}
int dif(int a, int b)
{
	int c = a - b;
	if (c < 0)
	{
		c += mod;
	}
	return c;
}
int mlt(int a, int b)
{
	ll c = a * 1LL * b;
	return c % mod;
}
int ibit(int n, int i)
{
	return ((n >> i) & 1);
}
void outp(vii &ou)
{
	for (int i = 0; i < ou.size(); i++)
	{
		for (int j = 0; j < ou[i].size(); j++)
		{
			cout << ou[i][j] << ' ';
		}
		cout << '\n';
	}
}
int bp(int x, int y)
{
	if (y == 0)
	{
		return 1;
	}
	int a = 0;
	if (!(y % 2))
	{
		a = bp(x, y / 2);
	}
	return (y % 2) ? mlt(bp(x, y - 1), x) : mlt(a, a);
}
int obr(int x)
{
	return bp(x, mod - 2);
}
const int maxn = 200007;
int fact[1000007], ofact[1000007];
vii del(maxn), alldivs(maxn);
vi maxpr(maxn);
vi mu(maxn), sqf(maxn, 1);
void prec()
{
	fact[0] = 1;
	ofact[0] = 1;
	for (int i = 1; i < maxn; i++)
	{
		fact[i] = mlt(fact[i - 1], i);
	}
	//cerr << "sdsds" << endl;
	ofact[maxn - 1] = obr(fact[maxn - 1]);
	for (int i = maxn - 2; i > 0; i--)
	{
		ofact[i] = mlt(ofact[i + 1], i + 1);
	}
}
int c(int a, int b)
{
	return ((a <= b) && (a >= 0)) ? mlt(fact[b], mlt(ofact[a], ofact[b - a])) : 0;
}
ll gcd(ll x, ll y)
{
	//cerr << x << y << endl;
	if (x == 0)return y;
	return(x > y) ? gcd(y, x) : gcd(y%x, x);
}
vector<int>obrs;
int ans(int ones, int twos, int threes, int n)
{
	int cur = fact[ones+twos+threes+2];
	cur = mlt(cur, obrs[ones + 1]);
	cur = mlt(cur, obrs[twos+ones+2]);
	cur = mlt(cur, fact[twos+threes+1]);
	cur = mlt(cur, obrs[twos+1]);
	cur = mlt(cur, fact[threes]);
	cur = obr(cur);
	cur = mlt(cur, fact[n]);
	cur = mlt(cur, cur);
	return cur;
}
int main()
{
	int n;
	cin >> n >> mod;
	prec();
	//obrs.resize(2228);
	n *= 3;
	vii dp(3, vi(2 * n + 12));
	vi newdp(2 * n + 12);
	dp[0][n] = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int bal = -n; bal <= n; bal++)
		{
			newdp[bal + n] = 0;
			if (i >= 1)newdp[bal + n] = sum(newdp[bal + n], dp[(i + 2) % 3][max(0, bal + n - 1)]);
			if (i >= 2)newdp[bal + n] = sum(newdp[bal + n], mlt(dp[(i + 1) % 3][min(2*n+10, bal + n +1)], i-1));
			if (i >= 3)newdp[bal + n] = sum(newdp[bal + n], mlt((i-2)*(i-1),dp[i% 3][bal+n]));
		//	cerr << "ibal " << i << ' ' << bal << ' ' << newdp[bal + n] << endl;
		}
		dp[i % 3] = newdp;
	}
	int summ = 0;
	for (int bal = 0; bal <= n; bal++)summ = sum(dp[0][bal + n], summ);
	cout << summ << endl;
	cin >> n;
}

Compiler output:
a.cc:38:6: error: redefinition of 'int mod'
   38 |  int mod = 1000000007;
      |      ^~~
a.cc:17:5: note: 'int mod' previously defined here
   17 | int mod = 998244353;
      |     ^~~