For #1 since it's the squared distance, the x and y coordinates are independent to each other

Hence, the cost for x is sum((x[itr] - cX) ^ 2)
And this is sum(x[itr] * x[itr] - 2 * cX * x[itr] + cX * cx)
From this we have a 2nd degree equation
N * cX * cX - 2 * cX * sum(x[itr]) + sum(x[itr] * x[itr])
And cX = sum(x[itr]) / N
#[2, 5] it is correct to do some hill climbing like ... right?
rez = [0, 0]
p = maxRange
while p >= 0:
mn = f(rez)
where = -1
for dir in allDirections(2 * nrDimensions):
if f(rez + changeDir[dir] * p) < mn:
mn = f(rez + changeDir[dir] * p)
where = dir
if where == -1:
p /= 2
else
rez = changeDir[where] * p + rez
this should run in O(N * logMaxRange * nrDimension) ~ around there

with a bigger, lets say, constant
#11 Is there a faster way than making a min-matching in the graph, and the result is just the answer?