Language: C++

#include <bits/stdc++.h>
#define MOD 1e9 + 7;

int main() {
  int n; cin >> n;
  vector<int> v(n);
  for (auto a: v) cin >> v[i];
  
  long long int ans = 1;
  vector<int> cnt(3, 0);
  cnt[0] = 1;
  
  for(int i = 1; i < n; i++) {
    int tmp = 0;
    bool flag = false;
    for(int j = 0; j < 3; j++) {
      if (cnt[j] == v[i]) {
        tmp += 1;
        if (!flag) {
          cnt[j] += 1;
          flag = true;
        }
      ans = (ans * tmp % mod);
    }
    cout << ans << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:10: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    5 |   int n; cin >> n;
      |          ^~~
      |          std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:6:3: error: 'vector' was not declared in this scope
    6 |   vector<int> v(n);
      |   ^~~~~~
a.cc:6:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:6:10: error: expected primary-expression before 'int'
    6 |   vector<int> v(n);
      |          ^~~
a.cc:7:16: error: 'v' was not declared in this scope
    7 |   for (auto a: v) cin >> v[i];
      |                ^
a.cc:7:28: error: 'i' was not declared in this scope
    7 |   for (auto a: v) cin >> v[i];
      |                            ^
a.cc:10:10: error: expected primary-expression before 'int'
   10 |   vector<int> cnt(3, 0);
      |          ^~~
a.cc:11:3: error: 'cnt' was not declared in this scope; did you mean 'int'?
   11 |   cnt[0] = 1;
      |   ^~~
      |   int
a.cc:17:21: error: 'v' was not declared in this scope
   17 |       if (cnt[j] == v[i]) {
      |                     ^
a.cc:23:26: error: 'mod' was not declared in this scope; did you mean 'modf'?
   23 |       ans = (ans * tmp % mod);
      |                          ^~~
      |                          modf
a.cc:25:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   25 |     cout << ans << endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:25:20: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   25 |     cout << ans << endl;
      |                    ^~~~
      |                    std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:27:2: error: expected '}' at end of input
   27 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^