criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1000000007;

int main(void){
    string s; cin >> s;
    s = 'D' + s;
    ll dp[100005][4] = {};
    dp[0][0] = 1;

    for(int i=1; i<s.size(); i++){
        if(s[i] == 'A'){
            dp[i][0] = dp[i-1][0];
            dp[i][1] = (dp[i-1][1] + dp[i-1][0])%mod;
            dp[i][2] = dp[i-1][2];
            dp[i][3] = dp[i-1][3];
        }
        if(s[i] == 'B'){
            dp[i][0] = dp[i-1][0];
            dp[i][1] = dp[i-1][1];
            dp[i][2] = (dp[i-1][2] + dp[i-1][1])%mod;
            dp[i][3] = dp[i-1][3];
        }
        if(s[i] == 'C'){}
            dp[i][0] = dp[i-1][0];
            dp[i][1] = dp[i-1][1];
            dp[i][2] = dp[i-1][2];
            dp[i][3] = (dp[i-1][3] + dp[i-1][2])%mod;
        }
        if(s[i] == '?'){ // 3をかけるのがミソ
            dp[i][0] = 3*dp[i-1][0];
            dp[i][1] = (3*dp[i-1][1] + dp[i-1][0])%mod;
            dp[i][2] = (3*dp[i-1][2] + dp[i-1][1])%mod;
            dp[i][3] = (3*dp[i-1][3] + dp[i-1][2])%mod;
        }
    }

    cout << dp[s.size()-1][3] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:14: error: 'i' was not declared in this scope
   41 |         if(s[i] == '?'){ // 3をかけるのがミソ
      |              ^
a.cc: At global scope:
a.cc:49:5: error: 'cout' does not name a type
   49 |     cout << dp[s.size()-1][3] << endl;
      |     ^~~~
a.cc:50:1: error: expected declaration before '}' token
   50 | }
      | ^
Language: C++

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7t;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
      
  
  
  
  


int main(){
  ll i, j;
  string s;
  cin >> s;
  ll n = s.size();
  vector<ll> a(n + 1),ab(n + 1), abc(n + 1),x(n+1);
  x[0]=1;
  for(i = 1; i < n + 1;i++){
    x[i]=x[i-1];
    a[i] = a[i - 1];
    ab[i] = ab[i - 1];
    abc[i] = abc[i - 1];
    switch(s[i - 1]){
      case 'A':
        a[i] += x[i];
        break;
      case 'B':
        ab[i] += a[i - 1];
        break;
      case 'C':
        abc[i] += ab[i - 1];
        break;
      case '?':
        abc[i] = 3 * abc[i - 1] + ab[i - 1];
        ab[i] = 3 * ab[i - 1] + a[i - 1];
        //cout << "tsts" << endl;
        a[i] = 3 * a[i - 1] + x[i-1];
        x[i]=x[i-1]*3;
        
        break;
    }
    //cout << a[i] spa ab[i] spa abc[i] << endl;
    a[i] %= MOD;
    ab[i] %= MOD;
    abc[i] %= MOD;
    x[i]%=MOD;
  }
  cout << abc[n] << endl;
    
        
  return 0;
}

Compiler output:
a.cc:8:14: error: unable to find numeric literal operator 'operator""t'
    8 | ll MOD = 1e9+7t;
      |              ^~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
constexpr int MOD = 1000000007;
//http://drken1215.hatenablog.com/entry/2018/08/05/224100_1
void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}
string S;
long long dp[210000][5];

/*
dp[i+1][0] i文字目まで考えた時にABCとの称号をスタートすらしてない
dp[i+1][1] i文字目まで考えた時Aまでは照合させたようなもの
dp[i+1][2] i文字目まで考えた時にBまでは照合させたようなもの
dp[i+1][3] i文字目まで考えたときにABCとの照合でCまでは照合させた
*/

void add(ll &a,ll b){
    a += b;
    if (a >= MOD) a-= MOD;
}

int main ()
{
    dp[0][0] = 1;
    cin>>S;
    REP(i,S.size())
        //i文字目でカウントをすすめない
        REP(j,4){
            if (S[i] != '?') add(dp[i+1][j],dp[i][j]);
            else add(dp[i+1][j],dp[i][j] * 3 %MOD);
        }
        //i文字目でカウントをすすめる
        if (S[i] == 'A' || S[i] == '?') add(dp[i+1][1],dp[i][0]);
        if (S[i] == 'B' || S[i] == '?') add(dp[i+1][2],dp[i][1]);
        if (S[i] == 'C' || S[i] == '?') add(dp[i+1][3],dp[i][2]);
    }
    cout<<dp[S.size()][3]<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:15: error: 'i' was not declared in this scope
   48 |         if (S[i] == 'A' || S[i] == '?') add(dp[i+1][1],dp[i][0]);
      |               ^
a.cc:49:15: error: 'i' was not declared in this scope
   49 |         if (S[i] == 'B' || S[i] == '?') add(dp[i+1][2],dp[i][1]);
      |               ^
a.cc:50:15: error: 'i' was not declared in this scope
   50 |         if (S[i] == 'C' || S[i] == '?') add(dp[i+1][3],dp[i][2]);
      |               ^
a.cc: At global scope:
a.cc:52:5: error: 'cout' does not name a type
   52 |     cout<<dp[S.size()][3]<<endl;
      |     ^~~~
a.cc:53:5: error: expected unqualified-id before 'return'
   53 |     return 0;
      |     ^~~~~~
a.cc:54:1: error: expected declaration before '}' token
   54 | }
      | ^
Language: C++

  1 #include<bits/stdc++.h>                                                                               
  2 using namespace std;
  3 #define int long long
  4 
  5 const int mod=1e9+7;
  6 
  7 void add(int &a,int b){
  8    a+=b;
  9    if(a>=mod) a-=mod;
 10 }
 11 
 12 signed main()
 13 {
 14    string s; cin>>s;
 15    int N=s.size();
 16 
 17    vector<vector<int> > dp(N+1,vector<int>(4));
 18    dp[0][0]=1;
 19    for(int i=0;i<N;i++){
 20       for(int j=0;j<=3;j++){
 21          if(s[i]=='?'){
 22             add(dp[i+1][j],dp[i][j]*3%mod);
 23          }
 24          else{
 25             add(dp[i+1][j],dp[i][j]);
 26          }
 27       }
 28       if(s[i]=='A' or s[i]=='?'){
 29          add(dp[i+1][1],dp[i][0]);
 30       }
 31       if(s[i]=='B' or s[i]=='?'){
 32          add(dp[i+1][2],dp[i][1]);
 33       }
 34       if(s[i]=='C' or s[i]=='?'){
 35          add(dp[i+1][3],dp[i][2]);
 36       }
 37    }
 38    cout<<dp[N][3]<<endl;
 39 }


