func_code_string: #include <bits/stdc++.h>      using namespace std;      typedef long long ll;   typedef pair<int, int> pii;      const int N = 510;   const int MOD = 998244353;      int a[N];   int b[N];   int dp[N][N];      void add_self(int& x, int y) {       if ((x += y) >= MOD) {           x -= MOD;       }   }      void sub_self(int& x, int y) {       if ((x -= y) < 0) {           x += MOD;       }   }      int add(int x, int y) {       return add_self(x, y), x;   }      int sub(int x, int y) {       return sub_self(x, y), x;   }      int mul(int x, int y) {       return (ll)x * y % MOD;   }      int main() {       int n;       cin >> n;          for (int i = 0; i < n; i++) {           char c;           scanf(  %c , &c);           if (c ==  + ) {               b[i] = 1;               scanf( %d , a + i);           }       }          int answer = 0;          for (int k = 0; k < n; k++) {           if (!b[k]) {               continue;           }              memset(dp, 0, sizeof(dp));              for (int j = 0; j <= n; j++) {               dp[n][j] = 1;           }              for (int i = n - 1; ~i; --i) {               for (int j = 0; j < n; j++) {                   if (i == k) {                       dp[i][j] = dp[i + 1][j];                   } else {                       dp[i][j] = dp[i + 1][j];                       if (b[i]) {                           add_self(dp[i][j], dp[i + 1][j + (pii(a[i], i) < pii(a[k], k))]);                       } else if (i < k || j > 0) {                           add_self(dp[i][j], dp[i + 1][max(0, j - 1)]);                       }                   }               }           }              add_self(answer, mul(a[k], dp[0][0]));       }          cout << answer << endl;   }