di-zhang-fdu/OlympiadExtended huggingface dataset:
Subfield: Geometry


Question: Let $k$ and $n$ be integers with $0 \leq k \leq n-2$. Consider a set $L$ of $n$ lines in the plane such that no two of them are parallel and no three have a common point. Denote by $I$ the set of intersection points of lines in $L$. Let $O$ be a point in the plane not lying on any line of $L$.

A point $X \in I$ is colored red if the open line segment $O X$ intersects at most $k$ lines in $L$. Prove that $I$ contains at least $\frac{1}{2}(k+1)(k+2)$ red points.

Solution:
There are at least $\frac{1}{2}(k+1)(k+2)$ points in the intersection set $I$ in view of the condition $n \geq k+2$.

For each point $P \in I$, define its order as the number of lines that intersect the open line segment $O P$. By definition, $P$ is red if its order is at most $k$. Note that there is always at least one point $X \in I$ of order 0 . Indeed, the lines in $L$ divide the plane into regions, bounded or not, and $O$ belongs to one of them. Clearly any corner of this region is a point of $I$ with order 0.

Claim. Suppose that two points $P, Q \in I$ lie on the same line of $L$, and no other line of $L$ intersects the open line segment $P Q$. Then the orders of $P$ and $Q$ differ by at most 1 .

Proof. Let $P$ and $Q$ have orders $p$ and $q$, respectively, with $p \geq q$. Consider triangle $O P Q$. Now $p$ equals the number of lines in $L$ that intersect the interior of side $O P$. None of these lines intersects the interior of side $P Q$, and at most one can pass through $Q$. All remaining lines must intersect the interior of side $O Q$, implying that $q \geq p-1$. The conclusion follows.

We prove the main result by induction on $k$. The base $k=0$ is clear since there is a point of order 0 which is red. Assuming the statement true for $k-1$, we pass on to the inductive step. Select a point $P \in I$ of order 0 , and consider one of the lines $\ell \in L$ that pass through $P$. There are $n-1$ intersection points on $\ell$, one of which is $P$. Out of the remaining $n-2$ points, the $k$ closest to $P$ have orders not exceeding $k$ by the Claim. It follows that there are at least $k+1$ red points on $\ell$.

Let us now consider the situation with $\ell$ removed (together with all intersection points it contains). By hypothesis of induction, there are at least $\frac{1}{2} k(k+1)$ points of order not exceeding $k-1$ in the resulting configuration. Restoring $\ell$ back produces at most one new intersection point on each line segment joining any of these points to $O$, so their order is at most $k$ in the original configuration. The total number of points with order not exceeding $k$ is therefore at least $(k+1)+\frac{1}{2} k(k+1)=\frac{1}{2}(k+1)(k+2)$. This completes the proof.
Subfield: Number Theory


Question: Let $a_{1}, a_{2}, \ldots, a_{n}$ be distinct positive integers, $n \geq 3$. Prove that there exist distinct indices $i$ and $j$ such that $a_{i}+a_{j}$ does not divide any of the numbers $3 a_{1}, 3 a_{2}, \ldots, 3 a_{n}$.

Solution:
Without loss of generality, let $0<a_{1}<a_{2}<\cdots<a_{n}$. One can also assume that $a_{1}, a_{2}, \ldots, a_{n}$ are coprime. Otherwise division by their greatest common divisor reduces the question to the new sequence whose terms are coprime integers.

Suppose that the claim is false. Then for each $i<n$ there exists a $j$ such that $a_{n}+a_{i}$ divides $3 a_{j}$. If $a_{n}+a_{i}$ is not divisible by 3 then $a_{n}+a_{i}$ divides $a_{j}$ which is impossible as $0<a_{j} \leq a_{n}<a_{n}+a_{i}$. Thus $a_{n}+a_{i}$ is a multiple of 3 for $i=1, \ldots, n-1$, so that $a_{1}, a_{2}, \ldots, a_{n-1}$ are all congruent (to $-a_{n}$ ) modulo 3 .