Compiler output:
a.cc:1:5: error: stray '#' in program
    1 |   1 #include<bits/stdc++.h>
      |     ^
a.cc:3:5: error: stray '#' in program
    3 |   3 #define int long long
      |     ^
a.cc:1:3: error: expected unqualified-id before numeric constant
    1 |   1 #include<bits/stdc++.h>
      |   ^
a.cc:3:3: error: expected unqualified-id before numeric constant
    3 |   3 #define int long long
      |   ^
a.cc:6:3: error: expected unqualified-id before numeric constant
    6 |   6
      |   ^
a.cc:11:2: error: expected unqualified-id before numeric constant
   11 |  11
      |  ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;


int main(){
  string S;cin>> S;
  string ABC="ABC";
  int N=S.size();

  ll dp[N+1][4];

  for (int j=0;j<4;++j){
    dp[N][j]=(j==3)?1:0;
  }

  for (int n=N-1;n>=0;n--){
    for (int j=0;j<4;++j){
      ll m=S[n]=='?')? 3:1;
      dp[n][j]=m*dp[n+1][j];
      if((j!=3)&&(S[n]=='?'||S[n]==ABC[j])){
        dp[n][j]+=dp[n+1][j+1];
      }
    }
  }

  cout << dp[0][0]<< endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:21: error: expected ',' or ';' before ')' token
   20 |       ll m=S[n]=='?')? 3:1;
      |                     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;


int main(){
  string S;cin>> S;
  string ABC="ABC";
  int N=S.size();

  ll dp[N+1][4];

  for (int j=0;j<4;++j){
    dp[N][j]=(j==3)?1:0;
  }

  for (int n=N-1;n>=0;n--){
    for (int j=0;j<4;++j){
      dp[n][j]=(S[n]=='?')? 3:1)*dp[n+1][j];
      if((j!=3)&&(S[n]=='?'||S[n]==ABC[j])){
        dp[n][j]+=dp[n+1][j+1];
      }
    }
  }

  cout << dp[0][0]<< endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:32: error: expected ';' before ')' token
   20 |       dp[n][j]=(S[n]=='?')? 3:1)*dp[n+1][j];
      |                                ^
      |                                ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;


