Let $a_{1}, a_{2}, \ldots, a_{n}, k$, and $M$ be positive integers such that  $$ \frac{1}{a_{1}}+\frac{1}{a_{2}}+\cdots+\frac{1}{a_{n}}=k \quad \text { and } \quad a_{1} a_{2} \ldots a_{n}=M $$  If $M>1$, prove that the polynomial  $$ P(x)=M(x+1)^{k}-\left(x+a_{1}\right)\left(x+a_{2}\right) \cdots\left(x+a_{n}\right) $$  has no positive roots. (Trinidad and Tobago)

Solution: We first prove that, for $x>0$,  $$ a_{i}(x+1)^{1 / a_{i}} \leqslant x+a_{i}, $$  with equality if and only if $a_{i}=1$. It is clear that equality occurs if $a_{i}=1$. If $a_{i}>1$, the AM-GM inequality applied to a single copy of $x+1$ and $a_{i}-1$ copies of 1 yields  $$ \frac{(x+1)+\overbrace{1+1+\cdots+1}^{a_{i}-1 \text { ones }}}{a_{i}} \geqslant \sqrt[a_{i}]{(x+1) \cdot 1^{a_{i}-1}} \Longrightarrow a_{i}(x+1)^{1 / a_{i}} \leqslant x+a_{i} $$  Since $x+1>1$, the inequality is strict for $a_{i}>1$. Multiplying the inequalities (1) for $i=1,2, \ldots, n$ yields  $$ \prod_{i=1}^{n} a_{i}(x+1)^{1 / a_{i}} \leqslant \prod_{i=1}^{n}\left(x+a_{i}\right) \Longleftrightarrow M(x+1)^{\sum_{i=1}^{n} 1 / a_{i}}-\prod_{i=1}^{n}\left(x+a_{i}\right) \leqslant 0 \Longleftrightarrow P(x) \leqslant 0 $$  with equality iff $a_{i}=1$ for all $i \in\{1,2, \ldots, n\}$. But this implies $M=1$, which is not possible. Hence $P(x)<0$ for all $x \in \mathbb{R}^{+}$, and $P$ has no positive roots.  Comment 1. Inequality (1) can be obtained in several ways. For instance, we may also use the binomial theorem: since $a_{i} \geqslant 1$,  $$ \left(1+\frac{x}{a_{i}}\right)^{a_{i}}=\sum_{j=0}^{a_{i}}\binom{a_{i}}{j}\left(\frac{x}{a_{i}}\right)^{j} \geqslant\binom{ a_{i}}{0}+\binom{a_{i}}{1} \cdot \frac{x}{a_{i}}=1+x $$  Both proofs of (1) mimic proofs to Bernoulli's inequality for a positive integer exponent $a_{i}$; we can use this inequality directly:  $$ \left(1+\frac{x}{a_{i}}\right)^{a_{i}} \geqslant 1+a_{i} \cdot \frac{x}{a_{i}}=1+x $$  and so  $$ x+a_{i}=a_{i}\left(1+\frac{x}{a_{i}}\right) \geqslant a_{i}(1+x)^{1 / a_{i}} $$  or its (reversed) formulation, with exponent $1 / a_{i} \leqslant 1$ :  $$ (1+x)^{1 / a_{i}} \leqslant 1+\frac{1}{a_{i}} \cdot x=\frac{x+a_{i}}{a_{i}} \Longrightarrow a_{i}(1+x)^{1 / a_{i}} \leqslant x+a_{i} . $$


Solution: We will prove that, in fact, all coefficients of the polynomial $P(x)$ are non-positive, and at least one of them is negative, which implies that $P(x)<0$ for $x>0$.  Indeed, since $a_{j} \geqslant 1$ for all $j$ and $a_{j}>1$ for some $j$ (since $a_{1} a_{2} \ldots a_{n}=M>1$ ), we have $k=\frac{1}{a_{1}}+\frac{1}{a_{2}}+\cdots+\frac{1}{a_{n}}<n$, so the coefficient of $x^{n}$ in $P(x)$ is $-1<0$. Moreover, the coefficient of $x^{r}$ in $P(x)$ is negative for $k<r \leqslant n=\operatorname{deg}(P)$.  For $0 \leqslant r \leqslant k$, the coefficient of $x^{r}$ in $P(x)$ is  $$ M \cdot\binom{k}{r}-\sum_{1 \leqslant i_{1}<i_{2}<\cdots<i_{n-r} \leqslant n} a_{i_{1}} a_{i_{2}} \cdots a_{i_{n-r}}=a_{1} a_{2} \cdots a_{n} \cdot\binom{k}{r}-\sum_{1 \leqslant i_{1}<i_{2}<\cdots<i_{n-r} \leqslant n} a_{i_{1}} a_{i_{2}} \cdots a_{i_{n-r}} $$  which is non-positive iff  $$ \binom{k}{r} \leqslant \sum_{1 \leqslant j_{1}<j_{2}<\cdots<j_{r} \leqslant n} \frac{1}{a_{j_{1}} a_{j_{2}} \cdots a_{j_{r}}} $$  We will prove (2) by induction on $r$. For $r=0$ it is an equality because the constant term of $P(x)$ is $P(0)=0$, and if $r=1$, (2) becomes $k=\sum_{i=1}^{n} \frac{1}{a_{i}}$. For $r>1$, if (2) is true for a given $r<k$, we have  $$ \binom{k}{r+1}=\frac{k-r}{r+1} \cdot\binom{k}{r} \leqslant \frac{k-r}{r+1} \cdot \sum_{1 \leqslant j_{1}<j_{2}<\cdots<j_{r} \leqslant n} \frac{1}{a_{j_{1}} a_{j_{2}} \cdots a_{j_{r}}} $$  and it suffices to prove that  $$ \frac{k-r}{r+1} \cdot \sum_{1 \leqslant j_{1}<j_{2}<\cdots<j_{r} \leqslant n} \frac{1}{a_{j_{1}} a_{j_{2}} \cdots a_{j_{r}}} \leqslant \sum_{1 \leqslant j_{1}<\cdots<j_{r}<j_{r+1} \leqslant n} \frac{1}{a_{j_{1}} a_{j_{2}} \cdots a_{j_{r}} a_{j_{r+1}}} $$  which is equivalent to  $$ \left(\frac{1}{a_{1}}+\frac{1}{a_{2}}+\cdots+\frac{1}{a_{n}}-r\right) \sum_{1 \leqslant j_{1}<j_{2}<\cdots<j_{r} \leqslant n} \frac{1}{a_{j_{1}} a_{j_{2}} \cdots a_{j_{r}}} \leqslant(r+1) \sum_{1 \leqslant j_{1}<\cdots<j_{r}<j_{r+1} \leqslant n} \frac{1}{a_{j_{1}} a_{j_{2}} \cdots a_{j_{r}} a_{j_{r+1}}} $$  Since there are $r+1$ ways to choose a fraction $\frac{1}{a_{j_{i}}}$ from $\frac{1}{a_{j_{1}} a_{j_{2}} \cdots a_{j_{r}} a_{j_{r}+1}}$ to factor out, every term $\frac{1}{a_{j_{1}} a_{j_{2}} \cdots a_{j_{r}} a_{j_{r+1}}}$ in the right hand side appears exactly $r+1$ times in the product  $$ \left(\frac{1}{a_{1}}+\frac{1}{a_{2}}+\cdots+\frac{1}{a_{n}}\right)_{1 \leqslant j_{1}<j_{2}<\cdots<j_{r} \leqslant n} \sum_{a_{j_{1}} a_{j_{2}} \cdots a_{j_{r}}} $$  Hence all terms in the right hand side cancel out. The remaining terms in the left hand side can be grouped in sums of the type  $$ \begin{aligned} \frac{1}{a_{j_{1}}^{2} a_{j_{2}} \cdots a_{j_{r}}}+\frac{1}{a_{j_{1}} a_{j_{2}}^{2} \cdots a_{j_{r}}}+\cdots+\frac{1}{a_{j_{1}} a_{j_{2}} \cdots a_{j_{r}}^{2}} & -\frac{r}{a_{j_{1}} a_{j_{2}} \cdots a_{j_{r}}} \\ & =\frac{1}{a_{j_{1}} a_{j_{2}} \cdots a_{j_{r}}}\left(\frac{1}{a_{j_{1}}}+\frac{1}{a_{j_{2}}}+\cdots+\frac{1}{a_{j_{r}}}-r\right) \end{aligned} $$  which are all non-positive because $a_{i} \geqslant 1 \Longrightarrow \frac{1}{a_{i}} \leqslant 1, i=1,2, \ldots, n$. Comment 2. The result is valid for any real numbers $a_{i}, i=1,2, \ldots, n$ with $a_{i} \geqslant 1$ and product $M$ greater than 1. A variation of Solution 1, namely using weighted AM-GM (or the Bernoulli inequality for real exponents), actually proves that $P(x)<0$ for $x>-1$ and $x \neq 0$.


Let $q$ be a real number. Gugu has a napkin with ten distinct real numbers written on it, and he writes the following three lines of real numbers on the blackboard:  - In the first line, Gugu writes down every number of the form $a-b$, where $a$ and $b$ are two (not necessarily distinct) numbers on his napkin. - In the second line, Gugu writes down every number of the form $q a b$, where $a$ and $b$ are two (not necessarily distinct) numbers from the first line. - In the third line, Gugu writes down every number of the form $a^{2}+b^{2}-c^{2}-d^{2}$, where $a, b, c, d$ are four (not necessarily distinct) numbers from the first line.  Determine all values of $q$ such that, regardless of the numbers on Gugu's napkin, every number in the second line is also a number in the third line.

Solution: Call a number $q$ good if every number in the second line appears in the third line unconditionally. We first show that the numbers 0 and $\pm 2$ are good. The third line necessarily contains 0 , so 0 is good. For any two numbers $a, b$ in the first line, write $a=x-y$ and $b=u-v$, where $x, y, u, v$ are (not necessarily distinct) numbers on the napkin. We may now write  $$ 2 a b=2(x-y)(u-v)=(x-v)^{2}+(y-u)^{2}-(x-u)^{2}-(y-v)^{2} $$  which shows that 2 is good. By negating both sides of the above equation, we also see that -2 is good.  We now show that $-2,0$, and 2 are the only good numbers. Assume for sake of contradiction that $q$ is a good number, where $q \notin\{-2,0,2\}$. We now consider some particular choices of numbers on Gugu's napkin to arrive at a contradiction.  Assume that the napkin contains the integers $1,2, \ldots, 10$. Then, the first line contains the integers $-9,-8, \ldots, 9$. The second line then contains $q$ and $81 q$, so the third line must also contain both of them. But the third line only contains integers, so $q$ must be an integer. Furthermore, the third line contains no number greater than $162=9^{2}+9^{2}-0^{2}-0^{2}$ or less than -162 , so we must have $-162 \leqslant 81 q \leqslant 162$. This shows that the only possibilities for $q$ are $\pm 1$.  Now assume that $q= \pm 1$. Let the napkin contain $0,1,4,8,12,16,20,24,28,32$. The first line contains $\pm 1$ and $\pm 4$, so the second line contains $\pm 4$. However, for every number $a$ in the first line, $a \not \equiv 2(\bmod 4)$, so we may conclude that $a^{2} \equiv 0,1(\bmod 8)$. Consequently, every number in the third line must be congruent to $-2,-1,0,1,2(\bmod 8)$; in particular, $\pm 4$ cannot be in the third line, which is a contradiction.


Solution: Let $q$ be a good number, as defined in the first solution, and define the polynomial $P\left(x_{1}, \ldots, x_{10}\right)$ as  $$ \prod_{i<j}\left(x_{i}-x_{j}\right) \prod_{a_{i} \in S}\left(q\left(x_{1}-x_{2}\right)\left(x_{3}-x_{4}\right)-\left(a_{1}-a_{2}\right)^{2}-\left(a_{3}-a_{4}\right)^{2}+\left(a_{5}-a_{6}\right)^{2}+\left(a_{7}-a_{8}\right)^{2}\right), $$  where $S=\left\{x_{1}, \ldots, x_{10}\right\}$. We claim that $P\left(x_{1}, \ldots, x_{10}\right)=0$ for every choice of real numbers $\left(x_{1}, \ldots, x_{10}\right)$. If any two of the $x_{i}$ are equal, then $P\left(x_{1}, \ldots, x_{10}\right)=0$ trivially. If no two are equal, assume that Gugu has those ten numbers $x_{1}, \ldots, x_{10}$ on his napkin. Then, the number $q\left(x_{1}-x_{2}\right)\left(x_{3}-x_{4}\right)$ is in the second line, so we must have some $a_{1}, \ldots, a_{8}$ so that  $$ q\left(x_{1}-x_{2}\right)\left(x_{3}-x_{4}\right)-\left(a_{1}-a_{2}\right)^{2}-\left(a_{3}-a_{4}\right)^{2}+\left(a_{5}-a_{6}\right)^{2}+\left(a_{7}-a_{8}\right)^{2}=0 $$  and hence $P\left(x_{1}, \ldots, x_{10}\right)=0$. Since every polynomial that evaluates to zero everywhere is the zero polynomial, and the product of two nonzero polynomials is necessarily nonzero, we may define $F$ such that  $$ F\left(x_{1}, \ldots, x_{10}\right) \equiv q\left(x_{1}-x_{2}\right)\left(x_{3}-x_{4}\right)-\left(a_{1}-a_{2}\right)^{2}-\left(a_{3}-a_{4}\right)^{2}+\left(a_{5}-a_{6}\right)^{2}+\left(a_{7}-a_{8}\right)^{2} \equiv 0 $$  for some particular choice $a_{i} \in S$. Each of the sets $\left\{a_{1}, a_{2}\right\},\left\{a_{3}, a_{4}\right\},\left\{a_{5}, a_{6}\right\}$, and $\left\{a_{7}, a_{8}\right\}$ is equal to at most one of the four sets $\left\{x_{1}, x_{3}\right\},\left\{x_{2}, x_{3}\right\},\left\{x_{1}, x_{4}\right\}$, and $\left\{x_{2}, x_{4}\right\}$. Thus, without loss of generality, we may assume that at most one of the sets $\left\{a_{1}, a_{2}\right\},\left\{a_{3}, a_{4}\right\},\left\{a_{5}, a_{6}\right\}$, and $\left\{a_{7}, a_{8}\right\}$ is equal to $\left\{x_{1}, x_{3}\right\}$. Let $u_{1}, u_{3}, u_{5}, u_{7}$ be the indicator functions for this equality of sets: that is, $u_{i}=1$ if and only if $\left\{a_{i}, a_{i+1}\right\}=\left\{x_{1}, x_{3}\right\}$. By assumption, at least three of the $u_{i}$ are equal to 0 .  We now compute the coefficient of $x_{1} x_{3}$ in $F$. It is equal to $q+2\left(u_{1}+u_{3}-u_{5}-u_{7}\right)=0$, and since at least three of the $u_{i}$ are zero, we must have that $q \in\{-2,0,2\}$, as desired.


Let $S$ be a finite set, and let $\mathcal{A}$ be the set of all functions from $S$ to $S$. Let $f$ be an element of $\mathcal{A}$, and let $T=f(S)$ be the image of $S$ under $f$. Suppose that $f \circ g \circ f \neq g \circ f \circ g$ for every $g$ in $\mathcal{A}$ with $g \neq f$. Show that $f(T)=T$. (India)

