Note that the condition a2+b2+1=2ab is equivalent to (a−b)2=−1 or a−b=±i. Consider a graph whose vertices are the numbers written on the board, with an edge connecting two numbers if they differ by i. According to the problem's condition, this graph has exactly 760 edges.
Each connected component of this graph forms a path consisting of numbers of the form z,z+i,z+2i,…,z+(n−1)i. Suppose the graph has k connected components. Then it contains 777−k edges, so k=17.
Since 17⋅45=765<777, at least one connected component must have at least 46 vertices. Therefore, there exist two numbers in this component, say c and d=c+45i. Then (c−d)2=452⋅i2=−2025, which implies c2+d2+2025=2cd, as required.