Language: C++

#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007ULL
#define EPS 1e-8

ULL p3[100010];

inline ULL func(int u, int ofs){
	return ((u ? p3[u - 1] * u : 0ULL) + ofs * p3[u]) % MOD;
}

void mainmain(){
	p3[0] = 1;
	for(int i = 1; i < 100010; ++i){ p3[i] = p3[i - 1] * 3 % MOD; }
	string s;
	cin >> s;
	int lt = 0;
	int rt = count(ALL(s), '?');
	int a = 0;
	int c = count(ALL(s), 'C');
	ULL ans = 0;
	for(char x : s){
		if(x == '?'){ --rt; }
		if(x == 'C'){ --c; }
		if(x == '?' || x == 'B'){
			ULL t = func(lt, a);
			ULL u = func(rt, c);
			ans = (ans + t * u) % MOD;
		}
		if(x == '?'){ ++lt; }
		if(x == 'A'){ ++a; }
	}
	cout << ans << endl;
}



}
int main() try{
	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Compiler output:
a.cc:80:1: error: 'ULL' does not name a type; did you mean 'vLL'?
   80 | ULL p3[100010];
      | ^~~
      | vLL
a.cc:82:8: error: 'ULL' does not name a type; did you mean 'vLL'?
   82 | inline ULL func(int u, int ofs){
      |        ^~~
      |        vLL
a.cc: In function 'void {anonymous}::mainmain()':
a.cc:87:9: error: 'p3' was not declared in this scope
   87 |         p3[0] = 1;
      |         ^~
a.cc:95:9: error: 'ULL' was not declared in this scope; did you mean 'vLL'?
   95 |         ULL ans = 0;
      |         ^~~
      |         vLL
a.cc:100:28: error: expected ';' before 't'
  100 |                         ULL t = func(lt, a);
      |                            ^~
      |                            ;
a.cc:101:28: error: expected ';' before 'u'
  101 |                         ULL u = func(rt, c);
      |                            ^~
      |                            ;
a.cc:102:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
  102 |                         ans = (ans + t * u) % MOD;
      |                         ^~~
      |                         abs
a.cc:102:38: error: 't' was not declared in this scope
  102 |                         ans = (ans + t * u) % MOD;
      |                                      ^
a.cc:102:42: error: 'u' was not declared in this scope
  102 |                         ans = (ans + t * u) % MOD;
      |                                          ^
a.cc:107:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
  107 |         cout << ans << endl;
      |                 ^~~
      |                 abs