Now $a_{n}$ is not divisible by 3 or else so would be all remaining $a_{i}$ 's, meaning that $a_{1}, a_{2}, \ldots, a_{n}$ are not coprime. Hence $a_{n} \equiv r(\bmod 3)$ where $r \in\{1,2\}$, and $a_{i} \equiv 3-r(\bmod 3)$ for all $i=1, \ldots, n-1$.

Consider a sum $a_{n-1}+a_{i}$ where $1 \leq i \leq n-2$. There is at least one such sum as $n \geq 3$. Let $j$ be an index such that $a_{n-1}+a_{i}$ divides $3 a_{j}$. Observe that $a_{n-1}+a_{i}$ is not divisible by 3 since $a_{n-1}+a_{i} \equiv 2 a_{i} \not \equiv 0(\bmod 3)$. It follows that $a_{n-1}+a_{i}$ divides $a_{j}$, in particular $a_{n-1}+a_{i} \leq a_{j}$. Hence $a_{n-1}<a_{j} \leq a_{n}$, implying $j=n$. So $a_{n}$ is divisible by all sums $a_{n-1}+a_{i}, 1 \leq i \leq n-2$. In particular $a_{n-1}+a_{i} \leq a_{n}$ for $i=1, \ldots, n-2$.

Let $j$ be such that $a_{n}+a_{n-1}$ divides $3 a_{j}$. If $j \leq n-2$ then $a_{n}+a_{n-1} \leq 3 a_{j}<a_{j}+2 a_{n-1}$. This yields $a_{n}<a_{n-1}+a_{j}$; however $a_{n-1}+a_{j} \leq a_{n}$ for $j \leq n-2$. Therefore $j=n-1$ or $j=n$.

For $j=n-1$ we obtain $3 a_{n-1}=k\left(a_{n}+a_{n-1}\right)$ with $k$ an integer, and it is straightforward that $k=1\left(k \leq 0\right.$ and $k \geq 3$ contradict $0<a_{n-1}<a_{n} ; k=2$ leads to $\left.a_{n-1}=2 a_{n}>a_{n-1}\right)$. Thus $3 a_{n-1}=a_{n}+a_{n-1}$, i. e. $a_{n}=2 a_{n-1}$.

Similarly, if $j=n$ then $3 a_{n}=k\left(a_{n}+a_{n-1}\right)$ for some integer $k$, and only $k=2$ is possible. Hence $a_{n}=2 a_{n-1}$ holds true in both cases remaining, $j=n-1$ and $j=n$.

Now $a_{n}=2 a_{n-1}$ implies that the sum $a_{n-1}+a_{1}$ is strictly between $a_{n} / 2$ and $a_{n}$. But $a_{n-1}$ and $a_{1}$ are distinct as $n \geq 3$, so it follows from the above that $a_{n-1}+a_{1}$ divides $a_{n}$. This provides the desired contradiction.
Subfield: Number Theory


Question: Prove that there exist infinitely many positive integers $n$ such that $n^{2}+1$ has a prime divisor greater than $2 n+\sqrt{2 n}$.

Solution:
Let $p \equiv 1(\bmod 8)$ be a prime. The congruence $x^{2} \equiv-1(\bmod p)$ has two solutions in $[1, p-1]$ whose sum is $p$. If $n$ is the smaller one of them then $p$ divides $n^{2}+1$ and $n \leq(p-1) / 2$. We show that $p>2 n+\sqrt{10 n}$.

Let $n=(p-1) / 2-\ell$ where $\ell \geq 0$. Then $n^{2} \equiv-1(\bmod p)$ gives

$$
\left(\frac{p-1}{2}-\ell\right)^{2} \equiv-1 \quad(\bmod p) \quad \text { or } \quad(2 \ell+1)^{2}+4 \equiv 0 \quad(\bmod p)
$$

