<awangdev>1267. Count Servers that Communicate_1.java
public int countServers(int[][] grid) {
        
        int total = 0;
        int m = grid.length, n = grid[0].length;
        int[] row = new int[m], col = new int[n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (grid[i][j] == 1) {
                    total++;
                    row[i]++;
                    col[j]++;
                }
            }
        }
        
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (grid[i][j] == 1 && row[i] == 1 && col[j] == 1) { 
                    total--;
                }
            }
        }
        
        return total;
    }
public int sample_funcname ( int [ ] [ ] var_0 ) {
  int var_2 = 0 ;
  int var_4 = var_0 . length , var_5 = var_0 [ 0 ] . length ;
  int [ ] var_6 = new int [ var_4 ] , var_7 = new int [ var_5 ] ;
  for ( int var_8 = 0 ;
  var_8 < var_4 ;
  var_8 ++ ) {
    for ( int var_9 = 0 ;
    var_9 < var_5 ;
    var_9 ++ ) {
      if ( var_0 [ var_8 ] [ var_9 ] == 1 ) {
        var_2 ++ ;
        var_6 [ var_8 ] ++ ;
        var_7 [ var_9 ] ++ ;
      }
    }
  }
  for ( int var_8 = 0 ;
  var_8 < var_4 ;
  var_8 ++ ) {
    for ( int var_9 = 0 ;
    var_9 < var_5 ;
    var_9 ++ ) {
      if ( var_0 [ var_8 ] [ var_9 ] == 1 && var_6 [ var_8 ] == 1 && var_7 [ var_9 ] == 1 ) {
        var_2 -- ;
      }
    }
  }
  return var_2 ;
}
