exam: EGMO

problem: (Poland). Let $A B C$ be a triangle with incentre $I$. The circle through $B$ tangent to $A I$ at $I$ meets side $A B$ again at $P$. The circle through $C$ tangent to $A I$ at $I$ meets side $A C$ again at $Q$. Prove that $P Q$ is tangent to the incircle of $A B C$.

solution:
Let $Q X, P Y$ be tangent to the incircle of $A B C$, where $X, Y$ lie on the incircle and do not lie on $A C, A B$. Denote $\angle B A C=\alpha, \angle C B A=\beta, \angle A C B=\gamma$.

Since $A I$ is tangent to the circumcircle of $C Q I$ we get $\angle Q I A=\angle Q C I=\frac{\gamma}{2}$. Thus

$$
\angle I Q C=\angle I A Q+\angle Q I A=\frac{\alpha}{2}+\frac{\gamma}{2} .
$$

By the definition of $X$ we have $\angle I Q C=\angle X Q I$, therefore

$$
\angle A Q X=180^{\circ}-\angle X Q C=180^{\circ}-\alpha-\gamma=\beta
$$

Similarly one can prove that $\angle A P Y=\gamma$. This means that $Q, P, X, Y$ are collinear which leads us to the conclusion that $X=Y$ and $Q P$ is tangent to the incircle at $X$.
![](https://cdn.mathpix.com/cropped/2024_11_22_43b43e98da9917bcb8e0g-01.jpg?height=478&width=1456&top_left_y=1212&top_left_x=336)

problem_match: Problem 4

solution_match: Solution 1.


solution:
By the power of a point we have

$$
A D \cdot A C=A I^{2}=A P \cdot A B, \quad \text { which means that } \quad \frac{A Q}{A P}=\frac{A B}{A C}
$$

and therefore triangles $A D P, A B C$ are similar. Let $J$ be the incenter of $A Q P$. We obtain

$$
\angle J P Q=\angle I C B=\angle Q C I=\angle Q I J
$$

thus $J, P, I, Q$ are concyclic. Let $S$ be the intersection of $A I$ and $B C$. It follows that

$$
\angle I Q P=\angle I J P=\angle S I C=\angle I Q C .
$$

This means that $I Q$ is the angle bisector of $\angle C Q P$, so $Q P$ is indeed tangent to the incircle of $A B C$.

Comment. The final angle chasing from the Solution 2 may simply be replaced by the observation that since $J, P, I, Q$ are concyclic, then $I$ is the $A$-excenter of triangle $A P Q$.

solution_match: Solution 2.


solution:
Like before, notice that $A Q \cdot A C=A P \cdot A B=A I^{2}$. Consider the positive inversion $\Psi$ with center $A$ and power $A I^{2}$. This maps $P$ to $B$ (and vice-versa), $Q$ to $C$
(and vice-versa), and keeps the incenter $I$ fixed. The problem statement will follow from the fact that the image of the incircle of triangle $A B C$ under $\Psi$ is the so-called mixtilinear incircle of $A B C$, which is defined to be the circle tangent to the lines $A B, A C$, and the circumcircle of $A B C$. Indeed, since the image of the line $Q P$ is the circumcircle of $A B C$, and inversion preserves tangencies, this implies that $Q P$ is tangent to the incircle of $A B C$.

We justify the claim as follows: let $\gamma$ be the incircle of $A B C$ and let $\Gamma_{A}$ be the $A$-mixtilinear incircle of $A B C$. Let $K$ and $L$ be the tangency points of $\gamma$ with the sides $A B$ and $A C$, and let $U$ and $V$ be the tangency points of $\Gamma_{A}$ with the sides $A B$ and $A C$, respectively. It is well-known that the incenter $I$ is the midpoint of segment $U V$. In particular, since also $A I \perp U V$, this implies that $A U=A V=\frac{A I}{\cos \frac{A}{2}}$. Note that $A K=A L=A I \cdot \cos \frac{A}{2}$. Therefore, $A U \cdot A K=A V \cdot A L=A I^{2}$, which means that $U$ and $V$ are the images of $K$ and $L$ under $\Psi$. Since $\Gamma_{A}$ is the unique circle simultaneously tangent to $A B$ at $U$ and to $A C$ at $V$, it follows that the image of $\gamma$ under $\Psi$ must be precisely $\Gamma_{A}$, as claimed.

solution_match: Solution 3.


solution:
by Achilleas Sinefakopoulos, Greece. From the power of a point theorem, we have

$$
A P \cdot A B=A I^{2}=A Q \cdot A C
$$

Hence $P B C Q$ is cyclic, and so, $\angle A P Q=\angle B C A$. Let $K$ be the circumcenter of $\triangle B I P$ and let $L$ be the circumcenter of $\triangle Q I C$. Then $\overline{K L}$ is perpendicular to $\overline{A I}$ at $I$.

Let $N$ be the point of intersection of line $\overline{K L}$ with $\overline{A B}$.Then in the right triangle $\triangle N I A$, we have $\angle A N I=90^{\circ}-\frac{\angle B A C}{2}$ and from the external angle theorem for triangle $\triangle B N I$, we have $\angle A N I=\frac{\angle A B C}{2}+\angle N I B$. Hence

$$
\angle N I B=\angle A N I-\frac{\angle A B C}{2}=\left(90^{\circ}-\frac{\angle B A C}{2}\right)-\frac{\angle A B C}{2}=\frac{\angle B C A}{2} .
$$

Since $M I$ is tangent to the circumcircle of $\triangle B I P$ at $I$, we have

$$
\angle B P I=\angle B I M=\angle N I M-\angle N I B=90^{\circ}-\frac{\angle B C A}{2} .
$$

Also, since $\angle A P Q=\angle B C A$, we have

$$
\angle Q P I=180^{\circ}-\angle A P Q-\angle B P I=180^{\circ}-\angle B C A-\left(90^{\circ}-\frac{\angle B C A}{2}\right)=90^{\circ}-\frac{\angle B C A}{2}
$$

as well. Hence $I$ lies on the angle bisector of $\angle B P Q$, and so it is equidistant from its sides $\overline{P Q}$ and $\overline{P B}$. Therefore, the distance of $I$ from $\overline{P Q}$ equals the inradius of $\triangle A B C$, as desired.
![](https://cdn.mathpix.com/cropped/2024_11_22_43b43e98da9917bcb8e0g-03.jpg?height=967&width=1529&top_left_y=316&top_left_x=309)

solution_match: Solution


solution:
by Eirini Miliori (HEL2). Let $D$ be the point of intersection of $\overline{A I}$ and $\overline{B C}$ and let $R$ be the point of intersection of $\overline{A I}$ and $\overline{P Q}$. We have $\angle R I P=\angle P B I=\frac{\angle B}{2}$, $\angle R I Q=\angle I C Q=\frac{\angle C}{2}, \angle I Q C=\angle D I C=x$ and $\angle B P I=\angle B I D=\varphi$, since $\overline{A I}^{2}$ is tangent to both circles.
![](https://cdn.mathpix.com/cropped/2024_11_22_43b43e98da9917bcb8e0g-03.jpg?height=730&width=1157&top_left_y=1708&top_left_x=444)

From the angle bisector theorem, we have

$$
\frac{R Q}{R P}=\frac{A Q}{A P} \quad \text { and } \quad \frac{A C}{A B}=\frac{D C}{B D}
$$

Since $\overline{A I}$ is tangent to both circles at $I$, we have $A I^{2}=A Q \cdot A C$ and $A I^{2}=A P \cdot A B$. Therefore,

$$
\frac{R Q}{R P} \cdot \frac{D C}{B D}=\frac{A Q \cdot A C}{A B \cdot A P}=1
$$

From the sine law in triangles $\triangle Q R I$ and $\triangle P R I$, it follows that $\frac{R Q}{\sin \frac{\angle C}{2}}=\frac{R I}{\sin y}$ and $\frac{R P}{\sin \frac{\angle B}{2}}=\frac{R I}{\sin \omega}$, respectively. Hence

$$
\frac{R Q}{R P} \cdot \frac{\sin \frac{\angle B}{2}}{\sin \frac{\angle C}{2}}=\frac{\sin \omega}{\sin y}
$$

Similarly, from the sine law in triangles $\triangle I D C$ and $\triangle I D B$, it is $\frac{D C}{\sin x}=\frac{I D}{\sin \frac{\angle C}{2}}$ and $\frac{B D}{\sin \varphi}=\frac{I D}{\sin \frac{\angle B}{2}}$, and so

$$
\frac{D C}{B D} \cdot \frac{\sin \varphi}{\sin x}=\frac{\sin \frac{\angle B}{2}}{\sin \frac{\angle C}{2}}
$$

By multiplying equations (2) with (3), we obtain $\frac{R Q}{R P} \cdot \frac{D C}{B D} \cdot \frac{\sin \varphi}{\sin x}=\frac{\sin \omega}{\sin y}$, which combined with (1) and cross-multiplying yields

$$
\sin \varphi \cdot \sin y=\sin \omega \cdot \sin x
$$

Let $\theta=90^{\circ}+\frac{\angle A}{2}$. Since $I$ is the incenter of $\triangle A B C$, we have $x=90^{\circ}+\frac{\angle A}{2}-\varphi=\theta-\phi$. Also, in triangle $\triangle P I Q$, we see that $\omega+y+\frac{\angle B}{2}+\frac{\angle C}{2}=180^{\circ}$, and so $y=\theta-\omega$.
Therefore, equation (4) yields

$$
\sin \varphi \cdot \sin (\theta-\omega)=\sin \omega \cdot \sin (\theta-\varphi)
$$

or

$$
\frac{1}{2}(\cos (\varphi-\theta+\omega)-\cos (\varphi+\theta-\omega))=\frac{1}{2}(\cos (\omega-\theta+\varphi)-\cos (\omega+\theta-\varphi))
$$

which is equivalent to

$$
\cos (\varphi+\theta-\omega)=\cos (\omega+\theta-\varphi)
$$

So

$$
\varphi+\theta-\omega=2 k \cdot 180^{\circ} \pm(\omega+\theta-\varphi), \quad(k \in \mathbb{Z} .)
$$

If $\varphi+\theta-\omega=2 k \cdot 180^{\circ}+(\omega+\theta-\varphi)$, then $2(\varphi-\omega)=2 k \cdot 180^{\circ}$, with $|\varphi-\omega|<180^{\circ}$ forcing $k=0$ and $\varphi=\omega$. If $\varphi+\theta-\omega=2 k \cdot 180^{\circ}-(\omega+\theta-\varphi)$, then $2 \theta=2 k \cdot 180^{\circ}$, which contradicts the fact that $0^{\circ}<\theta<180^{\circ}$. Hence $\varphi=\omega$, and so $P I$ is the angle bisector of $\angle Q P B$.

Therefore the distance of $I$ from $\overline{P Q}$ is the same with the distance of $I$ from $A B$, which is equal to the inradius of $\triangle A B C$. Consequently, $\overline{P Q}$ is tangent to the incircle of $\triangle A B C$.


problem:
(Netherlands).

Let $n \geq 2$ be an integer, and let $a_{1}, a_{2}, \ldots, a_{n}$ be positive integers. Show that there exist positive integers $b_{1}, b_{2}, \ldots, b_{n}$ satisfying the following three conditions:

1). $a_{i} \leq b_{i}$ for $i=1,2, \ldots, n$;
2). the remainders of $b_{1}, b_{2}, \ldots, b_{n}$ on division by $n$ are pairwise different; and
3). $b_{1}+\cdots+b_{n} \leq n\left(\frac{n-1}{2}+\left\lfloor\frac{a_{1}+\cdots+a_{n}}{n}\right\rfloor\right)$.
(Here, $\lfloor x\rfloor$ denotes the integer part of real number $x$, that is, the largest integer that does not exceed $x$.)

