Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, m) for (int i = 0; i < (int)(m); i++)
const int inf = 1000000000; // 10^9 Ten to the power of nine.
int main()
{
	int n,a,b,c;cin>>n>>a>>b>>c;
	for(int i=1;i<=n;i++)
	cin>>s[i];
	for(int i=1;i<=n;i++)
	{
		if(s[i]=="AB"){
			if(a==0&&b==0){
				printf("No\n");
				return 0;
			}
			if(a>b)a--,b++,ans[i]='B';
			else if(a<b)a++,b--,ans[i]='A';
			else{
				if(s[i+1]=="BC")a--,b++,ans[i]='B';
				else a++,b--,ans[i]='A';
			}
		}
		if(s[i]=="BC"){
			if(c==0&&b==0){
				printf("No\n");
				return 0;
			}
			if(c>b)c--,b++,ans[i]='B';
			else if(c<b)c++,b--,ans[i]='C';
			else{
				if(s[i+1]=="AB")c--,b++,ans[i]='B';
				else c++,b--,ans[i]='C';
			}
		}
		if(s[i]=="AC"){
			if(a==0&&c==0){
				printf("No\n");
				return 0;
			}
			if(a>c)a--,c++,ans[i]='C';
			else if(a<c)a++,c--,ans[i]='A';
			else{
				if(s[i+1]=="BC")a--,c++,ans[i]='C';
				else a++,c--,ans[i]='A';
			}
		}
	}
	printf("Yes\n");
	for(int i=1;i<=n;i++)
	printf("%c\n",ans[i]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:14: error: 's' was not declared in this scope
   10 |         cin>>s[i];
      |              ^
a.cc:13:20: error: 's' was not declared in this scope
   13 |                 if(s[i]=="AB"){
      |                    ^
a.cc:18:40: error: 'ans' was not declared in this scope; did you mean 'abs'?
   18 |                         if(a>b)a--,b++,ans[i]='B';
      |                                        ^~~
      |                                        abs
a.cc:19:45: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |                         else if(a<b)a++,b--,ans[i]='A';
      |                                             ^~~
      |                                             abs
a.cc:21:57: error: 'ans' was not declared in this scope; did you mean 'abs'?
   21 |                                 if(s[i+1]=="BC")a--,b++,ans[i]='B';
      |                                                         ^~~
      |                                                         abs
a.cc:22:46: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |                                 else a++,b--,ans[i]='A';
      |                                              ^~~
      |                                              abs
a.cc:25:20: error: 's' was not declared in this scope
   25 |                 if(s[i]=="BC"){
      |                    ^
a.cc:30:40: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |                         if(c>b)c--,b++,ans[i]='B';
      |                                        ^~~
      |                                        abs
a.cc:31:45: error: 'ans' was not declared in this scope; did you mean 'abs'?
   31 |                         else if(c<b)c++,b--,ans[i]='C';
      |                                             ^~~
      |                                             abs
a.cc:33:57: error: 'ans' was not declared in this scope; did you mean 'abs'?
   33 |                                 if(s[i+1]=="AB")c--,b++,ans[i]='B';
      |                                                         ^~~
      |                                                         abs
a.cc:34:46: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |                                 else c++,b--,ans[i]='C';
      |                                              ^~~
      |                                              abs
a.cc:37:20: error: 's' was not declared in this scope
   37 |                 if(s[i]=="AC"){
      |                    ^
a.cc:42:40: error: 'ans' was not declared in this scope; did you mean 'abs'?
   42 |                         if(a>c)a--,c++,ans[i]='C';
      |                                        ^~~
      |                                        abs
a.cc:43:45: error: 'ans' was not declared in this scope; did you mean 'abs'?
   43 |                         else if(a<c)a++,c--,ans[i]='A';
      |                                             ^~~
      |                                             abs
a.cc:45:57: error: 'ans' was not declared in this scope; did you mean 'abs'?
   45 |                                 if(s[i+1]=="BC")a--,c++,ans[i]='C';
      |                                                         ^~~
      |                                                         abs
a.cc:46:46: error: 'ans' was not declared in this scope; did you mean 'abs'?
   46 |                                 else a++,c--,ans[i]='A';
      |                                              ^~~
      |                                              abs
a.cc:52:23: error: 'ans' was not declared in this scope; did you mean 'abs'?
   52 |         printf("%c\n",ans[i]);
      |                       ^~~
      |                       abs