Language: C++

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

ll dist(ll x, ll y, ll xx, ll yy) {
  return abs(x-xx)+abs(y-yy);
}

int main() {
  int n;
  vector<int> vals(3, 0);
  cin >> n;
  ll S = 0;
  for(int i = 0; i < 3; i++) {
    cin >> vals[i];
    S += vals[i];
  }
  ll xc = 3*S/2;
  ll yc = 3*S/2;
  
  vector<char> moves;
  ll& x = vals[0];
  ll& y = vals[1];
  for(int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "AB") {
      ll x1 = x+1; // a++
      ll y1 = y-1;
      ll z1 = S-x1-y1;
      ll x2 = x-1; // b++
      ll y2 = y+1;
      ll z2 = S-x2-y2;
      if (x1 < 0 || y1 < 0 || z1 < 0) {
        y++;
        x--;
        moves.push_back('B');
      } else if (x2 < 0 || y2 < 0 || z2 < 0) {
        x++;
        y--;
        moves.push_back('A');
      } else if (dist(xc, yc, x1, y1) < dist(xc, yc, x2, y2)) {
        x++;
        y--;
        moves.push_back('A');
      } else {
        x--;
        y++;
        moves.push_back('B');
      }
    } else if(s == "AC") {
      
      ll x1 = x+1; // a++
      ll y1 = y;
      ll z1 = S-x1-y1;
      ll x2 = x-1; // c++
      ll y2 = y;
      ll z2 = S-x2-y2;
      if (x1 < 0 || y1 < 0 || z1 < 0) {
        x--;
        moves.push_back('C');
      } else if (x2 < 0 || y2 < 0 || z2 < 0) {
        x++;
        moves.push_back('A');
      } else if (dist(xc, yc, x1, y1) < dist(xc, yc, x2, y2)) {
        x++;
        moves.push_back('A');
      } else {
        x--;
        moves.push_back('C');
      }
    } else {
      ll x1 = x; // b++
      ll y1 = y+1;
      ll z1 = S-x1-y1;
      ll x2 = x; // c++
      ll y2 = y-1;
      ll z2 = S-x2-y2;
      if (x1 < 0 || y1 < 0 || z1 < 0) {
        y--;
        moves.push_back('C');
      } else if (x2 < 0 || y2 < 0 || z2 < 0) {
        y++;
        moves.push_back('B');
      } else if (dist(xc, yc, x1, y1) < dist(xc, yc, x2, y2)) {
        y++;
        moves.push_back('B');
      } else {
        y--;
        moves.push_back('C');
      }
    }
    if (x < 0 || y < 0 || (S-x-y) < 0) {
      cout << "No" << endl;
      exit(0);
    }
  }
  cout << "Yes" << endl;
  for(char c : moves) cout << c << "\n";
}

