func_code_string: #include <bits/stdc++.h>   char map[101][10001];   long long mic[101][10001];   int n, m;   long long max = 1000000000;   int check = 0;   void find(int x) {     int sum = 0;     for (int i = 0; i < n; i++) {       sum += mic[i][x];       if (sum > max) return;     }     max = sum;   }   int main() {     scanf( %d %d  , &n, &m);     for (int i = 0; i < n; i++) {       gets(map[i]);       int temp = 0;       int mul = 0;       for (int j = 0; j < m; j++) mic[i][j] = 1000000000;       for (int j = 0; j <= m * 2; j++) {         if (map[i][j % m] ==  1 ) {           temp = 0;           mul = 1;         }         if ((temp < mic[i][j % m] && mul == 1) || mic[i][j % m] == 0)           mic[i][j % m] = temp;         temp += mul;       }       temp = 0;       mul = 0;       for (int j = (2 * m); j >= 0; j--) {         if (map[i][j % m] ==  1 ) {           temp = 0;           mul = 1;         }         if ((temp < mic[i][j % m] && mul == 1) || mic[i][j % m] == 0)           mic[i][j % m] = temp;         temp += mul;       }     }     for (int i = 0; i < m; i++) find(i);     if (max >= 1000000000)       printf( -1 );     else       printf( %d , max);     return 0;   }   