func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007ll;   const double EPS = 1e-11;   int n;   char s[1252525];   int cntright[1252525];   int cntleft[1252525];   int revright[1252525];   int revleft[1252525];   long long sumright[1252525];   long long sumleft[1252525];   int main() {     scanf( %d , &n);     scanf( %s , s);     for (int i = 0; i < (int)(n); ++i) {       if (s[i] ==  U ) {         cntright[i + 1] = cntright[i] + 1;         cntleft[i + 1] = cntleft[i];         revright[cntright[i + 1]] = i + 1;       } else {         cntright[i + 1] = cntright[i];         cntleft[i + 1] = cntleft[i] + 1;         revleft[cntleft[i + 1]] = i + 1;       }     }     for (int i = 0; i < (int)(n); ++i) {       if (s[i] ==  U ) {         sumright[i + 1] = sumright[i] + (n - i);         sumleft[i + 1] = sumleft[i];       } else {         sumright[i + 1] = sumright[i];         sumleft[i + 1] = sumleft[i] + (i + 1);       }     }     for (int q = 0; q < (int)(n); ++q) {       int l = cntright[q];       int r = cntleft[n] - cntleft[q + 1];       if (s[q] ==  U ) {         if (r > l) {           int rightbnd = l + 1;           int leftbnd = l;           int rrr = revleft[cntleft[q + 1] + rightbnd];           int lll = 0;           long long ans = 0ll;           ans +=               (sumright[q] - sumright[lll] - (long long)leftbnd * (n - q)) * 2ll;           ans += (sumleft[rrr] - sumleft[q + 1] - (long long)rightbnd * (q + 1)) *                  2ll;           ans += q + 1;           printf( %I64d , ans);         } else {           int rightbnd = r;           int leftbnd = r;           int rrr = n;           int lll = revright[cntright[q] - leftbnd];           long long ans = 0ll;           ans +=               (sumright[q] - sumright[lll] - (long long)leftbnd * (n - q)) * 2ll;           ans += (sumleft[rrr] - sumleft[q + 1] - (long long)rightbnd * (q + 1)) *                  2ll;           ans += n - q;           printf( %I64d , ans);         }       } else {         if (l > r) {           int rightbnd = r;           int leftbnd = r + 1;           int rrr = n;           int lll = revright[cntright[q] - leftbnd];           long long ans = 0ll;           ans +=               (sumright[q] - sumright[lll] - (long long)leftbnd * (n - q)) * 2ll;           ans += (sumleft[rrr] - sumleft[q + 1] - (long long)rightbnd * (q + 1)) *                  2ll;           ans += n - q;           printf( %I64d , ans);         } else {           int rightbnd = l;           int leftbnd = l;           int rrr = revleft[cntleft[q + 1] + rightbnd];           int lll = 0;           long long ans = 0ll;           ans +=               (sumright[q] - sumright[lll] - (long long)leftbnd * (n - q)) * 2ll;           ans += (sumleft[rrr] - sumleft[q + 1] - (long long)rightbnd * (q + 1)) *                  2ll;           ans += q + 1;           printf( %I64d , ans);         }       }       if (q != n - 1) {         putchar(   );       } else {         putchar(  n );       }     }     return 0;   }   