Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
const auto MOD = 1000000007LL;

int main() {
    Int n;
    cin >> n;
    auto a = vector<Int>(3, 0);
    Int ans = 1;
    rep(i, n) {
        Int x;
        cin >> x;
        if(x==0){
            if(a[0]==0){
                a[0] = 1;
                ans *= 3;
                ans %= MOD;
            } else if (a[1] == 0) {
                a[1] = 1;
                ans *= 2;
                ans %= MOD;
            } else{
                a[2] = 1;
            }
        }else{
            if(x == a[0] && x==a[1] && x==a[2]){
                ans *= 3;
                ans %= MOD;
                a[0]++;
            }else if ( x== a[0] && x== a[1]){
                ans *= 2;
                ans %= MOD;
                a[0]++;
            }else if ( x== a[1] && x== a[2]){
                ans *= 2;
                ans %= MOD;
                a[1]++;
            }else if ( x== a[2] && x== a[0]){
                ans *= 2;
                ans %= MOD;
                a[0]++;
            }else if ( x== a[0]){
                a[0]++;
            }else if ( x== a[1]){
                a[1]++;
            }else if ( x== a[2]){
                a[2]++;
            }
        }
    }

    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:5: error: 'Int' was not declared in this scope; did you mean 'int'?
    7 |     Int n;
      |     ^~~
      |     int
a.cc:8:12: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 |     cin >> n;
      |            ^
      |            yn
a.cc:9:24: error: template argument 2 is invalid
    9 |     auto a = vector<Int>(3, 0);
      |                        ^
a.cc:10:8: error: expected ';' before 'ans'
   10 |     Int ans = 1;
      |        ^~~~
      |        ;
a.cc:12:12: error: expected ';' before 'x'
   12 |         Int x;
      |            ^~
      |            ;
a.cc:13:16: error: 'x' was not declared in this scope
   13 |         cin >> x;
      |                ^
a.cc:17:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   17 |                 ans *= 3;
      |                 ^~~
      |                 abs
a.cc:21:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   21 |                 ans *= 2;
      |                 ^~~
      |                 abs
a.cc:28:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |                 ans *= 3;
      |                 ^~~
      |                 abs
a.cc:32:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |                 ans *= 2;
      |                 ^~~
      |                 abs
a.cc:36:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |                 ans *= 2;
      |                 ^~~
      |                 abs
a.cc:40:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   40 |                 ans *= 2;
      |                 ^~~
      |                 abs
a.cc:53:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   53 |     cout << ans << endl;
      |             ^~~
      |             abs