func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 200009;   const long long mod = 1e9 + 7;   char s[N]{};   long long prea[N];   long long pref[N];   long long sac[N];   long long saf[N];   long long ksm(int n, int y) {     if (y < 1) return 1;     long long x = n;     long long ret = 1;     while (y) {       if (y & 1) {         ret *= x;         ret %= mod;       }       x *= x;       x %= mod;       y /= 2;     }     return ret;   }   int main() {     int n;     cin >> n;     cin >> s + 1;     for (int i = 1; i <= n; i++) {       prea[i] = prea[i - 1];       pref[i] = pref[i - 1];       if (s[i] ==  a ) prea[i]++;       if (s[i] ==  ? ) pref[i]++;     }     for (int i = n; i >= 1; i--) {       sac[i] = sac[i + 1];       saf[i] = saf[i + 1];       if (s[i] ==  c ) sac[i]++;       if (s[i] ==  ? ) saf[i]++;     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       if (s[i] ==  b  || s[i] ==  ? ) {         long long l = pref[i - 1];         long long r = saf[i + 1];         ans += (prea[i - 1] * sac[i + 1] % mod) * (ksm(3, l + r) % mod) % mod;         ans %= mod;         ans += (prea[i - 1] * saf[i + 1] % mod) * (ksm(3, l + r - 1) % mod) % mod;         ans %= mod;         ans += (pref[i - 1] * sac[i + 1] % mod) * (ksm(3, l + r - 1) % mod) % mod;         ans %= mod;         ans += (pref[i - 1] * saf[i + 1] % mod) * (ksm(3, l + r - 2) % mod) % mod;         ans %= mod;       }     }     cout << ans << endl;   }   