Thus $(2 \ell+1)^{2}+4=r p$ for some $r \geq 0$. As $(2 \ell+1)^{2} \equiv 1 \equiv p(\bmod 8)$, we have $r \equiv 5(\bmod 8)$, so that $r \geq 5$. Hence $(2 \ell+1)^{2}+4 \geq 5 p$, implying $\ell \geq(\sqrt{5 p-4}-1) / 2$. Set $\sqrt{5 p-4}=u$ for clarity; then $\ell \geq(u-1) / 2$. Therefore

$$
n=\frac{p-1}{2}-\ell \leq \frac{1}{2}(p-u)
$$

Combined with $p=\left(u^{2}+4\right) / 5$, this leads to $u^{2}-5 u-10 n+4 \geq 0$. Solving this quadratic inequality with respect to $u \geq 0$ gives $u \geq(5+\sqrt{40 n+9}) / 2$. So the estimate $n \leq(p-u) / 2$ leads to

$$
p \geq 2 n+u \geq 2 n+\frac{1}{2}(5+\sqrt{40 n+9})>2 n+\sqrt{10 n}
$$

Since there are infinitely many primes of the form $8 k+1$, it follows easily that there are also infinitely many $n$ with the stated property.
Subfield: Algebra


Question: Let $a_{2}, \ldots, a_{n}$ be $n-1$ positive real numbers, where $n \geq 3$, such that $a_{2} a_{3} \cdots a_{n}=1$. Prove that

$$
\left(1+a_{2}\right)^{2}\left(1+a_{3}\right)^{3} \cdots\left(1+a_{n}\right)^{n}>n^{n} .
$$

Solution:
The substitution $a_{2}=\frac{x_{2}}{x_{1}}, a_{3}=\frac{x_{3}}{x_{2}}, \ldots, a_{n}=\frac{x_{1}}{x_{n-1}}$ transforms the original problem into the inequality

$$
\left(x_{1}+x_{2}\right)^{2}\left(x_{2}+x_{3}\right)^{3} \cdots\left(x_{n-1}+x_{1}\right)^{n}>n^{n} x_{1}^{2} x_{2}^{3} \cdots x_{n-1}^{n}\tag{*}
$$

for all $x_{1}, \ldots, x_{n-1}>0$. To prove this, we use the AM-GM inequality for each factor of the left-hand side as follows:

$$
\begin{array}{rlcll}
\left(x_{1}+x_{2}\right)^{2} & & & & \geq 2^{2} x_{1} x_{2} \\
\left(x_{2}+x_{3}\right)^{3} & = & \left(2\left(\frac{x_{2}}{2}\right)+x_{3}\right)^{3} & & \geq 3^{3}\left(\frac{x_{2}}{2}\right)^{2} x_{3} \\
\left(x_{3}+x_{4}\right)^{4} & = & \left(3\left(\frac{x_{3}}{3}\right)+x_{4}\right)^{4} & & \geq 4^{4}\left(\frac{x_{3}}{3}\right)^{3} x_{4} \\
& \vdots & \vdots && \vdots \\
\left(x_{n-1}+x_{1}\right)^{n} & = & \left((n-1)\left(\frac{x_{n-1}}{n-1}\right)+x_{1}\right)^{n} && \geq n^{n}\left(\frac{x_{n-1}}{n-1}\right)^{n-1} x_{1}
\end{array}
$$

Multiplying these inequalities together gives $(*)$, with inequality sign $\geq$ instead of $>$. However for the equality to occur it is necessary that $x_{1}=x_{2}, x_{2}=2 x_{3}, \ldots, x_{n-1}=(n-1) x_{1}$, implying $x_{1}=(n-1) ! x_{1}$. This is impossible since $x_{1}>0$ and $n \geq 3$. Therefore the inequality is strict.
Subfield: Algebra


Question: Find all functions $f: \mathbb{R} \rightarrow \mathbb{R}$ that satisfy the conditions

$$
f(1+x y)-f(x+y)=f(x) f(y) \text { for all } x, y \in \mathbb{R}
$$

and $f(-1) \neq 0$.

