Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int n,a,b,c; cin >> n >> a >> b >> c;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    vector<string> ans;
    if(1){
        rep(i,n){
            if(s[i] == "AB" && a == 1 && b == 1 && c == 0 && i != n-1 && s[i+1] == "AC") {
                ans.push_back("A");
                a++;b--;
            }else if(s[i] == "AB" && a == 1 && b == 1 && c == 0 && i != n-1 && s[i+1] == "BC"){
                ans.push_back("B");
                b++;a--;
            }else if(s[i] == "AC" && a == 1 && c == 1 && c == 0 && i != n-1 && s[i+1] == "AB"){
                ans.push_back("A");
                a++;c--;
            }else if(s[i] == "AC" && a == 1 && c == 1 && c == 0 && i != n-1 && s[i+1] == "BC"){
                ans.push_back("C");
                a--;c++;
            }else if(s[i] == "BC" && b == 1 && c == 1 && c == 0 && i != n-1 && s[i+1] == "AB"){
                ans.push_back("B");
                b++;c--;
            }else if(s[i] == "BC" && b == 1 && c == 1 && c == 0 && i != n-1 && s[i+1] == "AC"){
                ans.push_back("C");
                c++;b--;
            }else{
                if(s[i] == "AB"){
                    if(a <= b) {ans.push_back("A"); a++;b--;}
                    else {ans.push_back("B"); b++;a--;}
                }else if(s[i] == "AC"){
                    if(a <= c) {ans.push_back("A"); a++;c--;}
                    else {ans.push_back("C"); c++;a--;}
                }else {
                    if(b <= c){ans.push_back("B"); b++;c--;}
                    else {ans.push_back("C"); c++;b--;}
                }
            }
            if(a < 0 || b < 0 || c < 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    rep(i,n) cout << ans[i] << endl;
}#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

Compiler output:
a.cc:53:2: error: stray '#' in program
   53 | }#include <bits/stdc++.h>
      |  ^
a.cc:53:3: error: 'include' does not name a type
   53 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:60:5: error: redefinition of 'int main()'
   60 | int main(){
      |     ^~~~
a.cc:8:5: note: 'int main()' previously defined here
    8 | int main(){
      |     ^~~~