Language: C++

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000"]

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>

#define fr first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
//#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

using namespace std;

#ifdef __LOCAL
    #define dbg(x) cerr << #x << " : " << x << '\n'
    const int maxn = 110 + 10;
#else
    #define dbg(x)
    const int maxn = 110;
#endif

//tg: @galebickosikasa

const ll inf = (ll) 1e9 + 10;
const ld pi = 3.14159265358979323846264;
const ld eps = 1e-8;
const ll mod = (ll) 1e9 + 7;
const ll ns = 97;
const int MAXLOG = 20;
const int N = 45;

#define int ll

random_device rd;
mt19937 SuperRandom(rd());

int kek1 (vector<vector<int>>& goo, hm<int, int> kek) {
    auto moo = kek;
    int res = 0;
    for (int i = 0; i < 3; ++i) {
        int cnt = 0;
        moo = kek;
        for (int j = 0; j < 3; ++j) {
            int x = goo[i][j];
            if (moo[x] > 0) ++cnt, --moo[x];
        }
        res += cnt == 3;
    }
    for (int j = 0; j < 3; ++j) {
        int cnt = 0;
        moo = kek;
        for (int i = 0; i < 3; ++i) {
            int x = goo[i][j];
            if (moo[x] > 0) ++cnt, --moo[x];
        }
        res += cnt == 3;
    }
    moo = kek;
    int cnt = 0;
    for (int i = 0; i < 3; ++i) {
        int x = goo[i][i];
        if (moo[x] > 0) ++cnt, --moo[x];
    }
    res += cnt == 3;
    cnt = 0;
    moo = kek;
    for (int i = 0; i < 3; ++i) {
        int x = goo[i][2 - i];
        if (moo[x] > 0) ++cnt, --moo[x];
    }
    res += cnt == 3;
    return res;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    vector<vector<int>> goo (3, vector<int>(3));
    for (auto &x: goo) cinv (x);
    hm <int, int> kek;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        ++kek[x];
    }
    if (kek1 (goo, kek)) cout << "Yes";
    else cout << "No";






}

Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:5:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:186:14: note: called from here
  186 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~