Solution:
The only solution is the function $f(x)=x-1, x \in \mathbb{R}$.

We set $g(x)=f(x)+1$ and show that $g(x)=x$ for all real $x$. The conditions take the form

$$
g(1+x y)-g(x+y)=(g(x)-1)(g(y)-1) \quad \text { for all } x, y \in \mathbb{R} \text { and } g(-1) \neq 1
\tag{1}
$$

Denote $C=g(-1)-1 \neq 0$. Setting $y=-1$ in (1) gives

$$
g(1-x)-g(x-1)=C(g(x)-1) .
\tag{2}
$$

Set $x=1$ in $(2)$ to obtain $C(g(1)-1)=0$. Hence $g(1)=1$ as $C \neq 0$. Now plugging in $x=0$ and $x=2$ yields $g(0)=0$ and $g(2)=2$ respectively.

We pass on to the key observations

$$
g(x)+g(2-x)=2 \text { for all } x \in \mathbb{R}\tag{3}
$$

$$
g(x+2)-g(x)=2 \text { for all } x \in \mathbb{R}\tag{4}
$$

Replace $x$ by $1-x$ in (2), then change $x$ to $-x$ in the resulting equation. We obtain the relations $g(x)-g(-x)=C(g(1-x)-1), g(-x)-g(x)=C(g(1+x)-1)$. Then adding them up leads to $C(g(1-x)+g(1+x)-2)=0$. Thus $C \neq 0$ implies (3).

Let $u, v$ be such that $u+v=1$. Apply (1) to the pairs $(u, v)$ and $(2-u, 2-v)$ :

$$
g(1+u v)-g(1)=(g(u)-1)(g(v)-1), \quad g(3+u v)-g(3)=(g(2-u)-1)(g(2-v)-1) .
$$

Observe that the last two equations have equal right-hand sides by (3). Hence $u+v=1$ implies

$$
g(u v+3)-g(u v+1)=g(3)-g(1)
$$

Each $x \leq 5 / 4$ is expressible in the form $x=u v+1$ with $u+v=1$ (the quadratic function $t^{2}-t+(x-1)$ has real roots for $\left.x \leq 5 / 4\right)$. Hence $g(x+2)-g(x)=g(3)-g(1)$ whenever $x \leq 5 / 4$. Because $g(x)=x$ holds for $x=0,1,2$, setting $x=0$ yields $g(3)=3$. This proves (4) for $x \leq 5 / 4$. If $x>5 / 4$ then $-x<5 / 4$ and so $g(2-x)-g(-x)=2$ by the above. On the other hand (3) gives $g(x)=2-g(2-x), g(x+2)=2-g(-x)$, so that $g(x+2)-g(x)=g(2-x)-g(-x)=2$. Thus (4) is true for all $x \in \mathbb{R}$.

Now replace $x$ by $-x$ in (3) to obtain $g(-x)+g(2+x)=2$. In view of (4) this leads to $g(x)+g(-x)=0$, i. e. $g(-x)=-g(x)$ for all $x$. Taking this into account, we apply (1) to the pairs $(-x, y)$ and $(x,-y)$ :

$g(1-x y)-g(-x+y)=(g(x)+1)(1-g(y)), \quad g(1-x y)-g(x-y)=(1-g(x))(g(y)+1)$.

Adding up yields $g(1-x y)=1-g(x) g(y)$. Then $g(1+x y)=1+g(x) g(y)$ by (3). Now the original equation (1) takes the form $g(x+y)=g(x)+g(y)$. Hence $g$ is additive.

By additvity $g(1+x y)=g(1)+g(x y)=1+g(x y)$; since $g(1+x y)=1+g(x) g(y)$ was shown above, we also have $g(x y)=g(x) g(y)$ ( $g$ is multiplicative). In particular $y=x$ gives $g\left(x^{2}\right)=g(x)^{2} \geq 0$ for all $x$, meaning that $g(x) \geq 0$ for $x \geq 0$. Since $g$ is additive and bounded from below on $[0,+\infty)$, it is linear; more exactly $g(x)=g(1) x=x$ for all $x \in \mathbb{R}$.

