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<string> s(n);
    vector<char> ans;
    bool ok = true;
    rep(i,n) cin >> s[i];
    if (a+b+c == 0) ok = false;
    if (a+b+c == 1) {
        if (s[i] == "AB") {
            if (a == 0 && b == 0) {ok = false; break;}
            if (a < b) {a++; b--; ans.push_back('A');}
            else {b++; a--; ans.push_back('B');}
        }
        if (s[i] == "AC") {
            if (a == 0 && c == 0) {ok = false; break;}
            if (a < c) {a++; c--; ans.push_back('A');}
            else {c++; a--; ans.push_back('C');}
        }
        if (s[i] == "BC") {
            if (c == 0 && b == 0) {ok = false; break;}
            if (c < b) {c++; b--; ans.push_back('C');}
            else {b++; c--; ans.push_back('B');}
        }
    }
    if (a+b+c == 2) {
        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 (a < b) {a++; b--; ans.push_back('A');}
                    else {b++; a--; ans.push_back('B');}
                }
            }
        }
    }
    else {
        rep(i,n) {
            if (s[i] == "AB") {
                if (a == 0 && b == 0) {ok = false; break;}
                if (a < b) {a++; b--; ans.push_back('A');}
                else {b++; a--; ans.push_back('B');}
            }
            if (s[i] == "AC") {
                if (a == 0 && c == 0) {ok = false; break;}
                if (a < c) {a++; c--; ans.push_back('A');}
                else {c++; a--; ans.push_back('C');}
            }
            if (s[i] == "BC") {
                if (c == 0 && b == 0) {ok = false; break;}
                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:29:15: error: 'i' was not declared in this scope
   29 |         if (s[i] == "AB") {
      |               ^
a.cc:30:48: error: break statement not within loop or switch
   30 |             if (a == 0 && b == 0) {ok = false; break;}
      |                                                ^~~~~
a.cc:34:15: error: 'i' was not declared in this scope
   34 |         if (s[i] == "AC") {
      |               ^
a.cc:35:48: error: break statement not within loop or switch
   35 |             if (a == 0 && c == 0) {ok = false; break;}
      |                                                ^~~~~
a.cc:39:15: error: 'i' was not declared in this scope
   39 |         if (s[i] == "BC") {
      |               ^
a.cc:40:48: error: break statement not within loop or switch
   40 |             if (c == 0 && b == 0) {ok = false; break;}
      |                                                ^~~~~