We select $16$ cells on an $8\times 8$ chessboard. What is the minimal number of pairs of selected cells in the same row or column?
1. **Understanding the Problem:**
   We need to find the minimal number of pairs of selected cells in the same row or column when 16 cells are selected on an \(8 \times 8\) chessboard. This is equivalent to finding the minimum number of pairs of rooks attacking each other when 16 rooks are placed on the chessboard.

2. **Mathematical Representation:**
   Consider an \(8 \times 8\) matrix where each cell can either be empty (0) or contain a rook (1). The total number of rooks is 16. We need to count the number of pairs of rooks that are in the same row or column.

3. **Counting Pairs in Rows and Columns:**
   Let \(r_i\) be the number of rooks in the \(i\)-th row and \(c_j\) be the number of rooks in the \(j\)-th column. The number of pairs of rooks in the same row \(i\) is given by \(\binom{r_i}{2} = \frac{r_i(r_i - 1)}{2}\). Similarly, the number of pairs of rooks in the same column \(j\) is \(\binom{c_j}{2} = \frac{c_j(c_j - 1)}{2}\).

4. **Summing Over All Rows and Columns:**
   The total number of pairs of rooks attacking each other is:
   \[
   \sum_{i=1}^{8} \binom{r_i}{2} + \sum_{j=1}^{8} \binom{c_j}{2}
   \]

5. **Using Jensen's Inequality:**
   By the convexity of the function \(\binom{x}{2}\), we can apply Jensen's inequality. For a convex function \(f\), Jensen's inequality states that:
   \[
   f\left(\frac{1}{n} \sum_{i=1}^{n} x_i\right) \leq \frac{1}{n} \sum_{i=1}^{n} f(x_i)
   \]
   Here, \(f(x) = \binom{x}{2}\). Since the sum of the rooks in all rows and columns is 16, we have:
   \[
   \sum_{i=1}^{8} r_i = 16 \quad \text{and} \quad \sum_{j=1}^{8} c_j = 16
   \]

6. **Applying Jensen's Inequality:**
   Applying Jensen's inequality to the sums:
   \[
   \sum_{i=1}^{8} \binom{r_i}{2} \geq 8 \binom{\frac{16}{8}}{2} = 8 \binom{2}{2} = 8 \cdot 1 = 8
   \]
   \[
   \sum_{j=1}^{8} \binom{c_j}{2} \geq 8 \binom{\frac{16}{8}}{2} = 8 \binom{2}{2} = 8 \cdot 1 = 8
   \]

7. **Combining the Results:**
   Therefore, the total number of pairs of rooks attacking each other is at least:
   \[
   \sum_{i=1}^{8} \binom{r_i}{2} + \sum_{j=1}^{8} \binom{c_j}{2} \geq 8 + 8 = 16
   \]

8. **Constructing an Example:**
   To achieve exactly 16 pairs, we can place the rooks such that each row and each column contains exactly 2 rooks. One possible configuration is placing the rooks on two diagonals:
   - Place rooks at \((i, i)\) and \((i, 8-i+1)\) for \(i = 1, 2, \ldots, 8\).

   This configuration ensures that each row and each column has exactly 2 rooks, resulting in exactly 16 pairs of rooks attacking each other.

\(\blacksquare\)

The final answer is \( \boxed{ 16 } \).