In summary $f(x)=x-1, x \in \mathbb{R}$. It is straightforward that this function satisfies the requirements.

Final answer: $f(x)=x-1$
Subfield: Algebra


Question: Let $f: \mathbb{N} \rightarrow \mathbb{N}$ be a function, and let $f^{m}$ be $f$ applied $m$ times. Suppose that for every $n \in \mathbb{N}$ there exists a $k \in \mathbb{N}$ such that $f^{2 k}(n)=n+k$, and let $k_{n}$ be the smallest such $k$. Prove that the sequence $k_{1}, k_{2}, \ldots$ is unbounded.

Solution:
We restrict attention to the set

$$
S=\left\{1, f(1), f^{2}(1), \ldots\right\}
$$

Observe that $S$ is unbounded because for every number $n$ in $S$ there exists a $k>0$ such that $f^{2 k}(n)=n+k$ is in $S$. Clearly $f$ maps $S$ into itself; moreover $f$ is injective on $S$. Indeed if $f^{i}(1)=f^{j}(1)$ with $i \neq j$ then the values $f^{m}(1)$ start repeating periodically from some point on, and $S$ would be finite.

Define $g: S \rightarrow S$ by $g(n)=f^{2 k_{n}}(n)=n+k_{n}$. We prove that $g$ is injective too. Suppose that $g(a)=g(b)$ with $a<b$. Then $a+k_{a}=f^{2 k_{a}}(a)=f^{2 k_{b}}(b)=b+k_{b}$ implies $k_{a}>k_{b}$. So, since $f$ is injective on $S$, we obtain

$$
f^{2\left(k_{a}-k_{b}\right)}(a)=b=a+\left(k_{a}-k_{b}\right)
$$

However this contradicts the minimality of $k_{a}$ as $0<k_{a}-k_{b}<k_{a}$.

Let $T$ be the set of elements of $S$ that are not of the form $g(n)$ with $n \in S$. Note that $1 \in T$ by $g(n)>n$ for $n \in S$, so $T$ is non-empty. For each $t \in T$ denote $C_{t}=\left\{t, g(t), g^{2}(t), \ldots\right\}$; call $C_{t}$ the chain starting at $t$. Observe that distinct chains are disjoint because $g$ is injective. Each $n \in S \backslash T$ has the form $n=g\left(n^{\prime}\right)$ with $n^{\prime}<n, n^{\prime} \in S$. Repeated applications of the same observation show that $n \in C_{t}$ for some $t \in T$, i. e. $S$ is the disjoint union of the chains $C_{t}$.

If $f^{n}(1)$ is in the chain $C_{t}$ starting at $t=f^{n_{t}}(1)$ then $n=n_{t}+2 a_{1}+\cdots+2 a_{j}$ with

$$
f^{n}(1)=g^{j}\left(f^{n_{t}}(1)\right)=f^{2 a_{j}}\left(f^{2 a_{j-1}}\left(\cdots f^{2 a_{1}}\left(f^{n_{t}}(1)\right)\right)\right)=f^{n_{t}}(1)+a_{1}+\cdots+a_{j} .
$$

Hence

$$
f^{n}(1)=f^{n_{t}}(1)+\frac{n-n_{t}}{2}=t+\frac{n-n_{t}}{2} .\tag{1}
$$

Now we show that $T$ is infinite. We argue by contradiction. Suppose that there are only finitely many chains $C_{t_{1}}, \ldots, C_{t_{r}}$, starting at $t_{1}<\cdots<t_{r}$. Fix $N$. If $f^{n}(1)$ with $1 \leq n \leq N$ is in $C_{t}$ then $f^{n}(1)=t+\frac{n-n_{t}}{2} \leq t_{r}+\frac{N}{2}$ by (1). But then the $N+1$ distinct natural numbers $1, f(1), \ldots, f^{N}(1)$ are all less than $t_{r}+\frac{N}{2}$ and hence $N+1 \leq t_{r}+\frac{N}{2}$. This is a contradiction if $N$ is sufficiently large, and hence $T$ is infinite.