Solution: For $n \geqslant 1$, denote the $n$-th composition of $f$ with itself by  $$ f^{n} \stackrel{\text { def }}{=} \underbrace{f \circ f \circ \cdots \circ f}_{n \text { times }} $$  By hypothesis, if $g \in \mathcal{A}$ satisfies $f \circ g \circ f=g \circ f \circ g$, then $g=f$. A natural idea is to try to plug in $g=f^{n}$ for some $n$ in the expression $f \circ g \circ f=g \circ f \circ g$ in order to get $f^{n}=f$, which solves the problem: Claim. If there exists $n \geqslant 3$ such that $f^{n+2}=f^{2 n+1}$, then the restriction $f: T \rightarrow T$ of $f$ to $T$ is a bijection. Proof. Indeed, by hypothesis, $f^{n+2}=f^{2 n+1} \Longleftrightarrow f \circ f^{n} \circ f=f^{n} \circ f \circ f^{n} \Longrightarrow f^{n}=f$. Since $n-2 \geqslant 1$, the image of $f^{n-2}$ is contained in $T=f(S)$, hence $f^{n-2}$ restricts to a function $f^{n-2}: T \rightarrow T$. This is the inverse of $f: T \rightarrow T$. In fact, given $t \in T$, say $t=f(s)$ with $s \in S$, we have  $$ t=f(s)=f^{n}(s)=f^{n-2}(f(t))=f\left(f^{n-2}(t)\right), \quad \text { i.e., } \quad f^{n-2} \circ f=f \circ f^{n-2}=\operatorname{id} \text { on } T $$  (here id stands for the identity function). Hence, the restriction $f: T \rightarrow T$ of $f$ to $T$ is bijective with inverse given by $f^{n-2}: T \rightarrow T$.  It remains to show that $n$ as in the claim exists. For that, define  $$ S_{m} \stackrel{\text { def }}{=} f^{m}(S) \quad\left(S_{m} \text { is image of } f^{m}\right) $$  Clearly the image of $f^{m+1}$ is contained in the image of $f^{m}$, i.e., there is a descending chain of subsets of $S$  $$ S \supseteq S_{1} \supseteq S_{2} \supseteq S_{3} \supseteq S_{4} \supseteq \cdots, $$  which must eventually stabilise since $S$ is finite, i.e., there is a $k \geqslant 1$ such that  $$ S_{k}=S_{k+1}=S_{k+2}=S_{k+3}=\cdots \stackrel{\text { def }}{=} S_{\infty} $$  Hence $f$ restricts to a surjective function $f: S_{\infty} \rightarrow S_{\infty}$, which is also bijective since $S_{\infty} \subseteq S$ is finite. To sum up, $f: S_{\infty} \rightarrow S_{\infty}$ is a permutation of the elements of the finite set $S_{\infty}$, hence there exists an integer $r \geqslant 1$ such that $f^{r}=\mathrm{id}$ on $S_{\infty}$ (for example, we may choose $r=\left|S_{\infty}\right|!$ ). In other words,  $$ f^{m+r}=f^{m} \text { on } S \text { for all } m \geqslant k $$  Clearly, (*) also implies that $f^{m+t r}=f^{m}$ for all integers $t \geqslant 1$ and $m \geqslant k$. So, to find $n$ as in the claim and finish the problem, it is enough to choose $m$ and $t$ in order to ensure that there exists $n \geqslant 3$ satisfying  $$ \left\{\begin{array} { l }  { 2 n + 1 = m + t r } \\ { n + 2 = m } \end{array} \Longleftrightarrow \left\{\begin{array}{l} m=3+t r \\ n=m-2 \end{array}\right.\right. $$  This can be clearly done by choosing $m$ large enough with $m \equiv 3(\bmod r)$. For instance, we may take $n=2 k r+1$, so that  $$ f^{n+2}=f^{2 k r+3}=f^{4 k r+3}=f^{2 n+1} $$  where the middle equality follows by (*) since $2 k r+3 \geqslant k$.


A sequence of real numbers $a_{1}, a_{2}, \ldots$ satisfies the relation  $$ a_{n}=-\max _{i+j=n}\left(a_{i}+a_{j}\right) \quad \text { for all } n>2017 $$  Prove that this sequence is bounded, i.e., there is a constant $M$ such that $\left|a_{n}\right| \leqslant M$ for all positive integers $n$.

Solution: Set $D=2017$. Denote  $$ M_{n}=\max _{k<n} a_{k} \quad \text { and } \quad m_{n}=-\min _{k<n} a_{k}=\max _{k<n}\left(-a_{k}\right) . $$  Clearly, the sequences $\left(m_{n}\right)$ and $\left(M_{n}\right)$ are nondecreasing. We need to prove that both are bounded.  Consider an arbitrary $n>D$; our first aim is to bound $a_{n}$ in terms of $m_{n}$ and $M_{n}$. (i) There exist indices $p$ and $q$ such that $a_{n}=-\left(a_{p}+a_{q}\right)$ and $p+q=n$. Since $a_{p}, a_{q} \leqslant M_{n}$, we have $a_{n} \geqslant-2 M_{n}$. (ii) On the other hand, choose an index $k<n$ such that $a_{k}=M_{n}$. Then, we have  $$ a_{n}=-\max _{\ell<n}\left(a_{n-\ell}+a_{\ell}\right) \leqslant-\left(a_{n-k}+a_{k}\right)=-a_{n-k}-M_{n} \leqslant m_{n}-M_{n} $$  Summarizing (i) and (ii), we get  $$ -2 M_{n} \leqslant a_{n} \leqslant m_{n}-M_{n}, $$  whence  $$ m_{n} \leqslant m_{n+1} \leqslant \max \left\{m_{n}, 2 M_{n}\right\} \quad \text { and } \quad M_{n} \leqslant M_{n+1} \leqslant \max \left\{M_{n}, m_{n}-M_{n}\right\} $$  Now, say that an index $n>D$ is lucky if $m_{n} \leqslant 2 M_{n}$. Two cases are possible. Case 1. Assume that there exists a lucky index $n$. In this case, (1) yields $m_{n+1} \leqslant 2 M_{n}$ and $M_{n} \leqslant M_{n+1} \leqslant M_{n}$. Therefore, $M_{n+1}=M_{n}$ and $m_{n+1} \leqslant 2 M_{n}=2 M_{n+1}$. So, the index $n+1$ is also lucky, and $M_{n+1}=M_{n}$. Applying the same arguments repeatedly, we obtain that all indices $k>n$ are lucky (i.e., $m_{k} \leqslant 2 M_{k}$ for all these indices), and $M_{k}=M_{n}$ for all such indices. Thus, all of the $m_{k}$ and $M_{k}$ are bounded by $2 M_{n}$. Case 2. Assume now that there is no lucky index, i.e., $2 M_{n}<m_{n}$ for all $n>D$. Then (1) shows that for all $n>D$ we have $m_{n} \leqslant m_{n+1} \leqslant m_{n}$, so $m_{n}=m_{D+1}$ for all $n>D$. Since $M_{n}<m_{n} / 2$ for all such indices, all of the $m_{n}$ and $M_{n}$ are bounded by $m_{D+1}$.  Thus, in both cases the sequences $\left(m_{n}\right)$ and $\left(M_{n}\right)$ are bounded, as desired.


Solution: As in the previous solution, let $D=2017$. If the sequence is bounded above, say, by $Q$, then we have that $a_{n} \geqslant \min \left\{a_{1}, \ldots, a_{D},-2 Q\right\}$ for all $n$, so the sequence is bounded. Assume for sake of contradiction that the sequence is not bounded above. Let $\ell=\min \left\{a_{1}, \ldots, a_{D}\right\}$, and $L=\max \left\{a_{1}, \ldots, a_{D}\right\}$. Call an index $n$ good if the following criteria hold:  $$ a_{n}>a_{i} \text { for each } i<n, \quad a_{n}>-2 \ell, \quad \text { and } \quad n>D $$  We first show that there must be some good index $n$. By assumption, we may take an index $N$ such that $a_{N}>\max \{L,-2 \ell\}$. Choose $n$ minimally such that $a_{n}=\max \left\{a_{1}, a_{2}, \ldots, a_{N}\right\}$. Now, the first condition in (2) is satisfied because of the minimality of $n$, and the second and third conditions are satisfied because $a_{n} \geqslant a_{N}>L,-2 \ell$, and $L \geqslant a_{i}$ for every $i$ such that $1 \leqslant i \leqslant D$.  Let $n$ be a good index. We derive a contradiction. We have that  $$ a_{n}+a_{u}+a_{v} \leqslant 0 $$  whenever $u+v=n$. We define the index $u$ to maximize $a_{u}$ over $1 \leqslant u \leqslant n-1$, and let $v=n-u$. Then, we note that $a_{u} \geqslant a_{v}$ by the maximality of $a_{u}$.  Assume first that $v \leqslant D$. Then, we have that  $$ a_{N}+2 \ell \leqslant 0, $$  because $a_{u} \geqslant a_{v} \geqslant \ell$. But this contradicts our assumption that $a_{n}>-2 \ell$ in the second criteria of (2).  Now assume that $v>D$. Then, there exist some indices $w_{1}, w_{2}$ summing up to $v$ such that  $$ a_{v}+a_{w_{1}}+a_{w_{2}}=0 $$  But combining this with (3), we have  $$ a_{n}+a_{u} \leqslant a_{w_{1}}+a_{w_{2}} $$  Because $a_{n}>a_{u}$, we have that $\max \left\{a_{w_{1}}, a_{w_{2}}\right\}>a_{u}$. But since each of the $w_{i}$ is less than $v$, this contradicts the maximality of $a_{u}$.  Comment 1. We present two harder versions of this problem below. Version 1. Let $a_{1}, a_{2}, \ldots$ be a sequence of numbers that satisfies the relation  $$ a_{n}=-\max _{i+j+k=n}\left(a_{i}+a_{j}+a_{k}\right) \quad \text { for all } n>2017 $$  Then, this sequence is bounded. Proof. Set $D=2017$. Denote  $$ M_{n}=\max _{k<n} a_{k} \quad \text { and } \quad m_{n}=-\min _{k<n} a_{k}=\max _{k<n}\left(-a_{k}\right) . $$  Clearly, the sequences $\left(m_{n}\right)$ and $\left(M_{n}\right)$ are nondecreasing. We need to prove that both are bounded. Consider an arbitrary $n>2 D$; our first aim is to bound $a_{n}$ in terms of $m_{i}$ and $M_{i}$. Set $k=\lfloor n / 2\rfloor$. (i) Choose indices $p, q$, and $r$ such that $a_{n}=-\left(a_{p}+a_{q}+a_{r}\right)$ and $p+q+r=n$. Without loss of generality, $p \geqslant q \geqslant r$.  Assume that $p \geqslant k+1(>D)$; then $p>q+r$. Hence  $$ -a_{p}=\max _{i_{1}+i_{2}+i_{3}=p}\left(a_{i_{1}}+a_{i_{2}}+a_{i_{3}}\right) \geqslant a_{q}+a_{r}+a_{p-q-r} $$  and therefore $a_{n}=-\left(a_{p}+a_{q}+a_{r}\right) \geqslant\left(a_{q}+a_{r}+a_{p-q-r}\right)-a_{q}-a_{r}=a_{p-q-r} \geqslant-m_{n}$. Otherwise, we have $k \geqslant p \geqslant q \geqslant r$. Since $n<3 k$, we have $r<k$. Then $a_{p}, a_{q} \leqslant M_{k+1}$ and $a_{r} \leqslant M_{k}$, whence $a_{n} \geqslant-2 M_{k+1}-M_{k}$.  Thus, in any case $a_{n} \geqslant-\max \left\{m_{n}, 2 M_{k+1}+M_{k}\right\}$. (ii) On the other hand, choose $p \leqslant k$ and $q \leqslant k-1$ such that $a_{p}=M_{k+1}$ and $a_{q}=M_{k}$. Then $p+q<n$, so $a_{n} \leqslant-\left(a_{p}+a_{q}+a_{n-p-q}\right)=-a_{n-p-q}-M_{k+1}-M_{k} \leqslant m_{n}-M_{k+1}-M_{k}$.  To summarize,  $$ -\max \left\{m_{n}, 2 M_{k+1}+M_{k}\right\} \leqslant a_{n} \leqslant m_{n}-M_{k+1}-M_{k} $$  whence  $$ m_{n} \leqslant m_{n+1} \leqslant \max \left\{m_{n}, 2 M_{k+1}+M_{k}\right\} \quad \text { and } \quad M_{n} \leqslant M_{n+1} \leqslant \max \left\{M_{n}, m_{n}-M_{k+1}-M_{k}\right\} . $$  Now, say that an index $n>2 D$ is lucky if $m_{n} \leqslant 2 M_{\lfloor n / 2\rfloor+1}+M_{\lfloor n / 2]}$. Two cases are possible. Case 1. Assume that there exists a lucky index $n$; set $k=\lfloor n / 2\rfloor$. In this case, (4) yields $m_{n+1} \leqslant$ $2 M_{k+1}+M_{k}$ and $M_{n} \leqslant M_{n+1} \leqslant M_{n}$ (the last relation holds, since $m_{n}-M_{k+1}-M_{k} \leqslant\left(2 M_{k+1}+\right.$ $\left.M_{k}\right)-M_{k+1}-M_{k}=M_{k+1} \leqslant M_{n}$ ). Therefore, $M_{n+1}=M_{n}$ and $m_{n+1} \leqslant 2 M_{k+1}+M_{k}$; the last relation shows that the index $n+1$ is also lucky.  Thus, all indices $N>n$ are lucky, and $M_{N}=M_{n} \geqslant m_{N} / 3$, whence all the $m_{N}$ and $M_{N}$ are bounded by $3 M_{n}$. Case 2. Conversely, assume that there is no lucky index, i.e., $2 M_{\lfloor n / 2\rfloor+1}+M_{\lfloor n / 2\rfloor}<m_{n}$ for all $n>2 D$. Then (4) shows that for all $n>2 D$ we have $m_{n} \leqslant m_{n+1} \leqslant m_{n}$, i.e., $m_{N}=m_{2 D+1}$ for all $N>2 D$. Since $M_{N}<m_{2 N+1} / 3$ for all such indices, all the $m_{N}$ and $M_{N}$ are bounded by $m_{2 D+1}$.  Thus, in both cases the sequences $\left(m_{n}\right)$ and $\left(M_{n}\right)$ are bounded, as desired. Version 2. Let $a_{1}, a_{2}, \ldots$ be a sequence of numbers that satisfies the relation  $$ a_{n}=-\max _{i_{1}+\cdots+i_{k}=n}\left(a_{i_{1}}+\cdots+a_{i_{k}}\right) \quad \text { for all } n>2017 $$  Then, this sequence is bounded. Proof. As in the solutions above, let $D=2017$. If the sequence is bounded above, say, by $Q$, then we have that $a_{n} \geqslant \min \left\{a_{1}, \ldots, a_{D},-k Q\right\}$ for all $n$, so the sequence is bounded. Assume for sake of contradiction that the sequence is not bounded above. Let $\ell=\min \left\{a_{1}, \ldots, a_{D}\right\}$, and $L=\max \left\{a_{1}, \ldots, a_{D}\right\}$. Call an index $n$ good if the following criteria hold:  $$ a_{n}>a_{i} \text { for each } i<n, \quad a_{n}>-k \ell, \quad \text { and } \quad n>D $$  We first show that there must be some good index $n$. By assumption, we may take an index $N$ such that $a_{N}>\max \{L,-k \ell\}$. Choose $n$ minimally such that $a_{n}=\max \left\{a_{1}, a_{2}, \ldots, a_{N}\right\}$. Now, the first condition is satisfied because of the minimality of $n$, and the second and third conditions are satisfied because $a_{n} \geqslant a_{N}>L,-k \ell$, and $L \geqslant a_{i}$ for every $i$ such that $1 \leqslant i \leqslant D$.  Let $n$ be a good index. We derive a contradiction. We have that  $$ a_{n}+a_{v_{1}}+\cdots+a_{v_{k}} \leqslant 0 $$  whenever $v_{1}+\cdots+v_{k}=n$. We define the sequence of indices $v_{1}, \ldots, v_{k-1}$ to greedily maximize $a_{v_{1}}$, then $a_{v_{2}}$, and so forth, selecting only from indices such that the equation $v_{1}+\cdots+v_{k}=n$ can be satisfied by positive integers $v_{1}, \ldots, v_{k}$. More formally, we define them inductively so that the following criteria are satisfied by the $v_{i}$ :  1. $1 \leqslant v_{i} \leqslant n-(k-i)-\left(v_{1}+\cdots+v_{i-1}\right)$. 2. $a_{v_{i}}$ is maximal among all choices of $v_{i}$ from the first criteria.  First of all, we note that for each $i$, the first criteria is always satisfiable by some $v_{i}$, because we are guaranteed that  $$ v_{i-1} \leqslant n-(k-(i-1))-\left(v_{1}+\cdots+v_{i-2}\right), $$  which implies  $$ 1 \leqslant n-(k-i)-\left(v_{1}+\cdots+v_{i-1}\right) . $$  Secondly, the sum $v_{1}+\cdots+v_{k-1}$ is at most $n-1$. Define $v_{k}=n-\left(v_{1}+\cdots+v_{k-1}\right)$. Then, (6) is satisfied by the $v_{i}$. We also note that $a_{v_{i}} \geqslant a_{v_{j}}$ for all $i<j$; otherwise, in the definition of $v_{i}$, we could have selected $v_{j}$ instead.  Assume first that $v_{k} \leqslant D$. Then, from (6), we have that  $$ a_{n}+k \ell \leqslant 0, $$  by using that $a_{v_{1}} \geqslant \cdots \geqslant a_{v_{k}} \geqslant \ell$. But this contradicts our assumption that $a_{n}>-k \ell$ in the second criteria of (5).  Now assume that $v_{k}>D$, and then we must have some indices $w_{1}, \ldots, w_{k}$ summing up to $v_{k}$ such that  $$ a_{v_{k}}+a_{w_{1}}+\cdots+a_{w_{k}}=0 $$  But combining this with (6), we have  $$ a_{n}+a_{v_{1}}+\cdots+a_{v_{k-1}} \leqslant a_{w_{1}}+\cdots+a_{w_{k}} . $$  Because $a_{n}>a_{v_{1}} \geqslant \cdots \geqslant a_{v_{k-1}}$, we have that $\max \left\{a_{w_{1}}, \ldots, a_{w_{k}}\right\}>a_{v_{k-1}}$. But since each of the $w_{i}$ is less than $v_{k}$, in the definition of the $v_{k-1}$ we could have chosen one of the $w_{i}$ instead, which is a contradiction.  Comment 2. It seems that each sequence satisfying the condition in Version 2 is eventually periodic, at least when its terms are integers.  However, up to this moment, the Problem Selection Committee is not aware of a proof for this fact (even in the case $k=2$ ).


An integer $n \geqslant 3$ is given. We call an $n$-tuple of real numbers $\left(x_{1}, x_{2}, \ldots, x_{n}\right)$ Shiny if for each permutation $y_{1}, y_{2}, \ldots, y_{n}$ of these numbers we have  $$ \sum_{i=1}^{n-1} y_{i} y_{i+1}=y_{1} y_{2}+y_{2} y_{3}+y_{3} y_{4}+\cdots+y_{n-1} y_{n} \geqslant-1 $$  Find the largest constant $K=K(n)$ such that  $$ \sum_{1 \leqslant i<j \leqslant n} x_{i} x_{j} \geqslant K $$  holds for every Shiny $n$-tuple $\left(x_{1}, x_{2}, \ldots, x_{n}\right)$.

Solution: First of all, we show that we may not take a larger constant $K$. Let $t$ be a positive number, and take $x_{2}=x_{3}=\cdots=t$ and $x_{1}=-1 /(2 t)$. Then, every product $x_{i} x_{j}(i \neq j)$ is equal to either $t^{2}$ or $-1 / 2$. Hence, for every permutation $y_{i}$ of the $x_{i}$, we have  $$ y_{1} y_{2}+\cdots+y_{n-1} y_{n} \geqslant(n-3) t^{2}-1 \geqslant-1 . $$  This justifies that the $n$-tuple $\left(x_{1}, \ldots, x_{n}\right)$ is Shiny. Now, we have  $$ \sum_{i<j} x_{i} x_{j}=-\frac{n-1}{2}+\frac{(n-1)(n-2)}{2} t^{2} $$  Thus, as $t$ approaches 0 from above, $\sum_{i<j} x_{i} x_{j}$ gets arbitrarily close to $-(n-1) / 2$. This shows that we may not take $K$ any larger than $-(n-1) / 2$. It remains to show that $\sum_{i<j} x_{i} x_{j} \geqslant$ $-(n-1) / 2$ for any Shiny choice of the $x_{i}$.  From now onward, assume that $\left(x_{1}, \ldots, x_{n}\right)$ is a Shiny $n$-tuple. Let the $z_{i}(1 \leqslant i \leqslant n)$ be some permutation of the $x_{i}$ to be chosen later. The indices for $z_{i}$ will always be taken modulo $n$. We will first split up the sum $\sum_{i<j} x_{i} x_{j}=\sum_{i<j} z_{i} z_{j}$ into $\lfloor(n-1) / 2\rfloor$ expressions, each of the form $y_{1} y_{2}+\cdots+y_{n-1} y_{n}$ for some permutation $y_{i}$ of the $z_{i}$, and some leftover terms. More specifically, write where $L=z_{1} z_{-1}+z_{2} z_{-2}+\cdots+z_{(n-1) / 2} z_{-(n-1) / 2}$ if $n$ is odd, and $L=z_{1} z_{-1}+z_{1} z_{-2}+z_{2} z_{-2}+$ $\cdots+z_{(n-2) / 2} z_{-n / 2}$ if $n$ is even. We note that for each $p=1,2, \ldots,\lfloor(n-1) / 2\rfloor$, there is some permutation $y_{i}$ of the $z_{i}$ such that  $$ \sum_{\substack{i+j \equiv 2 p-1,2 p \\ i \neq j}(\bmod n)} z_{i} z_{j}=\sum_{k=1}^{n-1} y_{k} y_{k+1} $$  because we may choose $y_{2 i-1}=z_{i+p-1}$ for $1 \leqslant i \leqslant(n+1) / 2$ and $y_{2 i}=z_{p-i}$ for $1 \leqslant i \leqslant n / 2$. We show (1) graphically for $n=6,7$ in the diagrams below. The edges of the graphs each represent a product $z_{i} z_{j}$, and the dashed and dotted series of lines represents the sum of the edges, which is of the form $y_{1} y_{2}+\cdots+y_{n-1} y_{n}$ for some permutation $y_{i}$ of the $z_{i}$ precisely when the series of lines is a Hamiltonian path. The filled edges represent the summands of $L$. ![](https://cdn.mathpix.com/cropped/2024_11_18_ff08e3c077fa2f8c16b2g-24.jpg?height=791&width=1656&top_left_y=185&top_left_x=195)  Now, because the $z_{i}$ are Shiny, we have that (1) yields the following bound:  $$ \sum_{i<j} z_{i} z_{j} \geqslant-\left\lfloor\frac{n-1}{2}\right\rfloor+L $$  It remains to show that, for each $n$, there exists some permutation $z_{i}$ of the $x_{i}$ such that $L \geqslant 0$ when $n$ is odd, and $L \geqslant-1 / 2$ when $n$ is even. We now split into cases based on the parity of $n$ and provide constructions of the permutations $z_{i}$.  Since we have not made any assumptions yet about the $x_{i}$, we may now assume without loss of generality that  $$ x_{1} \leqslant x_{2} \leqslant \cdots \leqslant x_{k} \leqslant 0 \leqslant x_{k+1} \leqslant \cdots \leqslant x_{n} $$  Case 1: $n$ is odd. Without loss of generality, assume that $k$ (from (2)) is even, because we may negate all the $x_{i}$ if $k$ is odd. We then have $x_{1} x_{2}, x_{3} x_{4}, \ldots, x_{n-2} x_{n-1} \geqslant 0$ because the factors are of the same sign. Let $L=x_{1} x_{2}+x_{3} x_{4}+\cdots+x_{n-2} x_{n-1} \geqslant 0$. We choose our $z_{i}$ so that this definition of $L$ agrees with the sum of the leftover terms in (1). Relabel the $x_{i}$ as $z_{i}$ such that  $$ \left\{z_{1}, z_{n-1}\right\},\left\{z_{2}, z_{n-2}\right\}, \ldots,\left\{z_{(n-1) / 2}, z_{(n+1) / 2}\right\} $$  are some permutation of  $$ \left\{x_{1}, x_{2}\right\},\left\{x_{3}, x_{4}\right\}, \ldots,\left\{x_{n-2}, x_{n-1}\right\} $$  and $z_{n}=x_{n}$. Then, we have $L=z_{1} z_{n-1}+\cdots+z_{(n-1) / 2} z_{(n+1) / 2}$, as desired. Case 2: $n$ is even. Let $L=x_{1} x_{2}+x_{2} x_{3}+\cdots+x_{n-1} x_{n}$. Assume without loss of generality $k \neq 1$. Now, we have  $$ \begin{gathered} 2 L=\left(x_{1} x_{2}+\cdots+x_{n-1} x_{n}\right)+\left(x_{1} x_{2}+\cdots+x_{n-1} x_{n}\right) \geqslant\left(x_{2} x_{3}+\cdots+x_{n-1} x_{n}\right)+x_{k} x_{k+1} \\ \geqslant x_{2} x_{3}+\cdots+x_{n-1} x_{n}+x_{n} x_{1} \geqslant-1 \end{gathered} $$  where the first inequality holds because the only negative term in $L$ is $x_{k} x_{k+1}$, the second inequality holds because $x_{1} \leqslant x_{k} \leqslant 0 \leqslant x_{k+1} \leqslant x_{n}$, and the third inequality holds because the $x_{i}$ are assumed to be Shiny. We thus have that $L \geqslant-1 / 2$. We now choose a suitable $z_{i}$ such that the definition of $L$ matches the leftover terms in (1).  Relabel the $x_{i}$ with $z_{i}$ in the following manner: $x_{2 i-1}=z_{-i}, x_{2 i}=z_{i}$ (again taking indices modulo $n$ ). We have that  $$ L=\sum_{\substack{i+j \equiv 0,-1(\bmod n) \\ i \neq j \\(\bmod n)}} z_{i} z_{j}, $$  as desired.


Solution: We present another proof that $\sum_{i<j} x_{i} x_{j} \geqslant-(n-1) / 2$ for any Shiny $n$-tuple $\left(x_{1}, \ldots, x_{n}\right)$. Assume an ordering of the $x_{i}$ as in (2), and let $\ell=n-k$. Assume without loss of generality that $k \geqslant \ell$. Also assume $k \neq n$, (as otherwise, all of the $x_{i}$ are nonpositive, and so the inequality is trivial). Define the sets of indices $S=\{1,2, \ldots, k\}$ and $T=\{k+1, \ldots, n\}$. Define the following sums:  $$ K=\sum_{\substack{i<j \\ i, j \in S}} x_{i} x_{j}, \quad M=\sum_{\substack{i \in S \\ j \in T}} x_{i} x_{j}, \quad \text { and } \quad L=\sum_{\substack{i<j \\ i, j \in T}} x_{i} x_{j} $$  By definition, $K, L \geqslant 0$ and $M \leqslant 0$. We aim to show that $K+L+M \geqslant-(n-1) / 2$. We split into cases based on whether $k=\ell$ or $k>\ell$. Case 1: $k>\ell$. Consider all permutations $\phi:\{1,2, \ldots, n\} \rightarrow\{1,2, \ldots, n\}$ such that $\phi^{-1}(T)=\{2,4, \ldots, 2 \ell\}$. Note that there are $k!!$ ! such permutations $\phi$. Define  $$ f(\phi)=\sum_{i=1}^{n-1} x_{\phi(i)} x_{\phi(i+1)} $$  We know that $f(\phi) \geqslant-1$ for every permutation $\phi$ with the above property. Averaging $f(\phi)$ over all $\phi$ gives  $$ -1 \leqslant \frac{1}{k!\ell!} \sum_{\phi} f(\phi)=\frac{2 \ell}{k \ell} M+\frac{2(k-\ell-1)}{k(k-1)} K $$  where the equality holds because there are $k \ell$ products in $M$, of which $2 \ell$ are selected for each $\phi$, and there are $k(k-1) / 2$ products in $K$, of which $k-\ell-1$ are selected for each $\phi$. We now have  $$ K+L+M \geqslant K+L+\left(-\frac{k}{2}-\frac{k-\ell-1}{k-1} K\right)=-\frac{k}{2}+\frac{\ell}{k-1} K+L $$  Since $k \leqslant n-1$ and $K, L \geqslant 0$, we get the desired inequality. Case 2: $k=\ell=n / 2$. We do a similar approach, considering all $\phi:\{1,2, \ldots, n\} \rightarrow\{1,2, \ldots, n\}$ such that $\phi^{-1}(T)=$ $\{2,4, \ldots, 2 \ell\}$, and defining $f$ the same way. Analogously to Case 1 , we have  $$ -1 \leqslant \frac{1}{k!\ell!} \sum_{\phi} f(\phi)=\frac{2 \ell-1}{k \ell} M $$  because there are $k \ell$ products in $M$, of which $2 \ell-1$ are selected for each $\phi$. Now, we have that  $$ K+L+M \geqslant M \geqslant-\frac{n^{2}}{4(n-1)} \geqslant-\frac{n-1}{2} $$  where the last inequality holds because $n \geqslant 4$.


Find all functions $f: \mathbb{R} \rightarrow \mathbb{R}$ such that  $$ f(f(x) f(y))+f(x+y)=f(x y) $$  for all $x, y \in \mathbb{R}$. (Albania)

Solution: An easy check shows that all the 3 above mentioned functions indeed satisfy the original equation (*).  In order to show that these are the only solutions, first observe that if $f(x)$ is a solution then $-f(x)$ is also a solution. Hence, without loss of generality we may (and will) assume that $f(0) \leqslant 0$ from now on. We have to show that either $f$ is identically zero or $f(x)=x-1$ $(\forall x \in \mathbb{R})$.  Observe that, for a fixed $x \neq 1$, we may choose $y \in \mathbb{R}$ so that $x+y=x y \Longleftrightarrow y=\frac{x}{x-1}$, and therefore from the original equation (*) we have  $$ f\left(f(x) \cdot f\left(\frac{x}{x-1}\right)\right)=0 \quad(x \neq 1) $$  In particular, plugging in $x=0$ in (1), we conclude that $f$ has at least one zero, namely $(f(0))^{2}$ :  $$ f\left((f(0))^{2}\right)=0 $$  We analyze two cases (recall that $f(0) \leqslant 0$ ): Case 1: $f(0)=0$. Setting $y=0$ in the original equation we get the identically zero solution:  $$ f(f(x) f(0))+f(x)=f(0) \Longrightarrow f(x)=0 \text { for all } x \in \mathbb{R} $$  From now on, we work on the main Case 2: $f(0)<0$. We begin with the following


Let $a_{0}, a_{1}, a_{2}, \ldots$ be a sequence of integers and $b_{0}, b_{1}, b_{2}, \ldots$ be a sequence of positive integers such that $a_{0}=0, a_{1}=1$, and  $$ a_{n+1}=\left\{\begin{array}{ll} a_{n} b_{n}+a_{n-1}, & \text { if } b_{n-1}=1 \\ a_{n} b_{n}-a_{n-1}, & \text { if } b_{n-1}>1 \end{array} \quad \text { for } n=1,2, \ldots\right. $$  Prove that at least one of the two numbers $a_{2017}$ and $a_{2018}$ must be greater than or equal to 2017 . (Australia)

Solution: The value of $b_{0}$ is irrelevant since $a_{0}=0$, so we may assume that $b_{0}=1$. Lemma. We have $a_{n} \geqslant 1$ for all $n \geqslant 1$. Proof. Let us suppose otherwise in order to obtain a contradiction. Let  $$ n \geqslant 1 \text { be the smallest integer with } a_{n} \leqslant 0 \text {. } $$  Note that $n \geqslant 2$. It follows that $a_{n-1} \geqslant 1$ and $a_{n-2} \geqslant 0$. Thus we cannot have $a_{n}=$ $a_{n-1} b_{n-1}+a_{n-2}$, so we must have $a_{n}=a_{n-1} b_{n-1}-a_{n-2}$. Since $a_{n} \leqslant 0$, we have $a_{n-1} \leqslant a_{n-2}$. Thus we have $a_{n-2} \geqslant a_{n-1} \geqslant a_{n}$.  Let  $$ r \text { be the smallest index with } a_{r} \geqslant a_{r+1} \geqslant a_{r+2} \text {. } $$  Then $r \leqslant n-2$ by the above, but also $r \geqslant 2$ : if $b_{1}=1$, then $a_{2}=a_{1}=1$ and $a_{3}=a_{2} b_{2}+a_{1}>a_{2}$; if $b_{1}>1$, then $a_{2}=b_{1}>1=a_{1}$.  By the minimal choice (2) of $r$, it follows that $a_{r-1}<a_{r}$. And since $2 \leqslant r \leqslant n-2$, by the minimal choice (1) of $n$ we have $a_{r-1}, a_{r}, a_{r+1}>0$. In order to have $a_{r+1} \geqslant a_{r+2}$, we must have $a_{r+2}=a_{r+1} b_{r+1}-a_{r}$ so that $b_{r} \geqslant 2$. Putting everything together, we conclude that  $$ a_{r+1}=a_{r} b_{r} \pm a_{r-1} \geqslant 2 a_{r}-a_{r-1}=a_{r}+\left(a_{r}-a_{r-1}\right)>a_{r} $$  which contradicts (2). To complete the problem, we prove that $\max \left\{a_{n}, a_{n+1}\right\} \geqslant n$ by induction. The cases $n=0,1$ are given. Assume it is true for all non-negative integers strictly less than $n$, where $n \geqslant 2$. There are two cases:  Case 1: $b_{n-1}=1$. Then $a_{n+1}=a_{n} b_{n}+a_{n-1}$. By the inductive assumption one of $a_{n-1}, a_{n}$ is at least $n-1$ and the other, by the lemma, is at least 1 . Hence  $$ a_{n+1}=a_{n} b_{n}+a_{n-1} \geqslant a_{n}+a_{n-1} \geqslant(n-1)+1=n . $$  Thus $\max \left\{a_{n}, a_{n+1}\right\} \geqslant n$, as desired. Case 2: $b_{n-1}>1$. Since we defined $b_{0}=1$ there is an index $r$ with $1 \leqslant r \leqslant n-1$ such that  $$ b_{n-1}, b_{n-2}, \ldots, b_{r} \geqslant 2 \quad \text { and } \quad b_{r-1}=1 $$  We have $a_{r+1}=a_{r} b_{r}+a_{r-1} \geqslant 2 a_{r}+a_{r-1}$. Thus $a_{r+1}-a_{r} \geqslant a_{r}+a_{r-1}$. Now we claim that $a_{r}+a_{r-1} \geqslant r$. Indeed, this holds by inspection for $r=1$; for $r \geqslant 2$, one of $a_{r}, a_{r-1}$ is at least $r-1$ by the inductive assumption, while the other, by the lemma, is at least 1 . Hence $a_{r}+a_{r-1} \geqslant r$, as claimed, and therefore $a_{r+1}-a_{r} \geqslant r$ by the last inequality in the previous paragraph.  Since $r \geqslant 1$ and, by the lemma, $a_{r} \geqslant 1$, from $a_{r+1}-a_{r} \geqslant r$ we get the following two inequalities:  $$ a_{r+1} \geqslant r+1 \quad \text { and } \quad a_{r+1}>a_{r} . $$  Now observe that  $$ a_{m}>a_{m-1} \Longrightarrow a_{m+1}>a_{m} \text { for } m=r+1, r+2, \ldots, n-1 \text {, } $$  since $a_{m+1}=a_{m} b_{m}-a_{m-1} \geqslant 2 a_{m}-a_{m-1}=a_{m}+\left(a_{m}-a_{m-1}\right)>a_{m}$. Thus  $$ a_{n}>a_{n-1}>\cdots>a_{r+1} \geqslant r+1 \Longrightarrow a_{n} \geqslant n $$  So $\max \left\{a_{n}, a_{n+1}\right\} \geqslant n$, as desired.


Solution: We say that an index $n>1$ is bad if $b_{n-1}=1$ and $b_{n-2}>1$; otherwise $n$ is good. The value of $b_{0}$ is irrelevant to the definition of $\left(a_{n}\right)$ since $a_{0}=0$; so we assume that $b_{0}>1$. Lemma 1. (a) $a_{n} \geqslant 1$ for all $n>0$. (b) If $n>1$ is good, then $a_{n}>a_{n-1}$.  Proof. Induction on $n$. In the base cases $n=1,2$ we have $a_{1}=1 \geqslant 1, a_{2}=b_{1} a_{1} \geqslant 1$, and finally $a_{2}>a_{1}$ if 2 is good, since in this case $b_{1}>1$.  Now we assume that the lemma statement is proved for $n=1,2, \ldots, k$ with $k \geqslant 2$, and prove it for $n=k+1$. Recall that $a_{k}$ and $a_{k-1}$ are positive by the induction hypothesis. Case 1: $k$ is bad. We have $b_{k-1}=1$, so $a_{k+1}=b_{k} a_{k}+a_{k-1} \geqslant a_{k}+a_{k-1}>a_{k} \geqslant 1$, as required. Case 2: $k$ is good. We already have $a_{k}>a_{k-1} \geqslant 1$ by the induction hypothesis. We consider three easy subcases.  Subcase 2.1: $b_{k}>1$. Then $a_{k+1} \geqslant b_{k} a_{k}-a_{k-1} \geqslant a_{k}+\left(a_{k}-a_{k-1}\right)>a_{k} \geqslant 1$. Subcase 2.2: $b_{k}=b_{k-1}=1$. Then $a_{k+1}=a_{k}+a_{k-1}>a_{k} \geqslant 1$. Subcase 2.3: $b_{k}=1$ but $b_{k-1}>1$. Then $k+1$ is bad, and we need to prove only (a), which is trivial: $a_{k+1}=a_{k}-a_{k-1} \geqslant 1$. So, in all three subcases we have verified the required relations. Lemma 2. Assume that $n>1$ is bad. Then there exists a $j \in\{1,2,3\}$ such that $a_{n+j} \geqslant$ $a_{n-1}+j+1$, and $a_{n+i} \geqslant a_{n-1}+i$ for all $1 \leqslant i<j$. Proof. Recall that $b_{n-1}=1$. Set  $$ m=\inf \left\{i>0: b_{n+i-1}>1\right\} $$  (possibly $m=+\infty$ ). We claim that $j=\min \{m, 3\}$ works. Again, we distinguish several cases, according to the value of $m$; in each of them we use Lemma 1 without reference. Case 1: $m=1$, so $b_{n}>1$. Then $a_{n+1} \geqslant 2 a_{n}+a_{n-1} \geqslant a_{n-1}+2$, as required. Case 2: $m=2$, so $b_{n}=1$ and $b_{n+1}>1$. Then we successively get  $$ \begin{gathered} a_{n+1}=a_{n}+a_{n-1} \geqslant a_{n-1}+1 \\ a_{n+2} \geqslant 2 a_{n+1}+a_{n} \geqslant 2\left(a_{n-1}+1\right)+a_{n}=a_{n-1}+\left(a_{n-1}+a_{n}+2\right) \geqslant a_{n-1}+4 \end{gathered} $$  which is even better than we need.  Case 3: $m>2$, so $b_{n}=b_{n+1}=1$. Then we successively get  $$ \begin{gathered} a_{n+1}=a_{n}+a_{n-1} \geqslant a_{n-1}+1, \quad a_{n+2}=a_{n+1}+a_{n} \geqslant a_{n-1}+1+a_{n} \geqslant a_{n-1}+2, \\ a_{n+3} \geqslant a_{n+2}+a_{n+1} \geqslant\left(a_{n-1}+1\right)+\left(a_{n-1}+2\right) \geqslant a_{n-1}+4 \end{gathered} $$  as required. Lemmas 1 (b) and 2 provide enough information to prove that $\max \left\{a_{n}, a_{n+1}\right\} \geqslant n$ for all $n$ and, moreover, that $a_{n} \geqslant n$ often enough. Indeed, assume that we have found some $n$ with $a_{n-1} \geqslant n-1$. If $n$ is good, then by Lemma 1 (b) we have $a_{n} \geqslant n$ as well. If $n$ is bad, then Lemma 2 yields $\max \left\{a_{n+i}, a_{n+i+1}\right\} \geqslant a_{n-1}+i+1 \geqslant n+i$ for all $0 \leqslant i<j$ and $a_{n+j} \geqslant a_{n-1}+j+1 \geqslant n+j$; so $n+j$ is the next index to start with.


Assume that a function $f: \mathbb{R} \rightarrow \mathbb{R}$ satisfies the following condition: For every $x, y \in \mathbb{R}$ such that $(f(x)+y)(f(y)+x)>0$, we have $f(x)+y=f(y)+x$. Prove that $f(x)+y \leqslant f(y)+x$ whenever $x>y$. (Netherlands)

Solution: Define $g(x)=x-f(x)$. The condition on $f$ then rewrites as follows: For every $x, y \in \mathbb{R}$ such that $((x+y)-g(x))((x+y)-g(y))>0$, we have $g(x)=g(y)$. This condition may in turn be rewritten in the following form: If $g(x) \neq g(y)$, then the number $x+y$ lies (non-strictly) between $g(x)$ and $g(y)$. Notice here that the function $g_{1}(x)=-g(-x)$ also satisfies $(*)$, since  $$ \begin{aligned} g_{1}(x) \neq g_{1}(y) \Longrightarrow & g(-x) \neq g(-y) \Longrightarrow \quad-(x+y) \text { lies between } g(-x) \text { and } g(-y) \\ & \Longrightarrow \quad x+y \text { lies between } g_{1}(x) \text { and } g_{1}(y) \end{aligned} $$  On the other hand, the relation we need to prove reads now as  $$ g(x) \leqslant g(y) \quad \text { whenever } x<y $$  Again, this condition is equivalent to the same one with $g$ replaced by $g_{1}$. If $g(x)=2 x$ for all $x \in \mathbb{R}$, then $(*)$ is obvious; so in what follows we consider the other case. We split the solution into a sequence of lemmas, strengthening one another. We always consider some value of $x$ with $g(x) \neq 2 x$ and denote $X=g(x)$. Lemma 1. Assume that $X<2 x$. Then on the interval $(X-x ; x]$ the function $g$ attains at most two values - namely, $X$ and, possibly, some $Y>X$. Similarly, if $X>2 x$, then $g$ attains at most two values on $[x ; X-x)$ - namely, $X$ and, possibly, some $Y<X$. Proof. We start with the first claim of the lemma. Notice that $X-x<x$, so the considered interval is nonempty.  Take any $a \in(X-x ; x)$ with $g(a) \neq X$ (if it exists). If $g(a)<X$, then (*) yields $g(a) \leqslant$ $a+x \leqslant g(x)=X$, so $a \leqslant X-x$ which is impossible. Thus, $g(a)>X$ and hence by (*) we get $X \leqslant a+x \leqslant g(a)$.  Now, for any $b \in(X-x ; x)$ with $g(b) \neq X$ we similarly get $b+x \leqslant g(b)$. Therefore, the number $a+b$ (which is smaller than each of $a+x$ and $b+x$ ) cannot lie between $g(a)$ and $g(b)$, which by (*) implies that $g(a)=g(b)$. Hence $g$ may attain only two values on $(X-x ; x]$, namely $X$ and $g(a)>X$.  To prove the second claim, notice that $g_{1}(-x)=-X<2 \cdot(-x)$, so $g_{1}$ attains at most two values on $(-X+x,-x]$, i.e., $-X$ and, possibly, some $-Y>-X$. Passing back to $g$, we get what we need. Lemma 2. If $X<2 x$, then $g$ is constant on $(X-x ; x)$. Similarly, if $X>2 x$, then $g$ is constant on $(x ; X-x)$. Proof. Again, it suffices to prove the first claim only. Assume, for the sake of contradiction, that there exist $a, b \in(X-x ; x)$ with $g(a) \neq g(b)$; by Lemma 1, we may assume that $g(a)=X$ and $Y=g(b)>X$.  Notice that $\min \{X-a, X-b\}>X-x$, so there exists a $u \in(X-x ; x)$ such that $u<\min \{X-a, X-b\}$. By Lemma 1, we have either $g(u)=X$ or $g(u)=Y$. In the former case, by (*) we have $X \leqslant u+b \leqslant Y$ which contradicts $u<X-b$. In the second case, by (*) we have $X \leqslant u+a \leqslant Y$ which contradicts $u<X-a$. Thus the lemma is proved.  Lemma 3. If $X<2 x$, then $g(a)=X$ for all $a \in(X-x ; x)$. Similarly, if $X>2 x$, then $g(a)=X$ for all $a \in(x ; X-x)$. Proof. Again, we only prove the first claim. By Lemmas 1 and 2, this claim may be violated only if $g$ takes on a constant value $Y>X$ on $(X-x, x)$. Choose any $a, b \in(X-x ; x)$ with $a<b$. By (*), we have  $$ Y \geqslant b+x \geqslant X $$  In particular, we have $Y \geqslant b+x>2 a$. Applying Lemma 2 to $a$ in place of $x$, we obtain that $g$ is constant on $(a, Y-a)$. By (2) again, we have $x \leqslant Y-b<Y-a$; so $x, b \in(a ; Y-a)$. But $X=g(x) \neq g(b)=Y$, which is a contradiction.  Now we are able to finish the solution. Assume that $g(x)>g(y)$ for some $x<y$. Denote $X=g(x)$ and $Y=g(y)$; by (*), we have $X \geqslant x+y \geqslant Y$, so $Y-y \leqslant x<y \leqslant X-x$, and hence $(Y-y ; y) \cap(x ; X-x)=(x, y) \neq \varnothing$. On the other hand, since $Y-y<y$ and $x<X-x$, Lemma 3 shows that $g$ should attain a constant value $X$ on $(x ; X-x)$ and a constant value $Y \neq X$ on $(Y-y ; y)$. Since these intervals overlap, we get the final contradiction.


Solution: As in the previous solution, we pass to the function $g$ satisfying ( $*$ ) and notice that we need to prove the condition (1). We will also make use of the function $g_{1}$.  If $g$ is constant, then (1) is clearly satisfied. So, in the sequel we assume that $g$ takes on at least two different values. Now we collect some information about the function $g$. Claim 1. For any $c \in \mathbb{R}$, all the solutions of $g(x)=c$ are bounded. Proof. Fix any $y \in \mathbb{R}$ with $g(y) \neq c$. Assume first that $g(y)>c$. Now, for any $x$ with $g(x)=c$, by (*) we have $c \leqslant x+y \leqslant g(y)$, or $c-y \leqslant x \leqslant g(y)-y$. Since $c$ and $y$ are constant, we get what we need.  If $g(y)<c$, we may switch to the function $g_{1}$ for which we have $g_{1}(-y)>-c$. By the above arguments, we obtain that all the solutions of $g_{1}(-x)=-c$ are bounded, which is equivalent to what we need.  As an immediate consequence, the function $g$ takes on infinitely many values, which shows that the next claim is indeed widely applicable. Claim 2. If $g(x)<g(y)<g(z)$, then $x<z$. Proof. By (*), we have $g(x) \leqslant x+y \leqslant g(y) \leqslant z+y \leqslant g(z)$, so $x+y \leqslant z+y$, as required. Claim 3. Assume that $g(x)>g(y)$ for some $x<y$. Then $g(a) \in\{g(x), g(y)\}$ for all $a \in[x ; y]$. Proof. If $g(y)<g(a)<g(x)$, then the triple $(y, a, x)$ violates Claim 2. If $g(a)<g(y)<g(x)$, then the triple $(a, y, x)$ violates Claim 2. If $g(y)<g(x)<g(a)$, then the triple $(y, x, a)$ violates Claim 2. The only possible cases left are $g(a) \in\{g(x), g(y)\}$.  In view of Claim 3, we say that an interval $I$ (which may be open, closed, or semi-open) is a Dirichlet interval ${ }^{*}$ if the function $g$ takes on just two values on $I$.  Assume now, for the sake of contradiction, that (1) is violated by some $x<y$. By Claim 3, $[x ; y]$ is a Dirichlet interval. Set $r=\inf \{a:(a ; y]$ is a Dirichlet interval $\} \quad$ and $s=\sup \{b:[x ; b)$ is a Dirichlet interval $\}$. Clearly, $r \leqslant x<y \leqslant s$. By Claim 1, $r$ and $s$ are finite. Denote $X=g(x), Y=g(y)$, and $\Delta=(y-x) / 2$.  Suppose first that there exists a $t \in(r ; r+\Delta)$ with $f(t)=Y$. By the definition of $r$, the interval $(r-\Delta ; y]$ is not Dirichlet, so there exists an $r^{\prime} \in(r-\Delta ; r]$ such that $g\left(r^{\prime}\right) \notin\{X, Y\}$.  [^0]The function $g$ attains at least three distinct values on $\left[r^{\prime} ; y\right]$, namely $g\left(r^{\prime}\right), g(x)$, and $g(y)$. Claim 3 now yields $g\left(r^{\prime}\right) \leqslant g(y)$; the equality is impossible by the choice of $r^{\prime}$, so in fact $g\left(r^{\prime}\right)<Y$. Applying (*) to the pairs $\left(r^{\prime}, y\right)$ and $(t, x)$ we obtain $r^{\prime}+y \leqslant Y \leqslant t+x$, whence $r-\Delta+y<r^{\prime}+y \leqslant t+x<r+\Delta+x$, or $y-x<2 \Delta$. This is a contradiction.  Thus, $g(t)=X$ for all $t \in(r ; r+\Delta)$. Applying the same argument to $g_{1}$, we get $g(t)=Y$ for all $t \in(s-\Delta ; s)$.  Finally, choose some $s_{1}, s_{2} \in(s-\Delta ; s)$ with $s_{1}<s_{2}$ and denote $\delta=\left(s_{2}-s_{1}\right) / 2$. As before, we choose $r^{\prime} \in(r-\delta ; r)$ with $g\left(r^{\prime}\right) \notin\{X, Y\}$ and obtain $g\left(r^{\prime}\right)<Y$. Choose any $t \in(r ; r+\delta)$; by the above arguments, we have $g(t)=X$ and $g\left(s_{1}\right)=g\left(s_{2}\right)=Y$. As before, we apply (*) to the pairs $\left(r^{\prime}, s_{2}\right)$ and $\left(t, s_{1}\right)$ obtaining $r-\delta+s_{2}<r^{\prime}+s_{2} \leqslant Y \leqslant t+s_{1}<r+\delta+s_{1}$, or $s_{2}-s_{1}<2 \delta$. This is a final contradiction.  Comment 1. The original submission discussed the same functions $f$, but the question was different - namely, the following one:  Prove that the equation $f(x)=2017 x$ has at most one solution, and the equation $f(x)=-2017 x$ has at least one solution.  The Problem Selection Committee decided that the question we are proposing is more natural, since it provides more natural information about the function $g$ (which is indeed the main character in this story). On the other hand, the new problem statement is strong enough in order to imply the original one easily.  Namely, we will deduce from the new problem statement (along with the facts used in the solutions) that ( $i$ ) for every $N>0$ the equation $g(x)=-N x$ has at most one solution, and (ii) for every $N>1$ the equation $g(x)=N x$ has at least one solution.  Claim ( $i$ ) is now trivial. Indeed, $g$ is proven to be non-decreasing, so $g(x)+N x$ is strictly increasing and thus has at most one zero.  We proceed on claim $(i i)$. If $g(0)=0$, then the required root has been already found. Otherwise, we may assume that $g(0)>0$ and denote $c=g(0)$. We intend to prove that $x=c / N$ is the required root. Indeed, by monotonicity we have $g(c / N) \geqslant g(0)=c$; if we had $g(c / N)>c$, then (*) would yield $c \leqslant 0+c / N \leqslant g(c / N)$ which is false. Thus, $g(x)=c=N x$.  Comment 2. There are plenty of functions $g$ satisfying (*) (and hence of functions $f$ satisfying the problem conditions). One simple example is $g_{0}(x)=2 x$. Next, for any increasing sequence $A=\left(\ldots, a_{-1}, a_{0}, a_{1}, \ldots\right)$ which is unbounded in both directions (i.e., for every $N$ this sequence contains terms greater than $N$, as well as terms smaller than $-N$ ), the function $g_{A}$ defined by  $$ g_{A}(x)=a_{i}+a_{i+1} \quad \text { whenever } x \in\left[a_{i} ; a_{i+1}\right) $$  satisfies (*). Indeed, pick any $x<y$ with $g(x) \neq g(y)$; this means that $x \in\left[a_{i} ; a_{i+1}\right)$ and $y \in\left[a_{j} ; a_{j+1}\right)$ for some $i<j$. Then we have $g(x)=a_{i}+a_{i+1} \leqslant x+y<a_{j}+a_{j+1}=g(y)$, as required.  There also exist examples of the mixed behavior; e.g., for an arbitrary sequence $A$ as above and an arbitrary subset $I \subseteq \mathbb{Z}$ the function  $$ g_{A, I}(x)=\left\{\begin{array}{lll} g_{0}(x), & x \in\left[a_{i} ; a_{i+1}\right) & \text { with } i \in I ; \\ g_{A}(x), & x \in\left[a_{i} ; a_{i+1}\right) & \text { with } i \notin I \end{array}\right. $$  also satisfies (*). Finally, it is even possible to provide a complete description of all functions $g$ satisfying (*) (and hence of all functions $f$ satisfying the problem conditions); however, it seems to be far out of scope for the IMO. This description looks as follows.  Let $A$ be any closed subset of $\mathbb{R}$ which is unbounded in both directions. Define the functions $i_{A}$, $s_{A}$, and $g_{A}$ as follows:  $$ i_{A}(x)=\inf \{a \in A: a \geqslant x\}, \quad s_{A}(x)=\sup \{a \in A: a \leqslant x\}, \quad g_{A}(x)=i_{A}(x)+s_{A}(x) $$  It is easy to see that for different sets $A$ and $B$ the functions $g_{A}$ and $g_{B}$ are also different (since, e.g., for any $a \in A \backslash B$ the function $g_{B}$ is constant in a small neighborhood of $a$, but the function $g_{A}$ is not). One may check, similarly to the arguments above, that each such function satisfies (*).  Finally, one more modification is possible. Namely, for any $x \in A$ one may redefine $g_{A}(x)$ (which is $2 x$ ) to be any of the numbers  $$ \begin{array}{cll}  & g_{A+}(x)=i_{A+}(x)+x \quad \text { or } & g_{A-}(x)=x+s_{A-}(x), \\ \text { where } \quad i_{A+}(x)=\inf \{a \in A: a>x\} & \text { and } \quad s_{A-}(x)=\sup \{a \in A: a<x\} . \end{array} $$  This really changes the value if $x$ has some right (respectively, left) semi-neighborhood disjoint from $A$, so there are at most countably many possible changes; all of them can be performed independently.  With some effort, one may show that the construction above provides all functions $g$ satisfying (*).


A rectangle $\mathcal{R}$ with odd integer side lengths is divided into small rectangles with integer side lengths. Prove that there is at least one among the small rectangles whose distances from the four sides of $\mathcal{R}$ are either all odd or all even. (Singapore)

Solution: Let the width and height of $\mathcal{R}$ be odd numbers $a$ and $b$. Divide $\mathcal{R}$ into $a b$ unit squares and color them green and yellow in a checkered pattern. Since the side lengths of $a$ and $b$ are odd, the corner squares of $\mathcal{R}$ will all have the same color, say green.  Call a rectangle (either $\mathcal{R}$ or a small rectangle) green if its corners are all green; call it yellow if the corners are all yellow, and call it mixed if it has both green and yellow corners. In particular, $\mathcal{R}$ is a green rectangle.  We will use the following trivial observations.  - Every mixed rectangle contains the same number of green and yellow squares; - Every green rectangle contains one more green square than yellow square; - Every yellow rectangle contains one more yellow square than green square.  The rectangle $\mathcal{R}$ is green, so it contains more green unit squares than yellow unit squares. Therefore, among the small rectangles, at least one is green. Let $\mathcal{S}$ be such a small green rectangle, and let its distances from the sides of $\mathcal{R}$ be $x, y, u$ and $v$, as shown in the picture. The top-left corner of $\mathcal{R}$ and the top-left corner of $\mathcal{S}$ have the same color, which happen if and only if $x$ and $u$ have the same parity. Similarly, the other three green corners of $\mathcal{S}$ indicate that $x$ and $v$ have the same parity, $y$ and $u$ have the same parity, i.e. $x, y, u$ and $v$ are all odd or all even. ![](https://cdn.mathpix.com/cropped/2024_11_18_ff08e3c077fa2f8c16b2g-36.jpg?height=361&width=546&top_left_y=1493&top_left_x=755)


Let $n$ be a positive integer. Define a chameleon to be any sequence of $3 n$ letters, with exactly $n$ occurrences of each of the letters $a, b$, and $c$. Define a swap to be the transposition of two adjacent letters in a chameleon. Prove that for any chameleon $X$, there exists a chameleon $Y$ such that $X$ cannot be changed to $Y$ using fewer than $3 n^{2} / 2$ swaps. (Australia)

Solution: To start, notice that the swap of two identical letters does not change a chameleon, so we may assume there are no such swaps.  For any two chameleons $X$ and $Y$, define their distance $d(X, Y)$ to be the minimal number of swaps needed to transform $X$ into $Y$ (or vice versa). Clearly, $d(X, Y)+d(Y, Z) \geqslant d(X, Z)$ for any three chameleons $X, Y$, and $Z$. Lemma. Consider two chameleons  $$ P=\underbrace{a a \ldots a}_{n} \underbrace{b b \ldots b}_{n} \underbrace{c c \ldots c}_{n} \text { and } Q=\underbrace{c c \ldots c}_{n} \underbrace{b b \ldots b}_{n} \underbrace{a a \ldots a}_{n} . $$  Then $d(P, Q) \geqslant 3 n^{2}$. Proof. For any chameleon $X$ and any pair of distinct letters $u, v \in\{a, b, c\}$, we define $f_{u, v}(X)$ to be the number of pairs of positions in $X$ such that the left one is occupied by $u$, and the right one is occupied by $v$. Define $f(X)=f_{a, b}(X)+f_{a, c}(X)+f_{b, c}(X)$. Notice that $f_{a, b}(P)=f_{a, c}(P)=f_{b, c}(P)=n^{2}$ and $f_{a, b}(Q)=f_{a, c}(Q)=f_{b, c}(Q)=0$, so $f(P)=3 n^{2}$ and $f(Q)=0$.  Now consider some swap changing a chameleon $X$ to $X^{\prime}$; say, the letters $a$ and $b$ are swapped. Then $f_{a, b}(X)$ and $f_{a, b}\left(X^{\prime}\right)$ differ by exactly 1 , while $f_{a, c}(X)=f_{a, c}\left(X^{\prime}\right)$ and $f_{b, c}(X)=f_{b, c}\left(X^{\prime}\right)$. This yields $\left|f(X)-f\left(X^{\prime}\right)\right|=1$, i.e., on any swap the value of $f$ changes by 1 . Hence $d(X, Y) \geqslant$ $|f(X)-f(Y)|$ for any two chameleons $X$ and $Y$. In particular, $d(P, Q) \geqslant|f(P)-f(Q)|=3 n^{2}$, as desired.  Back to the problem, take any chameleon $X$ and notice that $d(X, P)+d(X, Q) \geqslant d(P, Q) \geqslant$ $3 n^{2}$ by the lemma. Consequently, $\max \{d(X, P), d(X, Q)\} \geqslant \frac{3 n^{2}}{2}$, which establishes the problem statement.  Comment 1. The problem may be reformulated in a graph language. Construct a graph $G$ with the chameleons as vertices, two vertices being connected with an edge if and only if these chameleons differ by a single swap. Then $d(X, Y)$ is the usual distance between the vertices $X$ and $Y$ in this graph. Recall that the radius of a connected graph $G$ is defined as  $$ r(G)=\min _{v \in V} \max _{u \in V} d(u, v) . $$  So we need to prove that the radius of the constructed graph is at least $3 n^{2} / 2$. It is well-known that the radius of any connected graph is at least the half of its diameter (which is simply $\max _{u, v \in V} d(u, v)$ ). Exactly this fact has been used above in order to finish the solution.


Solution: We use the notion of distance from   In any chameleon $X$, we enumerate the positions in it from left to right by $1,2, \ldots, 3 n$. Define $s_{c}(X)$ as the sum of positions occupied by $c$. The value of $s_{c}$ changes by at most 1 on each swap, but this fact alone does not suffice to solve the problem; so we need an improvement.  For every chameleon $X$, denote by $X_{\bar{c}}$ the sequence obtained from $X$ by removing all $n$ letters $c$. Enumerate the positions in $X_{\bar{c}}$ from left to right by $1,2, \ldots, 2 n$, and define $s_{\bar{c}, b}(X)$ as the sum of positions in $X_{\bar{c}}$ occupied by $b$. (In other words, here we consider the positions of the $b$ 's relatively to the $a$ 's only.) Finally, denote  $$ d^{\prime}(X, Y):=\left|s_{c}(X)-s_{c}(Y)\right|+\left|s_{\bar{c}, b}(X)-s_{\bar{c}, b}(Y)\right| $$  Now consider any swap changing a chameleon $X$ to $X^{\prime}$. If no letter $c$ is involved into this swap, then $s_{c}(X)=s_{c}\left(X^{\prime}\right)$; on the other hand, exactly one letter $b$ changes its position in $X_{\bar{c}}$, so $\left|s_{\bar{c}, b}(X)-s_{\bar{c}, b}\left(X^{\prime}\right)\right|=1$. If a letter $c$ is involved into a swap, then $X_{\bar{c}}=X_{\bar{c}}^{\prime}$, so $s_{\bar{c}, b}(X)=s_{\bar{c}, b}\left(X^{\prime}\right)$ and $\left|s_{c}(X)-s_{c}\left(X^{\prime}\right)\right|=1$. Thus, in all cases we have $d^{\prime}\left(X, X^{\prime}\right)=1$.  As in the previous solution, this means that $d(X, Y) \geqslant d^{\prime}(X, Y)$ for any two chameleons $X$ and $Y$. Now, for any chameleon $X$ we will indicate a chameleon $Y$ with $d^{\prime}(X, Y) \geqslant 3 n^{2} / 2$, thus finishing the solution.  The function $s_{c}$ attains all integer values from $1+\cdots+n=\frac{n(n+1)}{2}$ to $(2 n+1)+\cdots+3 n=$ $2 n^{2}+\frac{n(n+1)}{2}$. If $s_{c}(X) \leqslant n^{2}+\frac{n(n+1)}{2}$, then we put the letter $c$ into the last $n$ positions in $Y$; otherwise we put the letter $c$ into the first $n$ positions in $Y$. In either case we already have $\left|s_{c}(X)-s_{c}(Y)\right| \geqslant n^{2}$.  Similarly, $s_{\bar{c}, b}$ ranges from $\frac{n(n+1)}{2}$ to $n^{2}+\frac{n(n+1)}{2}$. So, if $s_{\bar{c}, b}(X) \leqslant \frac{n^{2}}{2}+\frac{n(n+1)}{2}$, then we put the letter $b$ into the last $n$ positions in $Y$ which are still free; otherwise, we put the letter $b$ into the first $n$ such positions. The remaining positions are occupied by $a$. In any case, we have $\left|s_{\bar{c}, b}(X)-s_{\bar{c}, b}(Y)\right| \geqslant \frac{n^{2}}{2}$, thus $d^{\prime}(X, Y) \geqslant n^{2}+\frac{n^{2}}{2}=\frac{3 n^{2}}{2}$, as desired.  Comment 2. The two solutions above used two lower bounds $|f(X)-f(Y)|$ and $d^{\prime}(X, Y)$ for the number $d(X, Y)$. One may see that these bounds are closely related to each other, as  $$ f_{a, c}(X)+f_{b, c}(X)=s_{c}(X)-\frac{n(n+1)}{2} \quad \text { and } \quad f_{a, b}(X)=s_{\bar{c}, b}(X)-\frac{n(n+1)}{2} . $$  One can see that, e.g., the bound $d^{\prime}(X, Y)$ could as well be used in the proof of the lemma in Solution 1. Let us describe here an even sharper bound which also can be used in different versions of the solutions above.  In each chameleon $X$, enumerate the occurrences of $a$ from the left to the right as $a_{1}, a_{2}, \ldots, a_{n}$. Since we got rid of swaps of identical letters, the relative order of these letters remains the same during the swaps. Perform the same operation with the other letters, obtaining new letters $b_{1}, \ldots, b_{n}$ and $c_{1}, \ldots, c_{n}$. Denote by $A$ the set of the $3 n$ obtained letters.  Since all $3 n$ letters became different, for any chameleon $X$ and any $s \in A$ we may define the position $N_{s}(X)$ of $s$ in $X$ (thus $1 \leqslant N_{s}(X) \leqslant 3 n$ ). Now, for any two chameleons $X$ and $Y$ we say that a pair of letters $(s, t) \in A \times A$ is an $(X, Y)$-inversion if $N_{s}(X)<N_{t}(X)$ but $N_{s}(Y)>N_{t}(Y)$, and define $d^{*}(X, Y)$ to be the number of $(X, Y)$-inversions. Then for any two chameleons $Y$ and $Y^{\prime}$ differing by a single swap, we have $\left|d^{*}(X, Y)-d^{*}\left(X, Y^{\prime}\right)\right|=1$. Since $d^{*}(X, X)=0$, this yields $d(X, Y) \geqslant d^{*}(X, Y)$ for any pair of chameleons $X$ and $Y$. The bound $d^{*}$ may also be used in both Solution 1 and Solution 2.  Comment 3. In fact, one may prove that the distance $d^{*}$ defined in the previous comment coincides with $d$. Indeed, if $X \neq Y$, then there exist an ( $X, Y$ )-inversion $(s, t)$. One can show that such $s$ and $t$ may be chosen to occupy consecutive positions in $Y$. Clearly, $s$ and $t$ correspond to different letters among $\{a, b, c\}$. So, swapping them in $Y$ we get another chameleon $Y^{\prime}$ with $d^{*}\left(X, Y^{\prime}\right)=d^{*}(X, Y)-1$. Proceeding in this manner, we may change $Y$ to $X$ in $d^{*}(X, Y)$ steps.  Using this fact, one can show that the estimate in the problem statement is sharp for all $n \geqslant 2$. (For $n=1$ it is not sharp, since any permutation of three letters can be changed to an opposite one in no less than three swaps.) We outline the proof below.  For any $k \geqslant 0$, define  $$ X_{2 k}=\underbrace{a b c a b c \ldots a b c}_{3 k \text { letters }} \underbrace{c b a c b a \ldots c b a}_{3 k \text { letters }} \text { and } \quad X_{2 k+3}=\underbrace{a b c a b c \ldots a b c}_{3 k \text { letters }} a b c b c a c a b \underbrace{c b a c b a \ldots c b a}_{3 k \text { letters }} . $$  We claim that for every $n \geqslant 2$ and every chameleon $Y$, we have $d^{*}\left(X_{n}, Y\right) \leqslant\left\lceil 3 n^{2} / 2\right\rceil$. This will mean that for every $n \geqslant 2$ the number $3 n^{2} / 2$ in the problem statement cannot be changed by any number larger than $\left\lceil 3 n^{2} / 2\right\rceil$.  For any distinct letters $u, v \in\{a, b, c\}$ and any two chameleons $X$ and $Y$, we define $d_{u, v}^{*}(X, Y)$ as the number of $(X, Y)$-inversions $(s, t)$ such that $s$ and $t$ are instances of $u$ and $v$ (in any of the two possible orders). Then $d^{*}(X, Y)=d_{a, b}^{*}(X, Y)+d_{b, c}^{*}(X, Y)+d_{c, a}^{*}(X, Y)$.  We start with the case when $n=2 k$ is even; denote $X=X_{2 k}$. We show that $d_{a, b}^{*}(X, Y) \leqslant 2 k^{2}$ for any chameleon $Y$; this yields the required estimate. Proceed by the induction on $k$ with the trivial base case $k=0$. To perform the induction step, notice that $d_{a, b}^{*}(X, Y)$ is indeed the minimal number of swaps needed to change $Y_{\bar{c}}$ into $X_{\bar{c}}$. One may show that moving $a_{1}$ and $a_{2 k}$ in $Y$ onto the first and the last positions in $Y$, respectively, takes at most $2 k$ swaps, and that subsequent moving $b_{1}$ and $b_{2 k}$ onto the second and the second last positions takes at most $2 k-2$ swaps. After performing that, one may delete these letters from both $X_{\bar{c}}$ and $Y_{\bar{c}}$ and apply the induction hypothesis; so $X_{\bar{c}}$ can be obtained from $Y_{\bar{c}}$ using at most $2(k-1)^{2}+2 k+(2 k-2)=2 k^{2}$ swaps, as required.  If $n=2 k+3$ is odd, the proof is similar but more technically involved. Namely, we claim that $d_{a, b}^{*}\left(X_{2 k+3}, Y\right) \leqslant 2 k^{2}+6 k+5$ for any chameleon $Y$, and that the equality is achieved only if $Y_{\bar{c}}=$ $b b \ldots b a a \ldots a$. The proof proceeds by a similar induction, with some care taken of the base case, as well as of extracting the equality case. Similar estimates hold for $d_{b, c}^{*}$ and $d_{c, a}^{*}$. Summing three such estimates, we obtain  $$ d^{*}\left(X_{2 k+3}, Y\right) \leqslant 3\left(2 k^{2}+6 k+5\right)=\left\lceil\frac{3 n^{2}}{2}\right\rceil+1 $$  which is by 1 more than we need. But the equality could be achieved only if $Y_{\bar{c}}=b b \ldots b a a \ldots a$ and, similarly, $Y_{\bar{b}}=a a \ldots a c c \ldots c$ and $Y_{\bar{a}}=c c \ldots c b b \ldots b$. Since these three equalities cannot hold simultaneously, the proof is finished.


Sir Alex plays the following game on a row of 9 cells. Initially, all cells are empty. In each move, Sir Alex is allowed to perform exactly one of the following two operations: (1) Choose any number of the form $2^{j}$, where $j$ is a non-negative integer, and put it into an empty cell. (2) Choose two (not necessarily adjacent) cells with the same number in them; denote that number by $2^{j}$. Replace the number in one of the cells with $2^{j+1}$ and erase the number in the other cell.  At the end of the game, one cell contains the number $2^{n}$, where $n$ is a given positive integer, while the other cells are empty. Determine the maximum number of moves that Sir Alex could have made, in terms of $n$. (Thailand)

Solution: We will solve a more general problem, replacing the row of 9 cells with a row of $k$ cells, where $k$ is a positive integer. Denote by $m(n, k)$ the maximum possible number of moves Sir Alex can make starting with a row of $k$ empty cells, and ending with one cell containing the number $2^{n}$ and all the other $k-1$ cells empty. Call an operation of type (1) an insertion, and an operation of type (2) a merge.  Only one move is possible when $k=1$, so we have $m(n, 1)=1$. From now on we consider $k \geqslant 2$, and we may assume Sir Alex's last move was a merge. Then, just before the last move, there were exactly two cells with the number $2^{n-1}$, and the other $k-2$ cells were empty.  Paint one of those numbers $2^{n-1}$ blue, and the other one red. Now trace back Sir Alex's moves, always painting the numbers blue or red following this rule: if $a$ and $b$ merge into $c$, paint $a$ and $b$ with the same color as $c$. Notice that in this backward process new numbers are produced only by reversing merges, since reversing an insertion simply means deleting one of the numbers. Therefore, all numbers appearing in the whole process will receive one of the two colors.  Sir Alex's first move is an insertion. Without loss of generality, assume this first number inserted is blue. Then, from this point on, until the last move, there is always at least one cell with a blue number.  Besides the last move, there is no move involving a blue and a red number, since all merges involves numbers with the same color, and insertions involve only one number. Call an insertion of a blue number or merge of two blue numbers a blue move, and define a red move analogously.  The whole sequence of blue moves could be repeated on another row of $k$ cells to produce one cell with the number $2^{n-1}$ and all the others empty, so there are at most $m(n-1, k)$ blue moves.  Now we look at the red moves. Since every time we perform a red move there is at least one cell occupied with a blue number, the whole sequence of red moves could be repeated on a row of $k-1$ cells to produce one cell with the number $2^{n-1}$ and all the others empty, so there are at most $m(n-1, k-1)$ red moves. This proves that  $$ m(n, k) \leqslant m(n-1, k)+m(n-1, k-1)+1 . $$  On the other hand, we can start with an empty row of $k$ cells and perform $m(n-1, k)$ moves to produce one cell with the number $2^{n-1}$ and all the others empty, and after that perform $m(n-1, k-1)$ moves on those $k-1$ empty cells to produce the number $2^{n-1}$ in one of them, leaving $k-2$ empty. With one more merge we get one cell with $2^{n}$ and the others empty, proving that  $$ m(n, k) \geqslant m(n-1, k)+m(n-1, k-1)+1 . $$  It follows that  $$ m(n, k)=m(n-1, k)+m(n-1, k-1)+1, $$  for $n \geqslant 1$ and $k \geqslant 2$. If $k=1$ or $n=0$, we must insert $2^{n}$ on our first move and immediately get the final configuration, so $m(0, k)=1$ and $m(n, 1)=1$, for $n \geqslant 0$ and $k \geqslant 1$. These initial values, together with the recurrence relation (1), determine $m(n, k)$ uniquely.  Finally, we show that  $$ m(n, k)=2 \sum_{j=0}^{k-1}\binom{n}{j}-1 $$  for all integers $n \geqslant 0$ and $k \geqslant 1$. We use induction on $n$. Since $m(0, k)=1$ for $k \geqslant 1,(2)$ is true for the base case. We make the induction hypothesis that (2) is true for some fixed positive integer $n$ and all $k \geqslant 1$. We have $m(n+1,1)=1=2\binom{n+1}{0}-1$, and for $k \geqslant 2$ the recurrence relation (1) and the induction hypothesis give us  $$ \begin{aligned} & m(n+1, k)=m(n, k)+m(n, k-1)+1=2 \sum_{j=0}^{k-1}\binom{n}{j}-1+2 \sum_{j=0}^{k-2}\binom{n}{j}-1+1 \\ & \quad=2 \sum_{j=0}^{k-1}\binom{n}{j}+2 \sum_{j=0}^{k-1}\binom{n}{j-1}-1=2 \sum_{j=0}^{k-1}\left(\binom{n}{j}+\binom{n}{j-1}\right)-1=2 \sum_{j=0}^{k-1}\binom{n+1}{j}-1, \end{aligned} $$  which completes the proof.  Comment 1. After deducing the recurrence relation (1), it may be convenient to homogenize the recurrence relation by defining $h(n, k)=m(n, k)+1$. We get the new relation  $$ h(n, k)=h(n-1, k)+h(n-1, k), $$  for $n \geqslant 1$ and $k \geqslant 2$, with initial values $h(0, k)=h(n, 1)=2$, for $n \geqslant 0$ and $k \geqslant 1$. This may help one to guess the answer, and also with other approaches like the one we develop next.  Comment 2. We can use a generating function to find the answer without guessing. We work with the homogenized recurrence relation (3). Define $h(n, 0)=0$ so that (3) is valid for $k=1$ as well. Now we set up the generating function $f(x, y)=\sum_{n, k \geqslant 0} h(n, k) x^{n} y^{k}$. Multiplying the recurrence relation (3) by $x^{n} y^{k}$ and summing over $n, k \geqslant 1$, we get  $$ \sum_{n, k \geqslant 1} h(n, k) x^{n} y^{k}=x \sum_{n, k \geqslant 1} h(n-1, k) x^{n-1} y^{k}+x y \sum_{n, k \geqslant 1} h(n-1, k-1) x^{n-1} y^{k-1} . $$  Completing the missing terms leads to the following equation on $f(x, y)$ :  $$ f(x, y)-\sum_{n \geqslant 0} h(n, 0) x^{n}-\sum_{k \geqslant 1} h(0, k) y^{k}=x f(x, y)-x \sum_{n \geqslant 0} h(n, 0) x^{n}+x y f(x, y) . $$  Substituting the initial values, we obtain  $$ f(x, y)=\frac{2 y}{1-y} \cdot \frac{1}{1-x(1+y)} . $$  Developing as a power series, we get  $$ f(x, y)=2 \sum_{j \geqslant 1} y^{j} \cdot \sum_{n \geqslant 0}(1+y)^{n} x^{n} . $$  The coefficient of $x^{n}$ in this power series is  $$ 2 \sum_{j \geqslant 1} y^{j} \cdot(1+y)^{n}=2 \sum_{j \geqslant 1} y^{j} \cdot \sum_{i \geqslant 0}\binom{n}{i} y^{i} $$  and extracting the coefficient of $y^{k}$ in this last expression we finally obtain the value for $h(n, k)$,  $$ h(n, k)=2 \sum_{j=0}^{k-1}\binom{n}{j} $$  This proves that  $$ m(n, k)=2 \sum_{j=0}^{k-1}\binom{n}{j}-1 $$  The generating function approach also works if applied to the non-homogeneous recurrence relation (1), but the computations are less straightforward.


Solution: Define merges and insertions as in   We will need the following lemma. Lemma. If the binary representation of a positive integer $A$ has $d$ nonzero digits, then $A$ cannot be represented as a sum of fewer than $d$ powers of 2 . Moreover, any representation of $A$ as a sum of $d$ powers of 2 must coincide with its binary representation. Proof. Let $s$ be the minimum number of summands in all possible representations of $A$ as sum of powers of 2 . Suppose there is such a representation with $s$ summands, where two of the summands are equal to each other. Then, replacing those two summands with the result of their sum, we obtain a representation with fewer than $s$ summands, which is a contradiction. We deduce that in any representation with $s$ summands, the summands are all distinct, so any such representation must coincide with the unique binary representation of $A$, and $s=d$.  Now we split the solution into a sequence of claims. Claim 1. After every move, the number $S$ is the sum of at most $k-1$ distinct powers of 2 . Proof. If $S$ is the sum of $k$ (or more) distinct powers of 2 , the Lemma implies that the $k$ cells are filled with these numbers. This is a contradiction since no more merges or insertions can be made.  Let $A(n, k-1)$ denote the set of all positive integers not exceeding $2^{n}$ with at most $k-1$ nonzero digits in its base 2 representation. Since every insertion increases the value of $S$, by Claim 1, the total number of insertions is at most $|A(n, k-1)|$. We proceed to prove that it is possible to achieve this number of insertions. Claim 2. Let $A(n, k-1)=\left\{a_{1}, a_{2}, \ldots, a_{m}\right\}$, with $a_{1}<a_{2}<\cdots<a_{m}$. If after some of Sir Alex's moves the value of $S$ is $a_{j}$, with $j \in\{1,2, \ldots, m-1\}$, then there is a sequence of moves after which the value of $S$ is exactly $a_{j+1}$. Proof. Suppose $S=a_{j}$. Performing all possible merges, we eventually get different powers of 2 in all nonempty cells. After that, by Claim 1 there will be at least one empty cell, in which we want to insert $a_{j+1}-a_{j}$. It remains to show that $a_{j+1}-a_{j}$ is a power of 2 .  For this purpose, we notice that if $a_{j}$ has less than $k-1$ nonzero digits in base 2 then $a_{j+1}=a_{j}+1$. Otherwise, we have $a_{j}=2^{b_{k-1}}+\cdots+2^{b_{2}}+2^{b_{1}}$ with $b_{1}<b_{2}<\cdots<b_{k-1}$. Then, adding any number less than $2^{b_{1}}$ to $a_{j}$ will result in a number with more than $k-1$ nonzero binary digits. On the other hand, $a_{j}+2^{b_{1}}$ is a sum of $k$ powers of 2 , not all distinct, so by the Lemma it will be a sum of less then $k$ distinct powers of 2 . This means that $a_{j+1}-a_{j}=2^{b_{1}}$, completing the proof.  Claims 1 and 2 prove that the maximum number of insertions is $|A(n, k-1)|$. We now compute this number. Claim 3. $|A(n, k-1)|=\sum_{j=0}^{k-1}\binom{n}{j}$. Proof. The number $2^{n}$ is the only element of $A(n, k-1)$ with $n+1$ binary digits. Any other element has at most $n$ binary digits, at least one and at most $k-1$ of them are nonzero (so they are ones). For each $j \in\{1,2, \ldots, k-1\}$, there are $\binom{n}{j}$ such elements with exactly $j$ binary digits equal to one. We conclude that $|A(n, k-1)|=1+\sum_{j=1}^{k-1}\binom{n}{j}=\sum_{j=0}^{k-1}\binom{n}{j}$.  Recalling that the number of insertions exceeds that of merges by exactly 1 , we deduce that the maximum number of moves is $2 \sum_{j=0}^{k-1}\binom{n}{j}-1$.


Let $N \geqslant 2$ be an integer. $N(N+1)$ soccer players, no two of the same height, stand in a row in some order. Coach Ralph wants to remove $N(N-1)$ people from this row so that in the remaining row of $2 N$ players, no one stands between the two tallest ones, no one stands between the third and the fourth tallest ones, ..., and finally no one stands between the two shortest ones. Show that this is always possible. (Russia)

Solution: Split the row into $N$ blocks with $N+1$ consecutive people each. We will show how to remove $N-1$ people from each block in order to satisfy the coach's wish.  First, construct a $(N+1) \times N$ matrix where $x_{i, j}$ is the height of the $i^{\text {th }}$ tallest person of the $j^{\text {th }}$ block-in other words, each column lists the heights within a single block, sorted in decreasing order from top to bottom.  We will reorder this matrix by repeatedly swapping whole columns. First, by column permutation, make sure that $x_{2,1}=\max \left\{x_{2, i}: i=1,2, \ldots, N\right\}$ (the first column contains the largest height of the second row). With the first column fixed, permute the other ones so that $x_{3,2}=\max \left\{x_{3, i}: i=2, \ldots, N\right\}$ (the second column contains the tallest person of the third row, first column excluded). In short, at step $k(k=1,2, \ldots, N-1)$, we permute the columns from $k$ to $N$ so that $x_{k+1, k}=\max \left\{x_{i, k}: i=k, k+1, \ldots, N\right\}$, and end up with an array like this:  | $\boldsymbol{x}_{\mathbf{1 , 1}}$ | $x_{1,2}$ | $x_{1,3}$ | $\cdots$ | $x_{1, N-1}$ | $x_{1, N}$ | | :---: | :---: | :---: | :---: | :---: | :---: | | $\vee$ | $\vee$ | $\vee$ |  | $\vee$ | $\vee$ | | $\boldsymbol{x}_{\mathbf{2 , 1}}$ | $\boldsymbol{x}_{\mathbf{2 , 2}}$ | $x_{2,3}$ | $\cdots$ | $x_{2, N-1}$ | $x_{2, N}$ | | $\vee$ | $\vee$ | $\vee$ |  | $\vee$ | $\vee$ | | $x_{3,1}$ | $\boldsymbol{x}_{\mathbf{3 , 2}}$ | $\boldsymbol{x}_{\mathbf{3 , 3}}$ | $\cdots$ | $x_{3, N-1}$ | $x_{3, N}$ | | $\vee$ | $\vee$ | $\vee$ |  | $\vee$ | $\vee$ | | $\vdots$ | $\vdots$ | $\vdots$ | $\ddots$ | $\vdots$ | $\vdots$ | | $\vee$ | $\vee$ | $\vee$ |  | $\vee$ | $\vee$ | | $x_{N, 1}$ | $x_{N, 2}$ | $x_{N, 3}$ | $\cdots$ | $\boldsymbol{x}_{\boldsymbol{N}, \boldsymbol{N}-\mathbf{1}}>$ | $\boldsymbol{x}_{\boldsymbol{N}, \boldsymbol{N}}$ | | $\vee$ | $\vee$ | $\vee$ |  | $\vee$ | $\vee$ | | $x_{N+1,1}$ | $x_{N+1,2}$ | $x_{N+1,3}$ | $\cdots$ | $x_{N+1, N-1}$ | $\boldsymbol{x}_{\boldsymbol{N + 1 , N}}$ |  Now we make the bold choice: from the original row of people, remove everyone but those with heights  $$ x_{1,1}>x_{2,1}>x_{2,2}>x_{3,2}>\cdots>x_{N, N-1}>x_{N, N}>x_{N+1, N} $$  Of course this height order (*) is not necessarily their spatial order in the new row. We now need to convince ourselves that each pair $\left(x_{k, k} ; x_{k+1, k}\right)$ remains spatially together in this new row. But $x_{k, k}$ and $x_{k+1, k}$ belong to the same column/block of consecutive $N+1$ people; the only people that could possibly stand between them were also in this block, and they are all gone.


Solution: Split the people into $N$ groups by height: group $G_{1}$ has the $N+1$ tallest ones, group $G_{2}$ has the next $N+1$ tallest, and so on, up to group $G_{N}$ with the $N+1$ shortest people.  Now scan the original row from left to right, stopping as soon as you have scanned two people (consecutively or not) from the same group, say, $G_{i}$. Since we have $N$ groups, this must happen before or at the $(N+1)^{\text {th }}$ person of the row. Choose this pair of people, removing all the other people from the same group $G_{i}$ and also all people that have been scanned so far. The only people that could separate this pair's heights were in group $G_{i}$ (and they are gone); the only people that could separate this pair's positions were already scanned (and they are gone too).  We are now left with $N-1$ groups (all except $G_{i}$ ). Since each of them lost at most one person, each one has at least $N$ unscanned people left in the row. Repeat the scanning process from left to right, choosing the next two people from the same group, removing this group and everyone scanned up to that point. Once again we end up with two people who are next to each other in the remaining row and whose heights cannot be separated by anyone else who remains (since the rest of their group is gone). After picking these 2 pairs, we still have $N-2$ groups with at least $N-1$ people each.  If we repeat the scanning process a total of $N$ times, it is easy to check that we will end up with 2 people from each group, for a total of $2 N$ people remaining. The height order is guaranteed by the grouping, and the scanning construction from left to right guarantees that each pair from a group stand next to each other in the final row. We are done.


Solution: This is essentially the same as solution 1, but presented inductively. The essence of the argument is the following lemma. Lemma. Assume that we have $N$ disjoint groups of at least $N+1$ people in each, all people have distinct heights. Then one can choose two people from each group so that among the chosen people, the two tallest ones are in one group, the third and the fourth tallest ones are in one group, ..., and the two shortest ones are in one group. Proof. Induction on $N \geqslant 1$; for $N=1$, the statement is trivial. Consider now $N$ groups $G_{1}, \ldots, G_{N}$ with at least $N+1$ people in each for $N \geqslant 2$. Enumerate the people by $1,2, \ldots, N(N+1)$ according to their height, say, from tallest to shortest. Find the least $s$ such that two people among $1,2, \ldots, s$ are in one group (without loss of generality, say this group is $G_{N}$ ). By the minimality of $s$, the two mentioned people in $G_{N}$ are $s$ and some $i<s$.  Now we choose people $i$ and $s$ in $G_{N}$, forget about this group, and remove the people $1,2, \ldots, s$ from $G_{1}, \ldots, G_{N-1}$. Due to minimality of $s$ again, each of the obtained groups $G_{1}^{\prime}, \ldots, G_{N-1}^{\prime}$ contains at least $N$ people. By the induction hypothesis, one can choose a pair of people from each of $G_{1}^{\prime}, \ldots, G_{N-1}^{\prime}$ so as to satisfy the required conditions. Since all these people have numbers greater than $s$, addition of the pair $(s, i)$ from $G_{N}$ does not violate these requirements.  To solve the problem, it suffices now to split the row into $N$ contiguous groups with $N+1$ people in each and apply the Lemma to those groups.  Comment 1. One can identify each person with a pair of indices $(p, h)(p, h \in\{1,2, \ldots, N(N+1)\})$ so that the $p^{\text {th }}$ person in the row (say, from left to right) is the $h^{\text {th }}$ tallest person in the group. Say that $(a, b)$ separates $\left(x_{1}, y_{1}\right)$ and $\left(x_{2}, y_{2}\right)$ whenever $a$ is strictly between $x_{1}$ and $y_{1}$, or $b$ is strictly between $x_{2}$ and $y_{2}$. So the coach wants to pick $2 N$ people $\left(p_{i}, h_{i}\right)(i=1,2, \ldots, 2 N)$ such that no chosen person separates ( $p_{1}, h_{1}$ ) from ( $p_{2}, h_{2}$ ), no chosen person separates ( $p_{3}, h_{3}$ ) and ( $p_{4}, h_{4}$ ), and so on. This formulation reveals a duality between positions and heights. In that sense, solutions 1 and 2 are dual of each other.  Comment 2. The number $N(N+1)$ is sharp for $N=2$ and $N=3$, due to arrangements $1,5,3,4,2$ and $1,10,6,4,3,9,5,8,7,2,11$.


A hunter and an invisible rabbit play a game in the Euclidean plane. The hunter's starting point $H_{0}$ coincides with the rabbit's starting point $R_{0}$. In the $n^{\text {th }}$ round of the game $(n \geqslant 1)$, the following happens. (1) First the invisible rabbit moves secretly and unobserved from its current point $R_{n-1}$ to some new point $R_{n}$ with $R_{n-1} R_{n}=1$. (2) The hunter has a tracking device (e.g. dog) that returns an approximate position $R_{n}^{\prime}$ of the rabbit, so that $R_{n} R_{n}^{\prime} \leqslant 1$. (3) The hunter then visibly moves from point $H_{n-1}$ to a new point $H_{n}$ with $H_{n-1} H_{n}=1$.  Is there a strategy for the hunter that guarantees that after $10^{9}$ such rounds the distance between the hunter and the rabbit is below 100 ?

Solution: If the answer were "yes", the hunter would have a strategy that would "work", no matter how the rabbit moved or where the radar pings $R_{n}^{\prime}$ appeared. We will show the opposite: with bad luck from the radar pings, there is no strategy for the hunter that guarantees that the distance stays below 100 in $10^{9}$ rounds.  So, let $d_{n}$ be the distance between the hunter and the rabbit after $n$ rounds. Of course, if $d_{n} \geqslant 100$ for any $n<10^{9}$, the rabbit has won - it just needs to move straight away from the hunter, and the distance will be kept at or above 100 thereon.  We will now show that, while $d_{n}<100$, whatever given strategy the hunter follows, the rabbit has a way of increasing $d_{n}^{2}$ by at least $\frac{1}{2}$ every 200 rounds (as long as the radar pings are lucky enough for the rabbit). This way, $d_{n}^{2}$ will reach $10^{4}$ in less than $2 \cdot 10^{4} \cdot 200=4 \cdot 10^{6}<10^{9}$ rounds, and the rabbit wins.  Suppose the hunter is at $H_{n}$ and the rabbit is at $R_{n}$. Suppose even that the rabbit reveals its position at this moment to the hunter (this allows us to ignore all information from previous radar pings). Let $r$ be the line $H_{n} R_{n}$, and $Y_{1}$ and $Y_{2}$ be points which are 1 unit away from $r$ and 200 units away from $R_{n}$, as in the figure below. ![](https://cdn.mathpix.com/cropped/2024_11_18_ff08e3c077fa2f8c16b2g-46.jpg?height=446&width=1140&top_left_y=1636&top_left_x=464)  The rabbit's plan is simply to choose one of the points $Y_{1}$ or $Y_{2}$ and hop 200 rounds straight towards it. Since all hops stay within 1 distance unit from $r$, it is possible that all radar pings stay on $r$. In particular, in this case, the hunter has no way of knowing whether the rabbit chose $Y_{1}$ or $Y_{2}$.  Looking at such pings, what is the hunter going to do? If the hunter's strategy tells him to go 200 rounds straight to the right, he ends up at point $H^{\prime}$ in the figure. Note that the hunter does not have a better alternative! Indeed, after these 200 rounds he will always end up at a point to the left of $H^{\prime}$. If his strategy took him to a point above $r$, he would end up even further from $Y_{2}$; and if his strategy took him below $r$, he would end up even further from $Y_{1}$. In other words, no matter what strategy the hunter follows, he can never be sure his distance to the rabbit will be less than $y \xlongequal{\text { def }} H^{\prime} Y_{1}=H^{\prime} Y_{2}$ after these 200 rounds.  To estimate $y^{2}$, we take $Z$ as the midpoint of segment $Y_{1} Y_{2}$, we take $R^{\prime}$ as a point 200 units to the right of $R_{n}$ and we define $\varepsilon=Z R^{\prime}$ (note that $H^{\prime} R^{\prime}=d_{n}$ ). Then  $$ y^{2}=1+\left(H^{\prime} Z\right)^{2}=1+\left(d_{n}-\varepsilon\right)^{2} $$  where  $$ \varepsilon=200-R_{n} Z=200-\sqrt{200^{2}-1}=\frac{1}{200+\sqrt{200^{2}-1}}>\frac{1}{400} $$  In particular, $\varepsilon^{2}+1=400 \varepsilon$, so  $$ y^{2}=d_{n}^{2}-2 \varepsilon d_{n}+\varepsilon^{2}+1=d_{n}^{2}+\varepsilon\left(400-2 d_{n}\right) $$  Since $\varepsilon>\frac{1}{400}$ and we assumed $d_{n}<100$, this shows that $y^{2}>d_{n}^{2}+\frac{1}{2}$. So, as we claimed, with this list of radar pings, no matter what the hunter does, the rabbit might achieve $d_{n+200}^{2}>d_{n}^{2}+\frac{1}{2}$. The wabbit wins.  Comment 1. Many different versions of the solution above can be found by replacing 200 with some other number $N$ for the number of hops the rabbit takes between reveals. If this is done, we have:  $$ \varepsilon=N-\sqrt{N^{2}-1}>\frac{1}{N+\sqrt{N^{2}-1}}>\frac{1}{2 N} $$  and  $$ \varepsilon^{2}+1=2 N \varepsilon $$  so, as long as $N>d_{n}$, we would find  $$ y^{2}=d_{n}^{2}+\varepsilon\left(2 N-2 d_{n}\right)>d_{n}^{2}+\frac{N-d_{n}}{N} $$  For example, taking $N=101$ is already enough-the squared distance increases by at least $\frac{1}{101}$ every 101 rounds, and $101^{2} \cdot 10^{4}=1.0201 \cdot 10^{8}<10^{9}$ rounds are enough for the rabbit. If the statement is made sharper, some such versions might not work any longer.  Comment 2. The original statement asked whether the distance could be kept under $10^{10}$ in $10^{100}$ rounds.


Let $n>1$ be an integer. An $n \times n \times n$ cube is composed of $n^{3}$ unit cubes. Each unit cube is painted with one color. For each $n \times n \times 1$ box consisting of $n^{2}$ unit cubes (of any of the three possible orientations), we consider the set of the colors present in that box (each color is listed only once). This way, we get $3 n$ sets of colors, split into three groups according to the orientation. It happens that for every set in any group, the same set appears in both of the other groups. Determine, in terms of $n$, the maximal possible number of colors that are present. (Russia)

Solution: Call a $n \times n \times 1$ box an $x$-box, a $y$-box, or a $z$-box, according to the direction of its short side. Let $C$ be the number of colors in a valid configuration. We start with the upper bound for $C$.  Let $\mathcal{C}_{1}, \mathcal{C}_{2}$, and $\mathcal{C}_{3}$ be the sets of colors which appear in the big cube exactly once, exactly twice, and at least thrice, respectively. Let $M_{i}$ be the set of unit cubes whose colors are in $\mathcal{C}_{i}$, and denote $n_{i}=\left|M_{i}\right|$.  Consider any $x$-box $X$, and let $Y$ and $Z$ be a $y$ - and a $z$-box containing the same set of colors as $X$ does. Claim. $4\left|X \cap M_{1}\right|+\left|X \cap M_{2}\right| \leqslant 3 n+1$. Proof. We distinguish two cases. Case 1: $X \cap M_{1} \neq \varnothing$. A cube from $X \cap M_{1}$ should appear in all three boxes $X, Y$, and $Z$, so it should lie in $X \cap Y \cap Z$. Thus $X \cap M_{1}=X \cap Y \cap Z$ and $\left|X \cap M_{1}\right|=1$.  Consider now the cubes in $X \cap M_{2}$. There are at most $2(n-1)$ of them lying in $X \cap Y$ or $X \cap Z$ (because the cube from $X \cap Y \cap Z$ is in $M_{1}$ ). Let $a$ be some other cube from $X \cap M_{2}$. Recall that there is just one other cube $a^{\prime}$ sharing a color with $a$. But both $Y$ and $Z$ should contain such cube, so $a^{\prime} \in Y \cap Z$ (but $a^{\prime} \notin X \cap Y \cap Z$ ). The map $a \mapsto a^{\prime}$ is clearly injective, so the number of cubes $a$ we are interested in does not exceed $|(Y \cap Z) \backslash X|=n-1$. Thus $\left|X \cap M_{2}\right| \leqslant 2(n-1)+(n-1)=3(n-1)$, and hence $4\left|X \cap M_{1}\right|+\left|X \cap M_{2}\right| \leqslant 4+3(n-1)=3 n+1$. Case 2: $X \cap M_{1}=\varnothing$.  In this case, the same argument applies with several changes. Indeed, $X \cap M_{2}$ contains at most $2 n-1$ cubes from $X \cap Y$ or $X \cap Z$. Any other cube $a$ in $X \cap M_{2}$ corresponds to some $a^{\prime} \in Y \cap Z$ (possibly with $a^{\prime} \in X$ ), so there are at most $n$ of them. All this results in $\left|X \cap M_{2}\right| \leqslant(2 n-1)+n=3 n-1$, which is even better than we need (by the assumptions of our case).  Summing up the inequalities from the Claim over all $x$-boxes $X$, we obtain  $$ 4 n_{1}+n_{2} \leqslant n(3 n+1) $$  Obviously, we also have $n_{1}+n_{2}+n_{3}=n^{3}$. Now we are prepared to estimate $C$. Due to the definition of the $M_{i}$, we have $n_{i} \geqslant i\left|\mathcal{C}_{i}\right|$, so  $$ C \leqslant n_{1}+\frac{n_{2}}{2}+\frac{n_{3}}{3}=\frac{n_{1}+n_{2}+n_{3}}{3}+\frac{4 n_{1}+n_{2}}{6} \leqslant \frac{n^{3}}{3}+\frac{3 n^{2}+n}{6}=\frac{n(n+1)(2 n+1)}{6} $$  It remains to present an example of an appropriate coloring in the above-mentioned number of colors. For each color, we present the set of all cubes of this color. These sets are:  1. $n$ singletons of the form $S_{i}=\{(i, i, i)\}$ (with $1 \leqslant i \leqslant n$ ); 2. $3\binom{n}{2}$ doubletons of the forms $D_{i, j}^{1}=\{(i, j, j),(j, i, i)\}, D_{i, j}^{2}=\{(j, i, j),(i, j, i)\}$, and $D_{i, j}^{3}=$ $\{(j, j, i),(i, i, j)\}$ (with $1 \leqslant i<j \leqslant n)$; 3. $2\binom{n}{3}$ triplets of the form $T_{i, j, k}=\{(i, j, k),(j, k, i),(k, i, j)\}$ (with $1 \leqslant i<j<k \leqslant n$ or $1 \leqslant i<k<j \leqslant n)$.  One may easily see that the $i^{\text {th }}$ boxes of each orientation contain the same set of colors, and that  $$ n+\frac{3 n(n-1)}{2}+\frac{n(n-1)(n-2)}{3}=\frac{n(n+1)(2 n+1)}{6} $$  colors are used, as required.


Solution: We will approach a new version of the original problem. In this new version, each cube may have a color, or be invisible (not both). Now we make sets of colors for each $n \times n \times 1$ box as before (where "invisible" is not considered a color) and group them by orientation, also as before. Finally, we require that, for every non-empty set in any group, the same set must appear in the other 2 groups. What is the maximum number of colors present with these new requirements?  Let us call strange a big $n \times n \times n$ cube whose painting scheme satisfies the new requirements, and let $D$ be the number of colors in a strange cube. Note that any cube that satisfies the original requirements is also strange, so $\max (D)$ is an upper bound for the original answer. Claim. $D \leqslant \frac{n(n+1)(2 n+1)}{6}$. Proof. The proof is by induction on $n$. If $n=1$, we must paint the cube with at most 1 color. Now, pick a $n \times n \times n$ strange cube $A$, where $n \geqslant 2$. If $A$ is completely invisible, $D=0$ and we are done. Otherwise, pick a non-empty set of colors $\mathcal{S}$ which corresponds to, say, the boxes $X, Y$ and $Z$ of different orientations.  Now find all cubes in $A$ whose colors are in $\mathcal{S}$ and make them invisible. Since $X, Y$ and $Z$ are now completely invisible, we can throw them away and focus on the remaining $(n-1) \times(n-1) \times(n-1)$ cube $B$. The sets of colors in all the groups for $B$ are the same as the sets for $A$, removing exactly the colors in $\mathcal{S}$, and no others! Therefore, every nonempty set that appears in one group for $B$ still shows up in all possible orientations (it is possible that an empty set of colors in $B$ only matched $X, Y$ or $Z$ before these were thrown away, but remember we do not require empty sets to match anyway). In summary, $B$ is also strange.  By the induction hypothesis, we may assume that $B$ has at most $\frac{(n-1) n(2 n-1)}{6}$ colors. Since there were at most $n^{2}$ different colors in $\mathcal{S}$, we have that $A$ has at most $\frac{(n-1) n(2 n-1)}{6}+n^{2}=$ $\frac{n(n+1)(2 n+1)}{6}$ colors.  Finally, the construction in the previous solution shows a painting scheme (with no invisible cubes) that reaches this maximum, so we are done.


For any finite sets $X$ and $Y$ of positive integers, denote by $f_{X}(k)$ the $k^{\text {th }}$ smallest positive integer not in $X$, and let  $$ X * Y=X \cup\left\{f_{X}(y): y \in Y\right\} $$  Let $A$ be a set of $a>0$ positive integers, and let $B$ be a set of $b>0$ positive integers. Prove that if $A * B=B * A$, then  $$ \underbrace{A *(A * \cdots *(A *(A * A)) \ldots)}_{A \text { appears } b \text { times }}=\underbrace{B *(B * \cdots *(B *(B * B)) \ldots)}_{B \text { appears } a \text { times }} . $$

Solution: For any function $g: \mathbb{Z}_{>0} \rightarrow \mathbb{Z}_{>0}$ and any subset $X \subset \mathbb{Z}_{>0}$, we define $g(X)=$ $\{g(x): x \in X\}$. We have that the image of $f_{X}$ is $f_{X}\left(\mathbb{Z}_{>0}\right)=\mathbb{Z}_{>0} \backslash X$. We now show a general lemma about the operation *, with the goal of showing that $*$ is associative. Lemma 1. Let $X$ and $Y$ be finite sets of positive integers. The functions $f_{X * Y}$ and $f_{X} \circ f_{Y}$ are equal. Proof. We have $f_{X * Y}\left(\mathbb{Z}_{>0}\right)=\mathbb{Z}_{>0} \backslash(X * Y)=\left(\mathbb{Z}_{>0} \backslash X\right) \backslash f_{X}(Y)=f_{X}\left(\mathbb{Z}_{>0}\right) \backslash f_{X}(Y)=f_{X}\left(\mathbb{Z}_{>0} \backslash Y\right)=f_{X}\left(f_{Y}\left(\mathbb{Z}_{>0}\right)\right)$. Thus, the functions $f_{X * Y}$ and $f_{X} \circ f_{Y}$ are strictly increasing functions with the same range. Because a strictly function is uniquely defined by its range, we have $f_{X * Y}=f_{X} \circ f_{Y}$.  Lemma 1 implies that * is associative, in the sense that $(A * B) * C=A *(B * C)$ for any finite sets $A, B$, and $C$ of positive integers. We prove the associativity by noting  $$ \begin{gathered} \mathbb{Z}_{>0} \backslash((A * B) * C)=f_{(A * B) * C}\left(\mathbb{Z}_{>0}\right)=f_{A * B}\left(f_{C}\left(\mathbb{Z}_{>0}\right)\right)=f_{A}\left(f_{B}\left(f_{C}\left(\mathbb{Z}_{>0}\right)\right)\right) \\ =f_{A}\left(f_{B * C}\left(\mathbb{Z}_{>0}\right)=f_{A *(B * C)}\left(\mathbb{Z}_{>0}\right)=\mathbb{Z}_{>0} \backslash(A *(B * C))\right. \end{gathered} $$  In light of the associativity of *, we may drop the parentheses when we write expressions like $A *(B * C)$. We also introduce the notation  $$ X^{* k}=\underbrace{X *(X * \cdots *(X *(X * X)) \ldots)}_{X \text { appears } k \text { times }} $$  Our goal is then to show that $A * B=B * A$ implies $A^{* b}=B^{* a}$. We will do so via the following general lemma. Lemma 2. Suppose that $X$ and $Y$ are finite sets of positive integers satisfying $X * Y=Y * X$ and $|X|=|Y|$. Then, we must have $X=Y$. Proof. Assume that $X$ and $Y$ are not equal. Let $s$ be the largest number in exactly one of $X$ and $Y$. Without loss of generality, say that $s \in X \backslash Y$. The number $f_{X}(s)$ counts the $s^{t h}$ number not in $X$, which implies that  $$ f_{X}(s)=s+\left|X \cap\left\{1,2, \ldots, f_{X}(s)\right\}\right| $$  Since $f_{X}(s) \geqslant s$, we have that  $$ \left\{f_{X}(s)+1, f_{X}(s)+2, \ldots\right\} \cap X=\left\{f_{X}(s)+1, f_{X}(s)+2, \ldots\right\} \cap Y $$  which, together with the assumption that $|X|=|Y|$, gives  $$ \left|X \cap\left\{1,2, \ldots, f_{X}(s)\right\}\right|=\left|Y \cap\left\{1,2, \ldots, f_{X}(s)\right\}\right| $$  Now consider the equation  $$ t-|Y \cap\{1,2, \ldots, t\}|=s $$  This equation is satisfied only when $t \in\left[f_{Y}(s), f_{Y}(s+1)\right)$, because the left hand side counts the number of elements up to $t$ that are not in $Y$. We have that the value $t=f_{X}(s)$ satisfies the above equation because of (1) and (2). Furthermore, since $f_{X}(s) \notin X$ and $f_{X}(s) \geqslant s$, we have that $f_{X}(s) \notin Y$ due to the maximality of $s$. Thus, by the above discussion, we must have $f_{X}(s)=f_{Y}(s)$.  Finally, we arrive at a contradiction. The value $f_{X}(s)$ is neither in $X$ nor in $f_{X}(Y)$, because $s$ is not in $Y$ by assumption. Thus, $f_{X}(s) \notin X * Y$. However, since $s \in X$, we have $f_{Y}(s) \in Y * X$, a contradiction.  We are now ready to finish the proof. Note first of all that $\left|A^{* b}\right|=a b=\left|B^{* a}\right|$. Moreover, since $A * B=B * A$, and $*$ is associative, it follows that $A^{* b} * B^{* a}=B^{* a} * A^{* b}$. Thus, by Lemma 2, we have $A^{* b}=B^{* a}$, as desired.  Comment 1. Taking $A=X^{* k}$ and $B=X^{* l}$ generates many non-trivial examples where $A * B=B * A$. There are also other examples not of this form. For example, if $A=\{1,2,4\}$ and $B=\{1,3\}$, then $A * B=\{1,2,3,4,6\}=B * A$.