Compiler output:
a.cc:4:1: error: 'll' does not name a type
    4 | ll dist(ll x, ll y, ll xx, ll yy) {
      | ^~
a.cc: In function 'int main()':
a.cc:12:3: error: 'll' was not declared in this scope
   12 |   ll S = 0;
      |   ^~
a.cc:15:5: error: 'S' was not declared in this scope
   15 |     S += vals[i];
      |     ^
a.cc:17:5: error: expected ';' before 'xc'
   17 |   ll xc = 3*S/2;
      |     ^~~
      |     ;
a.cc:18:5: error: expected ';' before 'yc'
   18 |   ll yc = 3*S/2;
      |     ^~~
      |     ;
a.cc:21:7: error: 'x' was not declared in this scope
   21 |   ll& x = vals[0];
      |       ^
a.cc:22:7: error: 'y' was not declared in this scope
   22 |   ll& y = vals[1];
      |       ^
a.cc:27:9: error: expected ';' before 'x1'
   27 |       ll x1 = x+1; // a++
      |         ^~~
      |         ;
a.cc:28:9: error: expected ';' before 'y1'
   28 |       ll y1 = y-1;
      |         ^~~
      |         ;
a.cc:29:9: error: expected ';' before 'z1'
   29 |       ll z1 = S-x1-y1;
      |         ^~~
      |         ;
a.cc:30:9: error: expected ';' before 'x2'
   30 |       ll x2 = x-1; // b++
      |         ^~~
      |         ;
a.cc:31:9: error: expected ';' before 'y2'
   31 |       ll y2 = y+1;
      |         ^~~
      |         ;
a.cc:32:9: error: expected ';' before 'z2'
   32 |       ll z2 = S-x2-y2;
      |         ^~~
      |         ;
a.cc:33:11: error: 'x1' was not declared in this scope; did you mean 'y1'?
   33 |       if (x1 < 0 || y1 < 0 || z1 < 0) {
      |           ^~
      |           y1
a.cc:33:24: error: ordered comparison of pointer with integer zero ('double (*)(double) noexcept' and 'int')
   33 |       if (x1 < 0 || y1 < 0 || z1 < 0) {
      |                     ~~~^~~
a.cc:33:31: error: 'z1' was not declared in this scope; did you mean 'y1'?
   33 |       if (x1 < 0 || y1 < 0 || z1 < 0) {
      |                               ^~
      |                               y1
a.cc:37:18: error: 'x2' was not declared in this scope
   37 |       } else if (x2 < 0 || y2 < 0 || z2 < 0) {
      |                  ^~
a.cc:37:28: error: 'y2' was not declared in this scope; did you mean 'yn'?
   37 |       } else if (x2 < 0 || y2 < 0 || z2 < 0) {
      |                            ^~
      |                            yn
a.cc:37:38: error: 'z2' was not declared in this scope
   37 |       } else if (x2 < 0 || y2 < 0 || z2 < 0) {
      |                                      ^~
a.cc:41:23: error: 'xc' was not declared in this scope
   41 |       } else if (dist(xc, yc, x1, y1) < dist(xc, yc, x2, y2)) {
      |                       ^~
a.cc:41:27: error: 'yc' was not declared in this scope; did you mean 'yn'?
   41 |       } else if (dist(xc, yc, x1, y1) < dist(xc, yc, x2, y2)) {
      |                           ^~
      |                           yn
a.cc:41:18: error: 'dist' was not declared in this scope
   41 |       } else if (dist(xc, yc, x1, y1) < dist(xc, yc, x2, y2)) {
      |                  ^~~~
a.cc:52:9: error: expected ';' before 'x1'
   52 |       ll x1 = x+1; // a++
      |         ^~~
      |         ;
a.cc:53:9: error: expected ';' before 'y1'
   53 |       ll y1 = y;
      |         ^~~
      |         ;
a.cc:54:9: error: expected ';' before 'z1'
   54 |       ll z1 = S-x1-y1;
      |         ^~~
      |         ;
a.cc:55:9: error: expected ';' before 'x2'
   55 |       ll x2 = x-1; // c++
      |         ^~~
      |         ;
a.cc:56:9: error: expected ';' before 'y2'
   56 |       ll y2 = y;
      |         ^~~
      |         ;
a.cc:57:9: error: expected ';' before 'z2'
   57 |       ll z2 = S-x2-y2;
      |         ^~~
      |         ;
a.cc:58:11: error: 'x1' was not declared in this scope; did you mean 'y1'?
   58 |       if (x1 < 0 || y1 < 0 || z1 < 0) {
      |           ^~
      |           y1
a.cc:58:24: error: ordered comparison of pointer with integer zero ('double (*)(double) noexcept' and 'int')
   58 |       if (x1 < 0 || y1 < 0 || z1 < 0) {
      |                     ~~~^~~
a.cc:58:31: error: 'z1' was not declared in this scope; did you mean 'y1'?
   58 |       if (x1 < 0 || y1 < 0 || z1 < 0) {
      |                               ^~
      |                               y1
a.cc:61:18: error: 'x2' was not declared in this scope
   61 |       } else if (x2 < 0 || y2 < 0 || z2 < 0) {
      |                  ^~
a.cc:61:28: error: 'y2' was not declared in this scope; did you mean 'yn'?
   61 |       } else if (x2 < 0 || y2 < 0 || z2 < 0) {
      |                            ^~
      |                            yn
a.cc:61:38: error: 'z2' was not declared in this scope
   61 |       } else if (x2 < 0 || y2 < 0 || z2 < 0) {
      |                                      ^~
a.cc:64:23: error: 'xc' was not declared in this scope
   64 |       } else if (dist(xc, yc, x1, y1) < dist(xc, yc, x2, y2)) {
      |                       ^~
a.cc:64:27: error: 'yc' was not declared in this scope; did you mean 'yn'?
   64 |       } else if (dist(xc, yc, x1, y1) < dist(xc, yc, x2, y2)) {
      |                           ^~
      |                           yn
a.cc:64:18: error: 'dist' was not declared in this scope
   64 |       } else if (dist(xc, yc, x1, y1) < dist(xc, yc, x2, y2)) {
      |                  ^~~~
a.cc:72:9: error: expected ';' before 'x1'
   72 |       ll x1 = x; // b++
      |         ^~~
      |         ;
a.cc:73:9: error: expected ';' before 'y1'
   73 |       ll y1 = y+1;
      |         ^~~
      |         ;
a.cc:74:9: error: expected ';' before 'z1'
   74 |       ll z1 = S-x1-y1;
      |         ^~~
      |         ;
a.cc:75:9: error: expected ';' before 'x2'
   75 |       ll x2 = x; // c++
      |         ^~~
      |         ;
a.cc:76:9: error: expected ';' before 'y2'
   76 |       ll y2 = y-1;
      |         ^~~
      |         ;
a.cc:77:9: error: expected ';' before 'z2'
   77 |       ll z2 = S-x2-y2;
      |         ^~~
      |         ;
a.cc:78:11: error: 'x1' was not declared in this scope; did you mean 'y1'?
   78 |       if (x1 < 0 || y1 < 0 || z1 < 0) {
      |           ^~
      |           y1
a.cc:78:24: error: ordered comparison of pointer with integer zero ('double (*)(double) noexcept' and 'int')
   78 |       if (x1 < 0 || y1 < 0 || z1 < 0) {
      |                     ~~~^~~
a.cc:78:31: error: 'z1' was not declared in this scope; did you mean 'y1'?
   78 |       if (x1 < 0 || y1 < 0 || z1 < 0) {
      |                               ^~
      |                               y1
a.cc:81:18: error: 'x2' was not declared in this scope
   81 |       } else if (x2 < 0 || y2 < 0 || z2 < 0) {
      |                  ^~
a.cc:81:28: error: 'y2' was not declared in this scope; did you mean 'yn'?
   81 |       } else if (x2 < 0 || y2 < 0 || z2 < 0) {
      |                            ^~
      |                            yn
a.cc:81:38: error: 'z2' was not declared in this scope
   81 |       } else if (x2 < 0 || y2 < 0 || z2 < 0) {
      |                                      ^~
a.cc:84:23: error: 'xc' was not declared in this scope
   84 |       } else if (dist(xc, yc, x1, y1) < dist(xc, yc, x2, y2)) {
      |                       ^~
a.cc:84:27: error: 'yc' was not declared in this scope; did you mean 'yn'?
   84 |       } else if (dist(xc, yc, x1, y1) < dist(xc, yc, x2, y2)) {
      |                           ^~
      |                           yn
a.cc:84:18: error: 'dist' was not declared in this scope
   84 |       } else if (dist(xc, yc, x1, y1) < dist(xc, yc, x2, y2)) {
      |                  ^~~~
a.cc:92:28: error: 'S' was not declared in this scope
   92 |     if (x < 0 || y < 0 || (S-x-y) < 0) {
      |                            ^