Language: C++

\#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,b,a) for(int i=b;i>a;i--)
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define cps CLOCKS_PER_SEC
#define complex cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / cps << '\n';
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;
inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
 
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
  }
  return r;
}

//think recursively also
ll n;
ll a,b,c;
string s[100005];
int dp[100002][3][3][3];
bool sol(int in,ll ca,ll cb,ll cc)
{  
  
  if(ca<0 || cb<0 || cc<0)
    return 0;
   if(in==n+1)
    {dp[in][ca][cb][cc]=0;
      if(ca>=0 && cb>=0 && cc>=0)
        dp[in][ca][cb][cc]=1;
      return (ca>=0 && cb>=0 && cc>=0);
    }
  if(dp[in][ca][cb][cc]!=-1)
    return dp[in][ca][cb][cc];
  bool ans=0;
   if(s[in]=="AB")
  {
    ans|=sol(in+1,ca-1,min(cb+1,2LL),cc);
    ans|=sol(in+1,min(ca+1,2LL),cb-1,cc);
  }
  else if(s[in]=="BC")
  {
    ans|=sol(in+1,ca,min(cb+1,2LL),cc-1);
    ans|=sol(in+1,ca,cb-1,min(cc+1,2LL));
  }
  else if(s[in]=="AC")
  {
    ans|=sol(in+1,min(ca+1,2LL),cb,cc-1);
    ans|=sol(in+1,ca-1,cb,min(cc+1,2LL));
  }
  dp[in][ca][cb][cc]=ans;
  return ans;

}
void go(int in,int a,int b,int c)
{
   if(in==n+1)
    return;
  if(s[in]=="AB")
  {
     if(sol(in+1,a-1,min(b+1,2),c))
     {
      cout<<"B"<<endl;
      go(in+1,a-1,min(b+1,2),c);
     }
     else
     {
      cout<<"A"<<endl;
      go(in+1,min(a+1,2),b-1,c);
     }
  }
  else if(s[in]=="BC")
  {
     if(sol(in+1,a,b-1,min(c+1,2)))
     {
      cout<<"C"<<endl;
      go(in+1,a,b-1,min(c+1,2));
     }
     else
     {
      cout<<"B"<<endl;
      go(in+1,a,min(b+1,2),c);
     }
  }
  else if(s[in]=="AC")
  {
    if(sol(in+1,a-1,b,min(c+1,2)))
    {
      cout<<"C"<<endl;
      go(in+1,a-1,b,min(c+1,2));
    }
    else
    {
      cout<<"A"<<endl;
      go(in+1,min(a+1,2),b,c-1);
    }
  }
}
void solve()
{ 
   cin>>n>>a>>b>>c;
  

  
   for(int i=1;i<=n;i++)
   {
     cin>>s[i];
    
   }
   memset(dp,-1,sizeof(dp));
  a=min(a,2LL);
  b=min(b,2LL);
  c=min(c,2LL);
   if(sol(1,a,b,c))
   {
    cout<<"Yes"<<endl;
    go(1,a,b,c);
    
   }
   else
   {
    cout<<"No"<<endl;
   }
   

}
int main()
{
   fast();
   // int t;
   // cin>>t;
   // for(int casee=1;casee<=t;casee++)
  { //cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}


Compiler output:
a.cc:1:1: error: stray '\' in program
    1 | \#include<bits/stdc++.h>
      | ^
a.cc:1:2: error: stray '#' in program
    1 | \#include<bits/stdc++.h>
      |  ^
a.cc:1:3: error: 'include' does not name a type
    1 | \#include<bits/stdc++.h>
      |   ^~~~~~~
In file included from /usr/include/c++/14/ext/typelist.h:46,
                 from /usr/include/c++/14/ext/pb_ds/assoc_container.hpp:45,
                 from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
  164 |   __is_null_pointer(std::nullptr_t)
      |                                   ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
  159 |     __is_null_pointer(_Type)
      |     ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
  164 |   __is_null_pointer(std::nullptr_t)
      |                          ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/utility:69,
                 from /usr/include/c++/14/ext/pb_ds/detail/type_utils.hpp:46,
                 from /usr/include/c++/14/ext/pb_ds/tag_and_trait.hpp:46,
                 from /usr/include/c++/14/ext/pb_ds/assoc_container.hpp:46:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
  666 |     struct is_null_pointer<std::nullptr_t>
      |                                 ^~~~~~~~~
In file included from /usr/include/c++/14/cstddef:50,
                 from /usr/include/c++/14/ext/pb_ds/detail/type_utils.hpp:45:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
  443 |   typedef decltype(nullptr) nullptr_t;
      |                             ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
  666 |     struct is_null_pointer<std::nullptr_t>
      |                                          ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
  670 |     struct is_null_pointer<const std::nullptr_t>
      |                                                ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
  674 |     struct is_null_pointer<volatile std::nullptr_t>
      |                                                   ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
  678 |     struct is_null_pointer<const volatile std::nullptr_t>
      |                                                         ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1429 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
 1429 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                                         ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1438 |     : public integral_constant<std::size_t, 0> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
 1438 |     : public integral_constant<std::size_t, 0> { };
      |                                              ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
 1440 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
 1441 |     struct rank<_Tp[_Size]>
      |                     ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
 1441 |     struct rank<_Tp[_Size]>
      |                           ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1442 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
 1442 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                                                 ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1446 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
 1446 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                                                 ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
 2086 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
 2087 |     struct remove_extent<_Tp[_Size]>
      |                              ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
 2087 |     struct remove_extent<_Tp[_Size]>
      |                                    ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
 2099 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
 2100 |     struct remove_all_extents<_Tp[_Size]>
      |                                   ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
 2100 |     struct remove_all_extents<_Tp[_Size]>
      |                                         ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
 2171 |   template<std::size_t _Len>
      |            ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
 2176 |         unsigned char __data[_Len];
      |                              ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
 2194 |   template<std::size_t _Len, std::size_t _Align =
      |            ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
 2194 |   template<std::size_t _Len, std::size_t _Align =
      |                              ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
 2195 |            __alignof__(typename __aligned_storage_msa<_Len>::__type)>
      |                                                       ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
 2195 |            __alignof__(typename __aligned_storage_msa<_Len>::__type)>
      |                                                           ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
 2202 |         unsigned char __data[_Len];
      |                              ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
 2203 |         struct __attribute__((__aligned__((_Align)))) { } __align;
      |                                            ^~~~~~
In file included from /usr/include/c++/14/ext/pb_ds/detail/type_utils.hpp:47:
/usr/include/c++/14/tr1/type_traits:153:26: error: 'std::size_t' has not been declared
  153 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/tr1/type_traits:154:25: error: '_Size' was not declared in this scope
  154 |     struct is_array<_Tp[_Size]>
      |                         ^~~~~
/usr/include/c++/14/tr1/type_traits:154:31: error: template argument 1 is invalid
  154 |     struct is_array<_Tp[_Size]>
      |                               ^
/usr/include/c++/14/tr1/type_traits:354:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  354 |     : public integral_constant<std::size_t, __alignof__(_Tp)> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/tr1/type_traits:354:61: error: template argument 1 is invalid
  354 |     : public integral_constant<std::size_t, __alignof__(_Tp)> { };
      |                                                             ^
/usr/include/c++/14/tr1/type_traits:354:61: note: invalid template non-type parameter
/usr/include/c++/14/tr1/type_traits:359:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  359 |     : public integral_constant<std::size_t, 0> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/tr1/type_traits:359:46: error: te