solution:
We define the $b_{i}$ recursively by letting $b_{i}$ be the smallest integer such that $b_{i} \geq a_{i}$ and such that $b_{i}$ is not congruent to any of $b_{1}, \ldots, b_{i-1}$ modulo $n$. Then $b_{i}-a_{i} \leq i-1$, since of the $i$ consecutive integers $a_{i}, a_{i}+1, \ldots, a_{i}+i-1$, at most $i-1$ are congruent to one of $b_{1}, \ldots, b_{i-1}$ modulo $n$. Since all $b_{i}$ are distinct modulo $n$, we have $\sum_{i=1}^{n} b_{i} \equiv \sum_{i=1}^{n}(i-1)=\frac{1}{2} n(n-1)$ modulo $n$, so $n$ divides $\sum_{i=1}^{n} b_{i}-\frac{1}{2} n(n-1)$. Moreover, we have $\sum_{i=1}^{n} b_{i}-\sum_{i=1}^{n} a_{i} \leq \sum_{i=1}^{n}(i-1)=\frac{1}{2} n(n-1)$, hence $\sum_{i=1}^{n} b_{i}-\frac{1}{2} n(n-1) \leq \sum_{i=1}^{n}$. As the left hand side is divisible by $n$, we have

$$
\frac{1}{n}\left(\sum_{i=1}^{n} b_{i}-\frac{1}{2} n(n-1)\right) \leq\left[\frac{1}{n} \sum_{i=1}^{n} a_{i}\right]
$$

