Language: C++

#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, a, b, c;
vector<string> svec;

int main() {
    cin >> n >> a >> b >> c;
    vector<char> ans;
    int sum = a+b+c;
    for(int i = 0; i < n; ++i) {
        string s; cin >> s;
        svec.emplace_back(s);
    }
    for(int i = 0; i < n; ++i) {
        string snow = svec.at(i);
        if(sum == 0) {
            cout << "No" << endl;
            return 0;
        }else if(sum == 1) {
            if(snow == "AB") {
                if(a == 0 && b == 0) {
                    cout << "No" << endl;
                    return 0;
                }else if(a == 0) {
                    ans.emplace_back('A');
                    a++; b--;
                }else {
                    ans.emplace_back('B');
                    b++; a--;
                }
            }else if(snow == "AC") {
                if(a == 0 && c == 0) {
                    cout << "No" << endl;
                    return 0;
                }else if(a == 0) {
                    ans.emplace_back('A');
                    a++; c--;
                }else {
                    ans.emplace_back('C');
                    c++; a--;
                }
            }else {
                if(b == 0 && c == 0) {
                    cout << "No" << endl;
                    return 0;
                }else if(b == 0) {
                    ans.emplace_back('B');
                    b++; c--;
                }else {
                    ans.emplace_back('C');
                    c++; b--;
                }
            }
        /*}else if(sum == 2) {
            if(snow == "AB") {
                if(a == 0 && b == 0) {
                    cout << "No" << endl;
                    return 0;
                }else if(a == 0) {
                    ans.emplace_back('A');
                    a++; b--;
                }else if(b == 0) {
                    ans.emplace_back('B');
                    b++; a--;
                }else if(a == 1 && b == 1) {
                    if(i != n-1) {
                        string snext = svec.at(i+1);
                        if(snext != snow) {
                            // 次が違う文字列なら次は決まってるかもしれない…
                            if(snext == "AC") {
                                ans.emplace_back('A');
                                a++; b--;
                            }else {
                                ans.emplace_back('B');
                                b++; a--;
                            }
                        }else {
                            // 次が同じ文字列なら今は何してもいい
                            ans.emplace_back('A');
                            a++; b--;
                        }
                    }
                }
            }else if(snow == "AC") {
                if(a == 0 && c == 0) {
                    cout << "No" << endl;
                    return 0;
                }else if(a == 0) {
                    ans.emplace_back('A');
                    a++; c--;
                }else if(c == 0) {
                    ans.emplace_back('C');
                    c++; a--;
                }else if(a == 1 && c == 1) {
                    if(i != n-1) {
                        string snext = svec.at(i+1);
                        if(snext != snow) {
                            if(snext == "AB") {
                                ans.emplace_back('A');
                                a++; c--;
                            }else {
                                ans.emplace_back('C');
                                c++; a--;
                            }
                        }else {
                            ans.emplace_back('C');
                            c++; a--;
                        }
                    }
                }*/
            }else {
                if(b == 0 && c == 0) {
                    cout << "No" << endl;
                    return 0;
                }else if(b == 0) {
                    ans.emplace_back('B');
                    b++; c--;
                }else if(c == 0) {
                    ans.emplace_back('C');
                    c++; b--;
                }else if(b == 1 && c == 1) {
                    if(i != n-1) {
                        string snext = svec.at(i+1);
                        if(snext != snow) {
                            if(snext == "AB") {
                                ans.emplace_back('B');
                                b++; c--;
                            }else {
                                ans.emplace_back('C');
                                c++; b--;
                            }
                        }else {
                            ans.emplace_back('B');
                            b++; c--;
                        }
                    }
                }
            }
        }else {
            if(snow == "AB") {
                if(a == 0 && b == 0) {
                    cout << "No" << endl;
                    return 0;
                }else if(a == 0) {
                    ans.emplace_back('A');
                    a++; b--;
                }else if(b == 0) {
                    ans.emplace_back('B');
                    b++; a--;
                }else {
                    if(a > b) {
                        ans.emplace_back('B');
                        b++; a--;
                    }else {
                        ans.emplace_back('A');
                        a++; b--;
                    }
                }
            }else if(snow == "AC") {
                if(a == 0 && c == 0) {
                    cout << "No" << endl;
                    return 0;
                }else if(a == 0) {
                    ans.emplace_back('A');
                    a++; c--;
                }else if(c == 0) {
                    ans.emplace_back('C');
                    c++; a--;
                }else {
                    if(a > c) {
                        ans.emplace_back('C');
                        c++; a--;
                    }else {
                        ans.emplace_back('A');
                        a++; c--;
                    }
                }
            }else {
                if(b == 0 && c == 0) {
                    cout << "No" << endl;
                    return 0;
                }else if(b == 0) {
                    ans.emplace_back('B');
                    b++; c--;
                }else if(c == 0) {
                    ans.emplace_back('C');
                    c++; b--;
                }else {
                    if(b > c) {
                        ans.emplace_back('C');
                        c++; b--;
                    }else {
                        ans.emplace_back('B');
                        b++; c--;
                    }
                }
            }
        }
    }

    cout << "Yes" << endl;
    for(int i = 0; i < ans.size(); ++i) {
        cout << ans.at(i) << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:142:10: error: 'else' without a previous 'if'
  142 |         }else {
      |          ^~~~
a.cc:143:16: error: 'snow' was not declared in this scope
  143 |             if(snow == "AB") {
      |                ^~~~
a.cc: At global scope:
a.cc:204:5: error: 'cout' does not name a type
  204 |     cout << "Yes" << endl;
      |     ^~~~
a.cc:205:5: error: expected unqualified-id before 'for'
  205 |     for(int i = 0; i < ans.size(); ++i) {
      |     ^~~
a.cc:205:20: error: 'i' does not name a type
  205 |     for(int i = 0; i < ans.size(); ++i) {
      |                    ^
a.cc:205:36: error: expected unqualified-id before '++' token
  205 |     for(int i = 0; i < ans.size(); ++i) {
      |                                    ^~
a.cc:208:1: error: expected declaration before '}' token
  208 | }
      | ^