5. Given a positive integer $n$, fill each cell of an $n \times n$ grid with an integer. Perform the following operation on this grid: select a cell, and add 1 to each of the $2n-1$ cells in the selected cell's row and column. Find the maximum integer $N=N(n)$, such that no matter what the initial numbers in the grid are, it is always possible to perform a series of the above operations to ensure that the grid contains at least $N$ even numbers.
（Supplied by Xinmao Wang）
5. Let the selected cell be in the $i$-th row and $j$-th column, and denote the operation in the problem as $M(i, j)$.

First, note that the result of a series of operations is independent of the order of the operations.

When $n$ is even, consider $2n-1$ operations $M(p, q)$ (where $p=i$ or $q=j$). These operations affect the cell at the $i$-th row and $j$-th column $2n-1$ times, each cell in the $i$-th row and $j$-th column (except the cell at $(i, j)$) $n$ times, and each cell not in the $i$-th row or $j$-th column 2 times. Thus, these $2n-1$ operations change the parity of the number in the cell at the $i$-th row and $j$-th column, while keeping the parity of the numbers in the other cells unchanged. Therefore, it is always possible to perform a series of operations to make all the numbers in the grid even. Hence, the required value is
$$
N=n^{2} \text {. }
$$

When $n$ is odd, by the above analysis, it is always possible to perform a series of operations to make the $(n-1)^{2}$ numbers in the top-left corner of the grid even. If at this point the number of odd numbers in the grid is at least $n$, then the operation $M(n, n)$ can reduce the number of odd numbers in the grid to no more than $n-1$. Therefore, the required value is
$$
N \geqslant n^{2}-n+1 \text {. }
$$

Next, consider the sums of the numbers in each row $s_{1}, s_{2}, \cdots, s_{n}$ and each column $t_{1}, t_{2}, \cdots, t_{n}$. Any single operation changes the parity of all $s_{1}, s_{2}, \cdots, s_{n}, t_{1}, t_{2}, \cdots, t_{n}$. Suppose initially $s_{1}, s_{2}, \cdots, s_{n-1}$ are all even, and $t_{1}, t_{2}, \cdots, t_{n-1}$ are all odd, as shown in Table 1.
Table 1
\begin{tabular}{|c|c|c|c|}
\hline 0 & $\cdots$ & 0 & 0 \\
\hline$\vdots$ & & $\vdots$ & $\vdots$ \\
\hline 0 & $\cdots$ & 0 & 0 \\
\hline 1 & $\cdots$ & 1 & 0 \\
\hline
\end{tabular}

After an odd number of operations, $s_{1}, s_{2}, \cdots, s_{n-1}$ are all odd, so each of the first $n-1$ rows has at least one odd number; after an even number of operations, $t_{1}, t_{2}, \cdots, t_{n-1}$ are all odd, so each of the first $n-1$ columns has at least one odd number. The grid always has at least $n-1$ odd numbers, and the number of even numbers is at least $n^{2}-n+1$.
In summary, the required value is
$$
N=n^{2}-n+1 \text {. }
$$