func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   T sq(T x) {     return x * x;   }   const long long inf = 2147383647;   const double pi = 2 * acos(0.0);   const double eps = 1e-9;   const long long maxint = 2147483647;   const long long minint = -2147483648;   char grid[450][450];   int row, col, mx;   int preRight[450][450], preDiag1[450][450], preDiag2[450][450],       preDown[450][450];   void precalRight() {     int i, j;     for (i = 0; i < row; i++) {       for (j = col - 1; j >= 0; j--) {         if (grid[i][j] ==  1 )           preRight[i][j] = 0;         else {           preRight[i][j] = 1;           if (j < col - 1) preRight[i][j] += preRight[i][j + 1];         }       }     }   }   void precalDiag1() {     int i, j;     for (i = row - 1; i >= 0; i--) {       for (j = col - 1; j >= 0; j--) {         if (grid[i][j] ==  1 )           preDiag1[i][j] = 0;         else {           preDiag1[i][j] = 1;           if (i < row - 1 && j < col - 1)             preDiag1[i][j] += preDiag1[i + 1][j + 1];         }       }     }   }   void precalDiag2() {     int i, j;     for (i = 0; i < row; i++) {       for (j = col - 1; j >= 0; j--) {         if (grid[i][j] ==  1 )           preDiag2[i][j] = 0;         else {           preDiag2[i][j] = 1;           if (i > 0 && j < col - 1) preDiag2[i][j] += preDiag2[i - 1][j + 1];         }       }     }   }   void precalDown() {     int i, j;     for (i = row; i >= 0; i--) {       for (j = col - 1; j >= 0; j--) {         if (grid[i][j] ==  1 )           preDown[i][j] = 0;         else {           preDown[i][j] = 1;           if (i < row - 1) preDown[i][j] += preDown[i + 1][j];         }       }     }   }   void precal() {     precalRight();     precalDiag1();     precalDiag2();     precalDown();   }   long long triangle(int r, int c) {     long long res = 0;     int i;     for (i = 1; i <= mx + 1; i++) {       if (preRight[r][c] - 1 >= i && preDown[r][c] - 1 >= i &&           preDiag2[r + i][c] - 1 >= i)         res++;       if (preRight[r][c] - 1 >= i && preDown[r][c + i] - 1 >= i &&           preDiag1[r][c] - 1 >= i)         res++;       if (preDown[r][c] - 1 >= i && preRight[r + i][c] - 1 >= i &&           preDiag1[r][c] - 1 >= i)         res++;       if (r + i < row && preDiag2[r + i][c] - 1 >= i &&           preRight[r + i][c] - 1 >= i && preDown[r][c + i] - 1 >= i)         res++;       if (i % 2 == 0) {         int j = i / 2;         if (preRight[r][c] - 1 >= i && preDiag1[r][c] - 1 >= j &&             preDiag2[r + j][c + j] - 1 >= j)           res++;         if (preDiag1[r][c] - 1 >= j && preDown[r][c] - 1 >= i &&             preDiag2[r + i][c] - 1 >= j)           res++;         if (r + j < row && preRight[r + j][c] - 1 >= i &&             preDiag2[r + j][c] - 1 >= j && preDiag1[r][c + j] - 1 >= j)           res++;         if (r + j < row && preDiag2[r + j][c] - 1 >= j &&             preDiag1[r + j][c] - 1 >= j && preDown[r][c + j] - 1 >= i)           res++;       }     }     return res;   }   int main() {     scanf( %d %d , &row, &col);     mx = max(row, col);     int i, j, k;     for (i = 0; i < row; i++) scanf( %s , grid[i]);     precal();     long long res = 0;     for (i = 0; i < row; i++) {       for (j = 0; j < col; j++) {         res += triangle(i, j);       }     }     printf( %lld n , res);     return 0;   }   