For which integers $N$ it is possible to write real numbers into the cells of a square of size $N \times N$ so that among the sums of each pair of adjacent cells there are all integers from $1$ to $2(N-1)N$ (each integer once)?

Maxim Didin
1. **Base Case: \( N = 2 \)**

   Consider the following \( 2 \times 2 \) grid:
   \[
   \begin{array}{|c|c|}
   \hline
   \frac{1}{2} & \frac{5}{2} \\
   \hline
   \frac{3}{2} & \frac{1}{2} \\
   \hline
   \end{array}
   \]
   The sums of each pair of adjacent cells are:
   - Horizontally: \( \frac{1}{2} + \frac{5}{2} = 3 \), \( \frac{3}{2} + \frac{1}{2} = 2 \)
   - Vertically: \( \frac{1}{2} + \frac{3}{2} = 2 \), \( \frac{5}{2} + \frac{1}{2} = 3 \)

   These sums cover all integers from 1 to \( 2(2-1)2 = 4 \).

2. **Inductive Step:**

   Assume that for some \( N \), we can construct an \( N \times N \) grid such that the sums of each pair of adjacent cells cover all integers from 1 to \( 2(N-1)N \).

   We need to show that we can construct an \( (N+1) \times (N+1) \) grid that covers all integers from 1 to \( 2N(N+1) \).

   - **Odd \( N \):**

     Suppose the last column of the \( N \times N \) grid consists of \( a, a+1, a+2, \ldots, a+N-1 \) from top to bottom, and the last row consists of \( a, a, a+2, a+2, \ldots, a+N-3, a+N-3, a+N-1 \) from left to right, where \( a = \frac{2N^2 - 4N + 3}{2} \).

     For the \( (N+1) \times (N+1) \) grid, let the \( (N+1) \)-th row consist of \( b, b+1, b+2, \ldots, b+N \) from left to right, and the \( (N+1) \)-th column consist of \( b-1, b+1, b+1, \ldots, b+N-2, b+N-2, b+N \) from top to bottom, where \( b = \frac{2N^2 + 1}{2} \).

     We need to verify that the sums cover the required range:
     \[
     a + b - 1 = \frac{2N^2 - 4N + 3}{2} + \frac{2N^2 + 1}{2} - 1 = 2(N-1)N + 1
     \]
     \[
     a + b + 2N - 2 = 2(N-1)N + 1 + 2N - 1 = 2N^2
     \]
     \[
     2b = 2 \cdot \frac{2N^2 + 1}{2} = 2N^2 + 1
     \]
     \[
     2b + 2N - 1 = 2N^2 + 1 + 2N - 1 = 2N(N+1)
     \]

     Thus, we cover the sums from \( 2(N-1)N + 1 \) to \( 2N(N+1) \). By the inductive hypothesis, we already covered 1 to \( 2(N-1)N \) inside the \( N \times N \) grid, hence we cover sums from 1 to \( 2N(N+1) \) in the \( (N+1) \times (N+1) \) grid.

   - **Even \( N \):**

     Suppose the last row of the \( N \times N \) grid consists of \( a, a+2, a+2, \ldots, a+N-3, a+N-3, a+N-1 \) from left to right, and the last column consists of \( a+1, a+2, \ldots, a+N-2, a+N-1 \), where \( a = \frac{2N^2 - 4N + 1}{2} \).

     For the \( (N+1) \times (N+1) \) grid, let the \( (N+1) \)-th row consist of \( b+1, b+2, \ldots, b+N \) from left to right, and the \( (N+1) \)-th column consist of \( b+1, b+1, \ldots, b+N-2, b+N-2, b+N \) from top to bottom, where \( b = \frac{2N^2 - 1}{2} \).

     We need to verify that the sums cover the required range:
     \[
     a + b + 1 = \frac{2N^2 - 4N + 1}{2} + \frac{2N^2 - 1}{2} + 1 = 2(N-1)N + 1
     \]
     \[
     a + b + 2N - 2 = 2(N-1)N + 1 + 2N - 1 = 2N^2
     \]
     \[
     2b + 2 = 2 \cdot \frac{2N^2 - 1}{2} + 2 = 2N^2 + 1
     \]
     \[
     2b + 2N - 1 = 2N^2 + 1 + 2N - 1 = 2N(N+1)
     \]

     Thus, we cover the sums from \( 2(N-1)N + 1 \) to \( 2N(N+1) \). By the inductive hypothesis, we already covered 1 to \( 2(N-1)N \) inside the \( N \times N \) grid, hence we cover sums from 1 to \( 2N(N+1) \) in the \( (N+1) \times (N+1) \) grid.

Therefore, by induction, every \( N \geq 2 \) works.

\(\blacksquare\)

The final answer is \( \boxed{ \text{Every } N \geq 2 } \).