int main(){
  string S;cin>> S;
  string ABC="ABC";
  int N=S.size();

  ll dp[N+1][4];
  memset(dp, 0, sizeof(dp));

  for (j=0;j<4;++j){
    dp[N][j]=(j==3)?1:0;
  }

  for (int i=N-1;i>=0;--i){
    for (int j=0;j<3;++j){
      if(S[i+1]=='?'){
        (dp[i][j]+=3*dp[i+1][j])%MOD;
        if(j!=3){
          (dp[i][j]+=dp[i+1][j+1])%MOD;
        }
      }
      else{
        (dp[i][j]+=dp[i+1][j])%MOD;
        if(j!=3&&S[i+1]==ABC[j+1]){
          (dp[i][j]+=dp[i+1][j+1])%MOD;
        }
      }
      
    }
  }

  cout << dp[0][0]<< endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:8: error: 'j' was not declared in this scope
   15 |   for (j=0;j<4;++j){
      |        ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

using ll = long long;

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    cout << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    cout << ']';
	return s;
}

ll dp[100001][4];


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
	cin >> s;

	int n = s.size();

	dp[n][3] = 1;i
	for(int i = 0; i < 3; ++i){
		dp[n][i] = 0;
	}

	for(int i = n-1; i >= 0; --i){
		int m = (s[i] == '?') ? 3 : 1;
		dp[i][3] = m * dp[i+1][3] % MOD;
	}

	for(int i = n-1; i >= 0; --i){
		for(int j = 2; j >= 0; --j){
			int m = (s[i] == '?') ? 3 : 1;
			int k = (s[i] == '?') or (s[i] == "ABC"[j]);
			dp[i][j] = (m * dp[i+1][j] % MOD + k * dp[i+1][j+1] % MOD) % MOD;
		}
	}


	ppp(dp[0][0]);

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:22: error: 'i' was not declared in this scope
   53 |         dp[n][3] = 1;i
      |                      ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;

int main(){
  string S;cin>>S;
  int N=S.size();
  ll dp[N+1][4];

  for (int i=N;i>=0;--i){
    for (int j=3;j>=0;--j){
      if(i==N){(dp[i][j]=(j==3? 1:0));}else{
        dp[i][j]=dp[i+1][j]*(S[i]=='?' ? 3LL:1LL);
        if((j<3)&&(S[i]=='?'|| S[i]=="ABC"[j])){
          dp[i][j]+=dp[i+1][j+1];
        }
      }
      dp%=MOD;
    }
  }

  cout << dp[0][0] << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: invalid operands of types 'll [(N + 1)][4]' {aka 'long long int [(N + 1)][4]'} and 'll' {aka 'long long int'} to binary 'operator%'
   19 |       dp%=MOD;
      |       ~~^~~~~
a.cc:19:9: note:   in evaluation of 'operator%=(ll [(N + 1)][4] {aka long long int [(N + 1)][4]}, ll {aka long long int})'
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;

int main(){
  string S;cin>>S;
  int N=S.size();
  ll dp[N][4];

  for (int i=N-1;i>=0;--i){
    if(i==N-1){dp[i][j]=(j==3? 1:0);}else{
      dp[i][j]=dp[i+1][j]*(j==3 ? 3:1);
      if(S[i]=='?'|| S[i]=="ABC"[j]){
        (dp[i][j]+=dp[i+1][j+1])%=MOD;
      }
    }
  }

  cout << dp[0][0] << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:22: error: 'j' was not declared in this scope
   12 |     if(i==N-1){dp[i][j]=(j==3? 1:0);}else{
      |                      ^
a.cc:13:13: error: 'j' was not declared in this scope
   13 |       dp[i][j]=dp[i+1][j]*(j==3 ? 3:1);
      |             ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
using namespace std;
const long long INF = 1000000007
int main () {
  string S;
  cin >> S;
  int A[100001];
  int B[100001];
  int C[100001];
  int a = 0;
  int c = 0;
  for (int i = 0; i < S.size(); i ++) {
    if (S[i] == 'A') {
      A[a] = i;
      B[i] = B[i - 1];
      a ++;
    }
    if (S[i] == 'B') {
      B[i] ++;
    }
    if (S[i] == 'C') {
      C[c] = i;
      A[i] = A[i - 1];
      B[i] = B[i - 1];
    }
    if (S[i] == '?') {
      A[a] = i;
      B[i] ++;
      C[c] = i;
      a ++;
      c ++;
    }
  }
  long long ans = 0ll;
  for(int i = 0; i < a; i ++) {
    for (int j = c - 1; c >= 0; c --) {
      if (C[j] <= A[i]) continue;
      ans += B[j - 1] - B[i];
      ans = ans % INF;
    }
  }
  ans = ans % INF;
  cout << ans << endl;
}
                              
  

Compiler output:
a.cc:6:1: error: expected ',' or ';' before 'int'
    6 | int main () {
      | ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
typedef pair<int, int> P;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    string s; cin >> s;
    int n = s.size(), MOD = 1000000007;
    long long dp[100010][4] = {};
    for(int i = N; i >= 0; --i){
        for(int j = 3; j >= 0; --j){
            if(i == N){
                dp[i][j] = (j == 3 ? 1:0);
            } else {
                dp[i][j] = dp[i+1][j]*(s[i] == '?' ? 3LL : 1LL);
                if(j < 3 && (s[i] == '?' || s[i == "ABC"[j]])){
                    dp[i][j] += dp[i+1][j+1];
                } 
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: 'N' was not declared in this scope
   17 |     for(int i = N; i >= 0; --i){
      |                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
long long dp[100010][5];
int main(){
    string s;
    cin >> s;
    for(int i = s.length(); i >= 0; --i){
        for(int j = 3; j >= 0; --j){
            if(i == s.length()){
                dp[i][j] = (j == 3 ? 1 : 0);
            }
            else{
                dp[i][j] = dp[i+1][j] * (S[i] == '?' ? (long long)3 : (long long)1);
                if(j < 3 && (S[i] == '?' || S[i] == "ABC"[j])){
                    dp[i][j] += dp[i+1][j+1];
                }
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:42: error: 'S' was not declared in this scope
   14 |                 dp[i][j] = dp[i+1][j] * (S[i] == '?' ? (long long)3 : (long long)1);
      |                                          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
long long dp[100010][5]
int main(){
    string s;
    cin >> s;
    for(int i = s.length(); i >= 0; --i){
        for(int j = 3; j >= 0; --j){
            if(i == s.length()){
                dp[i][j] = (j == 3 ? 1 : 0);
            }
            else{
                dp[i][j] = dp[i+1][j] * (S[i] == '?' ? (long long)3 : (long long)1);
                if(j < 3 && (S[i] == '?' || S[i] == "ABC"[j])){
                    dp[i][j] += dp[i+1][j+1];
                }
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
}


Compiler output:
a.cc:5:1: error: expected initializer before 'int'
    5 | int main(){
      | ^~~
Language: C++

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

string s;
ll ans;

void add(int state,int _c,int bcsum) {
	if (state == 0) {
		if (s[0] == 'A' || s[0] == '?') {
			ans = (ans + bcsum%inf)%inf;
		}
		return;
	} else if (s[state] == 'A') {
		ans = (ans + bcsum%inf)%inf;
		add(state-1,_c,bcsum);
		return;
	} else if (s[state] == 'B') {
		add(state-1,_c,bcsum+_c);
		return;
	} else if (s[state] == 'C') {
		add(state-1,_c+1,bcsum);
		return;
	} else {
		ans = (ans + bcsum%inf)%inf;
		add(state-1,_c,bcsum);
		add(state-1,_c,bcsum+_c);
		add(state-1,c+1,bcsum);
		return;
	}
}

int main() {
	cin >> s;
	add(s.size()-1,0,0);
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'void add(int, int, int)':
a.cc:35:29: error: 'c' was not declared in this scope; did you mean '_c'?
   35 |                 add(state-1,c+1,bcsum);
      |                             ^
      |                             _c
Language: C++

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

string s;
ll ans;

void add(int state,,int _c,int bcsum) {
	if (state == 0) {
		if (s[0] == 'A' || s[0] == '?') {
			ans = (ans + bcsum%inf)%inf;
		}
		return;
	} else if (s[state] == 'A') {
		ans = (ans + bcsum%inf)%inf;
		add(state-1,_c,bcsum);
		return;
	} else if (s[state] == 'B') {
		add(state-1,_c,bcsum+_c);
		return;
	} else if (s[state] == 'C') {
		add(state-1,_c+1,bcsum);
		return;
	} else {
		ans = (ans + bcsum%inf)%inf;
		add(state-1,_c,bcsum);
		add(state-1,_c,bcsum+_c);
		add(state-1,c+1,bcsum);
		return;
	}
}

int main() {
	cin >> s;
	add(s.size()-1,0,0);
	cout << ans << endl;
}

Compiler output:
a.cc:15:20: error: expected identifier before ',' token
   15 | void add(int state,,int _c,int bcsum) {
      |                    ^
a.cc: In function 'void add(int, int, int, int)':
a.cc:23:20: error: too few arguments to function 'void add(int, int, int, int)'
   23 |                 add(state-1,_c,bcsum);
      |                 ~~~^~~~~~~~~~~~~~~~~~
a.cc:15:6: note: declared here
   15 | void add(int state,,int _c,int bcsum) {
      |      ^~~
a.cc:26:20: error: too few arguments to function 'void add(int, int, int, int)'
   26 |                 add(state-1,_c,bcsum+_c);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:15:6: note: declared here
   15 | void add(int state,,int _c,int bcsum) {
      |      ^~~
a.cc:29:20: error: too few arguments to function 'void add(int, int, int, int)'
   29 |                 add(state-1,_c+1,bcsum);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~
a.cc:15:6: note: declared here
   15 | void add(int state,,int _c,int bcsum) {
      |      ^~~
a.cc:33:20: error: too few arguments to function 'void add(int, int, int, int)'
   33 |                 add(state-1,_c,bcsum);
      |                 ~~~^~~~~~~~~~~~~~~~~~
a.cc:15:6: note: declared here
   15 | void add(int state,,int _c,int bcsum) {
      |      ^~~
a.cc:34:20: error: too few arguments to function 'void add(int, int, int, int)'
   34 |                 add(state-1,_c,bcsum+_c);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:15:6: note: declared here
   15 | void add(int state,,int _c,int bcsum) {
      |      ^~~
a.cc:35:29: error: 'c' was not declared in this scope; did you mean '_c'?
   35 |                 add(state-1,c+1,bcsum);
      |                             ^
      |                             _c
a.cc: In function 'int main()':
a.cc:42:12: error: too few arguments to function 'void add(int, int, int, int)'
   42 |         add(s.size()-1,0,0);
      |         ~~~^~~~~~~~~~~~~~~~
a.cc:15:6: note: declared here
   15 | void add(int state,,int _c,int bcsum) {
      |      ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long power(int n, int m){
  if(m < 0){
    return 1;//今回だけ
  }else if(m==0){
    return 1;
  }else if(m % 2 == 0){
    long long tmp = power(n, m / 2);
    return (tmp * tmp) % mod;
  }else{
    return (n * power(n, m - 1)) % mod;
  }
}
int main() {
  string S;
  int ans = 0;
  cin >> S;
  int c[100001] = {0}, q[100001] = {0};
  for(int i = S.size() - 1; i >= 0; i--){
    c[i] = c[i + 1];
    q[i] = q[i + 1];
    if(S[i] == 'C'){
      c[i]++;
    }else if(S[i] == '?'){
      q[i]++;
    }
  }
  int w[4];
  for(int i = 0; i < 4; i++){
    w[i] = power(3, q[0] - i);
  }
  for(int i = 0; i < S.size() - 2; i++){
    if(S[i] == 'A'){
      for(int j = i + 1; j < S.size() - 1; j++){
        if(S[j] == 'B'){
          ans = ((ans + c[j + 1] * w[0] % mod) % mod + q[j + 1] * w[1] % mod) % mod;
        }
        else if(S[j] == '?'){
          ans = ((ans + c[j + 1] * w[1] % mod) % mod + q[j + 1] * w[2] % mod) % mod;
        }
      }
    }else if(S[i] == '?'){
      for(int j = i + 1; j < S.size() - 1; j++){
        if(S[j] == 'B'){
          ans = ((ans + c[j + 1] * w[1] % mod) % mod + q[j + 1] * w[2]) % mod) % mod;
        }
        else if(S[j] == '?'){
          ans = ((ans + c[j + 1] * w[2] % mod) % mod + q[j + 1] * w[3] % mod) % mod;
        }
      }
    }
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:78: error: expected ';' before ')' token
   47 |           ans = ((ans + c[j + 1] * w[1] % mod) % mod + q[j + 1] * w[2]) % mod) % mod;
      |                                                                              ^
      |                                                                              ;
Language: C++

#include<iostream>
#include<cmath>
#include<string>

using namespace std;

typedef long long ll;
ll MOD = 1000000007;

int main() {
   string S;
   cin >> S;
   int N = S.size();

   ll dp[10100][4] = {};

   dp[N][3] = 1;
   dp[N][2] = 0;
   dp[N][1] = 0;
   dp[N][0] = 0;

   for (int i = N - 1; i >= 0; i--) {
      for (int j = 3; j >= 0; j--) {
         /*
         if (j == 3) {
            if (S[i] == '?') dp[i][j] = 3 * dp[i + 1][j] % MOD;
            else dp[i][j] = dp[i + 1][j] % MOD;
         }
         */
         dp[i][j] = dp[i+1][j] * (S[i] == '?' ? 3LL : 1LL);
         else {
            if (S[i] == '?') dp[i][j] = dp[i + 1][j + 1] + 3 * dp[i + 1][j] % MOD;
            else if ((S[i] == 'A' && j == 0) || (S[i] == 'B' && j == 1) || (S[i] == 'C' && j == 2)) {
               dp[i][j] = dp[i + 1][j] + dp[i + 1][j + 1];
            } else dp[i][j] = dp[i + 1][j];
            dp[i][j] %= MOD; 
         }
      }
   }

   cout << dp[0][0] << endl;
   return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:10: error: 'else' without a previous 'if'
   31 |          else {
      |          ^~~~
Language: Java

import java.util.*;

public class Main{
public static void main(String[] args){
long mod = 1000000007;
Scanner sc = new Scanner(System.in);
String S = sc.next();
int l = S.length();
long[] A = new long[l];
long[] AB = new long[l];
long[] ABC = new long[l];
for(int i=0; i<l; i++){
switch(S.charAt(i)){
case 'A': A[i]=A[i-1]+1; AB[i]=AB[i-1]; ABC[i]=ABC[i-1];
case 'B': A[i]=A[i-1]; AB[i]=AB[i-1]+A[i-1]; ABC[i]=ABC[i-1];
case 'C': A[i]=A[i-1]; AB[i]=AB[i-1]; ABC[i]=ABC[i-1]+AB[i-1];
case '?: A[i]=A[i-1]+1; AB[i]=AB[i-1]+A[i-1]; ABC[i]=ABC[i-1]+AB[i-1];
}
A[i]%=mod; AB[i]%=mod; ABC[i]%=mod;
}
System.out.println(ABC[l-1]);
return;
}
}

Compiler output:
Main.java:17: error: unclosed character literal
case '?: A[i]=A[i-1]+1; AB[i]=AB[i-1]+A[i-1]; ABC[i]=ABC[i-1]+AB[i-1];
     ^
Main.java:17: error: : or -> expected
case '?: A[i]=A[i-1]+1; AB[i]=AB[i-1]+A[i-1]; ABC[i]=ABC[i-1]+AB[i-1];
                      ^
2 errors
Language: Java

import java.util.*;
class Main
{
    static int MOD = 1000000007;
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();

        int[] cntA = new int[n+1];
        int[] cntB = new int[n+1];
        int[] cntC = new int[n+1];
        int[] cntQ = new int[n+1];
        cntA[0] = cntB[0] = cntC[0] = cntQ[0] = 0;
        for(int i = 1; i < n+1; i++){
            char c = s.charAt(i-1);
            cntA[i] = cntA[i-1];
            cntB[i] = cntB[i-1];
            cntC[i] = cntC[i-1]; 
            cntQ[i] = cntQ[i-1];           
            switch(c){
                case 'A':
                    cntA[i]++;
                    break;
                case 'B':
                    cntB[i]++;
                    break;
                case 'C':
                    cntC[i]++;
                    break;
                default:
                    cntQ[i]++;
                    break;

            }
        }
        long ans = 0;
        long left;
        long right;
        for(int i = 0; i < n; i++){
            left = right = 0;
            if(s.charAt(i) == 'B' || s.charAt(i) == '?'){
                left += cntA[i+1] * pow3(cntQ[i]) % MOD;
                left += cntQ[i] * pow3(cntQ[i] - 1) % MOD;
                left %= MOD;
                right += (cntC[n] - cntC[i+1]) * pow3(cntQ[n] - cntQ[i+1]) % MOD;
                right += (cntQ[n] - cntQ[i+1]) * pow3(cntQ[n] - cntQ[i+1] - 1) % MOD;
                right %= MOD;
                ans += left * right % MOD;
                ans %= MOD;
            }
        }
        System.out.println(ans);
    }
    static long pow3(int n){
        if(n < 0) return 0;
        if(n == 0) return 1;
        if(n % 2 == 0){
            long d = pow3(n / 2);
            return d * d　% MOD;
        }
        return 3 * pow3(n-1)　% MOD;
    }
}

Compiler output:
Main.java:61: error: illegal character: '\u3000'
            return d * d?% MOD;
                        ^
Main.java:61: error: not a statement
            return d * d?% MOD;
                           ^
Main.java:63: error: illegal character: '\u3000'
        return 3 * pow3(n-1)?% MOD;
                            ^
Main.java:63: error: not a statement
        return 3 * pow3(n-1)?% MOD;
                               ^
4 errors
Language: C++

#include <iostream>
 
using namespace std;
char a[100009];
unsigned long long dp1[100009];
unsigned long long dp3[100009];
unsigned long long dp2[100009];
unsigned long long sum=0;
unsigned long long wenhao=0;
#define mood(x)  ((x)%1000000007) 
int main()
{
	ios::sync_with_stdio(false);
	cin>>(a+1);
	int len=strlen(a+1);
	
	for(int i=1;i<=len;i++)
	{	dp1[i]=dp1[i-1];
		dp2[i]=dp2[i-1];
		dp3[i]=dp3[i-1];
		if(a[i]=='A')
		{
			dp1[i]+=1;
			mood(dp1[i]);
		}
		else if(a[i]=='B')
		{
			dp2[i]=mood((mood(dp1[i-1])+mood(dp2[i])));
		}
		else if(a[i]=='C')
		{
			dp3[i]=mood((mood(dp2[i-1])+mood(dp3[i])));
		}
		else if(a[i]=='?')
		{   if(!wenhao) wenhao=1;
			else wenhao*=3;
			mood(wenhao);
			dp1[i]=mood(dp1[i-1]*3+wenhao);
			dp2[i]=mood(dp2[i-1]*3+dp1[i-1]);
			dp3[i]=mood(dp3[i-1]*3+dp2[i-1]);
			
		}
		
	}
	cout<<mood(dp3[len]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: 'strlen' was not declared in this scope
   15 |         int len=strlen(a+1);
      |                 ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 |
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 100005;
typedef long long ll;
char s[N];
int frt[N], bhd[N], qes_f[N], qes_b[N], Pow[N];
int main(){
    Pow[0] = 1;
    for(int i = 1; i < N; ++i) Pow[i] = 1ll * Pow[i-1] * 3 % mod;
    gets(s+1);
    ll ans = 0;
    int n = strlen(s+1);
    for(int i = 1; i <= n; ++i){
        frt[i] = frt[i-1]; qes_f[i] = qes_f[i-1];
        if(s[i] == 'A'){
            frt[i] += 1;
        }else if(s[i] == '?') qes_f[i] += 1;
    }
    for(int i = n; i >= 1; --i){
        bhd[i] = bhd[i+1]; qes_b[i] = qes_b[i+1];
        if(s[i] == 'C') bhd[i] += 1;
        else if(s[i] == '?') qes_b[i] += 1;
    }
    for(int i = 1; i <= n; ++i){
        if(s[i] == 'B' || s[i] == '?'){
            ans = (ans + (1ll * frt[i] * bhd[i] * Pow[qes_f[i-1]+qes_b[i+1]] % mod)
                + (1ll * frt[i] * qes_b[i+1] * Pow[qes_f[i-1]+qes_b[i+1]-1] % mod)
                + (1ll * bhd[i] * qes_f[i-1] * Pow[qes_f[i-1]+qes_b[i+1]-1] % mod)
                + (1ll * qes_b[i+1] * qes_f[i-1] * Pow[qes_f[i-1]+qes_b[i+1]-2] % mod)) % mod;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: 'gets' was not declared in this scope; did you mean 'getw'?
   11 |     gets(s+1);
      |     ^~~~
      |     getw
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

#define INF (1<<31-1)
#define mod 1000000007
#define ll long long

ll A, AB, ABC;

int main(){

	string S;

	cin >> S;
	int Q = 0;
	for (int i = 0; i < S.length(); i++){

		if (S[i] == 'A'){
			A = A + pow(3,Q);
		}
		else if (S[i] == 'B'){
			AB = (A + AB) % mod;
		}
		else if (S[i] == 'C'){
			ABC = (AB + ABC) % mod;
		}
		else if (S[i] == '?'){
			ABC = (AB + ABC * 3) % mod;
			AB = (A + AB * 3) % mod;
			A = (A * 3 + pow(3, Q)) % mod;
			Q++;
		}
//		cout << A << " " << AB << " " << ABC << endl;
	}

	cout << ABC % mod << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:49: error: invalid operands of types '__gnu_cxx::__promote<double>::__type' {aka 'double'} and 'int' to binary 'operator%'
   34 |                         A = (A * 3 + pow(3, Q)) % mod;
      |                             ~~~~~~~~~~~~~~~~~~~ ^
      |                                    |
      |                                    __gnu_cxx::__promote<double>::__type {aka double}
Language: C++


#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i<=b;i++)
#define fore(i,a) for(auto &i:a)


using namespace std;
typedef long long ll;

const int MOD = 1e9 + 1;
string S;

void add(ll &a, ll &b) {
	a += b;
	if (a >= MOD)a -= MOD;
}

//i番目までみた時の、状態j
//j=0 ""
//j=1 A
//j=2 AB
//j=3 ABC

ll dp[210000][4];

int main() {

	cin >> S;
	memset(dp, 0, sizeof(dp));

	dp[0][0] = 1;

	//Sを1文字ずつみていく。
	for (int i = 0; i < S.size(); ++i) {
		//Siを使わない。
		for (int j = 0; j < 4; ++j) {
			if (S[i] != '?')dp[i + 1][j] = dp[i][j];
			else dp[i + 1][j] = dp[i][j] * 3 % MOD;
		}

		//Siを使う。

		//状態0はAか？がくれば状態1に遷移する。
		if (S[i] == 'A' || S[i] == '?') add(dp[i + 1][1], dp[i][0]);

		//状態1はBか？がくれば状態2に遷移する。
		if (S[i] == 'B' || S[i] == '?') add(dp[i + 1][2], dp[i][1]);

		//状態2はCか？がくれば状態3に遷移する。
		if (S[i] == 'C' || S[i] == '?') add(dp[i + 1][3], dp[i][2]);
	}
	
	cout << dp[S.size()][3] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:9: error: 'memset' was not declared in this scope
   43 |         memset(dp, 0, sizeof(dp));
      |         ^~~~~~
a.cc:15:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   14 | #include <iomanip>
  +++ |+#include <cstring>
   15 |
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#define P 1000000007
using namespace std;
 
int main(){
  string s;
  cin >> s;
  int a[s.size()+1], c[s.size()+1], q[s.size()+1];
  a[0] = 0;
  c[0] = 0;
  q[0] = 0;
  long long ans0=0, ans1=0, ans2=0, ans3=0, ans=0;
  long long power=1;
  
  for(int i=0; i<s.size(); ++i){
    a[i+1] = a[i]+((s[i] == 'A')?1:0);
    c[i+1] = c[i]+((s[i] == 'C')?1:0);
    q[i+1] = q[i]+((s[i] == '?')?1:0);
  }
  
  for(int i=0; i<s.size(); ++i){
    if(s[i] == 'B'){
      ans0 += a[i]*(c[s.size()]-c[i+1]);
      ans1 += q[i]*(c[s.size()]-c[i+1]) + a[i]*(q[s.size()]-q[i+1]);
      ans2 += q[i]*(q[s.size()]-q[i+1]);
    }
    if(s[i] == '?'){
      ans1 += a[i]*(c[s.size()]-c[i+1]);
      ans2 += q[i]*(c[s.size()]-c[i+1]) + a[i]*(q[s.size()]-q[i+1]);
      ans3 += q[i]*(q[s.size()]-q[i+1]);
    }
  }
  ans0 %= P; ans1 %= P; ans2 %= P; ans3 %= P;
  
  if(q[s.size()] >= 3){
    for(int i=0; i < q[s.size()]-3; ++i)
      power = power*3%P;
    ans = (power*27%P*ans0 + power*9%P*ans1 + power*3*ans2 + power*ans3)%P;
  }else if(q[s.size() == 2){
    ans = (ans0 * 9 + ans1 * 3 + ans2) % P;
  }else if(q[s.size() == 1){
    ans = (ans0 * 3 + ans1) % P;
  }else if(q[s.size() == 0){
    ans = ans0;
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:27: error: expected ']' before ')' token
   41 |   }else if(q[s.size() == 2){
      |                           ^
      |                           ]
a.cc:43:27: error: expected ']' before ')' token
   43 |   }else if(q[s.size() == 1){
      |                           ^
      |                           ]
a.cc:45:27: error: expected ']' before ')' token
   45 |   }else if(q[s.size() == 0){
      |                           ^
      |                           ]
Language: C++

#include <iostream>
#include <stack>
#include <math.h>
#include <string.h>

using namespace std;

char S[100009]
long long dp[100009][4];
long long N = 1e9 + 7;

int main(int argc, char** argv) {
    cin >> S;
    int T = strlen(S);

    dp[0][0] = 1;
    dp[0][1] = 0;
    dp[0][2] = 0;
    dp[0][3] = 0;
    for (int i = 1; i <= T; i++) {
        if (S[i - 1] != '?')
            dp[i][0] = dp[i - 1][0];
        else
            dp[i][0] = 3 * dp[i - 1][0];
        dp[i][0] = dp[i][0] % N;
    }
    for (int i = 1; i <= T; i++) {
        for (int j = 1; j <= 3; j++) {
            if (S[i - 1] == 'A' + j - 1) {
                dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
            } else if (S[i - 1] == '?') {
                dp[i][j] = dp[i - 1][j - 1] + 3 * dp[i - 1][j];
            } else {
                dp[i][j] = 1 * dp[i - 1][j];
            }
            dp[i][j] = dp[i][j] % N;
        }
    }
    /*
    for (int i = 0; i <= T; i++) {
        for (int j = 0; j <= 3; j++) {
            cout << dp[i][j] << ",";
        }
        cout << endl;
    }
    */
    cout << dp[T][3] << endl;
}


Compiler output:
a.cc:9:1: error: expected initializer before 'long'
    9 | long long dp[100009][4];
      | ^~~~
a.cc: In function 'int main(int, char**)':
a.cc:13:12: error: 'S' was not declared in this scope
   13 |     cin >> S;
      |            ^
a.cc:16:5: error: 'dp' was not declared in this scope
   16 |     dp[0][0] = 1;
      |     ^~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int mod = 1000000007;
  ll dp[n+1][4];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int i=0; i<n; i++) {
    for (int j=0; j<4; j++) {
      if (s[i] != '?') dp[i+1][j] += dp[i][j] % mod;
      else dp[i+1][j] += dp[i][j] * 3 % mod;
      dp[i+1][j] %= mod;
    }
    if(s[i] == '?' || s[i] == 'A') {
      dp[i+1][1] += dp[i][0] % mod;
      dp[i+1][1] %= mod;
    }
    if(s[i] == '?' || s[i] == 'B') {
      dp[i+1][2] += dp[i][1] % mod;
      dp[i+1][2] %= mod;
    }
    if(s[i] == '?' || s[i] == 'C') {
      dp[i+1][3] += dp[i][2] % mod;
      dp[i+1][3] %= mod;
    }
  }
  cout << dp[n][3] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:3: error: 'memset' was not declared in this scope
   19 |   memset(dp, 0, sizeof(dp));
      |   ^~~~~~
a.cc:10:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    9 | #include <map>
  +++ |+#include <cstring>
   10 | using ll = long long;
Language: C++

#define uint unsigned int

#define REP(i, lim) for(int i=0; i<lim; i++)

#define MOD (1000000007)

int main(){
    string S;
    cin >> S;
    uint l = S.length();
    uint dp[100000][4] = {};

    REP(i, l)
        dp[i][0] = 1;
    for(int i = 0; i < l; i++){
        switch(S[i]){
            case 'A':
                dp[i+1][0] = dp[i][0]; 
                dp[i+1][1] = dp[i][0] + dp[i][1]; 
                dp[i+1][2] = dp[i][2]; 
                dp[i+1][3] = dp[i][3]; 
                break;
            case 'B':
                dp[i+1][0] = dp[i][0]; 
                dp[i+1][1] = dp[i][1]; 
                dp[i+1][2] = (dp[i][1] + dp[i][2] ) %MOD; 
                dp[i+1][3] = dp[i][3]; 
                break;
            case 'C':
                dp[i+1][0] = dp[i][0]; 
                dp[i+1][1] = dp[i][1]; 
                dp[i+1][2] = dp[i][2]; 
                dp[i+1][3] = (dp[i][2] + dp[i][3]) % MOD; 
                break;
            case '?':
                dp[i+1][0] = 3*dp[i][0]; 
                dp[i+1][1] = (dp[i][0] + 3*dp[i][1]) % MOD; 
                dp[i+1][2] = (dp[i][1] + 3*dp[i][2]) % MOD; 
                dp[i+1][3] = (3*dp[i][3] + dp[i][2]) % MOD; 
                break;
            default:
                cout << "error : " << S[i] <<endl;
        }
    }
    //REP(i,l+1){
    //    printf("%04d %04d %04d %04d\n", dp[i][0], dp[i][1], dp[i][2], dp[i][3]);
    //}

    cout << dp[l][3] << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'string' was not declared in this scope
    8 |     string S;
      |     ^~~~~~
a.cc:9:5: error: 'cin' was not declared in this scope
    9 |     cin >> S;
      |     ^~~
a.cc:9:12: error: 'S' was not declared in this scope
    9 |     cin >> S;
      |            ^
a.cc:42:17: error: 'cout' was not declared in this scope
   42 |                 cout << "error : " << S[i] <<endl;
      |                 ^~~~
a.cc:42:46: error: 'endl' was not declared in this scope
   42 |                 cout << "error : " << S[i] <<endl;
      |                                              ^~~~
a.cc:49:5: error: 'cout' was not declared in this scope
   49 |     cout << dp[l][3] << endl;
      |     ^~~~
a.cc:49:25: error: 'endl' was not declared in this scope
   49 |     cout << dp[l][3] << endl;
      |                         ^~~~
Language: C++

#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
char s[100000];
long long n, f[4][100000]; // 0 ? 1 A 2 AB 3 ABC

int main(){
    scanf("%s", s + 1);
    n = strlen(s + 1);
    s = " " + s;
    f[0][0] = 1;
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= 3; j++){
            f[j][i] = f[j][i-1];
            if (s[i] == '?') f[j][i] = (f[j][i]*3)% mod;
            if (j > 0 && (s[i] == '?' || s[i] - 'A' + 1 == j)){
                f[j][i] = (f[j][i] + f[j-1][i-1])% mod;
            }
        }
    }
    cout << f[3][n];
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:13: error: invalid operands of types 'const char [2]' and 'char [100000]' to binary 'operator+'
   10 |     s = " " + s;
      |         ~~~ ^ ~
      |         |     |
      |         |     char [100000]
      |         const char [2]
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
 
using namespace std;
 
int main(){
  string s;
  cin >> s;
  int a[s.size()+1], c[s.size()+1], q[s.size()+1];
  a[0] = 0;
  c[0] = 0;
  q[0] = 0;
  long long ans0=0, ans1=0, ans2=0, ans3=0, ans=0;
  long long power=1;
  
  for(int i=0; i<s.size(); ++i){
    a[i+1] = a[i]+((s[i] == 'A')?1:0);
    c[i+1] = c[i]+((s[i] == 'C')?1:0);
    q[i+1] = q[i]+((s[i] == '?')?1:0);
  }
  
  for(int i=0; i<q[s.size()]-3; ++i)
    power = power*3%1000000007;
  
  for(int i=0; i<s.size(); ++i){
    if(s[i] == 'B'){
      ans0 += a[i]*(c[s.size()]-c[i+1]);
      ans1 += q[i]*(c[s.size()]-c[i+1]) + a[i]*(q[s.size()]-q[i+1]);
      ans2 += q[i]*(q[s.size()]-q[i+1]);
    }
    if(s[i] == '?'){
      ans1 += a[i]*(c[s.size()]-c[i+1]);
      ans2 += q[i]*(c[s.size()]-c[i+1]) + a[i]*(q[s.size()]-q[i+1]);
      ans3 += q[i]*(q[s.size()]-q[i+1]);
    }
  }
  ans0 %= 1000000007;
  ans1 %= 1000000007;
  ans2 %= 1000000007;
  ans3 %= 1000000007;
  ans = (power*27%1000000007*ans0 + power*9%1000000007*ans1 + power*3*ans2 + power*ans3)%1000000007;
  cout << ans << endl;


Compiler output:
a.cc: In function 'int main()':
a.cc:43:23: error: expected '}' at end of input
   43 |   cout << ans << endl;
      |                       ^
a.cc:7:11: note: to match this '{'
    7 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <utility>
using namespace std;

int main()
{
	string str;
	cin >> str;

	int mod = 1000000007;
	
	long long currPow = 1;
	vector <long long> A(str.length() + 1, 0), AB(str.length() + 1, 0), ABC(str.length() + 1, 0);

	//A[0] = 1;

	for (int i = 0; i < str.length(); i++)
	{
		A[i + 1] = A[i];
		AB[i + 1] = AB[i];
		ABC[i + 1] = ABC[i];

		if (str[i] == 'A')
			A[i + 1] = (A[i] + currPow) % mod;

		else if (str[i] == 'B')
			AB[i + 1] = (A[i] + AB[i]) % mod;

		else if (str[i] == 'C')
			ABC[i + 1] = (AB[i] + ABC[i]) % mod;

		else
		{
			A[i + 1] = (3 * A[i]) % mod + currPow % mod;
			AB[i + 1] = (3 * AB[i]) % mod + A[i] % mod;
			ABC[i + 1] = (3 * ABC[i]) % mod + AB[i] % mod;

			currPow = (3 * currPow) % mod;
		}
	}

	cout << ABC[str.length()] << endl;
	sol2(str);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:9: error: 'sol2' was not declared in this scope
   46 |         sol2(str);
      |         ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;


int main(){
    int mod=1e9+7;
    string s;
    cin>>s;
    ll dp[100010][4];
    dp[0][0]=1;
    rep(i,s.size()){
        if(s[i]=='A'){
            dp[i+1][1]+=dp[i][0];
            dp[i+1][1]%=mod;
        }
        if(s[i]=='B'){
            dp[i+1][2]+=dp[i][1];
            dp[i+1][2]%=mod;
        }
        if(s[i]=='C'){
            dp[i+1][3]+=dp[i][2];
            dp[i+1][3]%=mod;
        }
        if(s[i]=='?'){
            dp[i+1][1]+=dp[i][0];
            dp[i+1][2]+=dp[i][1];
            dp[i+1][3]+=dp[i][2];
            dp[i+1][1]%=mod;
            dp[i+1][2]%=mod;
            dp[i+1][3]%=mod;
            rep(j,3)dp[i+1][j]+=3*dp[i][j]
        }
        else rep(j,4)dp[i+1][j]+=3*dp[i][j]
    }
    cout<<dp[s.size()][3]%mod<<endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:43: error: expected ';' before '}' token
   34 |             rep(j,3)dp[i+1][j]+=3*dp[i][j]
      |                                           ^
      |                                           ;
   35 |         }
      |         ~                                  
a.cc:36:44: error: expected ';' before '}' token
   36 |         else rep(j,4)dp[i+1][j]+=3*dp[i][j]
      |                                            ^
      |                                            ;
   37 |     }
      |     ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;


int main(){
    int mod=1e9+7;
    string s;
    cin>>s;
    ll dp[100010][4];
    dp[0][0]=1;
    rep(i,s.size())
        switch(s[i]){
            case A:
                dp[i+1][1]+=(dp[i][0]+dp[i][1]);
                dp[i+1][1]%=mod;
                break;
            case B:
                dp[i+1][2]+=(dp[i][1]+dp[i][2]);
                dp[i+1][2]%=mod;
                break;
            case C:
                dp[i+1][3]+=(dp[i][2]+dp[i][3]);
                dp[i+1][3]%=mod;
                break;
            default:
                dp[i+1][1]+=(dp[i][0]+3*dp[i][1]);
                dp[i+1][2]+=(dp[i][1]+3*dp[i][2]);
                dp[i+1][3]+=(dp[i][2]+3*dp[i][3]);
                dp[i+1][1]%=mod;
                dp[i+1][2]%=mod;
                dp[i+1][3]%=mod;
                break;
        }
    cout<<dp[s.size()][3]%mod<<endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:18: error: 'A' was not declared in this scope
   16 |             case A:
      |                  ^
a.cc:20:18: error: 'B' was not declared in this scope
   20 |             case B:
      |                  ^
a.cc:24:18: error: 'C' was not declared in this scope
   24 |             case C:
      |                  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;


int main(){
    int mod=1e9+7;
    string s;
    cin>>s;
    ll dp[100010][4];
    memset(dp,0,sizeof.(dp));
    dp[0][0]=1;
    rep(i,s.size())
        switch(s[i]){
            case 'A':
                dp[i+1][1]+=(dp[i][0]+dp[i][1]);
                dp[i+1][1]%=mod;
            case 'B':
                dp[i+1][2]+=(dp[i][1]+dp[i][2]);
                dp[i+1][2]%=mod;
            case 'C':
                dp[i+1][3]+=(dp[i][2]+dp[i][3]);
                dp[i+1][3]%=mod;
            default:
                dp[i+1][1]+=(dp[i][0]+3*dp[i][1]);
                dp[i+1][2]+=(dp[i][1]+3*dp[i][2]);
                dp[i+1][3]+=(dp[i][2]+3*dp[i][3]);
                dp[i+1][1]%=mod;
                dp[i+1][2]%=mod;
                dp[i+1][3]%=mod;
        }
    cout<<dp[s.size()][3]%mod<<endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:23: error: expected primary-expression before '.' token
   13 |     memset(dp,0,sizeof.(dp));
      |                       ^
a.cc:13:24: error: expected unqualified-id before '(' token
   13 |     memset(dp,0,sizeof.(dp));
      |                        ^
Language: Java

public class Main {
    public static int MOD = 1000000007;

    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        String str = s.next();
        System.out.println(new Main().ABC(str.toCharArray()));
        s.close();
    }

    private long ABC(char[] str){
        long c = 0, bc = 0, abc = 0, count = 1;

        for(int i = str.length-1; i >= 0; --i){
            char ch = str[i];
            if(ch == 'A')
                abc += bc;
            else if(ch == 'B')
                bc += c;
            else if(ch == 'C')
                c += count;
            else {
                abc = abc * 3 + bc;
                bc = bc * 3 + c;
                c = c * 3 + count;
                count *= 3;
            }
            abc %= MOD;
            bc %= MOD;
            c %= MOD;
            count %= MOD;
        }
        return (abc % MOD);
    }
}

Compiler output:
Main.java:5: error: cannot find symbol
        Scanner s = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:5: error: cannot find symbol
        Scanner s = new Scanner(System.in);
                        ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: Java

import java.util.*;

public class Main {
    public static int MOD = 1000000007;

    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        String str = s.next();
        System.out.println(new Solution().ABC(str.toCharArray()));
        s.close();
    }

    private int ABC(char[] str){
        long c = 0, bc = 0, abc = 0, count = 1;

        for(int i = str.length-1; i >= 0; --i){
            char ch = str[i];
            if(ch == 'A')
                abc += bc;
            else if(ch == 'B')
                bc += c;
            else if(ch == 'C')
                c += count;
            else {
                abc = abc * 3 + bc;
                bc = bc * 3 + c;
                c = c * 3 + count;
                count *= 3;
            }
        }
        return (int) (abc % MOD);
    }
}

Compiler output:
Main.java:9: error: cannot find symbol
        System.out.println(new Solution().ABC(str.toCharArray()));
                               ^
  symbol:   class Solution
  location: class Main
1 error