To complete the argument, choose any $k$ in $\mathbb{N}$ and consider the $k+1$ chains starting at the first $k+1$ numbers in $T$. Let $t$ be the greatest one among these numbers. Then each of the chains in question contains a number not exceeding $t$, and at least one of them does not contain any number among $t+1, \ldots, t+k$. So there is a number $n$ in this chain such that $g(n)-n>k$, i. e. $k_{n}>k$. In conclusion $k_{1}, k_{2}, \ldots$ is unbounded.
Subfield: Combinatorics


Question: Several positive integers are written in a row. Iteratively, Alice chooses two adjacent numbers $x$ and $y$ such that $x>y$ and $x$ is to the left of $y$, and replaces the pair $(x, y)$ by either $(y+1, x)$ or $(x-1, x)$. Prove that she can perform only finitely many such iterations.

Solution:
Note first that the allowed operation does not change the maximum $M$ of the initial sequence. Let $a_{1}, a_{2}, \ldots, a_{n}$ be the numbers obtained at some point of the process. Consider the sum

$$
S=a_{1}+2 a_{2}+\cdots+n a_{n} .
$$

We claim that $S$ increases by a positive integer amount with every operation. Let the operation replace the pair $\left(a_{i}, a_{i+1}\right)$ by a pair $\left(c, a_{i}\right)$, where $a_{i}>a_{i+1}$ and $c=a_{i+1}+1$ or $c=a_{i}-1$. Then the new and the old value of $S$ differ by $d=\left(i c+(i+1) a_{i}\right)-\left(i a_{i}+(i+1) a_{i+1}\right)=a_{i}-a_{i+1}+i\left(c-a_{i+1}\right)$. The integer $d$ is positive since $a_{i}-a_{i+1} \geq 1$ and $c-a_{i+1} \geq 0$.

On the other hand $S \leq(1+2+\cdots+n) M$ as $a_{i} \leq M$ for all $i=1, \ldots, n$. Since $S$ increases by at least 1 at each step and never exceeds the constant $(1+2+\cdots+n) M$, the process stops after a finite number of iterations.
Like in the first solution note that the operations do not change the maximum $M$ of the initial sequence. Now consider the reverse lexicographical order for $n$-tuples of integers. We say that $\left(x_{1}, \ldots, x_{n}\right)<\left(y_{1}, \ldots, y_{n}\right)$ if $x_{n}<y_{n}$, or if $x_{n}=y_{n}$ and $x_{n-1}<y_{n-1}$, or if $x_{n}=y_{n}$, $x_{n-1}=y_{n-1}$ and $x_{n-2}<y_{n-2}$, etc. Each iteration creates a sequence that is greater than the previous one with respect to this order, and no sequence occurs twice during the process. On the other hand there are finitely many possible sequences because their terms are always positive integers not exceeding $M$. Hence the process cannot continue forever.
Let the current numbers be $a_{1}, a_{2}, \ldots, a_{n}$. Define the score $s_{i}$ of $a_{i}$ as the number of $a_{j}$ 's that are less than $a_{i}$. Call the sequence $s_{1}, s_{2}, \ldots, s_{n}$ the score sequence of $a_{1}, a_{2}, \ldots, a_{n}$.

Let us say that a sequence $x_{1}, \ldots, x_{n}$ dominates a sequence $y_{1}, \ldots, y_{n}$ if the first index $i$ with $x_{i} \neq y_{i}$ is such that $x_{i}<y_{i}$. We show that after each operation the new score sequence dominates the old one. Score sequences do not repeat, and there are finitely many possibilities for them, no more than $(n-1)^{n}$. Hence the process will terminate.

