A positive integer is written in each cell of an $8 \times 8$ table so that each entry is the arithmetic mean of some two of its neighbors. Find the maximum number of distinct integers that may appear in the table.
First consider the minimum number $m$ in the table. If it appears in some cell $A$, two neighboring cells $B, C$ must also contain $m$ because there is no other way for $m$ to be the arithmetic mean of two numbers in the table. Since $B$ cannot neighbor $C$, it must have another neighbor $D$ in addition to $A$ that contains $m$.

So the minimum number in the table appears at least four times. Likewise, the maximum number appears at least four times. We can now find 8 cells that contain at most 2 distinct numbers. The remaining 56 cells of course contain at most 56 distinct numbers. So there are at most 58 distinct numbers in the table. The diagram below shows that this bound can be achieved.

| 1 | 1 | 21 | 22 | 37 | 38 | 58 | 58 |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| 1 | 1 | 20 | 23 | 36 | 39 | 58 | 58 |
| 3 | 2 | 19 | 24 | 35 | 40 | 57 | 56 |
| 4 | 5 | 18 | 25 | 34 | 41 | 54 | 55 |
| 7 | 6 | 17 | 26 | 33 | 42 | 53 | 52 |
| 8 | 9 | 16 | 27 | 32 | 43 | 50 | 51 |
| 11 | 10 | 15 | 28 | 31 | 44 | 49 | 48 |
| 12 | 13 | 14 | 29 | 30 | 45 | 46 | 47 |