func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m;   void update(int *c, int x, int v) {     while (x <= m) {       c[x] += v;       x += x & -x;     }   }   long long sum(int *c, int x) {     long long ret = 0;     while (x > 0) {       ret += c[x];       x -= x & -x;     }     return ret;   }   long long calc(int *c, int L, int R) { return sum(c, R) - sum(c, L - 1); }   int c[3060 + 3060][3060], L[3060][3060], R[3060][3060], Ld[3060][3060];   char s[3060][3060];   vector<pair<int, int> > g[3060];   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %s , s[i] + 1);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) {         if (s[i][j] ==  . )           L[i][j] = 0;         else           L[i][j] = L[i][j - 1] + 1;       }     for (int i = n; i > 0; --i)       for (int j = m; j > 0; --j) {         if (s[i][j] ==  . )           R[i][j] = 0;         else           R[i][j] = R[i][j + 1] + 1;         if (s[i][j] ==  . )           Ld[i][j] = 0;         else           Ld[i][j] = Ld[i + 1][j - 1] + 1;       }     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) g[j + R[i][j] - 1].push_back(make_pair(i, j));     long long ans = 0;     for (int j = m; j > 0; --j) {       for (int i = 0; i < g[j].size(); ++i) {         int x = g[j][i].first;         int y = g[j][i].second;         update(c[x + y], y, 1);       }       for (int i = 1; i <= n; ++i) {         int mi = min(L[i][j], Ld[i][j]);         if (!mi) continue;         ans += calc(c[i + j], j - mi + 1, j);       }     }     cout << ans << endl;     return 0;   }   