Consider an operation that replaces $(x, y)$ by $(a, x)$, with $a=y+1$ or $a=x-1$. Suppose that $x$ was originally at position $i$. For each $j<i$ the score $s_{j}$ does not increase with the change because $y \leq a$ and $x \leq x$. If $s_{j}$ decreases for some $j<i$ then the new score sequence dominates the old one. Assume that $s_{j}$ stays the same for all $j<i$ and consider $s_{i}$. Since $x>y$ and $y \leq a \leq x$, we see that $s_{i}$ decreases by at least 1 . This concludes the proof.
Subfield: Combinatorics


Question: Let $n \geq 1$ be an integer. What is the maximum number of disjoint pairs of elements of the set $\{1,2, \ldots, n\}$ such that the sums of the different pairs are different integers not exceeding $n$ ?

Solution:
Consider $x$ such pairs in $\{1,2, \ldots, n\}$. The sum $S$ of the $2 x$ numbers in them is at least $1+2+\cdots+2 x$ since the pairs are disjoint. On the other hand $S \leq n+(n-1)+\cdots+(n-x+1)$ because the sums of the pairs are different and do not exceed $n$. This gives the inequality

$$
\frac{2 x(2 x+1)}{2} \leq n x-\frac{x(x-1)}{2}
$$

which leads to $x \leq \frac{2 n-1}{5}$. Hence there are at most $\left\lfloor\frac{2 n-1}{5}\right\rfloor$ pairs with the given properties.

We show a construction with exactly $\left\lfloor\frac{2 n-1}{5}\right\rfloor$ pairs. First consider the case $n=5 k+3$ with $k \geq 0$, where $\left\lfloor\frac{2 n-1}{5}\right\rfloor=2 k+1$. The pairs are displayed in the following table.

| Pairs | $3 k+1$ | $3 k$ | $\cdots$ | $2 k+2$ | $4 k+2$ | $4 k+1$ | $\cdots$ | $3 k+3$ | $3 k+2$ |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|  | 2 | 4 | $\cdots$ | $2 k$ | 1 | 3 | $\cdots$ | $2 k-1$ | $2 k+1$ |
| Sums | $3 k+3$ | $3 k+4$ | $\cdots$ | $4 k+2$ | $4 k+3$ | $4 k+4$ | $\cdots$ | $5 k+2$ | $5 k+3$ |

The $2 k+1$ pairs involve all numbers from 1 to $4 k+2$; their sums are all numbers from $3 k+3$ to $5 k+3$. The same construction works for $n=5 k+4$ and $n=5 k+5$ with $k \geq 0$. In these cases the required number $\left\lfloor\frac{2 n-1}{5}\right\rfloor$ of pairs equals $2 k+1$ again, and the numbers in the table do not exceed $5 k+3$. In the case $n=5 k+2$ with $k \geq 0$ one needs only $2 k$ pairs. They can be obtained by ignoring the last column of the table (thus removing $5 k+3$ ). Finally, $2 k$ pairs are also needed for the case $n=5 k+1$ with $k \geq 0$. Now it suffices to ignore the last column of the table and then subtract 1 from each number in the first row.

Final answer: $\lfloor\frac{2 n-1}{5}\rfloor$
Subfield: Combinatorics


Question: In a $999 \times 999$ square table some cells are white and the remaining ones are red. Let $T$ be the number of triples $\left(C_{1}, C_{2}, C_{3}\right)$ of cells, the first two in the same row and the last two in the same column, with $C_{1}$ and $C_{3}$ white and $C_{2}$ red. Find the maximum value $T$ can attain.

Solution:
We prove that in an $n \times n$ square table there are at most $\frac{4 n^{4}}{27}$ such triples.

Let row $i$ and column $j$ contain $a_{i}$ and $b_{j}$ white cells respectively, and let $R$ be the set of red cells. For every red cell $(i, j)$ there are $a_{i} b_{j}$ admissible triples $\left(C_{1}, C_{2}, C_{3}\right)$ with $C_{2}=(i, j)$, therefore

