func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T read() {     T f = 0, x = 0;     char c = getchar();     while (!isdigit(c)) f = c ==  - , c = getchar();     while (isdigit(c)) x = x * 10 + c - 48, c = getchar();     return f ? -x : x;   }   namespace run {   inline char getc() {     char c = getchar();     while (!isalpha(c)) c = getchar();     return c;   }   const int N = 2e5 + 9;   int head[N], nex[N], to[N], cnt, deg[N];   inline void add(int u, int v) {     deg[v]++, nex[++cnt] = head[u], head[u] = cnt, to[cnt] = v;   }   int n, m, bel[N], tot, dfn[N], num, dwn[N];   inline void dfs(int u) {     dfn[u] = ++num;     for (int i = head[u]; i; i = nex[i]) dfs(to[i]);     dwn[u] = num;   }   struct node {     int x, l, r, v;     explicit node() {}     node(int _x, int _l, int _r, int _v) : x(_x), l(_l), r(_r), v(_v) {}     inline bool operator<(const node &A) const { return x < A.x; }   } q[N << 1];   namespace Seg {   int sum[N << 2], num[N << 2];   inline void pushup(int k, int l, int r) {     if (l == r) return num[k] = sum[k] > 0, void();     if (sum[k])       num[k] = r - l + 1;     else       num[k] = num[(k << 1)] + num[(k << 1 | 1)];   }   inline void modify(int k, int l, int r, int _l, int _r, int v) {     if (_l <= l && r <= _r) return sum[k] += v, pushup(k, l, r);     if (_l <= ((l + r) >> 1)) modify((k << 1), l, ((l + r) >> 1), _l, _r, v);     if (_r > ((l + r) >> 1))       modify((k << 1 | 1), ((l + r) >> 1) + 1, r, _l, _r, v);     pushup(k, l, r);   }   }  // namespace Seg   inline int id(int x, int y) { return (x - 1) * m + y; }   int main() {     n = read<int>(), m = read<int>();     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         char c = getc();         if (c ==  D ) {           bel[id(i - 1, j)] = id(i, j), bel[id(i, j)] = id(i - 1, j);           if (i > 2) add(id(i - 2, j), id(i, j));           if (i + 1 <= n) add(id(i + 1, j), id(i - 1, j));         }         if (c ==  R ) {           bel[id(i, j - 1)] = id(i, j), bel[id(i, j)] = id(i, j - 1);           if (j > 2) add(id(i, j - 2), id(i, j));           if (j + 1 <= m) add(id(i, j + 1), id(i, j - 1));         }       }     for (int i = 1; i <= n * m; i++)       if (!deg[i]) dfs(i);     for (int i = 1; i <= n * m; i++) {       int l = dfn[bel[i]], r = dwn[bel[i]];       q[++tot] = node(dfn[i], l, r, 1), q[++tot] = node(dwn[i] + 1, l, r, -1);     }     sort(q + 1, q + tot + 1);     long long ans = 0;     for (int i = 1, j, las = 0; i <= tot; i = j + 1) {       j = i;       while (j + 1 <= tot && q[j + 1].x == q[i].x) j++;       ans += 1LL * (q[i].x - las) * Seg::num[1], las = q[i].x;       for (int k = i; k <= j; k++)         Seg::modify(1, 1, n * m, q[k].l, q[k].r, q[k].v);     }     printf( %lld n , ans >> 1);     return 0;   }   }  // namespace run   int main() { return run::main(); }   