#C7316. Maximize Even Ones Rows

    ID: 51174 Type: Default 1000ms 256MiB

Maximize Even Ones Rows

Maximize Even Ones Rows

You are given a binary matrix with dimensions \(n \times m\). You are allowed to perform any number of operations. In each operation, you can select any contiguous submatrix (i.e. a rectangular block) and flip all the bits inside it (i.e. change each \(0\) to \(1\) and each \(1\) to \(0\)). A submatrix of size \(1 \times 1\) is valid, so you can flip individual cells.

Your goal is to maximize the number of rows that have an even number of ones after performing a sequence of such operations.

Formally, given the matrix \(A\) where \(A_{ij} \in \{0,1\}\), you may flip entries in any chosen submatrix. Determine the maximum number of rows that can have an even sum (i.e. even number of ones) after an optimal series of operations.

Note: Since you can flip any individual cell (by choosing a submatrix of size \(1\times1\)), it is always possible to adjust each row independently such that its number of ones becomes even. Thus, the answer is always \(n\), the total number of rows.

inputFormat

The first line contains two integers \(n\) and \(m\) (\(1 \leq n, m \leq 10^3\)), representing the number of rows and columns in the matrix.

Each of the next \(n\) lines contains \(m\) integers separated by spaces. Each integer is either 0 or 1.

Input is read from standard input (stdin).

outputFormat

Output a single integer representing the maximum number of rows that can have an even number of ones after applying an optimal sequence of submatrix-flips.

Output the answer to standard output (stdout).

## sample
3 3
1 0 1
0 1 0
1 1 0
3