Language: C++

#include <bits/stdc++.h>

using ll = long long;
using namespace std;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define YES(f) if((f)){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(f) if((f)){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)

#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);

#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}


void init();
void solve();

signed main()
{
	init();
	solve();
}

int N;
vector<int> v;

void init()
{
	vector<pair<int, int>> vt;
	cin >> N;
	rep(i, N) {
		int t;
		cin >> t;
		vt.PB(MP(t, 0));
	}
	rep(i, N) {
		int t;
		cin >> t;
		vt.PB(MP(t, 1));
	}
	sort(all(vt));
	v.PB(1);
	int n = vt[0].second;
	reps(i, 1, 2*N) {
		if (n == vt[i].second) v.back()++;
		else {
			v.PB(1);
			n = 1 - n;
		}
	}
}

struct comb {
#define MOD_COMB 1000000007
	vector<ll> fact;
	vector<ll> facti;
	comb(int n) {
		init(n);
	}
	void init(int n) {
		fact.resize(n);
		facti.resize(n);
		fact[0] = 1;
		for (int i = 1; i < n; i++) {
			fact[i] = fact[i-1] * i % MOD_COMB;
		}
		facti[n-1] = po(fact[n-1], MOD_COMB - 2);
		for (int i = n-2; i >= 0; i--) {
			facti[i] = facti[i+1] * (i + 1) % MOD_COMB;
		}
	}
	ll nCr(int a, int b) {
		return (fact[a] * facti[b] % MOD_COMB) * facti[a-b] % MOD_COMB;
	}
	ll nPr(int a, int b) {
		return fact[a] * facti[a-b] % MOD_COMB;
	}
private:
	ll po(ll next, int cnt) {
		ll res = 1;
		if (cnt == 0) return 1;
		if (cnt & 1) res = res * next % MOD_COMB;
		return res * po(next * next % MOD_COMB, cnt >> 1) % MOD_COMB;
	}
};

void solve()
{
	int x[2] = {0, 0};
	comb c(312345);
	int res = 1;
	rep(i, v.size()) {
		int g = i % 2;
		x[g] += v[i];
		int mi = min(x[0], x[1]);
		int ma = max(x[0], x[1]);
		if (x[ng] != ma) ma = mi;
		res *= c.nPr(ma, mi);
		res %= MOD;
		x[0] -= mi;
		x[1] -= mi;
	}
	cout << res << endl;
}




Compiler output:
a.cc: In function 'void solve()':
a.cc:149:23: error: 'ng' was not declared in this scope; did you mean 'g'?
  149 |                 if (x[ng] != ma) ma = mi;
      |                       ^~
      |                       g