which we can rewrite as

$$
\sum_{i=1}^{n} b_{i} \leq n\left(\frac{n-1}{2}+\left[\frac{1}{n} \sum_{i=1}^{n} a_{i}\right]\right)
$$

as required.

problem_match: # Problem 5


solution:
Note that the problem is invariant under each of the following operations:

- adding a multiple of $n$ to some $a_{i}$ (and the corresponding $b_{i}$ );
- adding the same integer to all $a_{i}$ (and all $b_{i}$ );
- permuting the index set $1,2, \ldots, n$.

We may therefore remove the restriction that our $a_{i}$ and $b_{i}$ be positive.
For each congruence class $\bar{k}$ modulo $n(\bar{k}=\overline{0}, \ldots, \overline{n-1})$, let $h(k)$ be the number of $i$ such that $a_{i}$ belongs to $\bar{k}$. We will now show that the problem is solved if we can find a $t \in \mathbb{Z}$ such that

$$
\begin{array}{cl}
h(t) & \geq 1, \\
h(t)+h(t+1) & \geq 2 \\
h(t)+h(t+1)+h(t+2) & \geq 3
\end{array}
$$

Indeed, these inequalities guarantee the existence of elements $a_{i_{1}} \in \bar{t}, a_{i_{2}} \in \bar{t} \cup \overline{t+1}$, $a_{i_{3}} \in \bar{t} \cup \overline{t+1} \cup \overline{t+2}$, et cetera, where all $i_{k}$ are different. Subtracting appropriate
multiples of $n$ and reordering our elements, we may assume $a_{1}=t, a_{2} \in\{t, t+1\}$, $a_{3} \in\{t, t+1, t+2\}$, et cetera. Finally subtracting $t$ from the complete sequence, we may assume $a_{1}=0, a_{2} \in\{0,1\}, a_{3} \in\{0,1,2\}$ et cetera. Now simply setting $b_{i}=i-1$ for all $i$ suffices, since $a_{i} \leq b_{i}$ for all $i$, the $b_{i}$ are all different modulo $n$, and

