di-zhang-fdu/OlympiadExtended huggingface dataset:
Subfield: Number Theory


Question: For $x \in(0,1)$ let $y \in(0,1)$ be the number whose $n$th digit after the decimal point is the $\left(2^{n}\right)$ th digit after the decimal point of $x$. Show that if $x$ is rational then so is $y$.

Solution:
Since $x$ is rational, its digits repeat periodically starting at some point. We wish to show that this is also true for the digits of $y$, implying that $y$ is rational.

Let $d$ be the length of the period of $x$ and let $d=2^{u} \cdot v$, where $v$ is odd. There is a positive integer $w$ such that

$$
2^{w} \equiv 1 \quad(\bmod v)
$$

(For instance, one can choose $w$ to be $\varphi(v)$, the value of Euler's function at $v$.) Therefore

$$
2^{n+w}=2^{n} \cdot 2^{w} \equiv 2^{n} \quad(\bmod v)
$$

for each $n$. Also, for $n \geq u$ we have

$$
2^{n+w} \equiv 2^{n} \equiv 0 \quad\left(\bmod 2^{u}\right) .
$$

It follows that, for all $n \geq u$, the relation

$$
2^{n+w} \equiv 2^{n} \quad(\bmod d)
$$

holds. Thus, for $n$ sufficiently large, the $2^{n+w}$ th digit of $x$ is in the same spot in the cycle of $x$ as its $2^{n}$ th digit, and so these digits are equal. Hence the $(n+w)$ th digit of $y$ is equal to its $n$th digit. This means that the digits of $y$ repeat periodically with period $w$ from some point on, as required.
Subfield: Number Theory


Question: The sequence $f(1), f(2), f(3), \ldots$ is defined by

$$
f(n)=\frac{1}{n}\left(\left\lfloor\frac{n}{1}\right\rfloor+\left\lfloor\frac{n}{2}\right\rfloor+\cdots+\left\lfloor\frac{n}{n}\right\rfloor\right)
$$

where $\lfloor x\rfloor$ denotes the integer part of $x$.

(a) Prove that $f(n+1)>f(n)$ infinitely often.
(b) Prove that $f(n+1)<f(n)$ infinitely often.

Solution:
Let $g(n)=n f(n)$ for $n \geq 1$ and $g(0)=0$. We note that, for $k=1, \ldots, n$,

$$
\left\lfloor\frac{n}{k}\right\rfloor-\left\lfloor\frac{n-1}{k}\right\rfloor=0
$$

if $k$ is not a divisor of $n$ and

$$
\left\lfloor\frac{n}{k}\right\rfloor-\left\lfloor\frac{n-1}{k}\right\rfloor=1
$$

if $k$ divides $n$. It therefore follows that if $d(n)$ is the number of positive divisors of $n \geq 1$ then

$$
\begin{aligned}
g(n) & =\left\lfloor\frac{n}{1}\right\rfloor+\left\lfloor\frac{n}{2}\right\rfloor+\cdots+\left\lfloor\frac{n}{n-1}\right\rfloor+\left\lfloor\frac{n}{n}\right\rfloor \\
& =\left\lfloor\frac{n-1}{1}\right\rfloor+\left\lfloor\frac{n-1}{2}\right\rfloor+\cdots+\left\lfloor\frac{n-1}{n-1}\right\rfloor+\left\lfloor\frac{n-1}{n}\right\rfloor+d(n) \\
& =g(n-1)+d(n) .
\end{aligned}
$$

Hence

$$
g(n)=g(n-1)+d(n)=g(n-2)+d(n-1)+d(n)=\cdots=d(1)+d(2)+\cdots+d(n),
$$

meaning that

$$
f(n)=\frac{d(1)+d(2)+\cdots+d(n)}{n}
$$

In other words, $f(n)$ is equal to the arithmetic mean of $d(1), d(2), \ldots, d(n)$. In order to prove the claims, it is therefore sufficient to show that $d(n+1)>f(n)$ and $d(n+1)<f(n)$ both hold infinitely often.

We note that $d(1)=1$. For $n>1, d(n) \geq 2$ holds, with equality if and only if $n$ is prime. Since $f(6)=7 / 3>2$, it follows that $f(n)>2$ holds for all $n \geq 6$.

Since there are infinitely many primes, $d(n+1)=2$ holds for infinitely many values of $n$, and for each such $n \geq 6$ we have $d(n+1)=2<f(n)$. This proves claim (b).

To prove (a), notice that the sequence $d(1), d(2), d(3), \ldots$ is unbounded (e. g. $d\left(2^{k}\right)=k+1$ for all $k$ ). Hence $d(n+1)>\max \{d(1), d(2), \ldots, d(n)\}$ for infinitely many $n$. For all such $n$, we have $d(n+1)>f(n)$. This completes the solution.
Subfield: Number Theory


Question: Let $P$ be a polynomial of degree $n>1$ with integer coefficients and let $k$ be any positive integer. Consider the polynomial $Q(x)=P(P(\ldots P(P(x)) \ldots))$, with $k$ pairs of parentheses. Prove that $Q$ has no more than $n$ integer fixed points, i.e. integers satisfying the equation $Q(x)=x$.

Solution:
The claim is obvious if every integer fixed point of $Q$ is a fixed point of $P$ itself. For the sequel assume that this is not the case. Take any integer $x_{0}$ such that $Q\left(x_{0}\right)=x_{0}$, $P\left(x_{0}\right) \neq x_{0}$ and define inductively $x_{i+1}=P\left(x_{i}\right)$ for $i=0,1,2, \ldots ;$ then $x_{k}=x_{0}$.

It is evident that

$$
P(u)-P(v) \text { is divisible by } u-v \text { for distinct integers } u, v \text {. }\tag{1}
$$

(Indeed, if $P(x)=\sum a_{i} x^{i}$ then each $a_{i}\left(u^{i}-v^{i}\right)$ is divisible by $u-v$.) Therefore each term in the chain of (nonzero) differences

$$
x_{0}-x_{1}, \quad x_{1}-x_{2}, \quad \ldots, \quad x_{k-1}-x_{k}, \quad x_{k}-x_{k+1}\tag{2}
$$

is a divisor of the next one; and since $x_{k}-x_{k+1}=x_{0}-x_{1}$, all these differences have equal absolute values. For $x_{m}=\min \left(x_{1}, \ldots, x_{k}\right)$ this means that $x_{m-1}-x_{m}=-\left(x_{m}-x_{m+1}\right)$. Thus $x_{m-1}=x_{m+1}\left(\neq x_{m}\right)$. It follows that consecutive differences in the sequence (2) have opposite signs. Consequently, $x_{0}, x_{1}, x_{2}, \ldots$ is an alternating sequence of two distinct values. In other words, every integer fixed point of $Q$ is a fixed point of the polynomial $P(P(x))$. Our task is to prove that there are at most $n$ such points.

Let $a$ be one of them so that $b=P(a) \neq a$ (we have assumed that such an $a$ exists); then $a=P(b)$. Take any other integer fixed point $\alpha$ of $P(P(x))$ and let $P(\alpha)=\beta$, so that $P(\beta)=\alpha$; the numbers $\alpha$ and $\beta$ need not be distinct ( $\alpha$ can be a fixed point of $P$ ), but each of $\alpha, \beta$ is different from each of $a, b$. Applying property (1) to the four pairs of integers $(\alpha, a),(\beta, b)$, $(\alpha, b),(\beta, a)$ we get that the numbers $\alpha-a$ and $\beta-b$ divide each other, and also $\alpha-b$ and $\beta-a$ divide each other. Consequently

$$
\alpha-b= \pm(\beta-a), \quad \alpha-a= \pm(\beta-b)\tag{3}
$$

Suppose we have a plus in both instances: $\alpha-b=\beta-a$ and $\alpha-a=\beta-b$. Subtraction yields $a-b=b-a$, a contradiction, as $a \neq b$. Therefore at least one equality in (3) holds with a minus sign. For each of them this means that $\alpha+\beta=a+b$; equivalently $a+b-\alpha-P(\alpha)=0$.

Denote $a+b$ by $C$. We have shown that every integer fixed point of $Q$ other that $a$ and $b$ is a root of the polynomial $F(x)=C-x-P(x)$. This is of course true for $a$ and $b$ as well. And since $P$ has degree $n>1$, the polynomial $F$ has the same degree, so it cannot have more than $n$ roots. Hence the result.
Subfield: Number Theory


Question: Find all integer solutions of the equation

$$
\frac{x^{7}-1}{x-1}=y^{5}-1
$$

Solution:
The equation has no integer solutions. To show this, we first prove a lemma.

Lemma. If $x$ is an integer and $p$ is a prime divisor of $\frac{x^{7}-1}{x-1}$ then either $p \equiv 1(\bmod 7)$ or $p=7$.

Proof. Both $x^{7}-1$ and $x^{p-1}-1$ are divisible by $p$, by hypothesis and by Fermat's little theorem, respectively. Suppose that 7 does not divide $p-1$. Then $\operatorname{gcd}(p-1,7)=1$, so there exist integers $k$ and $m$ such that $7 k+(p-1) m=1$. We therefore have

$$
x \equiv x^{7 k+(p-1) m} \equiv\left(x^{7}\right)^{k} \cdot\left(x^{p-1}\right)^{m} \equiv 1 \quad(\bmod p)
$$

and so

$$
\frac{x^{7}-1}{x-1}=1+x+\cdots+x^{6} \equiv 7 \quad(\bmod p)
$$

It follows that $p$ divides 7 , hence $p=7$ must hold if $p \equiv 1(\bmod 7)$ does not, as stated.

The lemma shows that each positive divisor $d$ of $\frac{x^{7}-1}{x-1}$ satisfies either $d \equiv 0(\bmod 7)$ or $d \equiv 1(\bmod 7)$.

Now assume that $(x, y)$ is an integer solution of the original equation. Notice that $y-1>0$, because $\frac{x^{7}-1}{x-1}>0$ for all $x \neq 1$. Since $y-1$ divides $\frac{x^{7}-1}{x-1}=y^{5}-1$, we have $y \equiv 1(\bmod 7)$ or $y \equiv 2(\bmod 7)$ by the previous paragraph. In the first case, $1+y+y^{2}+y^{3}+y^{4} \equiv 5(\bmod 7)$, and in the second $1+y+y^{2}+y^{3}+y^{4} \equiv 3(\bmod 7)$. Both possibilities contradict the fact that the positive divisor $1+y+y^{2}+y^{3}+y^{4}$ of $\frac{x^{7}-1}{x-1}$ is congruent to 0 or 1 modulo 7 . So the given equation has no integer solutions.

Final answer: the given equation has no integer solutions
Subfield: Number Theory


Question: Prove that, for every positive integer $n$, there exists an integer $m$ such that $2^{m}+m$ is divisible by $n$.

Solution:
We will prove by induction on $d$ that, for every positive integer $N$, there exist positive integers $b_{0}, b_{1}, \ldots, b_{d-1}$ such that, for each $i=0,1,2, \ldots, d-1$, we have $b_{i}>N$ and

$$
2^{b_{i}}+b_{i} \equiv i \quad(\bmod d)
$$

This yields the claim for $m=b_{0}$.

The base case $d=1$ is trivial. Take an $a>1$ and assume that the statement holds for all $d<a$. Note that the remainders of $2^{i}$ modulo $a$ repeat periodically starting with some exponent $M$. Let $k$ be the length of the period; this means that $2^{M+k^{\prime}} \equiv 2^{M}(\bmod a)$ holds only for those $k^{\prime}$ which are multiples of $k$. Note further that the period cannot contain all the $a$ remainders, since 0 either is missing or is the only number in the period. Thus $k<a$.

Let $d=\operatorname{gcd}(a, k)$ and let $a^{\prime}=a / d, k^{\prime}=k / d$. Since $0<k<a$, we also have $0<d<a$. By the induction hypothesis, there exist positive integers $b_{0}, b_{1}, \ldots, b_{d-1}$ such that $b_{i}>\max \left(2^{M}, N\right)$ and

$$
2^{b_{i}}+b_{i} \equiv i \quad(\bmod d) \quad \text { for } \quad i=0,1,2, \ldots, d-1 \tag{1}
$$

For each $i=0,1, \ldots, d-1$ consider the sequence

$$
2^{b_{i}}+b_{i}, \quad 2^{b_{i}+k}+\left(b_{i}+k\right), \ldots, 2^{b_{i}+\left(a^{\prime}-1\right) k}+\left(b_{i}+\left(a^{\prime}-1\right) k\right)\tag{2}
$$

Modulo $a$, these numbers are congruent to

$$
2^{b_{i}}+b_{i}, 2^{b_{i}}+\left(b_{i}+k\right), \ldots, 2^{b_{i}}+\left(b_{i}+\left(a^{\prime}-1\right) k\right),
$$

respectively. The $d$ sequences contain $a^{\prime} d=a$ numbers altogether. We shall now prove that no two of these numbers are congruent modulo $a$.

Suppose that

$$
2^{b_{i}}+\left(b_{i}+m k\right) \equiv 2^{b_{j}}+\left(b_{j}+n k\right) \quad(\bmod a)\tag{3}
$$

for some values of $i, j \in\{0,1, \ldots, d-1\}$ and $m, n \in\left\{0,1, \ldots, a^{\prime}-1\right\}$. Since $d$ is a divisor of $a$, we also have

$$
2^{b_{i}}+\left(b_{i}+m k\right) \equiv 2^{b_{j}}+\left(b_{j}+n k\right) \quad(\bmod d) .
$$

Because $d$ is a divisor of $k$ and in view of $(1)$, we obtain $i \equiv j(\bmod d)$. As $i, j \in\{0,1, \ldots, d-1\}$, this just means that $i=j$. Substituting this into (3) yields $m k \equiv n k(\bmod a)$. Therefore $m k^{\prime} \equiv n k^{\prime}\left(\bmod a^{\prime}\right)$; and since $a^{\prime}$ and $k^{\prime}$ are coprime, we get $m \equiv n\left(\bmod a^{\prime}\right)$. Hence also $m=n$

It follows that the $a$ numbers that make up the $d$ sequences (2) satisfy all the requirements; they are certainly all greater than $N$ because we chose each $b_{i}>\max \left(2^{M}, N\right)$. So the statement holds for $a$, completing the induction.
Subfield: Algebra


Question: Let $n$ be an integer, and let $A$ be a subset of $\left\{0,1,2,3, \ldots, 5^{n}\right\}$ consisting of $4 n+2$ numbers. Prove that there exist $a, b, c \in A$ such that $a<b<c$ and $c+2 a>3 b$.

Solution:
(By contradiction) Suppose that there exist $4 n+2$ non-negative integers $x_{0}<$ $x_{1}<\cdots<x_{4 n+1}$ that violate the problem statement. Then in particular $x_{4 n+1}+2 x_{i} \leqslant 3 x_{i+1}$ for all $i=0, \ldots, 4 n-1$, which gives

$$
x_{4 n+1}-x_{i} \geqslant \frac{3}{2}\left(x_{4 n+1}-x_{i+1}\right)
$$

By a trivial induction we then get

$$
x_{4 n+1}-x_{i} \geqslant\left(\frac{3}{2}\right)^{4 n-i}\left(x_{4 n+1}-x_{4 n}\right)
$$

which for $i=0$ yields the contradiction

$$
x_{4 n+1}-x_{0} \geqslant\left(\frac{3}{2}\right)^{4 n}\left(x_{4 n+1}-x_{4 n}\right)=\left(\frac{81}{16}\right)^{n}\left(x_{4 n+1}-x_{4 n}\right)>5^{n} \cdot 1
$$
Denote the maximum element of $A$ by $c$. For $k=0, \ldots, 4 n-1$ let

$$
A_{k}=\left\{x \in A:\left(1-(2 / 3)^{k}\right) c \leqslant x<\left(1-(2 / 3)^{k+1}\right) c\right\} \text {. }
$$

Note that

$$
\left(1-(2 / 3)^{4 n}\right) c=c-(16 / 81)^{n} c>c-(1 / 5)^{n} c \geqslant c-1 \text {, }
$$

which shows that the sets $A_{0}, A_{1}, \ldots, A_{4 n-1}$ form a partition of $A \backslash\{c\}$. Since $A \backslash\{c\}$ has $4 n+1$ elements, by the pigeonhole principle some set $A_{k}$ does contain at least two elements of $A \backslash\{c\}$. Denote these two elements $a$ and $b$ and assume $a<b$, so that $a<b<c$. Then

$$
c+2 a \geqslant c+2\left(1-(2 / 3)^{k}\right) c=\left(3-2(2 / 3)^{k}\right) c=3\left(1-(2 / 3)^{k+1}\right) c>3 b
$$

as desired.
Subfield: Algebra


Question: Show that for all real numbers $x_{1}, \ldots, x_{n}$ the following inequality holds:

$$
\sum_{i=1}^{n} \sum_{j=1}^{n} \sqrt{\left|x_{i}-x_{j}\right|} \leqslant \sum_{i=1}^{n} \sum_{j=1}^{n} \sqrt{\left|x_{i}+x_{j}\right|}
$$

Solution:
If we add $t$ to all the variables then the left-hand side remains constant and the right-hand side becomes

$$
H(t):=\sum_{i=1}^{n} \sum_{j=1}^{n} \sqrt{\left|x_{i}+x_{j}+2 t\right|}
$$

Let $T$ be large enough such that both $H(-T)$ and $H(T)$ are larger than the value $L$ of the lefthand side of the inequality we want to prove. Not necessarily distinct points $p_{i, j}:=-\left(x_{i}+x_{j}\right) / 2$ together with $T$ and $-T$ split the real line into segments and two rays such that on each of these segments and rays the function $H(t)$ is concave since $f(t):=\sqrt{|\ell+2 t|}$ is concave on both intervals $(-\infty,-\ell / 2]$ and $[-\ell / 2,+\infty)$. Let $[a, b]$ be the segment containing zero. Then concavity implies $H(0) \geqslant \min \{H(a), H(b)\}$ and, since $H( \pm T)>L$, it suffices to prove the inequalities $H\left(-\left(x_{i}+x_{j}\right) / 2\right) \geqslant L$, that is to prove the original inequality in the case when all numbers are shifted in such a way that two variables $x_{i}$ and $x_{j}$ add up to zero. In the following we denote the shifted variables still by $x_{i}$.

If $i=j$, i.e. $x_{i}=0$ for some index $i$, then we can remove $x_{i}$ which will decrease both sides by $2 \sum_{k} \sqrt{\left|x_{k}\right|}$. Similarly, if $x_{i}+x_{j}=0$ for distinct $i$ and $j$ we can remove both $x_{i}$ and $x_{j}$ which decreases both sides by

$$
2 \sqrt{2\left|x_{i}\right|}+2 \cdot \sum_{k \neq i, j}\left(\sqrt{\left|x_{k}+x_{i}\right|}+\sqrt{\left|x_{k}+x_{j}\right|}\right)
$$

In either case we reduced our inequality to the case of smaller $n$. It remains to note that for $n=0$ and $n=1$ the inequality is trivial.
For real $p$ consider the integral

$$
I(p)=\int_{0}^{\infty} \frac{1-\cos (p x)}{x \sqrt{x}} d x
$$

which clearly converges to a strictly positive number. By changing the variable $y=|p| x$ one notices that $I(p)=\sqrt{|p|} I(1)$. Hence, by using the trigonometric formula $\cos (\alpha-\beta)-\cos (\alpha+$ $\beta)=2 \sin \alpha \sin \beta$ we obtain

$\sqrt{|a+b|}-\sqrt{|a-b|}=\frac{1}{I(1)} \int_{0}^{\infty} \frac{\cos ((a-b) x)-\cos ((a+b) x)}{x \sqrt{x}} d x=\frac{1}{I(1)} \int_{0}^{\infty} \frac{2 \sin (a x) \sin (b x)}{x \sqrt{x}} d x$,

from which our inequality immediately follows:

$$
\sum_{i=1}^{n} \sum_{j=1}^{n} \sqrt{\left|x_{i}+x_{j}\right|}-\sum_{i=1}^{n} \sum_{j=1}^{n} \sqrt{\left|x_{i}-x_{j}\right|}=\frac{2}{I(1)} \int_{0}^{\infty} \frac{\left(\sum_{i=1}^{n} \sin \left(x_{i} x\right)\right)^{2}}{x \sqrt{x}} d x \geqslant 0
$$
Subfield: Algebra


Question: Let $A$ be a finite set of (not necessarily positive) integers, and let $m \geqslant 2$ be an integer. Assume that there exist non-empty subsets $B_{1}, B_{2}, B_{3}, \ldots, B_{m}$ of $A$ whose elements add up to the sums $m^{1}, m^{2}, m^{3}, \ldots, m^{m}$, respectively. Prove that $A$ contains at least $m / 2$ elements.

Solution:
Let $A=\left\{a_{1}, \ldots, a_{k}\right\}$. Assume that, on the contrary, $k=|A|<m / 2$. Let

$$
s_{i}:=\sum_{j: a_{j} \in B_{i}} a_{j}
$$

be the sum of elements of $B_{i}$. We are given that $s_{i}=m^{i}$ for $i=1, \ldots, m$.

Now consider all $\mathrm{m}^{m}$ expressions of the form

$$
f\left(c_{1}, \ldots, c_{m}\right):=c_{1} s_{1}+c_{2} s_{2}+\ldots+c_{m} s_{m}, c_{i} \in\{0,1, \ldots, m-1\} \text { for all } i=1,2, \ldots, m
$$

Note that every number $f\left(c_{1}, \ldots, c_{m}\right)$ has the form

$$
\alpha_{1} a_{1}+\ldots+\alpha_{k} a_{k}, \alpha_{i} \in\{0,1, \ldots, m(m-1)\}
$$

Hence, there are at most $(m(m-1)+1)^{k}<m^{2 k}<m^{m}$ distinct values of our expressions; therefore, at least two of them coincide.

Since $s_{i}=m^{i}$, this contradicts the uniqueness of representation of positive integers in the base- $m$ system.
Subfield: Algebra


Question: Let $S$ be an infinite set of positive integers, such that there exist four pairwise distinct $a, b, c, d \in S$ with $\operatorname{gcd}(a, b) \neq \operatorname{gcd}(c, d)$. Prove that there exist three pairwise distinct $x, y, z \in S$ such that $\operatorname{gcd}(x, y)=\operatorname{gcd}(y, z) \neq \operatorname{gcd}(z, x)$.

Solution:
There exists $\alpha \in S$ so that $\{\operatorname{gcd}(\alpha, s) \mid s \in S, s \neq \alpha\}$ contains at least two elements. Since $\alpha$ has only finitely many divisors, there is a $d \mid \alpha$ such that the set $B=\{\beta \in$ $S \mid \operatorname{gcd}(\alpha, \beta)=d\}$ is infinite. Pick $\gamma \in S$ so that $\operatorname{gcd}(\alpha, \gamma) \neq d$. Pick $\beta_{1}, \beta_{2} \in B$ so that $\operatorname{gcd}\left(\beta_{1}, \gamma\right)=\operatorname{gcd}\left(\beta_{2}, \gamma\right)=: d^{\prime}$. If $d=d^{\prime}$, then $\operatorname{gcd}\left(\alpha, \beta_{1}\right)=\operatorname{gcd}\left(\gamma, \beta_{1}\right) \neq \operatorname{gcd}(\alpha, \gamma)$. If $d \neq d^{\prime}$, then either $\operatorname{gcd}\left(\alpha, \beta_{1}\right)=\operatorname{gcd}\left(\alpha, \beta_{2}\right)=d$ and $\operatorname{gcd}\left(\beta_{1}, \beta_{2}\right) \neq d \operatorname{or} \operatorname{gcd}\left(\gamma, \beta_{1}\right)=\operatorname{gcd}\left(\gamma, \beta_{2}\right)=d^{\prime}$ and $\operatorname{gcd}\left(\beta_{1}, \beta_{2}\right) \neq d^{\prime}$.
Subfield: Combinatorics


Question: Let $n \geqslant 3$ be an integer. An integer $m \geqslant n+1$ is called $n$-colourful if, given infinitely many marbles in each of $n$ colours $C_{1}, C_{2}, \ldots, C_{n}$, it is possible to place $m$ of them around a circle so that in any group of $n+1$ consecutive marbles there is at least one marble of colour $C_{i}$ for each $i=1, \ldots, n$.

Prove that there are only finitely many positive integers which are not $n$-colourful. Find the largest among them.

Solution:
First suppose that there are $n(n-1)-1$ marbles. Then for one of the colours, say blue, there are at most $n-2$ marbles, which partition the non-blue marbles into at most $n-2$ groups with at least $(n-1)^{2}>n(n-2)$ marbles in total. Thus one of these groups contains at least $n+1$ marbles and this group does not contain any blue marble.

Now suppose that the total number of marbles is at least $n(n-1)$. Then we may write this total number as $n k+j$ with some $k \geqslant n-1$ and with $0 \leqslant j \leqslant n-1$. We place around a circle $k-j$ copies of the colour sequence $[1,2,3, \ldots, n]$ followed by $j$ copies of the colour sequence $[1,1,2,3, \ldots, n]$.

Final answer: $m_{\max }=n^{2}-n-1$
Subfield: Combinatorics


Question: A thimblerigger has 2021 thimbles numbered from 1 through 2021. The thimbles are arranged in a circle in arbitrary order. The thimblerigger performs a sequence of 2021 moves; in the $k^{\text {th }}$ move, he swaps the positions of the two thimbles adjacent to thimble $k$.

Prove that there exists a value of $k$ such that, in the $k^{\text {th }}$ move, the thimblerigger swaps some thimbles $a$ and $b$ such that $a<k<b$.

Solution:
Assume the contrary. Say that the $k^{\text {th }}$ thimble is the central thimble of the $k^{\text {th }}$ move, and its position on that move is the central position of the move.

Step 1: Black and white colouring. 

Before the moves start, let us paint all thimbles in white. Then, after each move, we repaint its central thimble in black. This way, at the end of the process all thimbles have become black.

By our assumption, in every move $k$, the two swapped thimbles have the same colour (as their numbers are either both larger or both smaller than $k$ ). At every moment, assign the colours of the thimbles to their current positions; then the only position which changes its colour in a move is its central position. In particular, each position is central for exactly one move (when it is being repainted to black).

Step 2: Red and green colouring.

Now we introduce a colouring of the positions. If in the $k^{\text {th }}$ move, the numbers of the two swapped thimbles are both less than $k$, then we paint the central position of the move in red; otherwise we paint that position in green. This way, each position has been painted in red or green exactly once. We claim that among any two adjacent positions, one becomes green and the other one becomes red; this will provide the desired contradiction since 2021 is odd.

Consider two adjacent positions $A$ and $B$, which are central in the $a^{\text {th }}$ and in the $b^{\text {th }}$ moves, respectively, with $a<b$. Then in the $a^{\text {th }}$ move the thimble at position $B$ is white, and therefore has a number greater than $a$. After the $a^{\text {th }}$ move, position $A$ is green and the thimble at position $A$ is black. By the arguments from Step 1, position $A$ contains only black thimbles after the $a^{\text {th }}$ step. Therefore, on the $b^{\text {th }}$ move, position $A$ contains a black thimble whose number is therefore less than $b$, while thimble $b$ is at position $B$. So position $B$ becomes red, and hence $A$ and $B$ have different colours.
Subfield: Combinatorics


Question: Let $n$ and $k$ be two integers with $n>k \geqslant 1$. There are $2 n+1$ students standing in a circle. Each student $S$ has $2 k$ neighbours - namely, the $k$ students closest to $S$ on the right, and the $k$ students closest to $S$ on the left.

Suppose that $n+1$ of the students are girls, and the other $n$ are boys. Prove that there is a girl with at least $k$ girls among her neighbours.

Solution:
We replace the girls by 1's, and the boys by 0's, getting the numbers $a_{1}, a_{2}, \ldots, a_{2 n+1}$ arranged in a circle. We extend this sequence periodically by letting $a_{2 n+1+k}=a_{k}$ for all $k \in \mathbb{Z}$. We get an infinite periodic sequence

$$
\ldots, a_{1}, a_{2}, \ldots, a_{2 n+1}, a_{1}, a_{2}, \ldots, a_{2 n+1}, \ldots
$$

Consider the numbers $b_{i}=a_{i}+a_{i-k-1}-1 \in\{-1,0,1\}$ for all $i \in \mathbb{Z}$. We know that

$$
b_{m+1}+b_{m+2}+\cdots+b_{m+2 n+1}=1 \quad(m \in \mathbb{Z})
\tag{1}
$$

in particular, this yields that there exists some $i_{0}$ with $b_{i_{0}}=1$. Now we want to find an index $i$ such that

$$
b_{i}=1 \quad \text { and } \quad b_{i+1}+b_{i+2}+\cdots+b_{i+k} \geqslant 0 .
\tag{2}
$$

This will imply that $a_{i}=1$ and

$$
\left(a_{i-k}+a_{i-k+1}+\cdots+a_{i-1}\right)+\left(a_{i+1}+a_{i+2}+\cdots+a_{i+k}\right) \geqslant k,
$$

as desired.

Suppose, to the contrary, that for every index $i$ with $b_{i}=1$ the sum $b_{i+1}+b_{i+2}+\cdots+b_{i+k}$ is negative. We start from some index $i_{0}$ with $b_{i_{0}}=1$ and construct a sequence $i_{0}, i_{1}, i_{2}, \ldots$, where $i_{j}(j>0)$ is the smallest possible index such that $i_{j}>i_{j-1}+k$ and $b_{i_{j}}=1$. We can choose two numbers among $i_{0}, i_{1}, \ldots, i_{2 n+1}$ which are congruent modulo $2 n+1$ (without loss of generality, we may assume that these numbers are $i_{0}$ and $i_{T}$ ).

On the one hand, for every $j$ with $0 \leqslant j \leqslant T-1$ we have

$$
S_{j}:=b_{i_{j}}+b_{i_{j}+1}+b_{i_{j}+2}+\cdots+b_{i_{j+1}-1} \leqslant b_{i_{j}}+b_{i_{j}+1}+b_{i_{j}+2}+\cdots+b_{i_{j}+k} \leqslant 0
$$

since $b_{i_{j}+k+1}, \ldots, b_{i_{j+1}-1} \leqslant 0$. On the other hand, since $\left(i_{T}-i_{0}\right) \mid(2 n+1)$, from (1) we deduce

$$
S_{0}+\cdots+S_{T-1}=\sum_{i=i_{0}}^{i_{T}-1} b_{i}=\frac{i_{T}-i_{0}}{2 n+1}>0
$$

This contradiction finishes the solution.