func_code_string: #include <bits/stdc++.h>   using namespace std;   long long dp[2005][2005];   string s;   long long cnt[2005];   long long powr[2005];   long long solve(int l, int r) {     if (dp[l][r] != -1) {       return dp[l][r];     }     if (l >= r) return 0;     dp[l][r] = 0;     if (s[l] ==  ) ) {       dp[l][r] += solve(l + 1, r);     }     if (s[r] ==  ( ) {       dp[l][r] += solve(l, r - 1);     }     if (s[l] ==  )  && s[r] ==  ( ) {       dp[l][r] -= solve(l + 1, r - 1);     }     if (s[l] ==  (  && s[r] ==  ) ) {       dp[l][r] += solve(l + 1, r - 1) + powr[cnt[r] - cnt[l + 1]];     }     if (s[l] ==  ?  && s[r] ==  ? ) {       dp[l][r] += solve(l + 1, r) + solve(l, r - 1) + powr[cnt[r] - cnt[l + 1]];     }     if (s[l] ==  ?  && s[r] ==  ) ) {       dp[l][r] +=           solve(l + 1, r - 1) + solve(l + 1, r) + powr[cnt[r] - cnt[l + 1]];     }     if (s[r] ==  ?  && s[l] ==  ( ) {       dp[l][r] +=           solve(l + 1, r - 1) + solve(l, r - 1) + powr[cnt[r] - cnt[l + 1]];     }     return (dp[l][r] + 2LL * 998244353) % 998244353;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     ;     int t;     t = 1;     while (t--) {       cin >> s;       for (int i = 0; i < s.size(); i++) {         if (s[i] ==  ? ) {           cnt[i + 1] = cnt[i] + 1;         } else           cnt[i + 1] = cnt[i];       }       powr[0] = 1;       for (int i = 1; i < 2005; i++) {         powr[i] = powr[i - 1] * 2 % 998244353;       }       memset(dp, -1, sizeof(dp));       cout << solve(0, s.size() - 1);     }     return 0;   }   