func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int Max(int a, int b) { return (((b - a) >> (32 - 1)) & (a ^ b)) ^ b; }   inline int Min(int a, int b) { return (((b - a) >> (32 - 1)) & (a ^ b)) ^ a; }   string s;   long long num[2][1000005], len[2][1000005];   long long rnum[2][1000005];   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     int n;     while (cin >> n) {       cin >> s;       memset(num, 0, sizeof(num));       memset(rnum, 0, sizeof(rnum));       memset(len, 0, sizeof(len));       for (int i = (1); i <= (n); i++) {         for (int j = (0); j <= (1); j++) {           num[j][i] = num[j][i - 1];           len[j][i] = len[j][i - 1];         }         if (s[i - 1] ==  U ) {           num[0][i]++;           len[0][i] += i;           rnum[0][num[0][i]] = i;         } else {           num[1][i]++;           len[1][i] += i;           rnum[1][num[1][i]] = i;         }       }       for (int i = (1); i <= (n); i++) {         long long ret = 0;         int a = num[1][n] - num[1][i];         int b = num[0][i - 1];         if (s[i - 1] ==  U ) {           if (a <= b) {             int ps = rnum[0][b - a];             ret = 2 * ((len[1][n] - len[1][i]) - (len[0][i - 1] - len[0][ps])) +                   n - i + 1;           } else {             int ps = rnum[1][num[1][i] + b + 1];             ret = 2 * ((len[1][ps] - len[1][i]) - len[0][i - 1]) - i;           }         } else {           if (a < b) {             int ps = rnum[0][b - a - 1];             ret = 2 * ((len[1][n] - len[1][i]) - (len[0][i - 1] - len[0][ps])) +                   n + i + 1;           } else {             int ps = rnum[1][num[1][i] + b];             ret = 2 * ((len[1][ps] - len[1][i]) - len[0][i - 1]) + i;           }         }         cout << ret <<    ;       }       cout << endl;     }     return 0;   }   