Language: C++

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<ll,ll> P;

multiset<ll> s,r;


int main(){
    ll a,b,c,n;
    cin>>n>>a>>b>>c;
    string res="";
    string stmp="";
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(stmp!=""){
            if(stmp==s){
                res=res+s[0]+"\n"+s[1]+"\n";
                stmp="";
                continue;
            }else{
                if(stmp=="AB"){
                    if(s=="BC"){
                        res+="B\n";
                        a--;b++;
                    }else if(s=="AC"){
                        res+="A\n";
                        a++;b--;
                    }
                }else if(stmp=="AC"){
                    if(s=="AB"){
                        res+="A\n";
                        a++;c--;
                    }else if(s=="BC"){
                        res+="C\n";
                        a--;c++;
                    }
                }else{//BC
                    if(s=="AB"){
                        res+="B\n";
                        b++;c--;
                    }else if(s=="BC"){
                        res+="C\n";
                        b--;c++;
                    }
                }
            }
            stmp="";
        }
        int *x,*y;
        if(s=="AB"){
                x=&a;
                y=&b;
        }else if(s=="AC"){
                x=&a;
                y=&c;
        }else{
                x=&b;
                y=&c;
        }
        if(*x==*y){
            if(*x==0){
                cout<<"No";
                return 0;
            }else{
                stmp=s;
            }
        }else if(*x>*y){
            (*x)--;(*y)++;
            res=res+s[1]+"\n";
        }else{
            (*x)++;(*y)--;
            res=res+s[0]+"\n";
        }
    }
    if(stmp!=""){
        res=res+stmp[0]+"\n";
    }
    cout<<"Yes"<<endl;
    cout<<res<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:19: error: cannot convert 'll*' {aka 'long long int*'} to 'int*' in assignment
   54 |                 x=&a;
      |                   ^~
      |                   |
      |                   ll* {aka long long int*}
a.cc:55:19: error: cannot convert 'll*' {aka 'long long int*'} to 'int*' in assignment
   55 |                 y=&b;
      |                   ^~
      |                   |
      |                   ll* {aka long long int*}
a.cc:57:19: error: cannot convert 'll*' {aka 'long long int*'} to 'int*' in assignment
   57 |                 x=&a;
      |                   ^~
      |                   |
      |                   ll* {aka long long int*}
a.cc:58:19: error: cannot convert 'll*' {aka 'long long int*'} to 'int*' in assignment
   58 |                 y=&c;
      |                   ^~
      |                   |
      |                   ll* {aka long long int*}
a.cc:60:19: error: cannot convert 'll*' {aka 'long long int*'} to 'int*' in assignment
   60 |                 x=&b;
      |                   ^~
      |                   |
      |                   ll* {aka long long int*}
a.cc:61:19: error: cannot convert 'll*' {aka 'long long int*'} to 'int*' in assignment
   61 |                 y=&c;
      |                   ^~
      |                   |
      |                   ll* {aka long long int*}