Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
	int64_t n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<int> count_sim = { a,b,c };
	vector<string> opt(n);
	for (int i = 0; i < n; i++) cin >> opt.at(i);
	vector<int> count_opt(3, 0);
	for (int i = 0; i < n; i++) {
		if (opt.at(i) == "AB") count_opt.at(0)++;
		else if (opt.at(i) == "AC") count_opt.at(1)++;
		else count_opt.at(2)++;
	}
	vector<int> opt_sim(6, 0);
	for (int i = 0; i < count_opt(0); i++) {
		if (count_sim.at(0) > 0) {
			opt_sim.at(0)++;
			count_sim.at(0)--;
			count_sim.at(1)++;
		}
		else if(count_sim.at(1)>0){
			opt_sim.at(1)++;
			count_sim.at(0)++;
			count_sim.at(1)--;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = 0; i < count_opt(1); i++) {
		if (count_sim.at(0) > 0) {
			opt_sim.at(2)++;
			count_sim.at(0)--;
			count_sim.at(2)++;
		}
		else if (count_sim.at(2) > 0) {
			opt_sim.at(3)++;
			count_sim.at(0)++;
			count_sim.at(2)--;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = 0; i < count_opt(2); i++) {
		if (count_sim.at(1) > 0) {
			opt_sim.at(4)++;
			count_sim.at(1)--;
			count_sim.at(2)++;
		}
		else if (count_sim.at(2) > 0) {
			opt_sim.at(5)++;
			count_sim.at(2)++;
			count_sim.at(1)--;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	for (int i = 0; i < n; i++) {
		if(opt.at(i)=="AB"&&opt_sim.at(0)>0){
			cout << "A" << endl;
			opt_sim.at(0)--;
		}
		else if (opt.at(i) == "AB" && opt_sim.at(1) > 0) {
			cout << "B" << endl;
			opt_sim.at(1)--;
		}
		else if (opt.at(i) == "AC" && opt_sim.at(2) > 0) {
			cout << "A" << endl;
			opt_sim.at(2)--;
		}
		else if (opt.at(i) == "AC" && opt_sim.at(3) > 0) {
			cout << "A" << endl;
			opt_sim.at(3)--;
		}
		else if (opt.at(i) == "BA" && opt_sim.at(4) > 0) {
			cout << "A" << endl;
			opt_sim.at(4)--;
		}
		else if (opt.at(i) == "BA" && opt_sim.at(5) > 0) {
			cout << "A" << endl;
			opt_sim.at(5)--;
		}
		else {}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:35: warning: narrowing conversion of 'a' from 'int64_t' {aka 'long int'} to 'int' [-Wnarrowing]
    6 |         vector<int> count_sim = { a,b,c };
      |                                   ^
a.cc:6:35: warning: narrowing conversion of 'a' from 'int64_t' {aka 'long int'} to 'int' [-Wnarrowing]
a.cc:6:37: warning: narrowing conversion of 'b' from 'int64_t' {aka 'long int'} to 'int' [-Wnarrowing]
    6 |         vector<int> count_sim = { a,b,c };
      |                                     ^
a.cc:6:37: warning: narrowing conversion of 'b' from 'int64_t' {aka 'long int'} to 'int' [-Wnarrowing]
a.cc:6:39: warning: narrowing conversion of 'c' from 'int64_t' {aka 'long int'} to 'int' [-Wnarrowing]
    6 |         vector<int> count_sim = { a,b,c };
      |                                       ^
a.cc:6:39: warning: narrowing conversion of 'c' from 'int64_t' {aka 'long int'} to 'int' [-Wnarrowing]
a.cc:16:38: error: no match for call to '(std::vector<int>) (int)'
   16 |         for (int i = 0; i < count_opt(0); i++) {
      |                             ~~~~~~~~~^~~
a.cc:32:38: error: no match for call to '(std::vector<int>) (int)'
   32 |         for (int i = 0; i < count_opt(1); i++) {
      |                             ~~~~~~~~~^~~
a.cc:48:38: error: no match for call to '(std::vector<int>) (int)'
   48 |         for (int i = 0; i < count_opt(2); i++) {
      |                             ~~~~~~~~~^~~