$$
T=\sum_{(i, j) \in R} a_{i} b_{j}
$$

We use the inequality $2 a b \leq a^{2}+b^{2}$ to obtain

$$
T \leq \frac{1}{2} \sum_{(i, j) \in R}\left(a_{i}^{2}+b_{j}^{2}\right)=\frac{1}{2} \sum_{i=1}^{n}\left(n-a_{i}\right) a_{i}^{2}+\frac{1}{2} \sum_{j=1}^{n}\left(n-b_{j}\right) b_{j}^{2}
$$

This is because there are $n-a_{i}$ red cells in row $i$ and $n-b_{j}$ red cells in column $j$. Now we maximize the right-hand side.

By the AM-GM inequality we have

$$
(n-x) x^{2}=\frac{1}{2}(2 n-2 x) \cdot x \cdot x \leq \frac{1}{2}\left(\frac{2 n}{3}\right)^{3}=\frac{4 n^{3}}{27}
$$

with equality if and only if $x=\frac{2 n}{3}$. By putting everything together, we get

$$
T \leq \frac{n}{2} \frac{4 n^{3}}{27}+\frac{n}{2} \frac{4 n^{3}}{27}=\frac{4 n^{4}}{27}
$$

If $n=999$ then any coloring of the square table with $x=\frac{2 n}{3}=666$ white cells in each row and column attains the maximum as all inequalities in the previous argument become equalities. For example color a cell $(i, j)$ white if $i-j \equiv 1,2, \ldots, 666(\bmod 999)$, and red otherwise.

Therefore the maximum value $T$ can attain is $T=\frac{4 \cdot 999^{4}}{27}$.

Final answer: $\frac{4 \cdot 999^{4}}{27}$
Subfield: Combinatorics


Question: Let $k$ and $n$ be fixed positive integers. In the liar's guessing game, Amy chooses integers $x$ and $N$ with $1 \leq x \leq N$. She tells Ben what $N$ is, but not what $x$ is. Ben may then repeatedly ask Amy whether $x \in S$ for arbitrary sets $S$ of integers. Amy will always answer with yes or no, but she might lie. The only restriction is that she can lie at most $k$ times in a row. After he has asked as many questions as he wants, Ben must specify a set of at most $n$ positive integers. If $x$ is in this set he wins; otherwise, he loses. Prove that:
If $n \geq 2^{k}$ then Ben can always win.

Solution:
Consider an answer $A \in\{y e s, n o\}$ to a question of the kind "Is $x$ in the set $S$ ?" We say that $A$ is inconsistent with a number $i$ if $A=y e s$ and $i \notin S$, or if $A=n o$ and $i \in S$. Observe that an answer inconsistent with the target number $x$ is a lie.

Suppose that Ben has determined a set $T$ of size $m$ that contains $x$. This is true initially with $m=N$ and $T=\{1,2, \ldots, N\}$. For $m>2^{k}$ we show how Ben can find a number $y \in T$ that is different from $x$. By performing this step repeatedly he can reduce $T$ to be of size $2^{k} \leq n$ and thus win.

Since only the size $m>2^{k}$ of $T$ is relevant, assume that $T=\left\{0,1, \ldots, 2^{k}, \ldots, m-1\right\}$. Ben begins by asking repeatedly whether $x$ is $2^{k}$. If Amy answers no $k+1$ times in a row, one of these answers is truthful, and so $x \neq 2^{k}$. Otherwise Ben stops asking about $2^{k}$ at the first answer yes. He then asks, for each $i=1, \ldots, k$, if the binary representation of $x$ has a 0 in the $i$ th digit. Regardless of what the $k$ answers are, they are all inconsistent with a certain number $y \in\left\{0,1, \ldots, 2^{k}-1\right\}$. The preceding answer yes about $2^{k}$ is also inconsistent with $y$. Hence $y \neq x$. Otherwise the last $k+1$ answers are not truthful, which is impossible.

Either way, Ben finds a number in $T$ that is different from $x$, and the claim is proven.