Let $P=A_1A_2\dots A_k$ be a convex polygon in the plane.
The vertices $A_1$, $A_2$, \dots, $A_k$ have integral coordinates
and lie on a circle. Let $S$ be the area of $P$.
An odd positive integer $n$ is given such that
the squares of the side lengths of $P$ are integers divisible by $n$.
Prove that $2S$ is an integer divisible by $n$.

Solution:
Solution by Jeck Lim:
We will prove the result just for $n = p^e$
where $p$ is an odd prime and $e \ge 1$.
The case $k=3$ is resolved by Heron's formula directly:
we have $S = \frac14\sqrt{2(a^2b^2 + b^2c^2 + c^2a^2) - a^4-b^4-c^4}$,
so if $p^e \mid \gcd(a^2,b^2,c^2)$ then $p^{2e} \mid S^2$.

Now we show we can pick a diagonal and induct down on $k$ by using inversion.

Let the polygon be $A_1 A_2 \dots A_{k+1}$
and suppose for contradiction that all sides are divisible by $p^e$
but no diagonals are.
Let $O = A_{k+1}$ for notational convenience.
By applying inversion around $O$ with radius $1$,
we get the ``generalized Ptolemy theorem''
$
\frac{A_1A_2}{OA_1 \cdot OA_2}
+ \frac{A_2A_3}{OA_2 \cdot OA_3}
+ \dots
+ \frac{A_{k-1} A_k}{OA_{k-1} \cdot OA_k}
= \frac{A_1 A_k}{OA_1 \cdot OA_k}
$
or, making use of square roots,
$
\sqrt{\frac{A_1A_2^2}{OA_1^2 \cdot OA_2^2}}
+ \sqrt{\frac{A_2A_3^2}{OA_2^2 \cdot OA_3^2}}
+ \dots
+ \sqrt{\frac{A_{k-1} A_k^2}{OA_{k-1}^2 \cdot OA_k^2}}
= \sqrt{\frac{A_1 A_k^2}{OA_1^2 \cdot OA_k^2}}
$
Suppose $\nu_p$ of all diagonals is strictly less than $e$.
Then the relation becomes
$ \sqrt{q_1} + \dots + \sqrt{q_{k-1}} = \sqrt q $
where $q_i$ are positive rational numbers.
Since there are no nontrivial relations between square roots
(see \href{https://qchu.wordpress.com/2009/07/02/square-roots-have-no-unexpected-linear-relationships/}{this link})
there is a positive rational number $b$
such that $r_i = \sqrt{q_i/b}$ and $r = \sqrt{q/b}$
are all rational numbers.
Then
$ \sum r_i = r. $
However, the condition implies that $\nu_p(q_i^2) > \nu_p(q^2)$ for all $i$
(check this for $i=1$, $i=k-1$ and $2 \le i \le k-2$),
and hence $\nu_p(r_i) > \nu_p(r)$.
This is absurd.

I think you basically have to use some Ptolemy-like geometric property,
and also all correct solutions I know of for $n = p^e$
depend on finding a diagonal and inducting down.
(Actually, the case $k=4$ is pretty motivating;
Ptolemy implies one can cut in two.)


A set of positive integers is called fragrant
if it contains at least two elements and each of its elements
has a prime factor in common with at least one of the other elements.
Let $P(n)=n^2+n+1$.
What is the smallest possible positive integer value of $b$ such that
there exists a non-negative integer $a$ for which the set
$ \{P(a+1),P(a+2),\dots,P(a+b)\} $
is fragrant?

Solution:
The answer is $b = 6$.

First, we prove $b \ge 6$ must hold.
It is not hard to prove the following divisibilities by Euclid:

\gcd(P(n), P(n+1)) &\mid 1 \\
\gcd(P(n), P(n+2)) &\mid 7 \\
\gcd(P(n), P(n+3)) &\mid 3 \\
\gcd(P(n), P(n+4)) &\mid 19.

Now assume for contradiction $b \le 5$.
Then any GCD's among $P(a+1)$, \dots, $P(a+b)$ must be among $\{3, 7, 19\}$.
Consider a multi-graph on $\{a+1, \dots, a+b\}$ where we join two elements with nontrivial GCD
and label the edge with the corresponding prime.
Then we readily see there is at most one edge each of $\{3, 7, 19\}$:
id est at most one edge of gap $2$, $3$, $4$ (and no edges of gap $1$).
(By the gap of an edge $e = \{u,v\}$ we mean $|u - v|$.)
But one can see that it's now impossible for every vertex to have nonzero degree, contradiction.

To construct $b = 6$ we use the Chinese remainder theorem: select $a$ with

a+1 & \equiv 7 \pmod{19} \\
a+5 & \equiv 11 \pmod{19} \\
a+2 & \equiv 2 \pmod{7} \\
a+4 & \equiv 4 \pmod{7} \\
a+3 & \equiv 1 \pmod{3} \\
a+6 & \equiv 1 \pmod{3}

which does the trick.


The equation
$ (x-1)(x-2)\dots(x-2016)=(x-1)(x-2)\dots (x-2016) $
is written on the board, with $2016$ linear factors on each side.
What is the least possible value of $k$ for which it is possible to
erase exactly $k$ of these $4032$ linear factors so that at least
one factor remains on each side and the resulting equation
has no real solutions?

Solution:
The answer is $2016$.
Obviously this is necessary in order to delete duplicated factors.
We now prove it suffices to deleted $2 \pmod 4$ and $3 \pmod 4$
guys from the left-hand side, and $0 \pmod 4$,
$1 \pmod 4$ from the right-hand side.

Consider the $1008$ inequalities

(x-1)(x-4) &< (x-2)(x-3) \\
(x-5)(x-8) &< (x-6)(x-7) \\
(x-9)(x-12) &< (x-10)(x-11) \\
&\vdots \\
(x-2013)(x-2016) &< (x-2014)(x-2015).

Notice that in all these inequalities, at most one of them
has non-positive numbers in it, and we never have both zero.
If there is exactly one negative term among the $1008 \cdot 2 = 2016$ sides,
it is on the left and we can multiply all together.
Thus the only case that remains is if $x \in (4m-2, 4m-1)$ for some $m$,
say the $m$th inequality.
In that case, the two sides of that inequality differ by a factor of at least $9$.

We have $ \prod_{k \ge 0} \frac{(4k+2)(4k+3)}{(4k+1)(4k+4)} < e. $

[Proof of claim using logarithms]
It's equivalent to prove
$ \sum_{k \ge 0} \log ( 1 + \frac{2}{(4k+1)(4k+4)} ) < 1. $
To this end, we use the deep fact that $\log(1+t) \le t$,
and thus it follows from
$\sum_{k \ge 0} \frac{1}{(4k+1)(4k+4)} < 1/2$,
which one can obtain for example by noticing
it's less than $\frac14\frac{\pi^2}{6}$.

[Elementary proof of claim, given by Espen Slettnes]
To avoid calculus as above, for each $N \ge 0$, note the partial product is bounded by

\prod_{k=0}^N \frac{(4k+2)(4k+3)}{(4k+1)(4k+4)}
&=
\frac 21 \cdot ( \frac 34 \cdot \frac 65 )
\cdot ( \frac 78 \cdot \frac{10}{9} ) \cdot \dots
\cdot \frac{4N+3}{4N+4} \\
&< 2 \cdot 1 \cdot 1 \cdot \dots \cdot \frac{4N+3}{4N+4}
< 2 < e. \qedhere

This solves the problem, because then the factors being multiplied
on by the positive inequalities before the
$m$th one are both less than $e$, and $e^2 < 9$.
In symbols, for $4m-2 < x < 4m-1$ we should have
$ \frac{(x-(4m-6))(x-(4m-5))}{(x-(4m-7))(x-(4m-4))}
\times \dots \times \frac{(x-2)(x-3)}{(x-1)(x-4)} < e $
and
$ \frac{(x-(4m+2))(x-(4m+3))}{(x-(4m+1))(x-(4m+4))}
\times \dots \times \frac{(x-2014)(x-2015)}{(x-2013)(x-2016)} < e $
because the $(k+1)$st term of each left-hand side
is at most $\frac{(4k+2)(4k+3)}{(4k+1)(4k+4)}$, for $k \ge 0$.
As $e^2 < 9$, we're okay.


There are $n\ge 2$ line segments in the plane such that
every two segments cross and no three segments meet at a point.
Geoff has to choose an endpoint of each segment and place a frog
on it facing the other endpoint. Then he will clap his hands $n-1$ times.
Every time he claps, each frog will immediately jump forward
to the next intersection point on its segment.
Frogs never change the direction of their jumps.
Geoff wishes to place the frogs in such a way that no two of them
will ever occupy the same intersection point at the same time.

[(a)]
Prove that Geoff can always fulfill his wish if $n$ is odd.
Prove that Geoff can never fulfill his wish if $n$ is even.

Solution:
The following solution was communicated to me by Yang Liu.

Imagine taking a larger circle $\omega$ encasing
all $\binom{n}{2}$ intersection points.
Denote by $P_1$, $P_2$, \dots, $P_{2n}$ the order of the points on $\omega$
in clockwise order; we imagine placing the frogs on $P_i$ instead.
Observe that, in order for every pair of segments to meet,
each line segment must be of the form $P_i P_{i+n}$.
[Figure omitted]
Then:
[(a)]
Place the frogs on $P_1$, $P_3$, \dots, $P_{2n-1}$.
A simple parity arguments shows this works.

Observe that we cannot place frogs on consecutive $P_i$,
so the $n$ frogs must be placed on alternating points.
But since we also are supposed to not place frogs on
diametrically opposite points,
for even $n$ we immediately get a contradiction.

Yang says: this is easy to guess if you just do a
few small cases and notice that the pairs of
``violating points'' just forms a large cycle around.


For each integer $a_0 > 1$, define the sequence $a_0$, $a_1$, $a_2$,
\dots, by
$
a_{n+1} =

\sqrt{a_n} & \text{if $\sqrt{a_n}$ is an integer,} \\
a_n + 3 & \text{otherwise}

$
for each $n \ge 0$.
Determine all values of $a_0$ for which there is a number $A$
such that $a_n = A$ for infinitely many values of $n$.

Solution:
The answer is $a_0 \equiv 0 \pmod 3$ only.

First solution.:
We first compute the minimal term of any sequence, periodic or not.

Let $c$ be the smallest term in $a_n$.
Then either $c \equiv 2 \pmod 3$ or $c = 3$.

Clearly $c \neq 1, 4$.
Assume $c \not\equiv 2 \pmod 3$.
As $c$ is not itself a square,
the next perfect square after $c$ in the sequence
is one of $( \left\lfloor \sqrt c \right\rfloor + 1)^2$,
$( \left\lfloor \sqrt c \right\rfloor + 2)^2$,
or $( \left\lfloor \sqrt c \right\rfloor + 3)^2$.
So by minimality we require
$ c \le \left\lfloor \sqrt c \right\rfloor + 3 \le \sqrt c + 3 $
which requires $c \le 5$.
Since $c \neq 1,2,4,5$ we conclude $c = 3$.

Now we split the problem into two cases:

If $a_0 \equiv 0 \pmod 3$, then all terms of the sequence are $0 \pmod 3$.
The smallest term of the sequence is thus $3$ by the lemma
and we have $ 3 \to 6 \to 9 \to 3 $
so $A = 3$ works fine.

If $a_0 \not\equiv 0 \pmod 3$,
then no term of the sequence is $0 \pmod 3$,
and so in particular $3$ does not appear in the sequence.
So the smallest term of the sequence is $2 \pmod 3$ by lemma.
But since no squares are $2 \pmod 3$,
the sequence $a_k$ grows without bound forever after,
so no such $A$ can exist.

Hence the answer is $a_0 \equiv 0 \pmod 3$ only.

Second solution.:
We clean up the argument by proving the following lemma.

If $a_n$ is constant modulo $3$ and not $2 \pmod 3$,
then $a_n$ must eventually cycle in the form
$(m, m+3, m+6, \dots, m^2)$,
with no squares inside the cycle except $m^2$.

Observe that $a_n$ must eventually hit a square, say $a_k = c^2$;
the next term is $a_{k+1} = c$.
Then it is forever impossible to exceed $c^2$ again,
by what is essentially discrete intermediate value theorem.
Indeed, suppose $a_\ell > c^2$ and take $\ell > k$ minimal
(in particular $a_{\ell} \neq \sqrt{a_{\ell-1}}$).

Thus $a_{\ell-1} \in \{c^2-2, c^2-1, c^2\}$
and thus for modulo $3$ reasons we have $a_{\ell-1} = c^2$.
But that should imply $a_\ell = c < c^2$, contradiction.

We therefore conclude $\sup \{a_n, a_{n+1}, \dots \}$ is a
decreasing integer sequence in $n$.
It must eventually stabilize, say at $m^2$.
Now we can't hit a square between $m$ and $m^2$,
and so we are done.

Now, we contend that all $a_0 \equiv 0 \pmod 3$ work.
Indeed, for such $a_0$ we have $a_n \equiv 0 \pmod 3$ for all $n$,
so the lemma implies that the problem statement is valid.

Next, we observe that if $a_i \equiv 2 \pmod 3$,
then the sequence grows without bound afterwards
since no squares are $2 \pmod 3$.
In particular, if $a_0 \equiv 2 \pmod 3$ the answer is no.

Finally, we claim that if $a_0 \equiv 1 \pmod 3$,
then eventually some term is $2 \pmod 3$.
Assume for contradiction this is not so;
then $a_n \equiv 1 \pmod 3$ must hold forever,
and the lemma applies to give us a cycle of the form
$(m, m+3, \dots, m^2)$ where $m \equiv 1 \pmod 3$.
In particular $m \ge 4$ and
$ m \le (m-2)^2 < m^2 $
but $(m-2)^2 \equiv 1 \pmod 3$ which is a contradiction.


Solve over $\RR$ the functional equation
$ f( f(x)f(y) ) + f(x+y) = f(xy). $

Solution:
The only solutions are $f(x) = 0$, $f(x) = x-1$ and $f(x)=1-x$,
which clearly work.

Note that

If $f$ is a solution, so is $-f$.
Moreover, if $f(0)=0$ then setting $y=0$ gives $f\equiv0$.
So henceforth we assume $f(0)>0$.

We have $f(z) = 0 \iff z =1$.
Also, $f(0)=1$ and $f(1)=0$.

For the forwards direction, if $f(z)=0$ and $z \neq 1$
one may put $(x,y) = ( z, z(z-1)\inv )$
(so that $x+y=xy$) we deduce $f(0) = 0$ which is a contradiction.

For the reverse, $f(f(0)^2)=0$ by setting $x=y=0$, and use the previous part.
We also conclude $f(1) = 0$, $f(0) = 1$.

If $f$ is injective, we are done.

Setting $y=0$ in the original equation gives $f(f(x)) = 1-f(x)$.
We apply this three times on the expression $f^3(x)$:
$ f(1-f(x)) = f(f(f(x))) = 1 - f(f(x)) = f(x). $
Hence $1-f(x) = x$ or $f(x) = 1-x$.

The result $f(f(x)) + f(x) = 1$ also implies that surjectivity
would solve the problem.

$f$ is injective.

Setting $y=1$ in the original equation gives $f(x+1) = f(x)-1$, and by induction

f(x+n) = f(x)-n.
\label{eq:linshift}

Assume now $f(a) = f(b)$.
By using \eqref{eq:linshift} we may shift $a$ and $b$ to be large enough that
we may find $x$ and $y$ obeying $x+y=a+1$, $xy=b$.
Setting these gives

f(f(x)f(y)) &= f(xy) - f(x+y) = f(b) - f(a+1) \\
&= f(b) + 1 - f(a) = 1

from which we conclude
$ f( f(x)f(y) + 1 ) = 0. $
Hence by the first claim
we have $f(x)f(y) + 1 = 1$, so $f(x)f(y) = 0$.
Applying the first claim again gives $1 \in \{x,y\}$.
But that implies $a=b$.

Jessica Wan points out that for any $a \neq b$,
at least one of $a^2 > 4(b-1)$ and $b^2 > 4(a-1)$ is true.
So shifting via \eqref{eq:linshift} is actually unnecessary for this proof.

One can solve the problem over $\QQ$ using only \eqref{eq:linshift} and the easy parts.
Indeed, that already implies $f(n) = 1-n$ for all $n$.
Now we induct to show $f(p/q) = 1-p/q$ for all $0 < p < q$ (on $q$).
By choosing $x = 1+p/q$, $y = 1+q/p$, we cause $xy = x+y$,
and hence $0 = f( f(1+p/q)f(1+q/p) )$
or $1 = f(1+p/q)f(1+q/p)$.

By induction we compute $f(1+q/p)$ and this gives $f(p/q+1) = f(p/q)-1$.


A hunter and an invisible rabbit play a game in the plane.
The rabbit and hunter start at points $A_0 = B_0$.
In the $n$th round of the game ($n \ge 1$), three things occur in order:
[(i)]
The rabbit moves invisibly from $A_{n-1}$ to a point $A_n$
such that $A_{n-1} A_n = 1$.
The hunter has a tracking device (e.g.\ dog)
which reports an approximate location $P_n$ of the rabbit,
such that $P_n A_n \le 1$.
The hunter moves visibly from $B_{n-1}$ to a point $B_n$
such that $B_{n-1} B_n = 1$.

Solution:
No, the hunter cannot.
We will show how to increase the distance in the following way:

Suppose the rabbit is at a distance $d \ge 1$ from the hunter
at some point in time.
Then it can increase its distance to at least
$\sqrt{d^2+1/2}$ in $4d$ steps
regardless of what the hunter already knows about the rabbit.

Consider a positive integer $n > d$, to be chosen later.
Let the hunter start at $B$ and the rabbit at $A$, as shown.
Let $\ell$ denote line $AB$.

Now, we may assume the rabbit reveals its location $A$,
so that all previous information becomes irrelevant.

The rabbit chooses two points $X$ and $Y$ symmetric about $\ell$
such that $XY = 2$ and $AX = AY = n$, as shown.
The rabbit can then hop to either $X$ or $Y$,
pinging the point $P_n$ on the $\ell$ each time.
This takes $n$ hops.
[Figure omitted]

Now among all points $H$ the hunter can go to,
$\min \max \{HX, HY\}$ is clearly minimized with $H \in \ell$ by symmetry.
So the hunter moves to a point $H$ such that $BH = n$ as well.
In that case the new distance is $HX = HY$.

We now compute

HX^2 &= 1 + HM^2 = 1 + ( \sqrt{AX^2-1}-AH )^2 \\
&= 1 + ( \sqrt{n^2-1}-(n-d) )^2 \\
&\ge 1 + ( ( n-\frac1n ) - (n-d) )^2 \\
&= 1 + (d-1/n)^2

which exceeds $d^2 + 1/2$ whenever $n \ge 4d$.

In particular we can always take $n = 400$ even very crudely;
applying the lemma $2 \cdot 100^2$ times,
this gives a bound of $400 \cdot 2 \cdot 100^2 < 10^9$, as desired.

The step of revealing the location of the rabbit seems
critical because as far as I am aware it is basically
impossible to keep track of ping locations in the problem.

Reasons to believe the answer is ``no'':
the $10^9$ constant,
and also that ``follow the last ping'' is losing for the hunter.

I think there are roughly two ways you can approach the problem
once you recognize the answer.

[(i)]
Try and control the location of the pings
Abandon the notion of controlling possible locations,
and try to increase the distance by a little bit,
say from $d$ to $\sqrt{d^2+\varepsilon}$.
This involves revealing the location of the rabbit
before each iteration of several jumps.

I think it's clear that the difficulty of
my approach is realizing that (ii) is possible;
once you do, the two-point approach is more or less the only one possible.

My opinion is that (ii) is not that magical;
as I said it was the first idea I had.
But I am biased, because when I test-solved the problem
at the IMO it was called ``C5'' and not ``IMO3'';
this effectively told me it was unlikely that the official solution
was along the lines of (i),
because otherwise it would have been placed much later in the shortlist.


Let $R$ and $S$ be different points on a circle $\Omega$
such that $RS$ is not a diameter.
Let $\ell$ be the tangent line to $\Omega$ at $R$.
Point $T$ is such that $S$ is the midpoint of $RT$.
Point $J$ is chosen on minor arc $RS$ of $\Omega$ so that
the circumcircle $\Gamma$ of triangle $JST$ intersects $\ell$
at two distinct points.
Let $A$ be the common point of $\Gamma$ and $\ell$ closer to $R$.
Line $AJ$ meets $\Omega$ again at $K$.
Prove that line $KT$ is tangent to $\Gamma$.

Solution:
First solution (elementary).:
First, note
$ ∠ RKA = ∠ RKJ = ∠ RSJ = ∠ TSJ = ∠ TAJ = ∠ TAK $
so $RK \parallel AT$.
Now,

$RA$ is tangent at $R$ iff $\triangle KRS \sim \triangle RTA$ (oppositely),
because both equate to $-∠ RKS = ∠ SKR = ∠ SRA = ∠ TRA$.
Similarly, $TK$ is tangent at $T$
iff $\triangle KTS \sim \triangle ART$.
The two similarities are equivalent because $RS = ST$
the SAS gives $KR \cdot TA = RS \cdot RT = TS \cdot TR$.

[Figure omitted]

The problem is actually symmetric with respect to two circles;
$RA$ is tangent at $R$ if and only if $TK$ at $T$.

Second solution (inversion).:
Consider an inversion at $R$ fixing the circumcircle $\Gamma$ of $TSJA$.
Then:

$T$ and $S$ swap,
$A$ and $B$ swap, where $B$ is the second intersection
of $\ell$ with $\Gamma$.
Circle $\Omega$ inverts to the line through $T$
parallel to $RAB$, call it $\ell$.
$J^\ast$ is the second intersection of $\ell$ with $\Gamma$.
$K^\ast$ is the intersection of $\ell$ with the circumcircle
of $RBJ^\ast$; this implies $RK^\ast J^\ast B$ is an isosceles trapezoid.
In particular, one reads $RK^\ast \parallel AT$ from this,
hence $RK^\ast TA$ is a parallelogram.

Thus we wish to show the circumcircle of $RSK^\ast$ is tangent to $\Gamma$.
But that follows from the final parallelogram observed:
$S$ is the center of the parallelogram since it is the midpoint of the diagonal.

This also implies $RKTB$ is cyclic, from $K^\ast SA$ collinear.
Moreover, quadrilateral $KK^\ast TS$ is cyclic (by power of a point);
this leads to the second official solution to the problem.


Fix $N \ge 1$. A collection of $N(N+1)$ soccer players of distinct
heights stand in a row.
Sir Alex Song wishes to remove $N(N-1)$ players from this row
to obtain a new row of $2N$ players in which the following $N$
conditions hold: no one stands between the two tallest players,
no one stands between the third and fourth tallest players, \dots,
no one stands between the two shortest players.
Prove that this is possible.

Solution:
Some opening remarks:
\textbf{location and height are symmetric to each other},
if one thinks about this problem as permutation pattern avoidance.
So while officially there are multiple solutions,
they are basically isomorphic to one another,
and I am not aware of any solution otherwise.

[Figure omitted]

Take a partition of $N$ groups in order by height:
$G_1 = \{1,\dots,N+1\}$, $G_2 = \{N+2, \dots, 2N+2\}$, and so on.
We will pick two people from each group $G_k$.

Scan from the left until we find two people in the same group $G_k$.
Delete all people scanned and also everyone in $G_k$.
All the groups still have at least $N$ people left,
so we can induct down with the non-deleted people;
the chosen pair is to the far left anyways.

The important bit is to scan by position
but group by height,
and moreover not change the groups as we scan.
Dually, one can have a solution which scans by height
but groups by position.


An irreducible lattice point is an ordered pair
of integers $(x,y)$ satisfying $\gcd(x,y) = 1$.
Prove that if $S$ is a finite set of irreducible lattice points
then there exists a nonconstant
homogeneous polynomial $f(x,y)$ with integer coefficients
such that $f(x,y)=1$ for each $(x,y) \in S$.

Solution:
We present two solutions.

First solution (Dan Carmon, Israel).:
We prove the result by induction on $|S|$,
with the base case being Bezout's Lemma ($n=1$).
For the inductive step, suppose we want to add a given pair
$(a_{m+1},b_{m+1})$ to $\left\{ (a_1, \dots, a_m), (b_1, \dots, b_m) \right\}$.

[Standard]
By a suitable linear transformation we may assume
$ (a_{m+1},b_{m+1}) = (1,0). $

[Outline of proof]
It would be sufficient to show there exists a $2 \times 2$ matrix
$T = [ u & v \\ s & t ]$
with integer entries such that $\det T = 1$ and
$T \cdot [ a_{m+1} \\ b_{m+1} ]
= [ 1 \\ 0 ]$.
Then we could apply $T$ to all the ordered pairs in $S$ (viewed as column vectors);
if $f$ was a polynomial that works on the transformed ordered pairs,
then $f(ux+vy, sx+ty)$ works for the original ordered pairs.
(Here, the condition that $\det T = 1$ ensures that $T\inv$ has integer entries,
and hence that $T$ maps irreducible lattice points to irreducible lattice points.)

To generate such a matrix $T$, choose
$T = [ u & v \\ -b_{m+1} & a_{m+1} ]$
where $u$ and $v$ are chosen via B\'{e}zout lemma so that $ua_{m+1} + vb_{m+1} = 1$.
This matrix $T$ is rigged so that $\det T = 1$ and the leftmost column of $T\inv$ is
$[ a_{m+1} \\ b_{m+1} ]$.

This transformation claim is not necessary to proceed;
the solution below can be rewritten to avoid it with only cosmetic edits.
However, it makes things a bit easier to read.

Let $g(x,y)$ be a polynomial which works on the latter set.
We claim we can choose the new polynomial $f$ of the form
$ f(x,y) = g(x,y)^{M} - C x^{\deg g \cdot M-m} \prod_{i=1}^m (b_i x - a_i y). $
where $C$ and $M$ are integer parameters we may adjust.

Since $f(a_i, b_i) = 1$ by construction we just need
$ 1 = f(1,0) = g(1,0)^M - C \prod b_i. $
If $\prod b_i = 0$ we are done,
since $b_i = 0 \implies a_i = \pm 1$ in that case
and so $g(1, 0) = \pm 1$, thus take $M = 2$.
So it suffices to prove:

We have $\gcd( g(1,0), b_i ) = 1$ when $b_i \neq 0$.

Fix $i$. If $b_i = 0$ then $a_i = \pm 1$ and $g(\pm 1,0) = \pm 1$.
Otherwise know
$ 1 = g(a_i, b_i) \equiv g(a_i, 0) \pmod{b_i} $
and since the polynomial is homogeneous with $\gcd(a_i, b_i) = 1$
it follows $g(1,0) \not\equiv 0 \pmod{b_i}$ as well.

Then take $M$ a large multiple of $\varphi(\prod |b_i|)$ and we're done.

Second solution (Lagrange).:
The main claim is that:

For every positive integer $N$,
there is a homogeneous polynomial $P(x,y)$ such that
$P(x,y) \equiv 1 \pmod N$ whenever $\gcd(x,y) = 1$.

(This claim is actually implied by the problem.)

For $N = p^e$ a prime take $(x^{p-1} + y^{p-1})^{\varphi(N)}$
when $p$ is odd, and $(x^2+xy+y^2)^{\varphi(N)}$ for $p=2$.

Now, if $N$ is a product of primes,
we can collate coefficient by coefficient using the
Chinese remainder theorem.

Let $S = \left\{ (a_i, b_i) \mid i=1, \dots, m \right\}$.
We have the natural homogeneous ``Lagrange polynomials''
$ L_k(x,y) \coloneq \prod_{i \neq k} (b_i x - a_i y) $
Now let
$ N \coloneq \prod_k L_k(x_k, y_k) $
and take $P$ as in the claim.
Then we can take a large power of $P$,
and for each $i$ subtract an appropriate multiple of $L_i(x,y)$; that is, choose
$
f(x,y)
= P(x,y)^{C} - \sum_i L_i(x,y) \cdot Q_i(x,y)
$
where $C$ is large enough that $C \deg P > \max_i \deg L_i$,
and $Q_i(x,y)$ is any homogeneous polynomial of degree $C \deg P - \deg L_i$
such that $L_k(x_k, y_k) Q_k(x_k, y_k) = \frac{P(x_k, y_k)^C - 1}{N} \cdot L_k(x_k, y_k)$
(which is an integer).


Let $\Gamma$ be the circumcircle of acute triangle $ABC$.
Points $D$ and $E$ lie on segments $AB$ and $AC$,
respectively, such that $AD = AE$.
The perpendicular bisectors of $BD$ and $CE$
intersect the minor arcs $AB$ and $AC$ of $\Gamma$
at points $F$ and $G$, respectively.
Prove that the lines $DE$ and $FG$ are parallel.

Solution:
We present a synthetic solution from the IMO shortlist
as well as a complex numbers approach.
We also outline a trig solution (the one I found at IMO),
and a fourth solution from Derek Liu.

Synthetic solution (from Shortlist).:
Construct parallelograms $AXFD$ and $AEGY$,
noting that $X$ and $Y$ lie on $\Gamma$.
As $XF \parallel AB$ we can let $M$
denote the midpoint of minor arcs $\widehat{XF}$ and $\widehat{AB}$
(which coincide). Define $N$ similarly.

[Figure omitted]

Observe that $XF = AD = AE = YG$,
so arcs $\widehat{XF}$ and $\widehat{YG}$ have equal measure;
hence arcs $\widehat{MF}$ and $\widehat{NG}$ have equal measure;
therefore $MN \parallel FG$.

Since $MN$ and $DE$ are both perpendicular
to the $\angle A$ bisector, we're done.

Complex numbers solution.:
Let $b$, $c$, $f$, $g$, $a$ be as usual.
Note that

d-a &= ( 2 \cdot \frac{f+a+b-ab\ol f}{2} -b )-a
= f - \frac{ab}{f} \\
e-a &= g - \frac{ac}{g}

We are given $AD = AE$ from which one deduces

( \frac{e-a}{d-a} )^2 &= \frac cb
\implies \frac{(g^2-ac)^2}{(f^2-ab)^2} = \frac{g^2 c}{f^2 b} \\
\implies bc(bg^2-cf^2)a^2 &= g^2f^4c - f^2g^4b = f^2g^2(f^2c-g^2b) \\
\implies bc \cdot a^2 &= (fg)^2 \implies ( -\frac{fg}{a} )^2 = bc.

Since $\frac{-fg}{a}$ is the point $X$ on the circle
with $AX \perp FG$,
we conclude $FG$ is either parallel or perpendicular
to the $\angle A$-bisector; it must the latter
since the $\angle A$-bisector separates the two minor arcs.

Trig solution (outline).:
Let $\ell$ denote the $\angle A$ bisector.
Fix $D$ and $F$.
We define the phantom point $G'$ such that $FG' \perp \ell$
and $E'$ on side $AC$ such that $GE'=GC$.

[Converse of the IMO problem]
We have $AD = AE'$, so that $E = E'$.

Since $FG' \perp \ell$,
one can deduce $\angle FBD = 1/2 C + x$
and $\angle GCA = 1/2 B + x$ for some $x$.
(One fast way to see this is to note that $FG \parallel MN$
where $M$ and $N$ are in the first solution.)
Then $\angle FAB = 1/2 C -x$ and $\angle GAC = 1/2 B - x$.

Let $R$ be the circumradius.
Now, by the law of sines,
$ BF = 2R \sin( 1/2 C - x ). $
From there we get

BD &= 2 \cdot BF \cos(1/2 C + x)
= 4R \cos(1/2 C+x) \sin (1/2 C-x) \\
DA &= AB - BD = 2R\sin C
- 4R\cos(1/2 C+x) \sin(1/2 C -x) \\
&= 2R[ \sin C - 2\cos( 1/2 C + x ) \sin ( 1/2 C -x ) ] \\
&= 2R[ \sin C - ( \sin C - \sin 2x ) ]
= 2R \sin 2x.

A similar calculation gives $AE' = 2R \sin 2x$ as needed.

Thus, $FG' \parallel DE$, so $G = G'$ as well.
This concludes the proof.

Synthetic solution from Derek Liu.:
Let lines $FD$ and $GE$ intersect $\Gamma$ again at $J$ and $K$, respectively.
[Figure omitted]
Notice that $\triangle BFD\sim\triangle JAD$; as $FB=FD$, it follows that $AJ=AD$.
Likewise, $\triangle CGE\sim\triangle KAE$ and $GC=GE$, so $AK=AE$.
Hence,
$ AK=AE=AD=AJ, $
so $DEJK$ is cyclic with center $A$.

It follows that
$ ∠ KED=∠ KJD=∠ KJF=∠ KGF, $
so we're done.

Note that $K$ and $J$ must be distinct for this solution to work.
Since $G$ and $K$ lie on opposite sides of $AC$, $K$ is on major arc $ABC$.
As $AK=AD=AE\le \min(AB,AC)$, $K$ lies on minor arc $AB$.
Similarly, $J$ lies on minor arc $AC$, so $K\neq J.$


Find all integers $n \geq 3$ for which
there exist real numbers $a_1, a_2, \dots, a_n$ satisfying
$ a_i a_{i+1} +1 = a_{i+2} $
for $i=1,2, \dots, n$, where indices are taken modulo $n$.

Solution:
The answer is $3 \mid n$,
achieved by $(-1,-1,2,-1,-1,2,\dots)$.
We present two solutions.

First solution by inequalities.:
We compute $a_i a_{i+1} a_{i+2}$ in two ways:

a_i a_{i+1} a_{i+2} &= [a_{i+2}-1]a_{i+2} = a_{i+2}^2 - a_{i+2} \\
&= a_i [a_{i+3}-1] = a_i a_{i+3} - a_i.

Cyclically summing $a_{i+2}^2 - a_{i+2} = a_i a_{i+3} - a_i$ then gives
$ \sum_i a_{i+2}^2 = \sum_i a_i a_{i+3}
\iff \sum_{\text{cyc}} ( a_i - a_{i+3} )^2 = 0. $
This means for inequality reasons the sequence is $3$-periodic.
Since the sequence is clearly not $1$-periodic,
as $x^2 + 1 = x$ has no real solutions.
Thus $3 \mid n$.

Second solution by sign counting.:
Extend $a_n$ to be a periodic sequence.
The idea is to look at the signs, and show the sequence
of the signs must be $--+$ repeated.
This takes several steps:

The pattern $---$ is impossible. Obvious, since the third term should be $ > 1$.
The pattern $++$ is impossible. Then the sequence becomes strictly increasing,
hence may not be periodic.
Zeros are impossible. If $a_1 = 0$, then $a_2 = 0$, $a_3 > 0$, $a_4 > 0$,
which gives the impossible $++$.
The pattern $--+-+$ is impossible.
Compute the terms:

a_1 &= -x < 0 \\
a_2 &= -y < 0 \\
a_3 &= 1 + xy > 1 \\
a_4 &= 1 - y(1+xy) < 0 \\
a_5 &= 1 + (1+xy)(1-y(1+xy)) < 1.

But now
$ a_6 - a_5 = (1 + a_5 a_4) - (1 + a_3 a_4)
= a_4 (a_5 - a_3) > 0 $
since $a_5 > 1 > a_3$.
This means we have the impossible $++$ pattern.
The infinite alternating pattern $-+-+-+-+\dots$ is impossible.
Note that
$ a_1 a_2 + 1 = a_3 < 0 < a_4 = 1 + a_2 a_3 \implies a_1 < a_3 $
since $a_2 > 0$;
extending this we get $a_1 < a_3 < a_5 < \dots$
which contradicts the periodicity.

We finally collate the logic of sign patterns.
Since the pattern is not alternating, there must be $--$ somewhere.
Afterwards must be $+$, and then after that must be two minus signs
(since one minus sign is impossible by impossibility of $--+-+$
and $---$ is also forbidden);
thus we get the periodic $--+$ as desired.


An anti-Pascal triangle is an equilateral triangular array
of numbers such that, except for the numbers in the bottom row,
each number is the absolute value of the difference
of the two numbers immediately below it.
For example, the following array is an anti-Pascal triangle
with four rows which contains every integer from $1$ to $10$.
[Figure omitted]
Does there exist an anti-Pascal triangle with $2018$ rows
which contains every integer from $1$ to $1+2+\dots +2018$?

Solution:
The answer is no, there is no anti-Pascal triangle
with the required properties.

Let $n = 2018$ and $N = 1+2+\dots+n$.
For every number $d$ not in the bottom row,
draw an arrow from $d$ to the larger of the two numbers below it
(i.e.\ if $d=a-b$, draw $d \to a$).
This creates an oriented forest (which looks like lightning strikes).

Consider the directed path starting from the top vertex $A$.
Starting from the first number, it increments by at least $1+2+\dots+n$,
since the increments at each step in the path are distinct;
therefore equality must hold
and thus the path from the top ends at $N = 1+2+\dots+n$
with all the numbers $\{1,2,\dots,n\}$ being close by.
Let $B$ be that position.

[Figure omitted]
Consider the two left/right neighbors $X$ and $Y$ of the endpoint $B$.
Assume that $B$ is to the right of the midpoint of the bottom side,
and complete the equilateral triangle as shown to an apex $C$.
Consider the lightning strike from $C$ hitting the bottom at $D$.
It travels at least $\left\lfloor n/2-1 \right\rfloor$ steps, by construction.
But the increases must be at least $n+1$, $n+2$, \dots since $1,2,\dots,n$
are close to the $A \to B$ lightning path.
Then the number at $D$ is at least
$ (n+1) + (n+2) + \dots +
( n+( \left\lfloor n/2-1 \right\rfloor ) )
> 1 + 2 + \dots + n $
for $n \ge 2018$, contradiction.


A site is any point $(x,y)$ in the plane
for which $x,y \in \{1, \dots, 20\}$.
Initially, each of the $400$ sites is unoccupied.
Amy and Ben take turns placing stones on unoccupied sites,
with Amy going first;
Amy has the additional restriction that no two of her stones
may be at a distance equal to $\sqrt5$.
They stop once either player cannot move.
Find the greatest $K$ such that Amy can ensure that
she places at least $K$ stones.

Solution:
The answer is $K = 100$.

First, we show Amy can always place at least $100$ stones.
Indeed, treat the problem as a grid with checkerboard coloring.
Then Amy can choose to always play on one of the $200$ black squares.
In this way, she can guarantee half the black squares,
i.e.\ she can get $1/2 \cdot 200 = 100$ stones.

Second, we show Ben can prevent Amy from placing more than $100$ stones.
Divide into several $4 \times 4$ squares and then further partition
each $4 \times 4$ squares as shown in the grid below.
$
[
{cccc}
1 & 2 & 3 & 4 \\
3 & 4 & 1 & 2 \\
2 & 1 & 4 & 3 \\
4 & 3 & 2 & 1

]
$
The squares with each label form $4$-cycles by knight jumps.
For each such cycle, whenever Amy plays in the cycle,
Ben plays in the opposite point of the cycle,
preventing Amy from playing any more stones in that original cycle.
Hence Amy can play at most in $1/4$ of the stones, as desired.


Let $a_1$, $a_2$, \dots\ be an infinite sequence of positive integers,
and $N$ a positive integer.
Suppose that for all integers $n \ge N$, the expression
$ \frac{a_1}{a_2} + \frac{a_2}{a_3} + \dots
+ \frac{a_{n-1}}{a_n} + \frac{a_n}{a_1} $
is an integer.
Prove that $(a_n)$ is eventually constant.

Solution:
The condition implies that the difference
$ S(n) = \frac{a_{n+1} - a_n}{a_1} + \frac{a_n}{a_{n+1}} $
is an integer for all $n > N$.
We proceed by $p$-adic valuation only henceforth;
fix a prime $p$.
Then analyzing the $\nu_p$, we immediately get that for $n > N$:

If $\nu_p(a_n) < \nu_p(a_{n+1})$, then $\nu_p(a_{n+1}) = \nu_p(a_1)$.
If $\nu_p(a_n) = \nu_p(a_{n+1})$, no conclusion.
If $\nu_p(a_n) > \nu_p(a_{n+1})$,
then $\nu_p(a_{n+1}) \ge \nu_p(a_1)$.

In other words:

Let $p$ be a prime. Consider the sequence
$\nu_p(a_{N+1})$, $\nu_p(a_{N+2})$, \dots.
Then either:

We have $\nu_p(a_{N+1}) \ge \nu_p(a_{N+2}) \ge \dots$
and so on, i.e.\ the sequence is weakly decreasing immediately; or
For some index $K > N$ we have
$\nu_p(a_K) < \nu_p(a_{K+1}) = \nu_p(a_{K+2}) = \dots = \nu_p(a_1)$,
i.e.\ the sequence ``jumps'' to $\nu_p(a_1)$
at some point and then stays there forever after.
Note this requires $\nu_p(a_1) > 0$.

A cartoon of the situation is drawn below.
[Figure omitted]

As only finitely many primes $p$ divide $a_1$,
after some time $\nu_p(a_n)$ is fixed for all such $p \mid a_1$.
Afterwards, the sequence satisfies $a_{n+1} \mid a_n$ for each $n$,
and thus must be eventually constant.

This solution is almost completely $p$-adic,
in the sense that I think a similar result
holds if one replaces $a_n \in \ZZ$
by $a_n \in \ZZ_p$ for any particular prime $p$.
In other words, the primes almost do not talk to each other.

There is one caveat: if $x_n$ is an integer sequence
such that $\nu_p(x_n)$ is eventually constant for each prime
then $x_n$ may not be constant.
For example, take $x_n$ to be the $n$th prime!
That's why in the first claim (applied to co-finitely many of the primes),
we need the stronger non-decreasing condition,
rather than just eventually constant.

An alternative approach is to show that, when the fractions $a_n / a_1$
is written in simplest form for $n = N+1, N+2, \dots$,
the numerator and denominator are both weakly decreasing.
Hence it must eventually be constant; in which case it equals $\frac11$.


A convex quadrilateral $ABCD$ satisfies $AB \cdot CD = BC \cdot DA$.
Point $X$ lies inside $ABCD$ so that
$ \angle XAB=\angle XCD \quad \text{ and } \quad \angle XBC=\angle XDA. $
Prove that $\angle BXA + \angle DXC=180\dg$.

Solution:
We present two solutions by inversion.
The first is the official one.
The second is a solution via inversion, completed by USA5 Michael Ren.

Official solution by inversion.:
In what follows a convex quadrilateral is called
quasi-harmonic if $AB \cdot CD = BC \cdot DA$.

A quasi-harmonic quadrilateral is determined
up to similarity by its angles.

Do some inequalities.

This could be expected by degrees of freedom;
a quadrilateral has four degrees of freedom up to similarity;
the pseudo-harmonic condition is one
while the measures of angles $\angle A$, $\angle B$, $\angle C$, $\angle D$
(summing to $360\dg$) provide three degrees of freedom.
(Note that the point $X$ plays no role in this comment.)

Performing an inversion at $X$, one obtains a
second quasi-harmonic quadrilateral
$A^\ast B^\ast C^\ast D^\ast$ which has the same angles
as the original one, $\angle D^\ast = \angle A$,
$\angle A^\ast = \angle B$, and so on.
Thus by the claim we obtain similarity
$ D^\ast A^\ast B^\ast C^\ast \sim ABCD. $
If one then maps $D^\ast A^\ast B^\ast C^\ast$,
onto $ABCD$, the image of $X^\ast$
becomes a point isogonally conjugate to $X$.
In other words, $X$ has an isogonal conjugate in $ABCD$.

It is well-known that this is equivalent to
$\angle BXA + \angle DXC = 180\dg$,
for example by inscribing an ellipse with foci $X$ and $X^\ast$.

Second solution: ``rhombus inversion'', by Michael Ren.:
Since
$ \frac{AB}{AD} = \frac{CB}{CD} $
and
$ \frac{BA}{BC} = \frac{DA}{DC} $
it follows that $B$ and $D$ lie on an Apollonian circle $\omega_{AC}$
through $A$ and $C$,
while $A$ and $C$ lie on an Apollonian circle $\omega_{BD}$
through $B$ and $D$.
We let these two circles intersect at a point $P$ inside $ABCD$.

The main idea is then to
perform an inversion about $P$ with radius $1$.
We obtain:

The image of $ABCD$ is a rhombus.

By the inversion distance formula, we have
$ \frac{1}{A'B'} = \frac{PA}{AB} \cdot PB = \frac{PC}{BC} \cdot PB = \frac{1}{B'C'} $
and so $A'B' = B'C'$.
In a similar way, we derive $B'C' = C'D' = D'A'$,
so the image is a rhombus as claimed.

Let us now translate the angle conditions.
We were given that $∠ XAB = ∠ XCD$, but

∠ XAB &= ∠ XAP + ∠ PAB = ∠ PX'A' + ∠ A'B'P \\
∠ XCD &= ∠ XCP + ∠ PCD = ∠ PX'C' + ∠ C'D'P
\intertext{so subtracting these gives}
∠ A'X'C' &= ∠ A'B'P + ∠ PD'C' = ∠ (A'B', B'P) + ∠ (PD', C'D') \\
&= ∠ (A'B', B'P) + ∠ (PD', A'B') = ∠ D' P B'. \tag{1}

since $A'B' \parallel C'D'$.
Similarly, we obtain
$ ∠ B'X'D' = ∠ A'PC' \tag{2}. $
We now translate the desired condition.
Since

∠ AXB &= ∠ AXP + ∠ PXB = ∠ PA'X' + ∠ X'B'P \\
∠ CXD &= ∠ CXP + ∠ PXD = ∠ PC'X' + ∠ X'DP'

we compute

∠ AXB + ∠ CXD &= (∠ PA'X' + ∠ X'B'P) + (∠ PC'X' + ∠ X'D'P) \\
&= -[ ( ∠ A'X'P + ∠ X'PA' )
+ ( ∠ PX'B' + ∠ B'PX' ) ] \\
&\quad- [ ( ∠ C'X'P + ∠ X'PC' )
+ ( ∠ PX'D' + ∠ D'PX' ) ] \\
&= [ ∠ PX'A' + ∠ BX'P + ∠ PX'C' + ∠ D'X'P ] \\
&\quad+ [ ∠ A'PX' + ∠ X'PB' + ∠ C'PX' + ∠ X'PD' ] \\
&= ∠ A'PB' + ∠ C'PD' + ∠ B'X'C + ∠ D'X'A

and we wish to show this is equal to zero, i.e.\
the desired becomes
$ ∠ A'PB' + ∠ C'PD' + ∠ B'X'C + ∠ D'X'A = 0. \tag{3} $
In other words, the problem is to show (1) and (2) implies (3).

Henceforth drop apostrophes.
Here is the inverted diagram (with apostrophes dropped).
[Figure omitted]

Let $Q$ denote the reflection of $P$
and let $Y$ denote the second intersection of $(BQC)$ and $(AQD)$.
Then

-∠ AXC &= -∠ DPB = ∠ BQD = ∠ BQY + ∠ YQD = ∠ BCY + ∠ YAD \\
&= ∠(BC,CY) + ∠(YA,AD) = ∠ YCA = -∠ AYC.

Hence $XACY$ is concyclic; similarly $XBDY$ is concyclic.

$X \neq Y$.

To see this: Work pre-inversion assuming $AB < AC$.
Then $Q$ was the center of $\omega_{BD}$.
If $T$ was the second intersection of $BA$ with $(QBC)$,
then $QB = QD = QT = \sqrt{QA \cdot QC}$, by shooting lemma.
Since $\angle BAD < 180\dg$,
it follows $(QBCY)$ encloses $ABCD$ (pre-inversion).
(This part is where the hypothesis that
$ABCD$ is convex with $X$ inside is used.)

Finally, we do an angle chase to finish:

∠ DXA &= ∠ DXY + ∠ YXA = ∠ DBY + ∠ YCA \\
&= ∠ (DB, YB) + ∠ (CY, CA) = ∠ CYB + 90\dg \\
&= ∠ CQB + 90\dg = -∠ APB + 90\dg \tag{4}.

Similarly,
$ ∠ BXC = ∠ DPC + 90\dg. \tag{5} $

Summing (4) and (5) gives (3).

A difficult part of the problem in many solutions
is that the conclusion is false in the directed sense,
if the point $X$ is allowed to lie outside the quadrilateral.
We are saved in the first solution because the equivalence
of the isogonal conjugation requires $X$ inside the quadrilateral.
On the other hand, in the second solution,
the issue appears in the presence of the second point $Y$.


Solve over $\ZZ$ the functional equation
$f(2a) + 2f(b) = f(f(a+b))$.

Solution:
Notice that $f(x) \equiv 0$ or $f(x) \equiv 2x+k$ work
and are clearly the only linear solutions.
We now prove all solutions are linear.

Let $P(a,b)$ be the assertion.

For each $x \in \ZZ$ we have $f(2x) = 2f(x) - f(0)$.

Compare $P(0,x)$ and $P(x,0)$.

Now, $P(a,b)$ and $P(0,a+b)$ give

f(f(a+b)) &= f(2a) + 2f(b) = f(0) + 2f(a+b) \\
\implies [2f(a) - f(0)] + 2f(b) &= f(0) + 2f(a+b) \\
\implies ( f(a)-f(0) ) + ( f(b)-f(0) )
&= ( f(a+b)-f(0) ).

Thus the map $x \mapsto f(x) - f(0)$ is additive,
therefore linear.

The same proof works on the functional equation
$ f(2a) + 2f(b) = g(a+b) $
where $g$ is an arbitrary function (it implies that $f$ is linear).


In triangle $ABC$ point $A_1$ lies on side $BC$
and point $B_1$ lies on side $AC$.
Let $P$ and $Q$ be points on segments $AA_1$ and $BB_1$,
respectively, such that $PQ \parallel AB$.
Point $P_1$ is chosen on ray $PB_1$ beyond $B_1$
such that $\angle PP_1C = \angle BAC$.
Point $Q_1$ is chosen on ray $QA_1$ beyond $A_1$
such that $\angle CQ_1Q = \angle CBA$.
Prove that points $P_1$, $Q_1$, $P$, $Q$ are cyclic.

Solution:
We present two solutions.

First solution by bary (Evan Chen).:
Let $PB_1$ and $QA_1$ meet line $AB$ at $X$ and $Y$.
Since $XY \parallel PQ$ it is equivalent
to show $P_1XYQ_1$ is cyclic (Reim's theorem).

Note the angle condition implies $P_1CXA$ and $Q_1CYB$ are cyclic.

Letting $T = PX \cap QY$ (possibly at infinity),
it suffices to show that the
radical axis of $\triangle CXA$ and $\triangle CYB$ passes through $T$,
because that would imply $P_1XYQ_1$ is cyclic
(by power of a point when $T$ is Euclidean,
and because it is an isosceles trapezoid if $T$ is at infinity).

[Figure omitted]

To this end we use barycentric coordinates on $\triangle ABC$.
We begin by writing
$ P = (u+t : s : r), \quad Q = (t : u+s : r) $
from which it follows that
$A_1 = (0 : s : r)$ and $B_1 = (t : 0 : r)$.

Next, compute $X = (
\det [ u+t & r \\ t & r ]
: \det [ s & r \\ 0 & r ]
: 0 ) = (u : s : 0)$.
Similarly, $Y = (t : u : 0)$.
So we have computed all points.

Line $B_1X$ has equation
$-rs \cdot x + ru \cdot y + st \cdot z = 0$,
while line $C_1 Y$ has equation
$ru \cdot x - rt \cdot y + st \cdot z = 0$.

Line $B_1X$ is $0 = \det(B_1, X, -)
= \det [
t & 0 & r \\
u & s & 0 \\
x & y & z
]$.
Line $C_1Y$ is analogous.

The radical axis $(u+t) y - (u+s) x = 0$.

Circle $(AXC)$ is given by
$-a^2yz - b^2zx - c^2xy + (x+y+z) \cdot \frac{c^2 \cdot u}{u+s} y = 0$.
Similarly, circle $(BYC)$ has equation
$-a^2yz - b^2zx - c^2xy + (x+y+z) \cdot \frac{c^2 \cdot u}{u+t} x = 0$.
Subtracting gives the radical axis.

Finally, to see these three lines are concurrent, we now compute

\det
-rs & ru & st \\
ru & -rt & st \\
-(u+s) & u+t & 0

&= rst [ [u(u+t)-t(u+s)] + [s(u+t)-u(u+s)] ] \\
&= rst [ (u^2-st) + (st-u^2) ] = 0.

This completes the proof.

Second official solution by tricky angle chasing.:
Let lines $AA_1$ and $BB_1$ meet at the circumcircle of $\triangle ABC$
again at points $A_2$ and $B_2$.
By Reim's theorem, $PQA_2B_2$ are cyclic.
[Figure omitted]

The points $P$, $Q$, $A_2$, $Q_1$ are cyclic.
Similarly the points $P$, $Q$, $B_2$, $P_1$ are cyclic.

Note that $CA_1A_2Q_1$ is cyclic since
$∠ CQ_1A_1 = ∠ CQ_1Q = ∠ CBA = ∠ CA_2A = ∠ CA_2A_1$.
Then $∠ QQ_1A_2 = ∠ A_1Q_1A_2 = ∠ A_1 C A_2
= ∠ B C A_2 = ∠ B A A_2 = ∠ Q P A_2$.

This claim obviously solves the problem.


A social network has $2019$ users, some pairs of which are friends (friendship is symmetric).
If $A$, $B$, $C$ are three users such that $AB$ are friends and $AC$ are friends but $BC$ is not,
then the administrator may perform the following operation:
change the friendships such that $BC$ are friends, but $AB$ and $AC$ are no longer friends.

Initially, $1009$ users have $1010$ friends and $1010$ users have $1009$ friends.
Prove that the administrator can make a sequence of operations
such that all users have at most $1$ friend.

Solution:
We take the obvious graph formulation
and call the move a toggle.

Let $G$ be a connected graph.
Then one can toggle $G$ without disconnecting the graph,
unless $G$ is a clique, a cycle, or a tree.

Assume $G$ is connected and not a tree, so it has a cycle.
Take the smallest cycle $C$; by hypothesis $C \neq G$.

If $C$ is not a triangle (equivalently, $G$ is triangle-free),
then let $b \notin C$ be a vertex adjacent to $C$, say at $a$.
Take a vertex $c$ of the cycle adjacent to $a$ (hence not to $b$).
Then we can toggle $abc$.

Now assume there exists a triangle; let $K$ be the maximal clique.
By hypothesis, $K \neq G$.
We take an edge $e = ab$ dangling off the clique,
with $a \in K$ and $b \notin K$.
Note some vertex $c$ of $K$ is not adjacent to $b$; now toggle $abc$.

Back to the original problem;
let $G_{\text{imo}}$ be the given graph.
The point is that we can apply toggles (by the claim) repeatedly,
without disconnecting the graph, until we get a tree.
This is because

$G_{\text{imo}}$ is connected,
since any two vertices which are not adjacent
have a common neighbor by pigeonhole
($1009 + 1009 + 2 > 2019$).
$G_{\text{imo}}$ cannot become a cycle,
because it initially has an odd-degree vertex,
and toggles preserve parity of degree!
$G_{\text{imo}}$ is obviously not a clique initially
(and hence not afterwards).

So, we can eventually get $G_{\text{imo}}$ to be a tree.

Once $G_{\text{imo}}$ is a tree the problem follows by repeatedly applying
toggles arbitrarily until no more are possible;
the graph (although now disconnected) remains acyclic
(in particular having no triangles)
and therefore can only terminate in the desired situation.

The above proof in fact shows the following better result:

The task is possible if and only if
$G_{\text{imo}}$ is a connected graph which is not a clique
and has any vertex of odd degree.

The ``only if'' follows from the observation
that toggles preserve parity of degree.

Thus the given condition about the degrees of vertices
being $1009$ and $1010$ is largely a red herring;
it's a somewhat strange way of masking the correct and more natural
both-sufficient-and-necessary condition.


Solve over positive integers the equation
$ k! = \prod_{i=0}^{n-1} (2^n-2^i) = (2^n-1)(2^n-2)(2^n-4) \dots (2^n-2^{n-1}). $

Solution:
The answer is $(n,k) =(1,1)$ and $(n,k) = (2,3)$ which work.

Let $A = \prod_i (2^n-2^k)$, and assume $A = k!$ for some $k \ge 3$.
Recall by exponent lifting that
$ \nu_3(2^t-1) =
0 & t \text{ odd} \\
1 + \nu_3(t/2) & t \text{ even}.
$
Thus, we can compute

k > \nu_2(k!) &= \nu_2(A) = 1 + 2 + \dots + (n-1) = \frac{n(n-1)}{2} \\
\left\lfloor \frac k3 \right\rfloor
\le \nu_3(k!) &= \nu_3(A) = \left\lfloor \frac n2 \right\rfloor
+ \left\lfloor \frac n6 \right\rfloor + \dots < \frac 34n.

where the first inequality follows by Legendre's formula $\nu_2(k!) = k - s_2(k)$.

In this way, we get
$ \frac 94 n + 3 > k > \frac{n(n-1)}{2} $
which means $n \le 6$; a manual check then shows the
solutions we claimed earlier are the only ones.

An amusing corollary of the problem pointed out in the shortlist
is that the symmetric group $S_k$ cannot be isomorphic to the group $\GL_n(\FF_2)$
unless $(n,k) = (1,1)$ or $(n,k) = (2,3)$, which indeed produce isomorphisms.


Let $n$ be a positive integer.
Harry has $n$ coins lined up on his desk, which can show either heads or tails.
He does the following operation: if there are $k$ coins which show heads and $k > 0$,
then he flips the $k$th coin over; otherwise he stops the process.
(For example, the process starting with $THT$ would be
$THT \to HHT \to HTT \to TTT$, which takes three steps.)

Prove the process will always terminate, and determine the average number of steps
this takes over all $2^n$ configurations.

Solution:
The answer is $ E_n = 1/2 (1 + \dots + n) = \frac14 n(n+1) $
which is finite.

We'll represent the operation by a
directed graph $G_n$ on vertices $\{0,1\}^n$
(each string points to its successor)
with $1$ corresponding to heads and $0$ corresponding to tails.
For $b \in \{0,1\}$ we let $\ol b = 1-b$,
and denote binary strings as a sequence of $n$ symbols.

The main claim is that $G_n$
can be described explicitly in terms of $G_{n-1}$:

We take two copies $X$ and $Y$ of $G_{n-1}$.

In $X$, we take each string of length $n-1$
and just append a $0$ to it. In symbols,
we replace $s_1 \dots s_{n-1} \mapsto s_1 \dots s_{n-1} 0$.

In $Y$, we toggle every bit, then reverse the order,
and then append a $1$ to it.
In symbols, we replace
$s_1 \dots s_{n-1} \mapsto \ol s_{n-1} \ol s_{n-2} \dots \ol s_{1} 1$.

Finally, we add one new edge from $Y$ to $X$ by
$11 \dots 1 \to 11\dots110$.

An illustration of $G_4$ is given below.
[Figure omitted]

To prove this claim, we need only show
the arrows of this directed graph remain valid.
The graph $X$ is correct as a subgraph of $G_n$,
since the extra $0$ makes no difference.
As for $Y$, note that if $s = s_1 \dots s_{n-1}$ had $k$ ones,
then the modified string has $(n-1-k)+1 = n-k$ ones, ergo
$\ol s_{n-1} \dots \ol s_1 1
\mapsto \ol s_{n-1} \dots \ol s_{k+1} s_k \ol s_{k-1} \dots \ol s_1 1$
which is what we wanted.
Finally, the one edge from $Y$ to $X$ is obviously correct.

To finish, let $E_n$ denote the desired expected value.
Since $1 \dots 1$ takes $n$ steps to finish we have
$ E_n = 1/2 [ E_{n-1} + (E_{n-1}+n) ] $
based on cases on whether the chosen string is in $X$ or $Y$ or not.
By induction, we have $E_n = 1/2 (1 + \dots + n) = \frac14 n(n+1)$,
as desired.

Actually, the following is true:
if the indices of the $1$'s are $1 \le i_1 < \dots < i_\ell \le n$,
then the number of operations required is
$ 2(i_1 + \dots + i_\ell) - \ell^2. $
This problem also has an interpretation as a Turing machine:
the head starts at a position on the tape (the binary string).
If it sees a $1$, it changes the cell to a $0$ and moves left;
if it sees a $0$, it changes the cell to a $1$ and moves right.


Let $ABC$ be a triangle with incenter $I$ and incircle $\omega$.
Let $D$, $E$, $F$ denote the tangency points of $\omega$ with $BC$, $CA$, $AB$.
The line through $D$ perpendicular to $EF$ meets $\omega$ again at $R$ (other than $D$),
and line $AR$ meets $\omega$ again at $P$ (other than $R$).
Suppose the circumcircles of $\triangle PCE$ and $\triangle PBF$ meet again at $Q$ (other than $P$).
Prove that lines $DI$ and $PQ$ meet on the external $\angle A$-bisector.

Solution:
We present five solutions.

First solution by complex numbers (Evan Chen, with Yang Liu).:
We use complex numbers with $D=x$, $E=y$, $F=z$.
[Figure omitted]

Then $A = \frac{2yz}{y+z}$,
$R = \frac{-yz}{x}$ and so
$ P = \frac{A-R}{1-RA}
= \frac{\frac{2yz}{y+z} + \frac{yz}{x}}
{1 + \frac{yz}{x} \cdot \frac{2}{y+z}}
= \frac{yz(2x+y+z)}{2yz+x(y+z)}. $
We now compute

O_B &= \det
P & P \ol P & 1 \\
F & F \ol F & 1 \\
B & B \ol B & 1

\div \det
P & \ol P & 1 \\
F & \ol F & 1 \\
B & \ol B & 1

= \det
P & 1 & 1 \\
z & 1 & 1 \\
\frac{2xz}{x+z} & \frac{4xz}{(x+z)^2} & 1

\div \det
P & 1/P & 1 \\
z & 1/z & 1 \\
\frac{2xz}{x+z} & \frac{2}{x+z} & 1
\\
&= \frac{1}{x+z} \det
P & 0 & 1 \\
z & 0 & 1 \\
2xz(x+z) & -(x-z)^2 & (x+z)^2

\div \det
P & 1/P & 1 \\
z & 1/z & 1 \\
2xz & 2 & x+z
\\
&= \frac{(x-z)^2}{x+z} \cdot \frac{P-z}{(x+z)(P/z-z/P)+2z-2x + \frac{2xz}{P}-2P} \\
&= \frac{(x-z)^2}{x+z} \cdot \frac{P-z}{
(\frac xz-1) P - 2(x-z) + (xz-z^2) \frac 1P } \\
&= \frac{x-z}{x+z} \cdot \frac{P-z}{P/z + z/P - 2}
= \frac{x-z}{x+z} \cdot \frac{P-z}{\frac{(P-z)^2}{Pz}}
= \frac{x-z}{x+z} \cdot \frac{1}{\frac 1z - \frac 1P} \\
&= \frac{x-z}{x+z} \cdot \frac{y(2x+y+z)}{y(2x+y+z) - (2yz+xy+xz)}
= \frac{x-z}{x+z} \cdot \frac{yz(2x+y+z)}{xy+y^2-yz-xz} \\
&= \frac{x-z}{x+z} \cdot \frac{yz(2x+y+z)}{(y-z)(x+y)}.

Similarly
$ O_C = \frac{x-y}{x+y} \cdot \frac{yz(2x+y+z)}{(z-y)(x+z)}. $
Therefore, subtraction gives
$ O_B-O_C
=
\frac{yz(2x+y+z)}{(x+y)(x+z)(y-z)}
[ (x-z) + (x-y) ]
= \frac{yz(2x+y+z)(2x-y-z)}{(x+y)(x+z)(z-y)}.
$
It remains to compute $T$.
Since $T \in ID$ we have $t/x \in \RR$
so $\ol t = t/x^2$.
Also,

\frac{t - \frac{2yz}{y+z}}{y+z} \in i \RR
\implies 0 &= \frac{t-\frac{2yz}{y+z}}{y+z}
+ \frac{\frac{t}{x^2}-\frac{2}{y+z}}{\frac1y+\frac1z} \\
&= \frac{1+\frac{yz}{x^2}}{y+z} t - \frac{2yz}{(y+z)^2} - \frac{2yz}{(y+z)^2} \\
\implies t &= \frac{x^2}{x^2+yz} \cdot \frac{4yz}{y+z}

Thus

P-T &= \frac{yz(2x+y+z)}{2yz+x(y+z)} - \frac{4x^2yz}{(x^2+yz)(y+z)} \\
&= yz \cdot \frac{(2x+y+z)(x^2+yz)(y+z) - 4x^2(2yz+xy+xz)}
{(y+z)(x^2+yz)(2yz+xy+xz)} \\
&= -yz \cdot \frac{(2x-y-z)(x^2y+x^2z+4xyz+y^2z+yz^2)}
{(y+z)(x^2+yz)(2yz+xy+xz)}.

This gives $PT \perp O_B O_C$ as needed.

Second solution by tethered moving points, with optimization (Evan Chen).:
Fix $\triangle DEF$ and $\omega$, with $B = DD \cap FF$
and $C = DD \cap EE$.
We consider a variable point $M$ on $\omega$
and let $X$, $Y$ be on $EF$ with
$CY \cap \parallel ME$, $BX \cap \parallel MF$.
We define $W = CY \cap BX$.
Also, let line $MW$ meet $\omega$ again at $V$.

[Figure omitted]

[Angle chasing]
Pentagons $CVWXE$ and $BVWYF$ are cyclic.

By $∠ EVW = ∠ EVM = ∠ EFM = ∠ CEM = ∠ ECW$
and $∠ EXW = ∠ EFM = ∠ CEM = ∠ ECW$.

Let $N = DM \cap EF$ and $R'$ be the $D$-antipode on $\omega$.

[Black magic]
The points $V$, $N$, $R'$ are collinear.

We use tethered moving points with $\triangle DEF$ fixed.

Obviously the map $\omega \mapsto EF \mapsto \omega$ by $M \mapsto N \mapsto R'N \cap \omega$ is projective.
Also, the map $\omega \mapsto EF \mapsto \omega$ by $M \mapsto X \mapsto V$ is also projective
(the first by projection to the line at infinity at back;
the second say by inversion at $E$).

So it suffices to check for three points.
When $M=E$ we get $N=E$ so $R'N \cap \omega = E$, while $W=E$ and thus $V=E$.
The case $M=F$ is similar.
Finally, if $M = R'$, then $W$ is the center of $\omega$ and so $V = R'N \cap EF = D$.

We now address the original problem by specializing $M$:
choose it so that $N$ is the midpoint of $EF$.
Let $M' = DA \cap (DEF)$.

After this specialization, $V=P$ and $W=Q$.

Thus $RR'$ and $MM'$ are parallel to $EF$.
From $(EF;PR) = -1 = (EF;N\infty) \overset{R'}{=} (EF;NV)$,
we derive that $P=V$ and $Q=R$, proving (i).

Finally, the concurrence requested follows by Pascal theorem on $M'MDR'PR$.

Third solution by power of a point linearity (Luke Robitaille).:

Let us define
$ f(\bullet) = \opname{Pow}(\bullet, (CPE))
- \opname{Pow}(\bullet, (BPF)) $
which is a linear function from the plane to $\RR$.

Define $W = BA \cap PE$, $V = AC \cap PF$.
Also, let $W_1 = ER \cap AB$, $V_1 = FR \cap AC$.
Note that
$ -1 = (PR;EF) \overset{E}{=} (WA; W_1F) $
and similarly $(VA; V_1E) = -1$.

We have

f(F) &= \frac{|EF| \cdot (s-c) \sin C/2}{\sin B/2} \\
f(E) &= -\frac{|EF| \cdot (s-b) \sin B/2}{\sin C/2}.

We have
$ f(W) = WF^2 - WB \cdot WF = WF \cdot BF $
where lengths are directed.
Next,

f(F) &= \frac{AF \cdot f(W) + FW \cdot f(A)}{AW} \\
&= \frac{AF \cdot WF \cdot BF + FW \cdot
( AE \cdot AC - AF \cdot AB )}{AW} \\
&= \frac{WF(AF \cdot BF + AF \cdot AB) + FW \cdot AE \cdot AC}{AW} \\
&= \frac{WF \cdot AF^2 - WF \cdot AE \cdot AC}{AW}
= \frac{WF}{AW} \cdot (AE^2 - AE \cdot AC) \\
&= \frac{WF}{AW} \cdot AE \cdot CE
= -\frac{W_1F}{AW_1} \cdot AE \cdot CE.

Since $\triangle DEF$ is acute,
the point $R$ lies inside $\triangle AEF$.
Thus $W_1$ lies inside segment $AF$
and the ratio $\frac{W_1F}{AW_1}$ is positive.
We now determine its value: by the ratio lemma

\frac{|W_1F|}{|AW_1|}
&= \frac{|EF| \sin \angle W_1 E F}{|AE| \sin \angle A E W_1} \\
&= \frac{|EF| \sin \angle REF}{|AE| \sin \angle AER} \\
&= \frac{|EF| \sin \angle RDF}{|AE| \sin \angle EDR} \\
&= \frac{|EF| \sin C/2}{|AE| \sin B/2}.

Also, we have $AE \cdot CE < 0$ since $E$ lies inside $AC$.
Hence
$ f(F) = -\frac{|EF| \sin C/2}{|AE| \sin B/2}.
\cdot AE \cdot CE
= |EF| \cdot \frac{|CE| \sin B/2}{\sin C/2}
= |EF| \cdot \frac{(s-c) \sin B/2}{\sin C/2}. $
The calculation for $f(E)$ is similar,
(noting the sign flips since $f$ is anti-symmetric
in terms of $B$ and $C$).

Let $Z \in DI$ with $\angle ZAI = 90\dg$ be the point requested in the problem now.
Our goal is to show $f(Z) = 0$.
We assume WLOG that $AB < AC$, so $\frac{ZA}{EF} > 0$.
Then

|ZA| &= |AI| \cdot \tan \angle AIZ \\
&= |AI| \cdot \tan \angle(AI, DI) \\
&= \frac{s-a}{\cos A/2} \cdot \tan (BC, EF) \\
&= \frac{s-a}{\cos A/2} \tan (B/2-C/2).

To this end we compute

f(Z) &= f(A) + [ f(Z) - f(A) ]
= f(A) + \frac{ZA}{EF} [ f(E)-f(F) ] \\
&= f(A) - \frac{ZA}{EF}
[ \frac{|EF| \cdot (s-b) \sin B/2}{\sin C/2}
+ \frac{|EF| \cdot (s-c) \sin C/2}{\sin B/2} ] \\
&= f(A) - |ZA| [ \frac{(s-b) \sin B/2}{\sin C/2}
+ \frac{(s-c) \sin C/2}{\sin B/2} ] \\
&= [ b(s-a) - c(s-a) ]
- |ZA| [ \frac{(s-b) \sin B/2}{\sin C/2}
+ \frac{(s-c) \sin C/2}{\sin B/2} ] \\
&= (b-c)(s-a) - \frac{s-a}{\cos A/2} \tan (B/2-C/2)
[ \frac{(s-b) \sin B/2}{\sin C/2}
+ \frac{(s-c) \sin C/2}{\sin B/2} ].

Dividing out,

\frac{f(Z)}{s-a}
&= (b-c) - \frac{1}{\cos A/2} \tan (B/2-C/2)
[ \frac{r \cos B/2}{\sin C/2}
+ \frac{r \cos C/2}{\sin B/2} ] \\
&= (b-c) - \frac{r \tan(B/2-C/2)}{\cos A/2}
\cdot \frac{\cos B/2 \sin B/2 + \cos C/2 \sin C/2}
{\sin C/2 \sin B/2} \\
&= (b-c) - \frac{r \tan(B/2-C/2)}{\cos A/2}
\cdot \frac{\sin B + \sin C}
{2\sin C/2 \sin B/2} \\
&= (b-c) - \frac{r \tan(B/2-C/2)}{\cos A/2}
\cdot \frac{\sin(B/2+C/2)\cos(B/2-C/2)}
{\sin C/2 \sin B/2} \\
&= (b-c) - r \frac{\sin(B/2-C/2)}{\sin B/2 \sin C/2} \\
&= (b-c) - r(\cot C/2 - \cot B/2)
= (b-c) - ( (s-c) - (s-b) ) = 0.

Fourth solution by incircle inversion (USA IMO live stream, led by Andrew Gu).:
Let $T$ be the intersection of line $DI$ and the external $\angle A$-bisector.
Also, let $G$ be the antipode of $D$ on $\omega$.

We perform inversion around $\omega$, using $\bullet^\ast$ for the inverse.
Then $\triangle A^\ast B^\ast C^\ast$ is the medial triangle of $\triangle DEF$,
and $T^\ast$ is the foot from $A^\ast$ on to $DI$.
If we denote $Q^\ast$ as the second intersection
of $(PC^\ast E)$ and $(PB^\ast F)$,
then the goal is to show that $Q^\ast$ lies on $(PIT^\ast)$.

[Figure omitted]

Points $Q^\ast$, $B^\ast$, $C^\ast$ are collinear.

$∠ PQ^\ast C^\ast = ∠ PEC^\ast = ∠ PED = ∠ PFD
= ∠ PFB^\ast = ∠ PQ^\ast B^\ast$.

[cf Brazil 2011/5]
Points $P$, $A^\ast$, $G$ are collinear.

Project harmonic quadrilateral $PERF$ through $G$,
noting $GR \parallel EF$.

Denote by $M$ the center of parallelogram $DC^\ast A^\ast B^\ast$.
Note that it is the center of the circle with
diameter $DA^\ast$, which passes through $P$ and $T^\ast$.
Also, $MI \parallel PA^\ast G$.

Points $P$, $M$, $I$, $T^\ast$ are cyclic.

$∠ IT^\ast P = ∠ D T^\ast P = ∠ DA^\ast P
= ∠ M A^\ast P = ∠ A^\ast P M = ∠ IMP$.

Points $P$, $M$, $I$, $Q^\ast$ are cyclic.

$∠ MQ^\ast P = ∠ C^\ast Q^\ast P = ∠ C^\ast E P
= ∠ D E P = ∠ D G P = ∠ GPI = ∠ MIP$.

Fifth solution by double inversion (Brandon Wang, Luke Robitaille, Michael Ren, Evan Chen).:
We outline one final approach.
After inverting about $\omega$ as in the previous approach,
we then apply another inversion around $P$.
Dropping the apostrophes/stars/etc now one can check
that the problem we arrive at becomes the following.

[Doubly inverted problem]
In $\triangle PEF$, the $P$-symmedian meets $EF$
and $(PEF)$ at $K$, $L$.
Let $D \in EF$ with $\angle DPK = 90\dg$,
and let $T$ be the foot from $K$ to $DL$.
Denote by $I$ the reflection of $P$ about $EF$.
Finally, let $PDNE$ and $PDMF$ be cyclic harmonic quadrilaterals.
Then lines $EN$, $MF$, $TI$, are concurrent.

The proof proceeds in three steps.
Suppose the line through $L$ perpendicular to $EF$
meets $EF$ at $W$ and $(PEF)$ at $Z$.
[Figure omitted]

Since $∠ ZEP = ∠ WLP = ∠ WDP$,
it follows $ZE$ is tangent to $(PDNE)$.
Similarly, $ZF$ is tangent to $(PDMF)$.
$\triangle WTP$ is the orthic triangle of $\triangle DKL$,
so $WD$ bisects $\angle PWT$ and $WTI$ collinear.
$-1 = E(PN;DZ) = F(PM;DZ) = W(PI;DZ)$, so
$EN$, $FM$, $WI$ meet on $PZ$.


Consider the convex quadrilateral $ABCD$.
The point $P$ is in the interior of $ABCD$.
The following ratio equalities hold:
$\angle PAD:\angle PBA:\angle DPA
= 1:2:3
= \angle CBP:\angle BAP:\angle BPC.$
Prove that the following three lines meet in a point:
the internal bisectors of angles $\angle ADP$ and $\angle PCB$
and the perpendicular bisector of segment $AB$.

Solution:
Let $O$ denote the circumcenter of $\triangle PAB$.
We claim it is the desired concurrency point.
[Figure omitted]
Indeed, $O$ obviously lies on the perpendicular bisector of $AB$.
Now

∠ BCP &= ∠ CBP + ∠ BPC \\
&= 2∠ BAP = ∠ BOP

it follows $BOPC$ are cyclic.
And since $OP = OB$, it follows that $O$ is on
the bisector of $\angle PCB$, as needed.

The angle equality is only used insomuch $\angle BAP$
is the average of $\angle CBP$ and $\angle BPC$,
i.e.\ only $\frac{1+3}{2} = 2$ matters.


Let $a \ge b \ge c \ge d > 0$ be real numbers satisfying $a+b+c+d=1$.
Prove that
$ (a+2b+3c+4d) a^a b^b c^c d^d < 1. $

Solution:
By weighted AM-GM we have
$ a^a b^b c^c d^d \le \sum_{\text{cyc}} \frac{a}{a+b+c+d} \cdot a
= a^2+b^2+c^2+d^2. $
So, it is enough to prove that
$ (a^2+b^2+c^2+d^2)(a+2b+3c+4d) \le 1 = (a+b+c+d)^3. $
Expand both sides to get
$
{cccc}
+a^3 &+ b^2a &+ c^2a & +d^2a \\
+2a^2b &+ 2b^3 &+ 2bc^2 & +2d^2b \\
+3a^2c & + 3b^2c & + 3c^3 & + 3d^2c \\
+4a^2d &+ 4b^2d & + 4c^2d & + 4d^3

<
{cccc}
+a^3 &+ 3b^2a &+ 3c^2a & +3d^2a \\
+3a^2b &+ b^3 &+ 3bc^2 & +3d^2b \\
+3a^2c &+ 3b^2c &+ c^3 &+ 3d^2c \\
+3a^2d &+ 3b^2d &+ 3c^2d &+ d^3 \\
+6abc &+ 6bcd &+ 6cda &+ 6dab.

$
In other words, we need to prove that
$
{cccc}
& && \\
&+ b^3 & & \\
& & +2c^3 & \\
+a^2d &+ b^2d & + c^2d & + 3d^3 \\

<
{cccc}
&+ 2b^2a &+ 2c^2a & +2d^2a \\
+a^2b & &+ bc^2 & +d^2b \\
&&& \\
&&& \\
+6abc &+ 6bcd &+ 6cda &+ 6dab

$

This follows since

2b^2a &\ge b^3 + b^2d \\
2c^2a &\ge 2c^3 \\
2d^2a &\ge 2d^3 \\
a^2b &\ge a^2d \\
bc^2 &\ge c^2d \\
d^2b &\ge d^3

and $6(abc+bcd+cda+dab) > 0$.

Some students complained this problem was ``unfair'' and they couldn't solve it
because they didn't think an IMO problem would be solved only by expansion.
I don't agree with this.
Fedor Petrov provides the following motivational comments
for why the existence of this solution should not be that surprising:

Better to think about mathematics.
You have to bound from above a product $(a+2b+3c+4d)(a^2+b^2+c^2+d^2)$,
the coefficients $1,2,3,4$ are increasing and so play on your side,
so plausibly $(a+b+c+d)^3$ should majorize this term-wise,
you check it and this appears to be true.

He also gave the \href{https://aops.com/community/p18331252}{following advice}:

The general advice is to study mathematics, not olympiad problems in past years.
If the IMO problems set the students and their teachers on this path, I am more than satisfied.


There are $4n$ pebbles of weights $1, 2, 3, \dots, 4n$.
Each pebble is coloured in one of $n$ colours
and there are four pebbles of each colour.
Show that we can arrange the pebbles into two piles
the total weights of both piles are the same,
and each pile contains two pebbles of each colour.

Solution:
The first key idea is the deep fact that
$ 1+4n = 2+(4n-1) = 3+(4n-2) = \dots. $
So, place all four pebbles of the same colour in a box (hence $n$ boxes).
For each $k=1,2,\dots,2n$
we tape a piece of string between pebble $k$ and $4n+1-k$.
To solve the problem, it suffices to paint each string
either blue or green such that each box has two blue strings
and two green strings
(where a string between two pebbles in the same box counts double).
[Figure omitted]

We can therefore rephrase the problem as follows,
if we view boxes as vertices and strings as edges:

Given a $4$-regular multigraph on $n$ vertices
(where self-loops are allowed and have degree $2$),
one can color the edges blue and green
such that each vertex has two blue and two green edges.

Each connected component of the graph can be decomposed
into an Eulerian circuit, since $4$ is even.
A connected component with $k$ vertices has $2k$
edges in its Eulerian circuit,
so we may color the edges in this circuit alternating green and blue.
This may be checked to work.


There is an integer $n > 1$.
There are $n^2$ stations on a slope of a mountain, all at different altitudes.
Each of two cable car companies, $A$ and $B$, operates $k$ cable cars;
each cable car provides a transfer from one of the stations
to a higher one (with no intermediate stops).
The $k$ cable cars of $A$ have $k$ different starting points
and $k$ different finishing points, and a cable car which starts higher also finishes higher.
The same conditions hold for $B$.
We say that two stations are linked by a company if one can start from the lower station
and reach the higher one by using one or more cars of that company
(no other movements between stations are allowed).
Determine the smallest positive integer $k$ for which one can guarantee
that there are two stations that are linked by both companies.

Solution:
Answer: $k = n^2 - n + 1$.

When $k = n^2-n$,
the construction for $n=4$ is shown below which generalizes readily.
(We draw $A$ in red and $B$ in blue.)
[Figure omitted]

To see this is sharp, view $A$ and $B$ as graphs
whose connected components are paths (possibly with $0$ edges;
the direction of these edges is irrelevant).
Now, if $k = n^2-n+1$ it follows that $A$ and $B$
each have exactly $n-1$ connected components.

But in particular some component of $A$ has at least $n+1$ vertices.
This component has two vertices in the same component of $B$, as desired.

The main foothold for this problem is the hypothesis
that the number of stations should be $n^2$ rather than, say, $n$.
This gives a big hint towards finding the construction
which in turn shows how the bound can be computed.

On the other hand, the hypothesis that
``a cable car which starts higher
also finishes higher'' appears to be superfluous.


A deck of $n > 1$ cards is given.
A positive integer is written on each card.
The deck has the property that the arithmetic mean of the
numbers on each pair of cards is also the
geometric mean of the numbers on some collection of one or more cards.
For which $n$ does it follow that the numbers on the cards are all equal?

Solution:
ik (EST)}
.}

The assertion is true for all $n$.

\bigskip

\textbf{Setup (boilerplate).}
Suppose that $a_1$, \dots, $a_n$ satisfy the required properties
but are not all equal.
Let $d = \gcd(a_1, \dots, a_n) > 1$
then replace $a_1$, \dots, $a_n$ by
$\frac{a_1}{d}$, \dots, $\frac{a_n}{d}$.
Hence without loss of generality we may assume
$ \gcd(a_1, a_2, \dots, a_n) = 1. $
WLOG we also assume $ a_1 \ge a_2 \ge \dots \ge a_n. $

\bigskip

\textbf{Main proof.}
As $a_1 \ge 2$, let $p$ be a prime divisor of $a_1$.
Let $k$ be smallest index such that $p \nmid a_k$ (which must exist).
In particular, note that $a_1 \neq a_k$.

Consider the mean $x = \frac{a_1+a_k}{2}$; by assumption,
it equals some geometric mean, hence
$ \sqrt[m]{a_{i_1} \dots a_{i_m}} = \frac{a_1 + a_k}{2} > a_k. $
Since the arithmetic mean is an integer not divisible by $p$,
all the indices $i_1$, $i_2$, \dots, $i_m$
must be at least $k$.
But then the GM is at most $a_k$, contradiction.

A similar approach could be attempted by using
the smallest numbers rather than the largest ones,
but one must then handle the edge case $a_n = 1$
separately since no prime divides $1$.

Since $\frac{27+9}{2} = 18 = \sqrt[3]{27 \cdot 27 \cdot 8}$,
it is not true that in general the AM of two largest different cards
is not the GM of other numbers in the sequence
(say the cards are $27, 27, 9, 8, \dots$).


Consider an integer $n > 1$, and a set $\mathcal S$ of $n$ points
in the plane such that the distance between any two different points
in $\mathcal S$ is at least $1$.
Prove there is a line $\ell$ separating $\mathcal S$
such that the distance from any point of $\mathcal S$ to $\ell$
is at least $\Omega(n^{-1/3})$.

(A line $\ell$ separates a set of points $S$
if some segment joining two points in $\mathcal S$ crosses $\ell$.)

Solution:
We present the official solution given by the Problem Selection Committee.

Let's suppose that among all projections
of points in $\mathcal S$ onto some line $m$,
the maximum possible distance between two consecutive projections is $\delta$.
We will prove that $\delta \ge \Omega(n^{-1/3})$,
solving the problem.

We make the following the definitions:

Define $A$ and $B$ as the two points farthest apart in $\mathcal S$.
This means that all points lie in the intersections
of the circles centered at $A$ and $B$ with radius $R = AB \ge 1$.
We pick chord $XY$ of $\odot(B)$
such that $XY \perp AB$ and the distance
from $A$ to $XY$ is exactly $1/2$.
We denote by $\mathcal T$
the smaller region bound by $\odot(B)$ and chord $XY$.

The figure is shown below with $\mathcal T$ drawn in yellow,
and points of $\mathcal S$ drawn in blue.
[Figure omitted]

[Length of $AB$ + Pythagorean theorem]
We have $XY < 2\sqrt{n\delta}$.

First, note that we have $R = AB < (n-1) \cdot \delta$,
since the $n$ projections of points onto $AB$
are spaced at most $\delta$ apart.
The Pythagorean theorem gives
$ XY = 2\sqrt{R^2 - (R-1/2)^2}
= 2\sqrt{R - \frac14} < 2\sqrt{n\delta}. \qedhere $

[$|\mathcal T|$ lower bound + narrowness]
We have $XY > \frac{\sqrt3}{2} ( 1/2 \delta\inv - 1 )$.

Because $\mathcal T$ is so narrow (has width $1/2$ only),
the projections of points in $\mathcal T$ onto line $XY$
are spaced at least $\frac{\sqrt3}{2}$ apart (more than just $\delta$).
This means
$ XY > \frac{\sqrt3}{2}
( \left| \mathcal T \right| - 1 ). $
But projections of points in $\mathcal T$
onto the segment of length $1/2$ are spaced at most $\delta$ apart,
so apparently
$ \left| \mathcal T \right| > 1/2 \cdot \delta\inv. $
This implies the result.

Combining these two this implies $\delta \ge \Omega(n^{-1/3})$ as needed.

The constant $1/3$ in the problem is actually optimal
and cannot be improved;
the constructions give an example showing $\Theta(n^{-1/3} \log n)$.


Let $n \ge 100$ be an integer.
Ivan writes the numbers $n, n+1, \dots, 2n$ each on different cards.
He then shuffles these $n+1$ cards, and divides them into two piles.
Prove that at least one of the piles contains two cards such that
the sum of their numbers is a perfect square.

Solution:
We will find three cards $a < b < c$ such that

b+c &= (2k+1)^2 \\
c+a &= (2k)^2 \\
a+b &= (2k-1)^2

for some integer $k$.
Solving for $a$, $b$, $c$ gives

a &= \frac{(2k)^2+(2k-1)^2-(2k+1)^2}{2} = 2k^2 - 4k \\
b &= \frac{(2k+1)^2+(2k-1)^2-(2k)^2}{2} = 2k^2 + 1 \\
c &= \frac{(2k+1)^2+(2k)^2-(2k-1)^2}{2} = 2k^2 + 4k

We need to show that when $n \ge 100$, one can find a suitable $k$.

Let

I_k &\coloneq \left\{ n \in \ZZ \mid n \le a < b < c \le 2n \right\} \\
&= \{ n \in \ZZ \mid k^2+2k \le n \le 2k^2-4k \}

be the interval such that when $n \in I_k$,
the problem dies for that choice of $k$.
It would be sufficient to show these intervals $I_k$
cover all the integers $\ge 100$.
Starting from $I_9 = \left\{ 99 \le n \le 126 \right\}$,
we have
$ k \ge 9 \implies 2k^2 - 4k \ge (k+1)^2 + 2(k+1) $
which means the right endpoint of $I_k$
exceeds the left endpoint of $I_{k+1}$.
Hence for $n \ge 99$ in fact the problem is true.

The problem turns out to be false for $n = 98$, surprisingly.
The counterexample is for one pile to be
$ \{98,100,102,\dots,126\}
\cup \{129,131,135,\dots,161 \}
\cup \{162, 164, \dots, 196\}. $


Show that the inequality
$\sum_{i=1}^n \sum_{j=1}^n \sqrt{|x_i-x_j|}
\le \sum_{i=1}^n \sum_{j=1}^n \sqrt{|x_i+x_j|} $
holds for all real numbers $x_1$, $x_2$, \dots, $x_n$.

Solution:
The proof is by induction on $n \ge 1$ with the base cases $n=1$ and
$n=2$ being easy to verify by hand.

In the general situation, consider replacing the tuple $(x_i)_i$
with $(x_i+t)_i$ for some parameter $t \in \RR$.
The inequality becomes
$\sum_{i=1}^n \sum_{j=1}^n \sqrt{|x_i-x_j|}
\le \sum_{i=1}^n \sum_{j=1}^n \sqrt{|x_i+x_j+2t|}. $
The left-hand side is independent of $t$.

The right-hand side, viewed as a function $F(t)$ of $t$,
is minimized when $2t = -(x_i + x_j)$ for some $i$ and $j$.

Since $F(t)$ is the sum of piecewise concave functions,
it is hence itself piecewise concave.
Moreover $F$ increases without bound if $|t| \to \infty$.

On each of the finitely many intervals on which $F(t)$ is
concave, the function is minimized at its endpoints.
Hence the minimum value must occur at one of the endpoints.

If $t = -x_i$ for some $i$, this is the same as shifting all the
variables so that $x_i = 0$.
In that case, we may apply induction on $n-1$ variables,
deleting the variable $x_i$.

If $t = -\frac{x_i+x_j}{2}$, then notice
$ x_i + t = -(x_j + t) $
so it's the same as shifting all the variables such that $x_i = -x_j$.
In that case, we may apply induction on $n-2$ variables,
after deleting $x_i$ and $x_j$.


Let $D$ be an interior point of the acute triangle $ABC$
with $AB > AC$ so that $\angle DAB = \angle CAD$.
The point $E$ on the segment $AC$ satisfies $\angle ADE =\angle BCD$,
the point $F$ on the segment $AB$ satisfies $\angle FDA =\angle DBC$,
and the point $X$ on the line $AC$ satisfies $CX = BX$.
Let $O_1$ and $O_2$ be the circumcenters of the triangles
$ADC$ and $EXD$, respectively.
Prove that the lines $BC$, $EF$, and $O_1O_2$ are concurrent.

Solution:
This solution was contributed by Abdullahil Kafi.

Quadrilateral $BCEF$ is cyclic.

Let $D'$ be the isogonal conjugate of the point $D$. The
angle condition implies quadrilateral $CEDD'$ and $BFDD'$
are cyclic. By power of point we have $ AE\cdot AC=AD\cdot AD'=AF\cdot AB $
So $BCEF$ is cyclic.

Line $ZD$ is tangent to the circles $(BCD)$ and $(DEF)$
where $Z=EF\cap BC$.

Let $\angle CAD=\angle BAD=\alpha$, $\angle BCD=\beta$,
$\angle DBC=\gamma$, $\angle ACD=\phi$,
$\angle ABD=\epsilon$.
From $\triangle ABC$ we have
$2\alpha+\beta+\gamma+\phi+\epsilon=180^\circ$.
Let $\ell$ be a line tangent to $(BCD)$ and $K$ be a
point on it in the same side of $AD$ as $C$ and
$L=AD\cap BC$. From our labeling we have,

	 \angle AFE &= \beta + \phi \qquad \angle BFD =
	 \alpha + \gamma \qquad \angle DFE = \alpha + \phi
	 \qquad \angle CDL = \alpha + \phi

Now $\angle CDJ = 180^\circ - \gamma - \beta - (\alpha + \phi) = \alpha + \epsilon$.
So $\angle DFE = \angle EDK = \alpha + \epsilon$, which
means $\ell$ is also tangent to $(DEF)$. Now by the
radical center theorem we have $\ell$ passes through
$Z$.

Let $M$ be the Miquel point of the cyclic quadrilateral
$BCEF$. From the Miquel configuration we have $A$, $M$, $Z$
are collinear and $(AFEM)$, $(ZCEM)$ are cyclic.

Points $B$, $X$, $M$, $E$ are cyclic.

Notice that $\angle EMB = 180^\circ - \angle AMB -\angle EMZ$
$=$ $180^\circ - 2\angle ACB = \angle EXB$.

Let $N$ be the other intersection of circles $(ACD)$ and
$(DEX)$ and let $R$ be the intersection of $AC$ and $BM$.

[Figure omitted]

Points $B$, $D$, $M$, $N$ are cyclic.

By power of point we have
$
\opname{Pow}(R, (ACD)) = RC \cdot RA = RM \cdot RB
= RE \cdot RX = \opname{Pow}(R, (DEX)).
$
Hence $R$ lies on the radical axis of $(ACD)$ and
$(DEX)$, so $N$, $R$, $D$ are collinear. Also
$ RN \cdot RD = RA \cdot RC = RM \cdot RB $ So $BDMN$
is cyclic.

Notice that $(ACD)$, $(BDMN)$, $(DEX)$ are coaxial so their
centers are collinear. Now we just need to prove the
centers of $(ACD)$, $(BDMN)$ and $Z$ are collinear. To
prove this, take a circle $\omega$ with radius $ZD$
centered at $Z$. Notice that by power of point
$ ZC \cdot ZB = ZD^2 = ZE \cdot ZF = ZM \cdot ZA $
which means inversion circle $\omega$ swaps $(ACD)$ and $(BDMN)$.
So the centers of $(ACD)$ and $(BDMN)$ must
have to be collinear with the center of inversion circle, as desired.


Let $\Gamma$ be a circle with center $I$, and $ABCD$ a convex quadrilateral
such that each of the segments $AB$, $BC$, $CD$ and $DA$ is tangent to $\Gamma$.
Let $\Omega$ be the circumcircle of the triangle $AIC$.
The extension of $BA$ beyond $A$ meets $\Omega$ at $X$,
and the extension of $BC$ beyond $C$ meets $\Omega$ at $Z$.
The extensions of $AD$ and $CD$ beyond $D$ meet $\Omega$ at $Y$ and $T$, respectively.
Prove that
$ AD + DT + TX + XA = CD + DY + YZ + ZC. $

Solution:
Let $PQRS$ be the contact points of $\Gamma$ an $AB$, $BC$,
$CD$, $DA$.

[Figure omitted]

We have $\triangle IQZ \cong \triangle IRT$.
Similarly, $\triangle IPX \cong \triangle ISY$.

By considering $(CQIR)$ and $(CITZ)$,
there is a spiral similarity similarity
mapping $\triangle IQZ$ to $\triangle IRT$.
Since $IQ = IR$, it is in fact a congruence.

This congruence essentially solves the problem.
First, it implies:

$TX = YZ$.

Because we saw $IX = IY$ and $IT = IZ$.

Then, we can compute

AD + DT + XA
&= AD + (RT - RD) + (XP-AP) \\
&= (AD-RD-AP) + RT + XP = RT + XP

and

CD + DY + ZC &= CD + (SY-SD) + (ZQ-QC) \\
&= (CD-SD-QC) + SY + ZQ = SY + ZQ

but $ZQ = RT$ and $XP = SY$, as needed.


Two squirrels, Bushy and Jumpy, have collected $2021$ walnuts for the winter.
Jumpy numbers the walnuts from $1$ through $2021$, and digs $2021$ little holes
in a circular pattern in the ground around their favourite tree.
The next morning Jumpy notices that Bushy had placed one walnut into each hole,
but had paid no attention to the numbering.
Unhappy, Jumpy decides to reorder the walnuts by performing a sequence of 2021 moves.
In the $k$th move, Jumpy swaps the positions of the two walnuts adjacent to walnut $k$.

Prove that there exists a value of $k$ such that, on the $k$th move,
Jumpy swaps some walnuts $a$ and $b$ such that $a<k<b$.

Solution:
Assume for contradiction no such $k$ exists.
We will use a so-called ``threshold trick''.

This process takes exactly $2021$ steps.
Right after the $k$th move, we consider a situation where
we color walnut $k$ red as well, so at the $k$th step there are $k$ ones.
For brevity, a non-red walnut is called black.
An example is illustrated below with $2021$ replaced by $6$.
[Figure omitted]

At each step, the walnut that becomes red is between two non-red or two red walnuts.

By definition.

On the other hand, if there are $2021$ walnuts,
one obtains a parity obstruction to this simplified process:

After the first step, there is always a consecutive block of black walnuts positive even length.

After the first step, there is a block of $2020$ black walnuts.

Thereafter, note that a length $2$ block of black walnuts can never be changed.
Meanwhile for even lengths at least $4$, if one places a red walnut inside it,
the even length block splits into an odd length block and an even length block.

The statement is true with $2021$ replaced by any odd number, and false for any even number.

The motivation comes from the following rephrasing of the problem:

Start with all $0$'s and at each step change a $0$ between
two matching numbers from a $0$ to a $1$.

Although the coloring (or $0$/$1$) argument may appear to lose information
at first, I think it should be equivalent to the original process;
the ``extra'' information comes down to the choice of
which walnut to color red at each step.


Let $m \ge 2$ be an integer,
$A$ a finite set of integers (not necessarily positive)
and $B_1$, $B_2$, \dots, $B_m$ subsets of $A$.
Suppose that, for every $k=1,2,\dots,m$,
the sum of the elements of $B_k$ is $m^k$.
Prove that $A$ contains at least $\frac{m}{2}$ elements.

Solution:
If $0 \le X < m^{m+1}$ is a multiple of $m$, then write it in base $m$ as
$ X = \sum_{i=1}^m c_i m^i \qquad c_i \in \{0,1,2,\dots,m-1\} $
Then swapping the summation to over $A$ through the $B_i$'s gives
$ X = \sum_{i = 1}^n ( \sum_{b \in B_i} b ) c_i
= \sum_{a \in A} f_a(X) a
\quad\text{where}\quad
f_a(X) \coloneq \sum_{i : a \in B_i} c_i.
$

Evidently, $0 \le f_a(X) \le n(m-1)$ for any $a$ and $X$.
So, setting $|A| = n$, the right-hand side of the display takes on at most
$( n(m-1) + 1 )^n$ distinct values.
This means
$ m^m \le ( n(m-1) )^n $
which implies $n \ge m/2$.

[Motivation comments from USJL]
In linear algebra terms,
we have some $n$-dimensional 0/1 vectors $\vec{v_1}$, \dots, $\vec{v_m}$
and an $n$-dimensional vector $\vec a$
such that $\vec{v_i} \cdot \vec a = m^i$ for $i=1, \dots, m$.
The intuition is that if $n$ is too small,
then there should be lots of linear dependences between $\vec{v_i}$.

In fact, Siegel's lemma is a result that says,
if there are many more vectors than the dimension of the ambient space,
there exist linear dependences whose coefficients are not-too-big integers.
On the other hand, any linear dependence between $m$, $m^2$, \dots, $m^m$
is going to have coefficients that are pretty big;
at least one of them needs to exceed $m$.

Applying Siegel's lemma turns out to solve the problem
(and is roughly equivalent to the solution above).

In ,
\texttt{dgrozev} shows the stronger bound
$n \ge (\frac{2}{3}+\frac{c}{\log m} )m$ elements,
for some absolute constant $c > 0$.


The Bank of Oslo issues two types of coin: aluminum (denoted $A$) and bronze
(denoted $B$). Marianne has $n$ aluminum coins and $n$ bronze coins arranged in a
row in some arbitrary initial order.
A chain is any subsequence of consecutive coins of the same type.
Given a fixed positive integer $k \leq 2n$,
Gilberty repeatedly performs the following operation:
he identifies the longest chain containing the $k$\ts{th} coin from the left
and moves all coins in that chain to the left end of the row.
For example, if $n=4$ and $k=4$, the process starting
from the ordering $AABBBABA$ would be
$AABBBABA \to BBBAAABA \to AAABBBBA \to BBBBAAAA \to \dotsb$.

Find all pairs $(n,k)$ with $1 \leq k \leq 2n$
such that for every initial ordering,
at some moment during the process,
the leftmost $n$ coins will all be of the same type.

Solution:
Answer: $n \le k \le \left\lceil \frac 32 n \right\rceil$.

Call a maximal chain a block.
Then the line can be described as a sequence of blocks: it's one of:

\underbrace{A\dots A}_{e_1}
\underbrace{B\dots B}_{e_2}
\underbrace{A\dots A}_{e_3}
\dots
\underbrace{A\dots A}_{e_m} & \text{ for odd $m$} \\
\underbrace{A\dots A}_{e_1}
\underbrace{B\dots B}_{e_2}
\underbrace{A\dots A}_{e_3}
\dots
\underbrace{B\dots B}_{e_m} & \text{ for even $m$}

or the same thing with the roles of $A$ and $B$ flipped.

The main claim is the following:

The number $m$ of blocks will never increase after an operation.
Moreover, it stays the same if and only if

$k \le e_1$; or
$m$ is even and $e_m \ge 2n+1-k$.

This is obvious, just run the operation and see!

The problem asks for which values of $k$ we always reach $m=2$ eventually;
we already know that it's non-increasing.
We consider a few cases:

If $k < n$, then any configuration with $e_1 = n-1$ will never change.
If $k > \left\lceil 3n/2 \right\rceil$,
then take $m=4$ and $e_1 = e_2 = \left\lfloor n/2 \right\rfloor$
and $e_3 = e_4 = \left\lceil n/2 \right\rceil$.
This configuration retains $m=4$ always:
the blocks simply rotate.

Conversely, suppose $k \ge n$ has the property that $m > 2$ stays fixed.
If after the first three operations $m$ hasn't changed,
then we must have $m \ge 4$ even, and $e_m, e_{m-1}, e_{m-2} \ge 2n+1 - k$.
Now,
$ n \ge e_m + e_{m-2} \ge 2(2n+1-k) \implies k \ge \frac 32 n + 1 $
so this completes the proof.


Find all functions $f \colon \RR^+ \to \RR^+$ such that for each $x \in \RR^+$,
there is exactly one $y \in \RR^+$ satisfying $ xf(y)+yf(x) \leq 2. $

Solution:
The answer is $f(x) \equiv 1/x$ which obviously works (here $y=x$).

For the converse, assume we have $f$ such that
each $x \in \RR^+$ has a friend $y$ with $xf(y)+yf(x)\le2$.
By symmetry $y$ is also the friend of $x$.

In fact every number is its own friend.

Assume for contradiction $a \neq b$ are friends.
Then we know that $af(a) + af(a) > 2 \implies f(a) > \frac 1a$.
Analogously, $f(b) > \frac 1b$.
However, we then get
$ 2 \ge a f(b) + b f(a) > \frac ab + \frac ba \overset{\text{AMGM}}{\ge} 2 $
which is impossible.

The problem condition now simplifies to saying
$ f(x) \le \frac1x \text{ for all $x$}, \qquad
xf(y) + yf(x) > 2 \text{ for all $x \neq y$}. $
In particular, for any $x>0$ and $\eps > 0$ we have

2 &< xf(x+\eps) + (x+\eps)f(x) \le \frac{x}{x+\eps} + (x+\eps) f(x) \\
\implies f(x) &> \frac{x+2\eps}{(x+\eps)^2}
= \frac{1}{x + \frac{\eps^2}{x+2\eps}}.

Since this holds for all $\eps > 0$ this forces $f(x) \ge \frac1x$ as well.
We're done.

Alternatively, instead of using $x+\eps$,
it also works to consider $y = \frac{1}{f(x)}$.
For such a $y$, we would have
$ xf( \frac{1}{f(x)} ) + \frac{1}{f(x)} \cdot f(x)
= xf( \frac{1}{f(x)} ) + 1
\leq x \cdot f(x) + 1 \leq 1 + 1 = 2 $
which gives a similar contradiction.


Let $k$ be a positive integer and let $S$ be a finite set of odd prime numbers.
Prove that there is at most one way (up to rotation and reflection)
to place the elements of $S$ around the circle such that the product
of any two neighbors is of the form $x^2+x+k$ for some positive integer $x$.

Solution:
We replace ``positive integer $x$'' with ``nonnegative integer $x$'',
and say numbers of the form $x^2+x+k$ are good.
We could also replace ``nonnegative integer $x$'' with ``integer $x$''
owing to the obvious map $x \mapsto 1-x$.

If $p$ is an odd prime, there are at most two odd primes $q$ and $r$
less than $p$ for which $pq = x^2+x+k$ and $pr = y^2+y+k$ are good.

Moreover, if the above occurs and $x,y \ge 0$,
then $x+y+1=p$ and $xy \equiv k \pmod p$.

The equation $T^2+T+k \equiv 0 \pmod{p}$ has at most two solutions
modulo $p$, i.e.\ at most two solutions in the interval $[0,p-1]$.
Because $0 \le x,y < p$ from $p > \max(q,r)$ and $k > 0$,
the first half follows.

For the second half,
Vieta also gives $x+y \equiv -1 \pmod p$ and $xy \equiv k \pmod p$,
and we know $0 < x+y < 2p$.

If two such primes do exist as above, then $qr$ is also good (!).

Let $pq = x^2+x+k$ and $pr = y^2+y+k$ for $x,y \ge 0$ as before.
Fix $\alpha \in \CC$ such that $\alpha^2 + \alpha + k = 0$;
then for any $n \in \ZZ$, we have
$ n^2 + n + k = \opname{Norm}(n-\alpha). $
Hence
$
pq \cdot pr = \opname{Norm}\Big((x-\alpha)(y-\alpha)\Big)
= \opname{Norm}\Big( (xy-k) - (x+y+1)\alpha\Big)
$
But $\opname{Norm}(p) = p^2$,
so combining with the second half of the previous claim gives
$ qr = \opname{Norm}(\frac1p(xy-k)-\alpha) $ as needed.

These two claims imply the claim directly by induction on $|S|$,
since one can now delete the largest element of $S$.

To show that the condition is not vacuous,
the author gave a ring of $385$ primes for $k=41$;
see .


Let $ABCDE$ be a convex pentagon such that $BC=DE$.
Assume that there is a point $T$ inside $ABCDE$
with $TB=TD$, $TC=TE$ and $\angle ABT = \angle TEA$.
Let line $AB$ intersect lines $CD$ and $CT$ at points $P$ and $Q$, respectively.
Assume that the points $P$, $B$, $A$, $Q$ occur on their line in that order.
Let line $AE$ intersect $CD$ and $DT$ at points $R$ and $S$, respectively.
Assume that the points $R$, $E$, $A$, $S$ occur on their line in that order.
Prove that the points $P$, $S$, $Q$, $R$ lie on a circle.

Solution:
The conditions imply
$ \triangle BTC \cong \triangle DTE,
\qquad\text{and}\qquad
\triangle BTY \overset{-}{\sim} \triangle ETX. $
Define $K = CT \cap AE$, $L = DT \cap AB$,
$X = BT \cap AE$, $Y = ET \cap BY$.

[Figure omitted]

[Main claim]
We have
$ \triangle BTQ \overset{-}{\sim} \triangle ETS,
\qquad\text{and}\qquad
BY:YL:LQ = EX:XK:KS. $
In other words, $TBYLQ \overset{-}{\sim} TEXKS$.

We know $\triangle BTY \overset{-}{\sim} \triangle ETX$.
Also, $∠ BTL = ∠ BTD = ∠ CTE = ∠ KTE$
and $∠ BTQ = ∠ BTC = ∠ DTE = ∠ STE$.

It follows from the claim that:

$TL/TQ = TK/TS$, ergo $TL \cdot TS = TK \cdot TQ$,
so $KLSQ$ is cyclic; and
$TC/TK = TE/TK = TB/TL = TD/TL$, so $KL \parallel PCDR$.

With these two bullets, we're done by Reim theorem.


Find all triples $(a,b,p)$ of positive integers with $p$ prime and
$ a^p=b!+p. $

Solution:
The answer is $(2,2,2)$ and $(3,4,3)$ only, which work.

In what follows we assume $a \ge 2$.

We have $b \le 2p-2$, and hence $a < p^2$.

For the first half, assume first for contradiction that $b \ge 2p$.
Then $b!+p \equiv p \pmod{p^2}$, so $\nu_p(b!+p)=1$,
but $\nu_p(a^p)=1$ never occurs.

We can also rule out $b = 2p-1$ since that would give
$ (2p-1)!+p = p [ (p-1)! (p+1)(p+2)\dots(2p-1) + 1 ] $
By Wilson theorem the inner bracket is $(-1)^2+1 \equiv 2 \pmod p$
exactly, contradiction for $p > 2$.
And when $p=2$, $3!+2=8$ is not a perfect square.

The second half follows as $a^p \le (2p-2)!+p < p^{2p}$.
(Here we used the crude estimate
$(2p-2)! = \prod_{k=1}^{p-1}k \cdot (2p-1-k) < (p(p-1))^{p-1}$).

We have $a \ge p$, and hence $b \ge p$.

For the first half, assume for contradiction that $p > a$.
Then
$ b! + p = a^p \ge a^{p-1} + p \ge a^a + p > a! + p \implies b > a. $
Then taking modulo $a$ now gives $0 \equiv 0 + p \pmod{a}$,
which is obviously impossible.

The second half follows from $b! = a^p-p \ge p! - p > (p-1)!$.

We have $a=p$ exactly.

We know $p \ge b$ hence $p \mid b!+p$, so let $a = pk$ for $k < p$.
Then $k \mid b!$ yet $k \nmid a^p-p$, contradiction.

Let's get the small $p$ out of the way:

For $p=2$, checking $2 \le b \le 3$ gives $(a,b)=(2,2)$ only.
For $p=3$, checking $3 \le b \le 5$ gives $(a,b)=(3,4)$ only.

Once $p \ge 5$, if $b! = p^p - p = p(p^{p-1}-1)$
then applying Zsigmondy gets a prime factor $q \equiv 1 \pmod{p-1}$
which divides $p^{p-1}-1$.
Yet $q \le b \le 2p-2$ and $q \neq p$, contradiction.


Let $n$ be a positive integer.
A Nordic square is an $n \times n$ board
containing all the integers from $1$ to $n^2$
so that each cell contains exactly one number.
An uphill path is a sequence of one or more cells such that:

the first cell in the sequence is a valley,
meaning the number written is less than all its orthogonal neighbors,

each subsequent cell in the sequence is orthogonally
adjacent to the previous cell, and

the numbers written in the cells in the sequence are in increasing order.

Solution:
(SRB)}
.}

Answer: $2n^2-2n+1$.

Bound.:
The lower bound is the ``obvious'' one:

For any it generalizes to any $3 \mid n$,
and then to any $n$ by deleting the last $n \bmod 3$ rows
and either/both of the leftmost/rightmost column.

[Figure omitted]

Place $1$ anywhere in $T$ and then place all the small numbers at most $|T|$
adjacent to previously placed numbers (example above).
Then place the remaining numbers outside $T$ arbitrarily.

By construction, as $1$ is the only valley, any uphill path must start from $1$.
And by construction, it may only reach a given pair of terminal cells in one
way, i.e.\ the downhill paths we mentioned are the only one.
End proof.


Determine all composite integers $n>1$ that satisfy the following property:
if $d_1 < d_2 < \dots < d_k$ are all the positive divisors of $n$ with
then $d_i$ divides $d_{i+1} + d_{i+2}$ for every $1 \leq i \leq k - 2$.

Solution:
The answer is prime powers.

Verification that these work.:
When $n = p^e$, we get $d_i = p^{i-1}$.
The $i$\ts{th} relationship reads $ p^{i-1} \mid p^i + p^{i+1} $
which is obviously true.

Proof that these are the only answers.:
Conversely, suppose $n$ has at least two distinct prime divisors.
Let $p < q$ denote the two smallest ones,
and let $p^e$ be the largest power of $p$ which both divides $n$
and is less than $q$, hence $e \ge 1$.
Then the smallest factors of $n$ are $1$, $p$, \dots, $p^e$, $q$.
So we are supposed to have
$ \frac{n}{q} \mid \frac{n}{p^e} + \frac{n}{p^{e-1}}
= \frac{(p+1)n}{p^e} $
which means that the ratio
$ \frac{q(p+1)}{p^e} $
needs to be an integer, which is obviously not possible.


Let $ABC$ be an acute-angled triangle with $AB < AC$.
Let $\Omega$ be the circumcircle of $ABC$.
Let $S$ be the midpoint of the arc $CB$ of $\Omega$ containing $A$.
The perpendicular from $A$ to $BC$ meets $BS$ at $D$ and meets $\Omega$ again at $E \neq A$.
The line through $D$ parallel to $BC$ meets line $BE$ at $L$.
Denote the circumcircle of triangle $BDL$ by $\omega$.
Let $\omega$ meet $\Omega$ again at $P \neq B$.
Prove that the line tangent to $\omega$ at $P$ meets line $BS$
on the internal angle bisector of $\angle BAC$.

Solution:
We have $LPS$ collinear.

Because $∠ LPB = ∠ LDB = ∠ CBD = ∠ CBS = ∠ SCB = ∠ SPB$.

Let $F$ be the antipode of $A$, so $AMFS$ is a rectangle.

We have $PDF$ collinear. (This lets us erase $L$.)

Because $∠ SPD = ∠ LPD = ∠ LBD = ∠ SBE = ∠ FCS = ∠ FPS$.

Let us define $X = AM \cap BS$ and complete chord $PXQ$.
We aim to show that $PXQ$ is tangent to $(PDLB)$.

[Figure omitted]

[Main projective claim]
We have $XP = XA$.

Introduce $Y = PDF \cap AM$.
Note that
$ -1 = (SM;EF) \overset{A}{=} (S,X;D,AF \cap ES) \overset{F}{=} (\infty X;YA) $
where $\infty = AM \cap SF$ is at infinity (because $AMSF$ is a rectangle).
Thus, $XY = XA$.
[Figure omitted]
Since $\triangle APY$ is also right, we get $XP = XA$.

[Alternative proof of claim without harmonic bundles,
from Solution 9 of the marking scheme]
With $Y = PDF \cap AM$ defined as before, note that
$AE \parallel SM$ and $AM \parallel SF$ (as $AMFS$ is a rectangle)
gives respectively the similar triangles
$ \triangle AXD \sim \triangle MXS, \qquad \triangle XDY \sim \triangle SDF. $
From this we conclude
$ \frac{AX}{XD} = \frac{AX+XM}{XD+SX} = \frac{AM}{SD} = \frac{SF}{SD} = \frac{XY}{XD}. $
So $AX = XY$ and as before we conclude $XP = XA$.

From $XP = XA$, we conclude that $\arc{PM}$ and $\arc{AQ}$ have the same measure.
Since $\arc{AS}$ and $\arc{EM}$ have the same measure,
it follows $\arc{PE}$ and $\arc{SQ}$ have the same measure.
The desired tangency then follows from
$ ∠ QPL = ∠ QPS = ∠ PQE = ∠ PFE = ∠ PDL. $

[Logical ordering]
This solution is split into two phases:
the ``synthetic phase'' where we do a bunch of angle chasing, and the
``projective phase'' where we use cross-ratios because I like projective.
For logical readability (so we write in only one logical direction),
the projective phase is squeezed in two halves of the synthetic phase,
but during an actual solve it's expected to complete
the whole synthetic phase first (i.e.\ to reduce the problem to show $XP=XA$).

There are quite a multitude of approaches for this problem;
the marking scheme for this problem at the actual IMO had 13 different solutions.


For each integer $k\geq 2$, determine all infinite sequences of positive integers
$a_1$, $a_2$, \dots\ for which there exists a polynomial $P$ of the form
$ P(x)=x^k+c_{k-1}x^{k-1}+\dots + c_1 x+c_0, $
where $c_0$, $c_1$, \dots, $c_{k-1}$ are non-negative integers, such that
$ P(a_n)=a_{n+1}a_{n+2}\dotsm a_{n+k} $
for every integer $n\geq 1$.

Solution:
The answer is $a_n$ being an arithmetic progression.
Indeed, if $a_n = d(n-1) + a_1$ for $d \ge 0$ and $n \ge 1$, then
$ a_{n+1} a_{n+2} \dots a_{n+k} = (a_n+d)(a_n+2d)\dots(a_n+kd) $
so we can just take $P(x) = (x+d)(x+2d) \dots (x+kd)$.

The converse direction takes a few parts.

Either $a_1 < a_2 < \dotsb$ or the sequence is constant.

Note that

P(a_{n-1}) &= a_{n}a_{n+1}\dotsm a_{n+k-1} \\
P(a_n) &= a_{n+1}a_{n+2}\dotsm a_{n+k} \\
\implies a_{n+k} &= \frac{P(a_n)}{P(a_{n-1})} \cdot a_n.

Now the polynomial $P$ is strictly increasing over $\NN$.

So assume for contradiction there's an index $n$ such that $a_n < a_{n-1}$.
Then in fact the above equation shows $a_{n+k} < a_n < a_{n-1}$.
Then there's an index $\ell \in [n+1,n+k]$ such that
$a_\ell < a_{\ell-1}$, and also $a_\ell < a_n$.
Continuing in this way, we can an infinite descending subsequence of $(a_n)$,
but that's impossible because we assumed integers.

Hence we have $a_1 \le a_2 \le \dotsb$.
Now similarly, if $a_n = a_{n-1}$ for any index $n$, then $a_{n+k} = a_n$,
ergo $a_{n-1} = a_n = a_{n+1} = \dots = a_{n+k}$.
So the sequence is eventually constant, and then by downwards induction,
it is fully constant.

There exists a constant $C$ (depending only $P$, $k$)
such that we have $a_{n+1} \leq a_n + C$.

Let $C$ be a constant such that $P(x) < x^k + Cx^{k-1}$ for all $x \in \NN$
(for example $C = c_0 + c_1 + \dots + c_{k-1} + 1$ works).
We have

a_{n+k} &= \frac{P(a_n)}{a_{n+1} a_{n+2} \dots a_{n+k-1}} \\
&< \frac{P(a_n)}{(a_n+1)(a_n+2)\dots(a_n+k-1)} \\
&< \frac{a_n^k + C \cdot a_n^{k-1}}{(a_n+1)(a_n+2)\dots(a_n+k-1)} \\
&< a_n + C + 1. \qedhere

Assume henceforth $a_n$ is nonconstant, and hence unbounded.
For each index $n$ and term $a_n$ in the sequence,
consider the associated differences
$d_1 = a_{n+1} - a_n$, $d_2 = a_{n+2} - a_{n+1}$, \dots, $d_k = a_{n+k}-a_{n+k-1}$,
which we denote by
$ \Delta(n) \coloneq (d_1, \dots, d_k).$
This $\Delta$ can only take up to $C^k$ different values.
So in particular, some tuple $(d_1, \dots, d_n)$
must appear infinitely often as $\Delta(n)$; for that tuple, we obtain
$ P(a_N) = (a_N+d_1)(a_N+d_1+d_2) \dots (a_N+d_1+\dots+d_k) $
for infinitely many $N$.
But because of that, we actually must have
$ P(X) = (X+d_1)(X+d_1+d_2) \dots (X+d_1+\dots+d_k). $

However, this also means that exactly one output to $\Delta$
occurs infinitely often (because that output is determined by $P$).
Consequently, it follows that $\Delta$ is eventually constant.
For this to happen, $a_n$ must eventually coincide with an arithmetic
progression of some common difference $d$,
and $P(X) = (X+d)(X+2d) \dots (X+kd)$.
Finally, this implies by downwards induction that $a_n$ is
an arithmetic progression on all inputs.


Let $x_1$, $x_2$, \dots, $x_{2023}$ be pairwise different positive real numbers such that
$ a_n = \sqrt{(x_1+x_2+\dots+x_n)
(\frac{1}{x_1}+\frac{1}{x_2}+\dots+\frac{1}{x_n})} $
is an integer for every $n=1,2,\dots,2023$. Prove that $a_{2023} \geq 3034$.

Solution:
Note that $a_{n+1} > \sqrt{\sum_1^n x_i \sum_1^n \frac{1}{x_i}} = a_n$ for all $n$,
so that $a_{n+1} \geq a_n + 1$.
Observe $a_1 = 1$.
We are going to prove that $ a_{2m+1} \geq 3m+1 \qquad \text{for all } m \geq 0 $
by induction on $m$, with the base case being clear.

We now present two variations of the induction.
The first shorter solution compares $a_{n+2}$ directly to $a_n$,
showing it increases by at least $3$.
Then we give a longer approach that compares $a_{n+1}$ to $a_n$,
and shows it cannot increase by $1$ twice in a row.

Induct-by-two solution.:
Let $u = \sqrt{\frac{x_{n+1}}{x_{n+2}}} \neq 1$.
Note that by using Cauchy-Schwarz with three terms:

a_{n+2}^2 &= \Bigg[ (x_1+\dots+x_n)+x_{n+1}+x_{n+2} \Bigg]
\Bigg[ (\frac{1}{x_1}+\dots+\frac{1}{x_n})
+\frac{1}{x_{n+2}} + \frac{1}{x_{n+1}} \Bigg] \\
&\geq ( \sqrt{ (x_1+\dots+x_n)(\frac{1}{x_1}+\dots+\frac{1}{x_n})}
+ \sqrt{\frac{x_{n+1}}{x_{n+2}}} + \sqrt{\frac{x_{n+2}}{x_{n+1}}} )^2 \\
&= ( a_n + u + \frac 1u )^2. \\
\implies a_{n+2} &\ge a_n + u + \frac 1u > a_n + 2

where the last equality $u + \frac 1u > 2$ is by AM-GM, strict as $u \neq 1$.
It follows that $a_{n+2} \geq a_n + 3$, completing the proof.

Induct-by-one solution.:
The main claim is:

It's impossible to have
$a_n = c$, $a_{n+1} = c+1$, $a_{n+2} = c+2$ for any $c$ and $n$.

Let $p = x_{n+1}$ and $q = x_{n+2}$ for brevity.
Let $s = \sum_1^n x_i$ and $t = \sum_1^n \frac{1}{x_n}$, so $c^2 = a_n^2 = st$.

From $a_n = c$ and $a_{n+1} = c+1$ we have

(c+1)^2 &= a_{n+1}^2 = (p+s)( \frac 1p+t ) \\
&= st + pt + \frac1ps + 1 = c^2 + pt + \frac1ps + 1 \\
&\overset{\text{AM-GM}}{\geq} c^2 + 2\sqrt{st} + 1 = c^2 + 2\sqrt{c^2} + 1 = (c+1)^2.

Hence, equality must hold in the AM-GM we must have exactly
$ p t = \frac 1p s = c. $
If we repeat the argument again on $a_{n+1}=c+1$ and $a_{n+2}=c+2$, then
$ q ( \frac 1p + t ) = \frac 1q ( p + s ) = c + 1. $
However this forces $\frac pq = \frac qp = 1$ which is impossible.