$$
\sum_{i=1}^{n} b_{i}=\frac{n(n-1)}{2} \leq \frac{n(n-1)}{2}+n\left[\frac{\sum_{i=1}^{n} a_{i}}{n}\right] .
$$

Put $x_{i}=h(i)-1$ for all $i=0, \ldots, n-1$. Note that $x_{i} \geq-1$, because $h(i) \geq 0$. If we have $x_{i} \geq 0$ for all $i=0, \ldots, n-1$, then taking $t=0$ completes the proof. Otherwise, we can pick some index $j$ such that $x_{j}=-1$. Let $y_{i}=x_{i}$ where $i=0, \ldots, j-1, j+1, \ldots, n-1$ and $y_{j}=0$. For sequence $\left\{y_{i}\right\}$ we have

$$
\sum_{i=0}^{n-1} y_{i}=\sum_{i=0}^{n-1} x_{i}+1=\sum_{i=0}^{n-1} h(i)-n+1=1
$$

so from Raney's lemma there exists index $k$ such that $\sum_{i=k}^{k+j} y_{i}>0$ for all $j=0, \ldots, n-1$ where $y_{n+j}=y_{j}$ for $j=0, \ldots, k-1$. Taking $t=k$ we will have

$$
\sum_{t=k}^{k+i} h(t)-(i+1)=\sum_{t=k}^{k+i} x(t) \geq \sum_{t=k}^{k+i} y(t)-1 \geq 0
$$

for all $i=0, \ldots, n-1$ and we are done.


solution: Choose a random permutation $c_{1}, \ldots, c_{n}$ of the integers $1,2, \ldots, n$. Let $b_{i}=a_{i}+f\left(c_{i}-a_{i}\right)$, where $f(x) \in\{0, \ldots, n-1\}$ denotes a remainder of $x$ modulo $n$. Observe, that for such defined sequence the first two conditions hold. The expected value of $B:=b_{1}+\ldots+b_{n}$ is easily seen to be equal to $a_{1}+\ldots+a_{n}+n(n-1) / 2$. Indeed, for each $i$ the random number $c_{i}-a_{i}$ has uniform distribution modulo $n$, thus the expected value of $f\left(c_{i}-a_{i}\right)$ is $(0+\ldots+(n-1)) / n=(n-1) / 2$. Therefore we may find such $c$ that $B \leq a_{1}+\ldots+a_{n}+n(n-1) / 2$. But $B-n(n-1) / 2$ is divisible by $n$ and therefore $B \leq n\left[\left(a_{1}+\ldots+a_{n}\right) / n\right]+n(n-1) / 2$ as needed.


solution:
We will prove the required statement for all sequences of non-negative integers $a_{i}$ by induction on $n$.
Case $n=1$ is obvious, just set $b_{1}=a_{1}$.
Now suppose that the statement is true for some $n \geq 1$; we shall prove it for $n+1$.
First note that, by subtracting a multiple of $n+1$ to each $a_{i}$ and possibly rearranging indices we can reduce the problem to the case where $0 \leq a_{1} \leq a_{2} \leq \cdots \leq a_{n} \leq a_{n+1}<$ $n+1$.

Now, by the induction hypothesis there exists a sequence $d_{1}, d_{2}, \ldots, d_{n}$ which satisfies the properties required by the statement in relation to the numbers $a_{1}, \ldots, a_{n}$. Set $I=\{i \mid 1 \leq$ $i \leq n$ and $\left.d_{i} \bmod n \geq a_{i}\right\}$ and construct $b_{i}$, for $i=1, \ldots, n+1$, as follows:

