Gábor wanted to design a maze. He took a square-grid paper and marked a large square on it. In doing so, and subsequently, he always followed the grid lines, moving from grid point to grid point. Then, within the square, he drew some lines, totaling 400 units in length. These became the walls of the maze. When he was finished, he noticed that in his maze, from any unit square, one can reach any other unit square in exactly one way, excluding paths that pass through any unit square more than once. What is the side length of the first square he drew?
Let the original square be $n \times n$. Then it consists of $n^{2}$ "unit squares". Imagine connecting the center of each small square with the centers of its edge-neighbors. Thus, we have established $n(n-1)$ horizontal and the same number of vertical connections (assuming the sides of the squares on the paper are horizontal or vertical). Each time Gábor draws a line, he breaks one of these connections, always a different one. Therefore, from the initial $2 n(n-1)$ connections, $2 n(n-1)-400$ remain.

If we imagine a graph where the vertices are the centers of the small squares and the edges are the remaining connections, then this graph has $n^{2}$ vertices and $2 n(n-1)-400$ edges. We also know that from any vertex, it is possible to reach any other vertex, meaning the graph is connected; however, there is only one way to reach any vertex, meaning it is acyclic (if there were a cycle, selecting two vertices from it would result in multiple paths between them). Therefore, our graph is a tree (for more details, see Béla Andráffai's book "Introduction to Graph Theory"), and thus it is true that it has one more vertex than edges; that is,

$$
n^{2}=2 n(n-1)-400+1
$$

This equation has two roots: -19 and 21. Since a negative side length makes no sense, the side of the original square Gábor drew is 21 units.

Based on the work of Egmont Koblinger (Budapest, Fazekas M. Fóv. Gyak. Gimn., III. o. t.)