How to derive the flow pattern in magic square problem? 
And my question is how the boy managed to derive the pattern of the sequence of number that summed to 265?
Check this link:   https://www.youtube.com/shorts/pYwMQEE-6NY

 A: This is a well-known pattern for an $n \times n$ magic square (the given numbers should be in arithmetic progression). Arrange all the given numbers in increasing order.  If $n$ is odd, you start from the centre of the topmost row and fill in the first number. You follow the following process to fill the grids:

*

*If you've filled a block, go to the one in the row above and the column to the right of that block (or just the block northeast). If that block is empty, fill it.

*If you can't go to the top right block (because you're at one of the borders), you do a teleport (similar to pac-man) - going up from the topmost row means you go to the last row, going right from the rightmost column means you go to the leftmost column. Again, if that block is empty, fill it.

*If you filled a block, but the northeastern block is already filled, go to the one below it (or do a teleport if you're at the last row).
If $n$ is even, you start from the $n/2$th block of the topmost row, and the process is the same.
In our case, $n=5$. Since we need an arithmetic progression (and the boy uses a common difference of $1$), we'll take consecutive integers, starting from $a$ till $a+24$. Filling the blocks, we get:

Notice that the sum of each row, column, and diagonal is $5a + 60 = 5(a+12)$. The boy must have calculated this expression beforehand. Now, when he was given $265$, he equated $5(a+12) = 265$ in his mind, which is not a difficult task. So, $a+12 = 53 \implies a = 41$, and he filled the table.
As a side note, I wonder what would have happened if he got a number that is not a multiple of $5$. I found that for any $a$ and any integral common difference $d$ (not only $1$ but any integer), the sum is always a multiple of $5$. So, had he gotten a number which is not a multiple of $5$, he would have to give an answer which contained decimals.

A: I don't know the exact formula the boy used in the video, but I can provide you with one of my own that I discovered that works for $\textbf{all numbers}$.
An observation is that the rows, columns and diagonals passing through the center number are symmetric to each other, at least when you compare the difference to the middle number of that row, column and diagonal. For example, taking the middle row, and letting the number in the center be $0$, we get the numbers, from left to right, $-9,-7,0,7,9$, for the 0 mod 5 case for example.
Another important observation is that the center number is the sum divided by $5$, that is, $\frac{265}{5}=53$.
If we take the center number to 0, as we know what the center number is, we can now base every other number around it. Filling it in like below:

This will give you numbers that are all unique, and satisfy the requirements in the video.
Proof:
When the center number is $0$, it is easily verified that all the columns, rows and diagonals are equal, and all numbers are unique. If we increase the center number by a value, say $\lambda$, we see that the uniqueness of the numbers are not affected by the increase. As the differences are not affected, each of the rows, columns and diagonals have the sum of $5\lambda+c$, with $c$ being the residue $mod$ $5$.
Therefore, as we vary $\lambda$, we can achieve the condition shown in the video for every $5\lambda+c$, or every residue mod 5.