$$
b_{i}=\left\{\begin{array}{l}
d_{i} \bmod n, \text { when } i \in I, \\
n+1+\left(d_{i} \bmod n\right), \text { when } i \in\{1, \ldots, n\} \backslash I, \\
n, \text { for } i=n+1
\end{array}\right.
$$

Now, $a_{i} \leq d_{i} \bmod n \leq b_{i}$ for $i \in I$, while for $i \notin I$ we have $a_{i} \leq n \leq b_{i}$. Thus the sequence $\left(b_{i}\right)_{i=1}^{n+1}$ satisfies the first condition from the problem statement.
By the induction hypothesis, the numbers $d_{i} \bmod n$ are distinct for $i \in\{1, \ldots, n\}$, so the values $b_{i} \bmod (n+1)$ are distinct elements of $\{0, \ldots, n-1\}$ for $i \in\{1, \ldots, n\}$. Since $b_{n+1}=n$, the second condition is also satisfied.

Denote $k=|I|$. We have

$$
\begin{gathered}
\sum_{i=1}^{n+1} b_{i}=\sum_{i=1}^{n} b_{i}+n=\sum_{i=1}^{n} d_{i} \bmod n+(n-k)(n+1)+n= \\
\frac{n(n+1)}{2}+(n-k)(n+1)
\end{gathered}
$$

hence we need to show that

$$
\frac{n(n+1)}{2}+(n-k)(n+1) \leq \frac{n(n+1)}{2}+(n+1)\left[\frac{\sum_{i=1}^{n+1} a_{i}}{n+1}\right]
$$

equivalently, that

$$
n-k \leq\left[\frac{\sum_{i=1}^{n+1} a_{i}}{n+1}\right]
$$

Next, from the induction hypothesis we have

$$
\begin{gathered}
\frac{n(n-1)}{2}+n\left[\frac{\sum_{i=1}^{n} a_{i}}{n}\right] \geq \sum_{i=1}^{n} d_{i}=\sum_{i \in I} d_{i}+\sum_{i \notin I} d_{i} \geq \\
\sum_{i \in I} d_{i} \bmod n+\sum_{i \notin I}\left(n+d_{i} \bmod n\right)=\frac{n(n-1)}{2}+(n-k) n
\end{gathered}
$$

or

$$
n-k \leq\left[\frac{\sum_{i=1}^{n} a_{i}}{n}\right]
$$

Thus, it's enough to show that

$$
\frac{\sum_{i=1}^{n} a_{i}}{n} \leq \frac{\sum_{i=1}^{n+1} a_{i}}{n+1}
$$

because then

$$
n-k \leq\left[\frac{\sum_{i=1}^{n} a_{i}}{n}\right] \leq\left[\frac{\sum_{i=1}^{n+1} a_{i}}{n+1}\right]
$$

But the required inequality is equivalent to $\sum_{i=1}^{n} a_{i} \leq n a_{n+1}$, which is obvious.

solution_match: Solution 4.


solution:
We can assume that all $a_{i} \in\{0,1, \ldots, n-1\}$, as we can deduct $n$ from both $a_{i}$ and $b_{i}$ for arbitrary $i$ without violating any of the three conditions from the problem statement. We shall also assume that $a_{1} \leq \ldots \leq a_{n}$.
Now let us provide an algorithm for constructing $b_{1}, \ldots, b_{n}$.

We start at step 1 by choosing $f(1)$ to be the maximum $i$ in $\{1, \ldots, n\}$ such that $a_{i} \leq n-1$, that is $f(1)=n$. We set $b_{f(1)}=n-1$.
Having performed steps 1 through $j$, at step $j+1$ we set $f(j+1)$ to be the maximum $i$ in $\{1, \ldots, n\} \backslash\{f(1), \ldots, f(j)\}$ such that $a_{i} \leq n-j-1$, if such an index exists. If it does, we set $b_{f(j+1)}=n-j-1$. If there is no such index, then we define $T=j$ and assign to the terms $b_{i}$, where $i \notin f(\{1, \ldots, j\})$, the values $n, n+1 \ldots, 2 n-j-1$, in any order, thus concluding the run of our algorithm.

Notice that the sequence $\left(b_{i}\right)_{i=1}^{n}$ satisfies the first and second required conditions by construction. We wish to show that it also satisfies the third.

Notice that, since the values chosen for the $b_{i}$ 's are those from $n-T$ to $2 n-T-1$, we have

$$
\sum_{i=1}^{n} b_{i}=\frac{n(n-1)}{2}+(n-T) n
$$

It therefore suffices to show that

$$
\left[\frac{a_{1}+\ldots+a_{n}}{n}\right] \geq n-T
$$

or (since the RHS is obviously an integer) $a_{1}+\ldots+a_{n} \geq(n-T) n$.
First, we show that there exists $1 \leq i \leq T$ such that $n-i=b_{f(i)}=a_{f(i)}$.
Indeed, this is true if $a_{n}=n-1$, so we may suppose $a_{n}<n-1$ and therefore $a_{n-1} \leq n-2$, so that $T \geq 2$. If $a_{n-1}=n-2$, we are done. If not, then $a_{n-1}<n-2$ and therefore $a_{n-2} \leq n-3$ and $T \geq 3$. Inductively, we actually obtain $T=n$ and necessarily $f(n)=1$ and $a_{1}=b_{1}=0$, which gives the desired result.

Now let $t$ be the largest such index $i$. We know that $n-t=b_{f(t)}=a_{f(t)}$ and therefore $a_{1} \leq \ldots \leq a_{f(t)} \leq n-t$. If we have $a_{1}=\ldots=a_{f(t)}=n-t$, then $T=t$ and we have $a_{i} \geq n-T$ for all $i$, hence $\sum_{i} a_{i} \geq n(n-T)$. Otherwise, $T>t$ and in fact one can show $T=t+f(t+1)$ by proceeding inductively and using the fact that $t$ is the last time for which $a_{f(t)}=b_{f(t)}$.

Now we get that, since $a_{f(t+1)+1} \geq n-t$, then $\sum_{i} a_{i} \geq(n-t)(n-f(t+1))=(n-T+f(t+$ 1) $)(n-f(t+1))=n(n-T)+n f(t+1)-f(t+1)(n-T+f(t+1))=n(n-T)+t f(t+1) \geq$ $n(n-T)$.

Greedy algorithm variant $\mathbf{1}$ (ISR). Consider the residues $0, \ldots, n-1$ modulo $n$ arranged in a circle clockwise, and place each $a_{i}$ on its corresponding residue; so that on each residue there is a stack of all $a_{i}$ s congruent to it modulo $n$, and the sum of the sizes of all stacks is exactly $n$. We iteratively flatten and spread the stacks forward, in such a way that the $a_{i}$ s are placed in the nearest available space on the circle clockwise (skipping over any already flattened residue or still standing stack). We may choose the order in which the stacks are flattened. Since the total amount of numbers equals the total number of spaces, there is always an available space and at the end all spaces are covered. The $b_{i} \mathrm{~s}$ are then defined by adding to each $a_{i}$ the number of places it was moved forward, which clearly satifies (i) and (ii), and we must prove that they satisfy (iii) as well.

Suppose that we flatten a stack of $k$ numbers at a residue $i$, causing it to overtake a stack of $l$ numbers at residue $j \in(i, i+k)$ (we can allow $j$ to be larger than $n$ and identify it
with its residue modulo $n$ ). Then in fact in fact in whichever order we would flatten the two stacks, the total number of forward steps would be the same, and the total sum of the corresponding $b_{t}$ (such that $a_{t} \bmod n \in\{i, j\}$ ) would be the same. Moreover, we can merge the stacks to a single stack of $k+l$ numbers at residue $i$, by replacing each $a_{t} \equiv j$ $(\bmod n)$ by $a_{t}^{\prime}=a_{t}-(j-i)$, and this stack would be flattened forward into the same positions as the separate stacks would have been, so applying our algorithm to the new stacks will yield the same total sum of $\sum b_{i}-$ but the $a_{i}$ s are strictly decreased, so $\sum a_{i}$ is decreased, so $\left\lfloor\frac{\sum a_{i}}{n}\right\rfloor$ is not increased - so by merging the stacks, we can only make the inequality we wish to prove tighter.

Thus, as long as there is some stack that when flattened will overtake another stack, we may merge stacks and only make the inequality tighter. Since the amount of numbers equals the amount of places, the merging process terminates with stacks of sizes $k_{1}, \ldots, k_{m}$, such that the stack $j$, when flattened, will exactly cover the interval to the next stack. Clearly the numbers in each such stack were advanced by a total of $\sum_{t=1}^{k_{j}-1}=\frac{k_{j}\left(k_{j}-1\right)}{2}$, thus $\sum b_{i}=\sum a_{i}+\sum_{j} \frac{k_{j}\left(k_{j}-1\right)}{2}$. Writing $\sum a_{i}=n \cdot r+s$ with $0 \leq s<n$, we must therefore show

$$
s+\sum_{j} \frac{k_{j}\left(k_{j}-1\right)}{2} \leq \frac{n(n-1)}{2}
$$

Ending 1. Observing that both sides of the last inequality are congruent modulo $n$ (both are congruent to the sum of all different residues), and that $0 \leq s<n$, the inequality is eqivalent to the simpler $\sum_{j} \frac{k_{j}\left(k_{j}-1\right)}{2} \leq \frac{n(n-1)}{2}$. Since $x(x-1)$ is convex, and $k_{j}$ are nonnegative integers with $\sum_{j} k_{j}=n$, the left hand side is maximal when $k_{j^{\prime}}=n$ and the rest are 0 , and then eqaulity is achieved. (Alternatively it follows easily for any non-negative reals from AM-GM.)

Ending 2. If $m=1$ (and $k_{1}=n$ ), then all numbers are in a single stack and have the same residue, so $s=0$ and equality is attained. If $m \geq 2$, then by convexity $\sum_{j} \frac{k_{j}\left(k_{j}-1\right)}{2}$ is maximal for $m=2$ and $\left(k_{1}, k_{2}\right)=(n-1,1)$, where it equals $\frac{(n-1)(n-2)}{2}$. Since we always have $s \leq n-1$, we find

$$
s+\sum_{j} \frac{k_{j}\left(k_{j}-1\right)}{2} \leq(n-1)+\frac{(n-1)(n-2)}{2}=\frac{n(n-1)}{2}
$$

as required.
Greedy algorithm variant 1' (ISR). We apply the same algorithm as in the previous solution. However, this time we note that we may merge stacks not only when they overlap after flattening, but also when they merely touch front-to-back: That is, we relax the condition $j \in(i, i+k)$ to $j \in(i, i+k]$; the argument for why such merges are allowed is exactly the same (But note that this is now sharp, as merging non-touching stacks can cause the sum of $b_{i}$ s to decrease).

We now observe that as long as there at least two stacks left, at least one will spread to touch (or overtake) the next stack, so we can perform merges until there is only one stack left. We are left with verifying that the inequality indeed holds for the case of only one stack which is spread forward, and this is indeed immediate (and in fact equality is achieved).

Greedy algorithm variant 2 (ISR). Let $c_{i}=a_{i} \bmod n$. Iteratively define $b_{i}=a_{i}+l_{i}$ greedily, write $d_{i}=c_{i}+l_{i}$, and observe that $l_{i} \leq n-1$ (since all residues are present in $\left.a_{i}, \ldots, a_{i}+n-1\right)$, hence $0 \leq d_{i} \leq 2 n-2$. Let $I=\left\{i \in I: d_{i} \geq n\right\}$, and note that $d_{i}=b_{i}$ $\bmod n$ if $i \notin I$ and $d_{i}=\left(b_{i} \bmod n\right)+n$ if $i \in I$. Then we must show

$$
\begin{aligned}
& \sum\left(a_{i}+l_{i}\right)=\sum b_{i} \leq \frac{n(n-1)}{2}+n\left\lfloor\frac{\sum a_{i}}{n}\right\rfloor \\
\Longleftrightarrow & \sum\left(c_{i}+l_{i}\right) \leq \sum\left(b_{i} \bmod n\right)+n\left\lfloor\frac{\sum c_{i}}{n}\right\rfloor \\
\Longleftrightarrow & \left.n|I| \leq n\left\lfloor\frac{\sum c_{i}}{n}\right\rfloor \Longleftrightarrow|I| \leq \left\lvert\, \frac{\sum c_{i}}{n}\right.\right\rfloor \Longleftrightarrow|I| \leq \frac{\sum c_{i}}{n}
\end{aligned}
$$

Let $k=|I|$, and for each $0 \leq m<n$ let $J_{m}=\left\{i: c_{i} \geq n-m\right\}$. We claim that there must be some $m$ for which $\left|J_{m}\right| \geq m+k$ (clearly for such $m$, at least $k$ of the sums $d_{j}$ with $j \in J_{m}$ must exceed $n$, i.e. at least $k$ of the elements of $J_{m}$ must also be in $I$, so this $m$ is a "witness" to the fact $|I| \geq k$ ). Once we find such an $m$, then we clearly have

$$
\sum c_{i} \geq(n-m)\left|J_{m}\right| \geq(n-m)(k+m)=n k+m(n-(k+m)) \geq n k=n|I|
$$

as required. We now construct such an $m$ explicitly.
If $k=0$, then clearly $m=n$ works (and also the original inequality is trivial). Otherwise, there are some $d_{i}$ s greater than $n$, and let $r+n=\max d_{i}$, and suppose $d_{t}=r+n$ and let $s=c_{t}$. Note that $r<s<r+n$ since $l_{t}<n$. Let $m \geq 0$ be the smallest number such that $n-m-1$ is not in $\left\{d_{1}, \ldots, d_{t}\right\}$, or equivalently $m$ is the largest such that $[n-m, n) \subset\left\{d_{1}, \ldots, d_{t}\right\}$. We claim that this $m$ satisfies the required property. More specifically, we claim that $J_{m}^{\prime}=\left\{i \leq t: d_{i} \geq n-m\right\}$ contains exactly $m+k$ elements and is a subset of $J_{m}$.

Note that by the greediness of the algorithm, it is impossible that for $\left[c_{i}, d_{i}\right)$ to contain numbers congruent to $d_{j} \bmod n$ with $j>i$ (otherwise, the greedy choice would prefer $d_{j}$ to $d_{i}$ at stage $i$ ). We call this the greedy property. In particular, it follows that all $i$ such that $d_{i} \in\left[s, d_{t}\right)=\left[c_{t}, d_{t}\right)$ must satisfy $i<t$. Additionally, $\left\{d_{i}\right\}$ is disjoint from $[n+r+1,2 n)$ (by maximality of $d_{t}$ ), but does intersect every residue class, so it contains $[r+1, n)$ and in particular also $[s, n)$. By the greedy property the latter can only be attained by $d_{i}$ with $i<t$, thus $[s, n) \subset\left\{d_{1}, \ldots, d_{t}\right\}$, and in particular $n-m \leq s$ (and in particular $m \geq 1$ ).
On the other hand $n-m>r$ (since $r \notin\left\{d_{i}\right\}$ at all), so $n-m-1 \geq r$. It follows that there is a time $t^{\prime} \geq t$ for which $d_{t^{\prime}} \equiv n-m-1(\bmod n)$ : If $n-m-1=r$ then this is true for $t^{\prime}=t$ with $d_{t}=n+r=2 n-m-1$; whereas if $n-m-1 \in[r+1, n)$ then there is some $t^{\prime}$ for which $d_{t^{\prime}}=n-m-1$, and by the definition of $m$ it satisfies $t^{\prime}>t$.

Therefore for all $i<t \leq t^{\prime}$ for which $d_{i} \geq n-m$, necessarily also $c_{i} \geq n-m$, since otherwise $d_{t^{\prime}} \in\left[c_{i}, d_{i}\right)$, in contradiction to the greedy property. This is also true for $i=t$, since $c_{t}=s \geq n-m$ as previously shown. Thus, $J_{m}^{\prime} \subset J_{m}$ as claimed.
Finally, since by definition of $m$ and greediness we have $[n-m, n) \cup\left\{d_{i}: i \in I\right\} \subset$ $\left\{d_{1}, \ldots, d_{t}\right\}$, we find that $\left\{d_{j}: j \in J_{m}^{\prime}\right\}=[n-m, n) \cup\left\{d_{i}: i \in I\right\}$ and thus $\left|J_{m}^{\prime}\right|=$ $|[n-m, n)|+|I|=m+k$ as claimed.

solution_match: Solution 5.


problem:
(United Kingdom).

On a circle, Alina draws 2019 chords, the endpoints of which are all different. A point is considered marked if it is either
(i) one of the 4038 endpoints of a chord; or
(ii) an intersection point of at least two chords.

Alina labels each marked point. Of the 4038 points meeting criterion (i), Alina labels 2019 points with a 0 and the other 2019 points with a 1 . She labels each point meeting criterion (ii) with an arbitrary integer (not necessarily positive).
Along each chord, Alina considers the segments connecting two consecutive marked points. (A chord with $k$ marked points has $k-1$ such segments.) She labels each such segment in yellow with the sum of the labels of its two endpoints and in blue with the absolute value of their difference.

Alina finds that the $N+1$ yellow labels take each value $0,1, \ldots, N$ exactly once. Show that at least one blue label is a multiple of 3 .
(A chord is a line segment joining two different points on a circle.)

solution:
First we prove the following:
Lemma: if we color all of the points white or black, then the number of white-black edges, which we denote $E_{W B}$, is equal modulo 2 to the number of white (or black) points on the circumference, which we denote $C_{W}$, resp. $C_{B}$.

Observe that changing the colour of any interior point does not change the parity of $E_{W B}$, as each interior point has even degree, so it suffices to show the statement holds when all interior points are black. But then $E_{W B}=C_{W}$ so certainly the parities are equal.

Now returning to the original problem, assume that no two adjacent vertex labels differ by a multiple of three, and three-colour the vertices according to the residue class of the labels modulo 3. Let $E_{01}$ denote the number of edges between 0 -vertices and 1 -vertices, and $C_{0}$ denote the number of 0 -vertices on the boundary, and so on.

Then, consider the two-coloring obtained by combining the 1-vertices and 2-vertices. By applying the lemma, we see that $E_{01}+E_{02} \equiv C_{0} \bmod 2$.

$$
\text { Similarly } E_{01}+E_{12} \equiv C_{1}, \quad \text { and } E_{02}+E_{12} \equiv C_{2}, \quad \bmod 2
$$

Using the fact that $C_{0}=C_{1}=2019$ and $C_{2}=0$, we deduce that either $E_{02}$ and $E_{12}$ are even and $E_{01}$ is odd; or $E_{02}$ and $E_{12}$ are odd and $E_{01}$ is even.

But if the edge labels are the first $N$ non-negative integers, then $E_{01}=E_{12}$ unless $N \equiv 0$ modulo 3 , in which case $E_{01}=E_{02}$. So however Alina chooses the vertex labels, it is not possible that the multiset of edge labels is $\{0, \ldots, N\}$.
Hence in fact two vertex labels must differ by a multiple of 3 .

problem_match: # Problem 6


solution:
As before, colour vertices based on their label modulo 3.
Suppose this gives a valid 3-colouring of the graph with 2019 0s and 2019 1s on the
circumference. Identify pairs of 0-labelled vertices and pairs of 1-labelled vertices on the circumference, with one 0 and one 1 left over. The resulting graph has even degrees except these two leaves. So the connected component $\mathcal{C}$ containing these leaves has an Eulerian path, and any other component has an Eulerian cycle.

Let $E_{01}^{*}$ denote the number of edges between 0 -vertices and 1 -vertices in $\mathcal{C}$, and let $E_{01}^{\prime}$ denote the number of such edges in the other components, and so on. By studying whether a given vertex has label congruent to 0 modulo 3 or not as we go along the Eulerian path in $\mathcal{C}$, we find $E_{01}^{*}+E_{02}^{*}$ is odd, and similarly $E_{01}^{*}+E_{12}^{*}$ is odd. Since neither start nor end vertex is a 2 -vertex, $E_{02}^{*}+E_{12}^{*}$ must be even.

Applying the same argument for the Eulerian cycle in each other component and adding up, we find that $E_{01}^{\prime}+E_{02}^{\prime}, E_{01}^{\prime}+E_{12}^{\prime}, E_{02}^{\prime}+E_{12}^{\prime}$ are all even. So, again we find $E_{01}+E_{02}$, $E_{01}+E_{12}$ are odd, and $E_{02}+E_{12}$ is even, and we finish as in the original solution.