func_code_string: #include <bits/stdc++.h>   using namespace std;   int maps[501][501];   char str[501];   int dx[11] = {-1, 0, 1, 0, -1, -1, 1, 1, -1, -1};   int dy[11] = {0, 1, 0, -1, 0, 1, 1, -1, -1, 1};   int dp[550][550][10];   int n, m;   int pan(int x, int y) {     if (x < 1 || x > n || y < 1 || y > m) return 1;     if (maps[x][y]) return 1;     return 0;   }   int main() {     while (~scanf( %d%d , &n, &m)) {       for (int i = 1; i <= n; i++) {         scanf( %s , str);         for (int j = 1; j <= m; j++) {           if (str[j - 1] ==  0 )             maps[i][j] = 0;           else             maps[i][j] = 1;         }       }       int ans = 0;       for (int i = 1; i <= n; i++)         for (int j = 1; j <= m; j++) {           if (maps[i][j]) continue;           for (int q = 0; q < 9; q++) {             dp[i][j][q] = 1;             if (q == 4) continue;             for (int k = 1;; k++) {               int xx = i + dx[q] * k;               int yy = j + dy[q] * k;               if (pan(xx, yy)) break;               dp[i][j][q]++;             }           }         }       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= m; j++) {           if (maps[i][j]) continue;           for (int q = 0; q < 9; q++) {             if (q == 4) continue;             for (int k = 1;; k++) {               int xx = i + dx[q] * k;               int yy = j + dy[q] * k;               if (pan(xx, yy) || pan(i + dx[q + 1] * k, j + dy[q + 1] * k)) {                 break;               }               if (q == 0 && dp[xx][yy][6] >= k + 1) ans++;               if (q == 1 && dp[xx][yy][7] >= k + 1) ans++;               if (q == 2 && dp[xx][yy][8] >= k + 1) ans++;               if (q == 3 && dp[xx][yy][5] >= k + 1) ans++;               if (q == 5 && dp[xx][yy][2] >= k * 2) ans++;               if (q == 6 && dp[xx][yy][3] >= k * 2) ans++;               if (q == 7 && dp[xx][yy][0] >= k * 2) ans++;               if (q == 8 && dp[xx][yy][1] >= k * 2) ans++;             }           }         }       }       cout << ans << endl;     }     return 0;   }   