Language: C++

#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define mp make_pair #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, a, b) for (int i = a; i <= (b); ++i) #define repr(i, a, b) for (int i = a; i >= (b); --i) #define bit(n) (1LL << (n)) #define sz(x) ((ll)(x).size()) typedef long long ll; const int INF = 1001001001; const ll LINF = 1001001001001001001ll; const int MOD = 1000000007; template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } struct mint { ll x; mint(ll x = 0) : x((x % MOD + MOD) % MOD) { } mint& operator+=(const mint a) { if ((x += a.x) >= MOD) x -= MOD; return *this; } mint& operator-=(const mint a) { if ((x += MOD - a.x) >= MOD) x -= MOD; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; }  mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; }  mint inv() const { return pow(MOD - 2); } mint& operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; int main() { int N; cin >> N; vector<int> A(N); rep(i, N) { cin >> A[i]; } mint ans = 1; vector<int> RGB(3); rep(i, N) { ll temp = 0; int ind; rep(j, 3) { if (A[i] == RGB[j]) { temp++; ind = j; } } ans *= temp; RGB[ind]++; } cout << (ans.x?ans.x:1) << endl; }

Compiler output:
a.cc:1:26: warning: extra tokens at end of #include directive
    1 | #include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define mp make_pair #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, a, b) for (int i = a; i <= (b); ++i) #define repr(i, a, b) for (int i = a; i >= (b); --i) #define bit(n) (1LL << (n)) #define sz(x) ((ll)(x).size()) typedef long long ll; const int INF = 1001001001; const ll LINF = 1001001001001001001ll; const int MOD = 1000000007; template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } struct mint { ll x; mint(ll x = 0) : x((x % MOD + MOD) % MOD) { } mint& operator+=(const mint a) { if ((x += a.x) >= MOD) x -= MOD; return *this; } mint& operator-=(const mint a) { if ((x += MOD - a.x) >= MOD) x -= MOD; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; }  mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; }  mint inv() const { return pow(MOD - 2); } mint& operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; int main() { int N; cin >> N; vector<int> A(N); rep(i, N) { cin >> A[i]; } mint ans = 1; vector<int> RGB(3); rep(i, N) { ll temp = 0; int ind; rep(j, 3) { if (A[i] == RGB[j]) { temp++; ind = j; } } ans *= temp; RGB[ind]++; } cout << (ans.x?ans.x:1) << endl; }
      |                          ^~~~~
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status