Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<char> ans;
    bool ok = true;
    if (a+b+c != 2) {
        rep(i,n) {
            string s; cin >> s;
            if (s == "AB") {
                if (a >= b) {a--; b++; ans.push_back('B');}
                else {a++; b--; ans.push_back('A');}
            }
            if (s == "BC") {
                if (b >= c) {b--; c++; ans.push_back('C');}
                else {b++; c--; ans.push_back('B');}
            }
            if (s == "AC") {
                if (a >= c) {a--; c++; ans.push_back('C');}
                else {a++; c--; ans.push_back('A');}
            }
            if (a < 0 || b < 0 || c < 0) {ok = false; brea;}
        }
    } else {
        rep(i,n) {
            if (s[i] == "AB") {
                if (a == 1 && b == 1 && i != n-1) {
                    if (s[i+1] == "AB") {a++; b--; ans.push_back('A');}
                    if (s[i+1] == "AC") {a++; b--; ans.push_back('A');}
                    if (s[i+1] == "BC") {b++; a--; ans.push_back('B');}
                } else {
                    if (a < b) {a++; b--; ans.push_back('A');}
                    else {b++; a--; ans.push_back('B');}
                }
            }
            if (s[i] == "AC") {
                if (a == 1 && c == 1 && i != n-1) {
                    if (s[i+1] == "AB") {a++; c--; ans.push_back('A');}
                    if (s[i+1] == "AC") {a++; c--; ans.push_back('A');}
                    if (s[i+1] == "BC") {c++; a--; ans.push_back('C');}
                } else {
                    if (a < c) {a++; c--; ans.push_back('A');}
                    else {c++; a--; ans.push_back('C');}
                }
            }
            if (s[i] == "BC") {
                if (c == 1 && b == 1 && i != n-1) {
                    if (s[i+1] == "AB") {b++; c--; ans.push_back('B');}
                    if (s[i+1] == "AC") {c++; b--; ans.push_back('C');}
                    if (s[i+1] == "BC") {b++; c--; ans.push_back('B');}
                } else {
                    if (c < b) {c++; b--; ans.push_back('C');}
                    else {b++; c--; ans.push_back('B');}
                }
            }
        }
    }
    if (ok) {
        cout << "Yes" << endl;
        rep(i,n) cout << ans[i] << endl;
    } else {
        cout << "No" << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:55: error: 'brea' was not declared in this scope
   40 |             if (a < 0 || b < 0 || c < 0) {ok = false; brea;}
      |                                                       ^~~~
a.cc:44:17: error: 's' was not declared in this scope
   44 |             if (s[i] == "AB") {
      |                 ^
a.cc:54:17: error: 's' was not declared in this scope
   54 |             if (s[i] == "AC") {
      |                 ^
a.cc:64:17: error: 's' was not declared in this scope
   64 |             if (s[i] == "BC") {
      |                 ^