5. The segments between $n$ points such that there are no three collinear points among them are colored in one of $k$ colors. What is the smallest $n$ such that there exists a closed broken line with vertices at some of the $n$ points where all sides are colored the same color.
Solution. We will prove the following lemma.

Lemma. If among $n$ points, no three of which are collinear, at least $n$ segments are drawn, then a closed broken line with vertices at some of these points is drawn.

Proof. If there is a point from which at most one segment is drawn, then we remove that point and the segments drawn from it, if such segments exist. After one such step, we have one point less, and the number of drawn segments is reduced by at most one, which means that the number of segments is not less than the number of points. We continue the process until we have at least two segments drawn from each point. This must happen, because if we come to three points with three segments, then all points are certainly connected to each other and from each point there are at least two drawn segments. When we have $m$ points with at least $m$ segments and at least two segments drawn from each point, we choose one point which we denote by $A_{1}$. It is certainly connected to another point which we denote by $A_{2}$. Since $A_{2}$ is connected by at least two segments, we get that it is connected to at least one more point, say $A_{3}$. We continue the process and since the number of points, i.e., segments is finite, we must return to one of the already chosen points. Let $A_{j}=A_{i}$ be the first point that repeats. Then

$A_{i} A_{i+1} \ldots A_{j-1}$ is the desired broken line.

The required number in the problem is $n=2 k+1$.

Let there be $2 k+1$ points such that no three of them are collinear and let each two points be connected by a segment. Then $k(2 k+1)$ segments are drawn and there must be $2 k+1$ segments colored with the same color. However, then from the proved lemma it follows that there is a closed broken line composed of some of these $2 k+1$ monochromatic segments.

Let there be $2 k$ points among which no three are collinear, for example, let them be the vertices of a regular $2 k$-gon $A_{1} A_{2} \ldots A_{2 k}$. All sides and all diagonals of this polygon are parallel to one of the segments $A_{1} A_{2}, A_{2} A_{3}, \ldots, A_{k} A_{k+1}, A_{2} A_{2 k}, A_{3} A_{1}, \ldots, A_{k+1} A_{k-1}$. The segments parallel to $A_{1} A_{2}$ or $A_{2} A_{2 k}$ are colored with the first color, the segments parallel to $A_{2} A_{3}$ or $A_{3} A_{1}$ are colored with the second color, ..., the segments parallel to $A_{k} A_{k+1}$ or $A_{k+1} A_{k-1}$ are colored with the $k$-th color. Due to symmetry, it is enough to prove that there is no closed broken line colored with the first color. Segments colored with the first color are $A_{1} A_{2}, A_{2} A_{2 k}, A_{2 k} A_{3}, \ldots, A_{k} A_{k+2}, A_{k+2} A_{k+1}$ and they form a broken line that passes through all vertices of the polygon, has a start at $A_{1}$ and an end at $A_{k+1}$, so it cannot be closed and does not contain a closed broken line.