% © Evan Chen
% Downloaded from https://web.evanchen.cc/

\documentclass[11pt]{scrartcl}
\usepackage[sexy]{evan}
\ihead{\footnotesize\textbf{\thetitle}}
\ohead{\footnotesize\href{http://web.evanchen.cc}{\ttfamily web.evanchen.cc},
    updated \today}
\title{JMO 2024 Solution Notes}
\date{\today}

\begin{document}

\maketitle

\begin{abstract}
This is a compilation of solutions
for the 2024 JMO.
The ideas of the solution are a mix of my own work,
the solutions provided by the competition organizers,
and solutions found by the community.
However, all the writing is maintained by me.

These notes will tend to be a bit more advanced and terse than the ``official''
solutions from the organizers.
In particular, if a theorem or technique is not known to beginners
but is still considered ``standard'', then I often prefer to
use this theory anyways, rather than try to work around or conceal it.
For example, in geometry problems I typically use directed angles
without further comment, rather than awkwardly work around configuration issues.
Similarly, sentences like ``let $\mathbb{R}$ denote the set of real numbers''
are typically omitted entirely.

Corrections and comments are welcome!
\end{abstract}

\tableofcontents
\newpage

\addtocounter{section}{-1}
\section{Problems}
\begin{enumerate}[\bfseries 1.]
\item %% Problem 1
Let $ABCD$ be a cyclic quadrilateral with $AB=7$ and $CD=8$.
Points $P$ and $Q$ are selected on line segment $AB$ so that $AP=BQ=3$.
Points $R$ and $S$ are selected on line segment $CD$ so that $CR=DS=2$.
Prove that $PQRS$ is a cyclic quadrilateral.

\item %% Problem 2
Let $m$ and $n$ be positive integers.
Let $S$ be the set of lattice points $(x,y)$ with $1 \le x \le 2m$ and $1 \le y \le 2n$.
A configuration of $mn$ rectangles is called \emph{happy} if each point of $S$
is the vertex of exactly one rectangle.
Prove that the number of happy configurations is odd.

\item %% Problem 3
A sequence $a_1$, $a_2$, \dots\ of positive integers is defined recursively by
$a_1 = 2$ and \[ a_{n+1} = a_n^{n+1} - 1 \qquad \text{ for } n \ge 1. \]
Prove that for every odd prime $p$ and integer $k$,
some term of the sequence is divisible by $p^k$.

\item %% Problem 4
Let $n \geq 3$ be an integer.
Rowan and Colin play a game on an $n \times n$ grid of squares,
where each square is colored either red or blue.
Rowan is allowed to permute the rows of the grid and
Colin is allowed to permute the columns.
A grid coloring is orderly if:
\begin{itemize}
  \ii no matter how Rowan permutes the rows of the coloring,
  Colin can then permute the columns to restore the original grid coloring; and
  \ii no matter how Colin permutes the columns of the coloring,
  Rowan can then permute the rows to restore the original grid coloring.
\end{itemize}
In terms of $n$, how many orderly colorings are there?

\item %% Problem 5
Solve over $\RR$ the functional equation $f(x^2-y)+2yf(x) = f(f(x))+f(y)$.

\item %% Problem 6
Point $D$ is selected inside acute triangle $ABC$
so that $\angle DAC = \angle ACB$ and $\angle BDC = 90^\circ + \angle BAC$.
Point $E$ is chosen on ray $BD$ so that $AE = EC$.
Let $M$ be the midpoint of $BC$.
Show that line $AB$ is tangent to the circumcircle of triangle $BEM$.

\end{enumerate}
\pagebreak

\section{Solutions to Day 1}
\subsection{JMO 2024/1, proposed by Evan o'Dorney}
\textsl{Available online at \url{https://aops.com/community/p30216434}.}
\begin{mdframed}[style=mdpurplebox,frametitle={Problem statement}]
Let $ABCD$ be a cyclic quadrilateral with $AB=7$ and $CD=8$.
Points $P$ and $Q$ are selected on line segment $AB$ so that $AP=BQ=3$.
Points $R$ and $S$ are selected on line segment $CD$ so that $CR=DS=2$.
Prove that $PQRS$ is a cyclic quadrilateral.
\end{mdframed}
Here are two possible approaches.

\paragraph{The one-liner.}
The four points $P$, $Q$, $R$, $S$ have equal power $-12$ with respect to $(ABCD)$.
So in fact they're on a circle concentric with $(ABCD)$.

\paragraph{The external power solution.}
We distinguish between two cases.

\subparagraph{Case where $AB$ and $CD$ are not parallel.}
We let lines $AB$ and $CD$ meet at $T$.
Without loss of generality,
$A$ lies between $B$ and $T$ and $D$ lies between $C$ and $T$.
Let $x=TA$ and $y=TD$, as shown below.
\begin{center}
\begin{asy}
size(8cm);
pair A = dir(170);
pair B = dir(80);
pair C = dir(323.912853);
pair D = dir(216.087147);
pair T = extension(A, B, C, D);
filldraw(unitcircle, opacity(0.1)+lightcyan, blue);
draw(B--T--C--B, blue);
draw(A--D, blue);

pair P = 4*A/7+3*B/7;
pair Q = 3*A/7+4*B/7;
pair R = 6*C/8+2*D/8;
pair S = 2*C/8+6*D/8;

filldraw(circumcircle(P, Q, R), opacity(0.1)+yellow, dashed+red);
label("$x$", midpoint(T--A), dir(A+B), deepgreen);
label("$3$", midpoint(A--P), dir(A+B), deepgreen);
label("$1$", midpoint(P--Q), -dir(A+B), deepgreen);
label("$3$", midpoint(Q--B), dir(A+B), deepgreen);
label("$y$", midpoint(T--D), dir(C+D), deepgreen);
label("$2$", midpoint(D--S), dir(C+D), deepgreen);
label("$4$", midpoint(S--R), -dir(C+D), deepgreen);
label("$2$", midpoint(R--C), dir(C+D), deepgreen);

dot("$A$", A, dir(120));
dot("$B$", B, dir(B));
dot("$C$", C, dir(300));
dot("$D$", D, dir(240));
dot("$T$", T, dir(T));
dot("$P$", P, dir(160));
dot("$Q$", Q, dir(80));
dot("$R$", R, dir(270));
dot("$S$", S, dir(270));

/* -----------------------------------------------------------------+
|                 TSQX: by CJ Quines and Evan Chen                  |
| https://github.com/vEnhance/dotfiles/blob/main/py-scripts/tsqx.py |
+-------------------------------------------------------------------+
A 120 = dir 170
B = dir 80
C 300 = dir 323.912853
D 240 = dir 216.087147
T = extension A B C D
unitcircle / 0.1 lightcyan / blue
B--T--C--B / blue
A--D / blue
P 160 = 4*A/7+3*B/7
Q 80 = 3*A/7+4*B/7
R 270 = 6*C/8+2*D/8
S 270 = 2*C/8+6*D/8
circumcircle P Q R / 0.1 yellow / dashed red
!label("$x$", midpoint(T--A), dir(A+B), deepgreen);
!label("$3$", midpoint(A--P), dir(A+B), deepgreen);
!label("$1$", midpoint(P--Q), -dir(A+B), deepgreen);
!label("$3$", midpoint(Q--B), dir(A+B), deepgreen);
!label("$y$", midpoint(T--D), dir(C+D), deepgreen);
!label("$2$", midpoint(D--S), dir(C+D), deepgreen);
!label("$4$", midpoint(S--R), -dir(C+D), deepgreen);
!label("$2$", midpoint(R--C), dir(C+D), deepgreen);
*/
\end{asy}
\end{center}
By power of a point,
\begin{align*}
  \text{$ABCD$ cyclic} \iff x(x+7) &= y(y+8) \\
  \text{$PQRS$ cyclic} \iff (x+3)(x+4) &= (y+2)(y+6).
\end{align*}
However, the latter equation is just the former with $12$ added to both sides.
(That is, $(x+3)(x+4) = x(x+7)+12$ while $(y+2)(y+6)=y(y+8)+12$.)
So the conclusion is immediate.

\subparagraph{Case where $AB$ and $CD$ are parallel.}
In that case $ABCD$ is an isosceles trapezoid.
Then the entire picture is symmetric around the common perpendicular bisector
of the lines $AB$ and $CD$.
Now $PQRS$ is also an isosceles trapezoid, so it's cyclic too.
\begin{center}
\begin{asy}
size(4cm);
pair A = dir(135);
pair B = dir(45);
pair C = dir(323.912853);
pair D = dir(216.087147);
filldraw(unitcircle, opacity(0.1)+lightcyan, blue);
draw(A--B--C--D--cycle, blue);

pair P = 4*A/7+3*B/7;
pair Q = 3*A/7+4*B/7;
pair R = 6*C/8+2*D/8;
pair S = 2*C/8+6*D/8;

filldraw(circumcircle(P, Q, R), opacity(0.1)+yellow, dashed+red);

dot("$A$", A, dir(120));
dot("$B$", B, dir(B));
dot("$C$", C, dir(300));
dot("$D$", D, dir(240));
dot("$P$", P, dir(90));
dot("$Q$", Q, dir(80));
dot("$R$", R, dir(270));
dot("$S$", S, dir(270));
\end{asy}
\end{center}
\pagebreak

\subsection{JMO 2024/2, proposed by Serena An and Claire Zhang}
\textsl{Available online at \url{https://aops.com/community/p30216444}.}
\begin{mdframed}[style=mdpurplebox,frametitle={Problem statement}]
Let $m$ and $n$ be positive integers.
Let $S$ be the set of lattice points $(x,y)$ with $1 \le x \le 2m$ and $1 \le y \le 2n$.
A configuration of $mn$ rectangles is called \emph{happy} if each point of $S$
is the vertex of exactly one rectangle.
Prove that the number of happy configurations is odd.
\end{mdframed}
There are several possible approaches to the problem;
most of them involve pairing some of the happy configurations in various ways,
leaving only a few configurations which remain fixed.
We present the original proposer's solution and Evan's more complicated one.

\paragraph{Original proposer's solution.}
To this end, let's denote by $f(2m, 2n)$ the number of happy configurations
for a $2m \times 2n$ grid of lattice points
(not necessarily equally spaced --- this doesn't change the count).
We already have the following easy case.
\begin{claim*}
  We have $f(2, 2n) = (2n-1)!{!} = (2n-1) \cdot (2n-3) \cdot \dots \cdot 3 \cdot 1$.
\end{claim*}
\begin{proof}
  The top row is the top edge of some rectangle and there are $2n-1$ choices
  for the bottom edge of that rectangle.
  It then follows $f(2, 2n) = (2n-1) \cdot f(2, 2n-2)$
  and the conclusion follows by induction on $n$, with $f(2,2) = 1$.
\end{proof}

We will prove that:
\begin{claim*}
  Assume $m,n \ge 1$. When $f(2m, 2n) \equiv f(2m-2, 2n) \pmod 2$.
\end{claim*}
\begin{proof}
  Given a happy configuration $\mathcal C$, let $\tau(\mathcal C)$
  be the happy configuration obtained by swapping the last two columns.
  Obviously $\tau(\tau(\mathcal C)) = \mathcal C$ for every happy $\mathcal C$.
  So in general, we can consider two different kinds of configurations $\mathcal C$,
  those for which $\tau(\mathcal C) \neq \mathcal C$,
  so we get pairs $\{\mathcal C, \tau(\mathcal C)\}$,
  and those with $\tau(\mathcal C) = \mathcal C$.

  Now configurations fixed by $\tau$ can be described readily:
  this occurs if and only if the last two columns are self-contained,
  meaning every rectangle with a vertex in these columns is
  completely contained in these two columns.
  \begin{center}
  \begin{asy}
    real eps = 0.6;
    filldraw(box((8.4, 0.4), (10.6, 8.6)), opacity(0.2)+yellow, black+dashed);
    for (int x=1; x<=10; ++x) {
      for (int y=1; y<=8; ++y) {
        pair P = (x,y);
        if (x==9 || x==10) { fill(circle(P, 0.1), blue); }
        else { dot(P); }
      }
    }
    draw((9,0.3)..(9.5,-0.2)..(10,0.3), deepgreen+1.2, Arrows(TeXHead));
    label("$\tau$", (9.5,-0.2), dir(-90), deepgreen);
    label("$f(2,2n)$", (9.5,8.6), dir(90), black);
    label("$f(2m-2,2n)$", (4.5,8.6), dir(90), black);
    draw((0.8,8.4)--(0.8,8.6)--(8.2,8.6)--(8.2,8.4), grey);
  \end{asy}
  \end{center}
  Hence it follows that
  \[ f(2m, 2n) = 2 (\text{number of pairs}) + f(2m-2, 2n) \cdot f(2, 2n). \]
  Taking modulo $2$ gives the result.
\end{proof}
By the same token $f(2m, 2n) \equiv f(2m, 2n-2) \pmod 2$.
So all $f$-values have the same parity, and from $f(2,2)=1$ we're done.

\begin{remark*}
  There are many variations of the solution using different kinds of $\tau$.
  The solution with $\tau$ swapping two rows seems to be the simplest.
\end{remark*}

\paragraph{Evan's permutation-based solution.}
Retain the notation $f(2m, 2n)$ from before.
Given a happy configuration, consider all the rectangles
whose left edge is in the first column.
Highlight every column containing the right edge of such a rectangle.
For example, in the figure below, there are two highlighted columns.
(The rectangles are drawn crooked so one can tell them apart.)
\begin{center}
\begin{asy}
  real eps = 0.6;
  for (int x=1; x<=10; ++x) {
    for (int y=1; y<=6; ++y) {
      pair P = (x,y);
      dot(P);
    }
  }
  dotfactor *= 1;
  real eps = 0.3;
  void rect(real a, real b, real u, real v, pen p) {
    draw( (a,b)--((a+u)/2, b-eps)--(u,b)--(u+eps,(b+v)/2)--(u,v)
      --((a+u)/2, v+eps)--(a,v)--(a-eps, (b+v)/2)--cycle, p);
    fill(circle((a,b), 0.2), p);
    fill(circle((u,b), 0.2), p);
    fill(circle((a,v), 0.2), p);
    fill(circle((u,v), 0.2), p);
  }

  rect(1,1,8,3, blue + 1.5);
  rect(1,2,5,6, deepgreen + 1.5);
  rect(1,4,8,5, red + 1.5);

  filldraw(box((4.5, 0.6), (5.5, 6.4)), opacity(0.2)+yellow, black+dashed);
  filldraw(box((7.5, 0.6), (8.5, 6.4)), opacity(0.2)+yellow, black+dashed);
\end{asy}
\end{center}
We organize happy configurations based on the set of highlighted columns.
Specifically, define the relation $\sim$ on configurations by saying that
$\mathcal C \sim \mathcal C'$ if they differ by any permutation of the highlighted columns.
This is an equivalence relation.
And in general, if there are $k$ highlighted columns,
its equivalence class under $\sim$ has $k!$ elements.

Then
\begin{claim*}
  $f(2m, 2n)$ has the same parity as the number of happy configurations
  with \emph{exactly} one highlighted column.
\end{claim*}
\begin{proof}
  Since $k!$ is even for all $k \ge 2$, but odd when $k=1$.
\end{proof}

There are $2m-1$ ways to pick a single highlighted column,
and then $f(2, 2n) = (2n-1){!}{!}$ ways to use the left column and highlighted column.
So the count in the claim is exactly given by
\[ (2m-1) \cdot (2n-1){!}{!} f(2m-2, 2n). \]
This implies $f(2m, 2n) \equiv f(2m-2,2n) \pmod 2$
and proceeding by induction as before solves the problem.
\pagebreak

\subsection{JMO 2024/3, proposed by John Berman}
\textsl{Available online at \url{https://aops.com/community/p30216450}.}
\begin{mdframed}[style=mdpurplebox,frametitle={Problem statement}]
A sequence $a_1$, $a_2$, \dots\ of positive integers is defined recursively by
$a_1 = 2$ and \[ a_{n+1} = a_n^{n+1} - 1 \qquad \text{ for } n \ge 1. \]
Prove that for every odd prime $p$ and integer $k$,
some term of the sequence is divisible by $p^k$.
\end{mdframed}
We start with the following.
\begin{claim*}
  Assume $n$ is a positive integer divisible by $p-1$.
  Then either $a_{n-1} \equiv 0 \pmod p$ or $a_n \equiv 0 \pmod p$.
\end{claim*}
\begin{proof}
  Suppose that $a_{n-1} \not\equiv 0 \pmod p$.
  Then by Fermat's little theorem,
  \[ a_n = a_{n-1}^n - 1 \equiv x^{p-1} - 1 \equiv 0 \pmod p \]
  where $x \coloneqq a_{n-1}^{\frac{n}{p-1}}$ is an integer not divisible by $p$.
\end{proof}

\begin{claim*}
  If $n \ge 2$ is even, then
  \[ a_{n}^{n+1} \mid a_{n+2}. \]
\end{claim*}
\begin{proof}
  Note $a_{n+2} = a_{n+1}^{n+2} - 1$.
  The right-hand side is a difference of $(n+2)$\ts{nd} powers,
  which for even $n$ is divisible by $a_{n+1} + 1 = a_{n}^{n+1}$.
\end{proof}

By considering multiples $n$ of $p-1$ which are larger than $k$,
we see that if $a_n \equiv 0 \pmod p$ ever happens,
we are done by combining the two previous claims.
So the difficult case of the problem is the bad situation
where $a_{n-1} \equiv 0 \pmod p$ occurs for almost all $n \equiv 0 \pmod{p-1}$.

To resolve the difficult case and finish the problem,
we zoom in on specific $n$ that will let us use lifting the exponent on $a_{n-1}$.
\begin{claim*}
  Suppose $n$ is an (even) integer satisfying
  \begin{align*}
    n &\equiv 0 \pmod{p-1} \\
    n &\equiv 1 \pmod{p^{k-1}}.
  \end{align*}
  If $a_{n-1} \equiv 0 \pmod p$, then in fact $p^k \mid a_{n-1}$.
\end{claim*}
\begin{proof}
  Write $a_{n-1} = a_{n-2}^{n-1} - 1$.
  We know $a_{n-2} \not\equiv 0 \pmod p$, and so $a_{n-2}^n \equiv 1 \pmod p$.
  Taking modulo $p$ gives
  \[ 0 \equiv \frac{1}{a_{n-2}} - 1 \pmod p \implies a_{n-2} \equiv 1 \pmod p. \]
  Hence lifting the exponent applies and we get
  \[ \nu_p(a_{n-1}) \equiv \nu_p \left( a_{n-2}^{n-1} - 1 \right)
    = \nu_p(a_{n-2}-1) + \nu_p(n-1) \geq 1 + (k-1) = k \]
  as desired.
\end{proof}

\begin{remark*}
  The first few terms are $a_1=2$, $a_2=3$, $a_3=26$, $a_4=456975$,
  and $a_5 = 19927930852449199486318359374$, \dots.
  No element of the sequence is divisible by $4$:
  the residues modulo $4$ alternate between $2$ and $3$.
\end{remark*}

\begin{remark*}
  The second claim is important for the solution to work once $k \ge 2$.
  One could imagine a variation of the first claim that states
  if $n$ is divisible by $\varphi(p^k) = p^{k-1}(p-1)$,
  then either $a_{n-1} \equiv 0 \pmod p$ or $a_n \equiv 0 \pmod{p^k}$.
  However this gives an obstruction (for $k \ge 2$)
  where we are guaranteed to have $n-1 \not\equiv 0 \pmod p$ now,
  so lifting the exponent will never give additional factors of $p$ we want.
\end{remark*}
\pagebreak

\section{Solutions to Day 2}
\subsection{JMO 2024/4, proposed by Alec Sun}
\textsl{Available online at \url{https://aops.com/community/p30227193}.}
\begin{mdframed}[style=mdpurplebox,frametitle={Problem statement}]
Let $n \geq 3$ be an integer.
Rowan and Colin play a game on an $n \times n$ grid of squares,
where each square is colored either red or blue.
Rowan is allowed to permute the rows of the grid and
Colin is allowed to permute the columns.
A grid coloring is orderly if:
\begin{itemize}
  \ii no matter how Rowan permutes the rows of the coloring,
  Colin can then permute the columns to restore the original grid coloring; and
  \ii no matter how Colin permutes the columns of the coloring,
  Rowan can then permute the rows to restore the original grid coloring.
\end{itemize}
In terms of $n$, how many orderly colorings are there?
\end{mdframed}
The answer is $2n!+2$.
In fact, we can describe all the orderly colorings as follows:
\begin{itemize}
  \ii The all-blue coloring.
  \ii The all-red coloring.
  \ii Each of the $n!$ colorings where every row/column has exactly one red cell.
  \ii Each of the $n!$ colorings where every row/column has exactly one blue cell.
\end{itemize}
These obviously work; we turn our attention to proving these are the only ones.

For the other direction, fix a orderly coloring $\mathcal A$.

Consider any particular column $C$ in $\mathcal A$
and let $m$ denote the number of red cells that $C$ has.
Any row permutation (say $\sigma$) that Rowan chooses will transform $C$ into
some column $\sigma(C)$, and our assumption requires $\sigma(C)$
has to appear somewhere in the original assignment $\mathcal A$.
An example for $n = 7$, $m = 2$, and a random $\sigma$ is shown below.

\begin{center}
\begin{asy}
  defaultpen(fontsize(14pt));
  pen bo = black + 1.4;
  filldraw(shift(0,0)*unitsquare, lightcyan, bo);
  filldraw(shift(0,1)*unitsquare, lightred, bo);
  filldraw(shift(0,2)*unitsquare, lightcyan, bo);
  filldraw(shift(0,3)*unitsquare, lightcyan, bo);
  filldraw(shift(0,4)*unitsquare, lightred, bo);
  filldraw(shift(0,5)*unitsquare, lightcyan, bo);
  filldraw(shift(0,6)*unitsquare, lightcyan, bo);
  label("$C$", (0.5,0), dir(-90));

  pen gr = deepgreen;
  real h = 8;
  draw((1,1.5)--(h,4.5), gr, EndArrow, Margins);
  draw((1,4.5)--(h,3.5), gr, EndArrow, Margins);
  draw((1,2.5)--(h,1.5), gr, EndArrow, Margins);
  draw((1,0.5)--(h,0.5), gr, EndArrow, Margins);
  draw((1,3.5)--(h,6.5), gr, EndArrow, Margins);
  draw((1,6.5)--(h,5.5), gr, EndArrow, Margins);
  draw((1,5.5)--(h,2.5), gr, EndArrow, Margins);

  filldraw(shift(h,0)*unitsquare, lightcyan, bo);
  filldraw(shift(h,1)*unitsquare, lightcyan, bo);
  filldraw(shift(h,2)*unitsquare, lightcyan, bo);
  filldraw(shift(h,3)*unitsquare, lightred, bo);
  filldraw(shift(h,4)*unitsquare, lightred, bo);
  filldraw(shift(h,5)*unitsquare, lightcyan, bo);
  filldraw(shift(h,6)*unitsquare, lightcyan, bo);
  label("$\sigma(C)$", (h+0.5,0), dir(-90));
  label("$\sigma$", ((1+h)/2, 0), dir(-90), gr);
\end{asy}
\end{center}

On the other hand, the number of possible patterns of $\sigma(C)$ is easily seen
to be exactly $\binom{n}{m}$ --- and they must all appear.
In particular, if $m \notin \{0, 1, n-1, n\}$,
then we immediately get a contradiction because $\mathcal A$ would need
too many columns (there are only $n$ columns in $\mathcal A$,
which is fewer than $\binom{n}{m}$).
Moreover, if either $m=1$ or $m=n-1$,
these columns are all the columns of $\mathcal A$;
these lead to the $2n!$ main cases we found before.

The only remaining case is when $m \in \{0,n\}$ for every column,
i.e.\ every column is monochromatic.
It's easy to see in that case the columns must all be the same color.
\pagebreak

\subsection{JMO 2024/5, proposed by Carl Schildkraut}
\textsl{Available online at \url{https://aops.com/community/p30227204}.}
\begin{mdframed}[style=mdpurplebox,frametitle={Problem statement}]
Solve over $\RR$ the functional equation $f(x^2-y)+2yf(x) = f(f(x))+f(y)$.
\end{mdframed}
The answer is $f(x) \equiv x^2$, $f(x) \equiv 0$, $f(x) \equiv -x^2$,
which obviously work.

Let $P(x,y)$ be the usual assertion.
\begin{claim*}
  We have $f(0) = 0$ and $f$ even.
\end{claim*}
\begin{proof}
  Combine $P(1,1/2)$ with $P(1,0)$ to get $f(0) = 0$.
  Use $P(0,y)$ to deduce $f$ is even.
\end{proof}

\begin{claim*}
  $f(x) \in \{-x^2, 0, x^2\}$ for every $x \in \RR$.
\end{claim*}
\begin{proof}
  Note that $P(x,x^2/2)$ and $P(x,0)$ respectively give
  \[ x^2f(x) = f(x^2) = f(f(x)). \]
  Repeating this key identity several times gives
  \begin{align*}
    f(f(f(x))) &= f(f(x^2)) = f(x^4) = x^4 f(x^2) \\
    &= f(x)^2 \cdot f(f(x)) = f(x)^2 f(x^2) = f(x)^3 x^2
  \end{align*}
  Suppose $t \neq 0$ is such that $f(t^2) \neq 0$.
  Then the above equalities imply
  \[ t^4 f(t^2) = f(t)^2 f(t^2) \implies f(t) = \pm t^2 \]
  and then
  \[ f(t)^2 f(t^2) = f(t)^3 t^2 \implies f(t^2) = \pm t^2. \]
  Together with $f$ even, we get the desired result.
\end{proof}
\begin{remark*}
  Another proof is possible here that doesn't use as iterations of $f$:
  the idea is to ``show $f$ is injective up to sign outside its kernel''.
  Specifically, if $f(a) = f(b) \neq 0$,
  then $a^2f(a) = f(f(a)) = f(f(b)) = b^2f(b) \implies a^2=b^2$.
  But we also have $f(f(x))=f(x^2)$,
  so we are done except in the case $f(f(x))=f(x^2)=0$.
  That would imply $x^2f(x) = 0$, so the claim follows.
\end{remark*}

Now, note that $P(1,y)$ gives
\[ f(1-y) + 2y \cdot f(1) = f(1) + f(y). \]
We consider cases on $f(1)$ and show that $f$ matches the desired form.
\begin{itemize}
  \ii If $f(1) = 1$, then $f(1-y) + (2y-1) = f(y)$.
  Consider the nine possibilities that arise:
  \[
    \begin{array}{lll}
    (1-y)^2 + (2y-1) = y^2 &
    0 + (2y-1) = y^2 &
    -(1-y)^2 + (2y-1) = y^2 \\
    (1-y)^2 + (2y-1) = 0 &
    0 + (2y-1) = 0 &
    -(1-y)^2 + (2y-1) = 0 \\
    (1-y)^2 + (2y-1) = -y^2 &
    0 + (2y-1) = -y^2 &
    -(1-y)^2 + (2y-1) = -y^2.
    \end{array}
  \]
  Each of the last eight equations is a nontrivial polynomial equation.
  Hence, there is some constant $C > 100$ such that the latter eight equations
  are all false for any real number $y > C$.
  Consequently, $f(y) = y^2$ for $y > C$.

  Finally, for any real number $z > 0$, take $x,y > C$ such that $x^2-y=z$;
  then $P(x,y)$ proves $f(z) = z^2$ too.

  \ii Note that (as $f$ is even), $f$ works iff $-f$ works,
  so the case $f(1) = -1$ is analogous.

  \ii If $f(1) = 0$, then $f(1-y) = f(y)$.
  Hence for any $y$ such that $|1-y| \neq |y|$, we conclude $f(y) = 0$.
  Then take $P(2, 7/2) \implies f(1/2) = 0$.
\end{itemize}

\begin{remark*}
  There is another clever symmetry approach possible after the main claim.
  The idea is to write
  \[ P(x,y^2) \implies f(x^2-y^2) + 2y^2f(x) = f(f(x)) + f(f(y)). \]
  Since $f$ is even gives $f(x^2-y^2) = f(y^2-x^2)$,
  one can swap the roles of $x$ and $y$ to get $2y^2f(x) = 2x^2f(y)$.
  Set $y=1$ to finish.
\end{remark*}
\pagebreak

\subsection{JMO 2024/6, proposed by Anton Trygub}
\textsl{Available online at \url{https://aops.com/community/p30227196}.}
\begin{mdframed}[style=mdpurplebox,frametitle={Problem statement}]
Point $D$ is selected inside acute triangle $ABC$
so that $\angle DAC = \angle ACB$ and $\angle BDC = 90^\circ + \angle BAC$.
Point $E$ is chosen on ray $BD$ so that $AE = EC$.
Let $M$ be the midpoint of $BC$.
Show that line $AB$ is tangent to the circumcircle of triangle $BEM$.
\end{mdframed}
This problem has several approaches and we showcase a collection of them.

\paragraph{The author's original solution.}
Complete isosceles trapezoid $ABQC$ (so $D \in \ol{AQ}$).
Reflect $B$ across $E$ to point $F$.
\begin{center}
\begin{asy}
size(7cm);
pair A = dir(185);
pair C = dir(355);
pair B = dir(115);
pair Q = A*C/B;
pair X = extension(A, B, Q, C);
pair Y = 2*X-A;
filldraw(A--B--C--cycle, opacity(0.1)+lightred, red);
draw(unitcircle, red);
pair D = IP(A--Q, circumcircle(B, C, Y));
pair N = midpoint(A--C);
pair M = midpoint(B--C);
draw(A--Q, mediumblue);
pair E = extension(N, origin, B, D);
pair F = 2*E-B;
draw(F--B, deepgreen);
pair S = dir(90);
draw(S--N, brown);
draw(F--Q, brown);
draw(M--E, grey);
draw(F--C--Q, grey);
filldraw(circumcircle(Q, D, C), opacity(0.1)+yellow, orange);
markangle(n=2, radius=6, M, E, B, deepgreen);
markangle(n=2, radius=6, C, F, B, deepgreen);
markangle(n=1, radius=6, D, Q, C, deepgreen);
markangle(n=1, radius=6, A, B, C, deepgreen);

dot("$A$", A, dir(225));
dot("$C$", C, dir(315));
dot("$B$", B, dir(160));
dot("$Q$", Q, dir(100));
dot("$D$", D, dir(180));
dot(N);
dot("$M$", M, dir(90));
dot("$E$", E, dir(225));
dot("$F$", F, dir(F));

/* -----------------------------------------------------------------+
|                 TSQX: by CJ Quines and Evan Chen                  |
| https://github.com/vEnhance/dotfiles/blob/main/py-scripts/tsqx.py |
+-------------------------------------------------------------------+
!size(7cm);
A 225 = dir 185
C 315 = dir 355
B 160 = dir 115
Q 100 = A*C/B
X := extension A B Q C
Y := 2*X-A
A--B--C--cycle / 0.1 lightred / red
unitcircle / red
D 180 = IP A--Q (circumcircle B C Y)
N = midpoint A--C
M 90 = midpoint B--C
A--Q / mediumblue
E 225 = extension N origin B D
F = 2*E-B
F--B / deepgreen
S := dir 90
S--N / brown
F--Q / brown
M--E / grey
F--C--Q / grey
circumcircle Q D C / 0.1 yellow / orange
!markangle(n=2, radius=6, M, E, B, deepgreen);
!markangle(n=2, radius=6, C, F, B, deepgreen);
!markangle(n=1, radius=6, D, Q, C, deepgreen);
!markangle(n=1, radius=6, A, B, C, deepgreen);
*/
\end{asy}
\end{center}
\begin{claim*}
  We have $DQCF$ is cyclic.
\end{claim*}
\begin{proof}
  Since $EA=EC$, we have $\ol{QF} \perp \ol{AC}$
  as line $QF$ is the image of the perpendicular bisector of $\ol{AC}$
  under a homothety from $B$ with scale factor $2$.
  Then
  \begin{align*}
  \dang FDC &= -\dang CDB = 180\dg - (90\dg + \dang CAB) = 90\dg - \dang CAB \\
    &= 90\dg - \dang QCA = \dang FQC. \qedhere
  \end{align*}
\end{proof}
To conclude, note that
\[ \dang BEM = \dang BFC = \dang DFC = \dang DQC = \dang AQC = \dang ABC = \dang ABM. \]

\begin{remark*}
  [Motivation]
  Here is one possible way to come up with the construction of point $F$
  (at least this is what led Evan to find it).
  If one directs all the angles in the obvious way,
  there are really two points $D$ and $D'$ that are possible,
  although one is outside the triangle;
  they give corresponding points $E$ and $E'$.
  The circles $BEM$ and $BE'M$ must then actually coincide since they
  are both alleged to be tangent to line $AB$.
  See the figure below.
  \begin{center}
  \begin{asy}
    size(11cm);
    pair A = dir(185);
    pair C = dir(355);
    pair B = dir(115);
    pair Q = A*C/B;
    pair X = extension(A, B, Q, C);
    pair Y = 2*X-A;
    filldraw(A--B--C--cycle, opacity(0.1)+lightred, red);
    draw(unitcircle, red);
    draw(circumcircle(B, C, Y), grey);
    pair D = IP(A--Q, circumcircle(B, C, Y));
    pair D_prime = -D+2*foot(circumcenter(B, C, Y), A, D);
    pair N = midpoint(A--C);
    pair M = midpoint(B--C);
    draw(A--D_prime, mediumblue);
    pair E = extension(N, origin, B, D);
    pair E_prime = extension(N, origin, B, D_prime);
    pair F = 2*E-B;
    pair F_prime = 2*E_prime-B;
    draw(F--B--D_prime, deepgreen);
    draw(E_prime--N, brown);
    draw(F--F_prime, brown);

    filldraw(circumcircle(B, E, E_prime), opacity(0.2)+grey, red+1.1);

    filldraw(M--E--E_prime--cycle, opacity(0.1)+yellow, brown+1.1);
    filldraw(D--C--D_prime--cycle, opacity(0.1)+cyan, heavycyan+1.1);
    filldraw(F--C--F_prime--cycle, opacity(0.1)+yellow, brown+1.1);

    dot("$A$", A, dir(225));
    dot("$C$", C, dir(315));
    dot("$B$", B, dir(160));
    dot("$Q$", Q, dir(130));
    dot("$D$", D, dir(180));
    dot("$D'$", D_prime, dir(D_prime));
    dot(N);
    dot("$M$", M, dir(65));
    dot("$E$", E, dir(225));
    dot("$E'$", E_prime, dir(E_prime));
    dot("$F$", F, dir(F));
    dot("$F'$", F_prime, dir(F_prime));

    /* -----------------------------------------------------------------+
    |                 TSQX: by CJ Quines and Evan Chen                  |
    | https://github.com/vEnhance/dotfiles/blob/main/py-scripts/tsqx.py |
    +-------------------------------------------------------------------+
    !size(11cm);
    A 225 = dir 185
    C 315 = dir 355
    B 160 = dir 115
    Q 130 = A*C/B
    X := extension A B Q C
    Y := 2*X-A
    A--B--C--cycle / 0.1 lightred / red
    unitcircle / red
    circumcircle B C Y / grey
    D 180 = IP A--Q (circumcircle B C Y)
    D' = -D+2*foot (circumcenter B C Y) A D
    N .= midpoint A--C
    M 65 = midpoint B--C
    A--D' / mediumblue
    E 225 = extension N origin B D
    E' = extension N origin B D'
    F = 2*E-B
    F' = 2*E'-B
    F--B--D' / deepgreen
    E'--N / brown
    F--F' / brown
    circumcircle E B E' / 0.2 grey / red 1.1
    M--E--E'--cycle / 0.1 yellow / brown 1.1
    D--C--D'--cycle / 0.1 cyan / heavycyan 1.1
    F--C--F'--cycle / 0.1 yellow / brown 1.1
    */
  \end{asy}
  \end{center}
  One can already prove using angle chasing that $\ol{AB}$ is tangent to $(BEE')$.
  So the point of the problem is to show that $M$ lies on this circle too.
  However, from looking at the diagram, one may realize that in fact it seems
  \[ \triangle MEE' \overset{+}{\sim} \triangle CDD' \]
  is going to be true from just those marked in the figure
  (and this would certainly imply the desired concyclic conclusion).
  Since $M$ is a midpoint, it makes sense to dilate $\triangle EME'$
  from $B$ by a factor of $2$ to get $\triangle FCF'$
  so that the desired similarity is actually a spiral similarity at $C$.
  Then the spiral similarity lemma says that the desired similarity
  is equivalent to requiring $\ol{DD'} \cap \ol{FF'} = Q$
  to lie on both $(CDF)$ and $(CD'F')$.
  Hence the key construction and claim from the solution are both discovered naturally,
  and we find the solution above.
  (The points $D'$, $E'$, $F'$ can then be deleted to hide the motivation.)
\end{remark*}

\paragraph{Another short solution.}
Let $Z$ be on line $BDE$ such that $\angle BAZ = 90\dg$.
This lets us interpret the angle condition as follows:
\begin{claim*}
  Points $A$, $D$, $Z$, $C$ are cyclic.
\end{claim*}
\begin{proof}
  Because $\dang ZAC = 90\dg - A = 180\dg - \dang CDB = \dang ZDC$.
\end{proof}

\begin{center}
\begin{asy}
size(8cm);
pair A = dir(185);
pair C = dir(355);
pair B = dir(110);
pair Q = A*C/B;
pair X = extension(A, B, Q, C);
pair Y = 2*X-A;
filldraw(A--B--C--cycle, opacity(0.1)+lightred, red);
draw(unitcircle, red);
pair D = IP(A--Q, circumcircle(B, C, Y));
pair N = midpoint(A--C);
pair M = midpoint(B--C);
draw(A--Q, mediumblue);
pair E = extension(N, origin, B, D);
pair S = dir(90);
draw(S--N, brown);
draw(M--E, blue);
pair Z = extension(B, D, A, -B);
draw(A--Z--B, deepgreen);
filldraw(circumcircle(A, D, Z), opacity(0.1)+palecyan, deepgreen);
pair W = midpoint(B--Z);
pair O = origin;
draw(M--W--O--cycle, deepgreen);

filldraw(circumcircle(E, O, M), opacity(0.1)+palecyan, deepgreen);

dot("$A$", A, dir(180));
dot("$C$", C, dir(0));
dot("$B$", B, dir(140));
dot("$D$", D, dir(160));
dot("$N$", N, dir(N));
dot("$M$", M, dir(90));
dot("$E$", E, dir(225));
dot("$Z$", Z, dir(Z));
dot("$W$", W, dir(250));
dot("$O$", O, dir(180));

/* -----------------------------------------------------------------+
|                 TSQX: by CJ Quines and Evan Chen                  |
| https://github.com/vEnhance/dotfiles/blob/main/py-scripts/tsqx.py |
+-------------------------------------------------------------------+
!size(8cm);
A 180 = dir 185
C 0 = dir 355
B 140 = dir 110
Q := A*C/B
X := extension A B Q C
Y := 2*X-A
A--B--C--cycle / 0.1 lightred / red
unitcircle / red
D 160 = IP A--Q (circumcircle B C Y)
N = midpoint A--C
M 90 = midpoint B--C
A--Q / mediumblue
E 225 = extension N origin B D
S := dir 90
S--N / brown
M--E / blue
Z = extension B D A -B
A--Z--B / deepgreen
circumcircle A D Z / 0.1 palecyan / deepgreen
W 250 = midpoint B--Z
O 180 = origin
M--W--O--cycle / deepgreen
circumcircle E O M / 0.1 palecyan / deepgreen
*/
\end{asy}
\end{center}

Define $W$ as the midpoint of $\ol{BZ}$, so $\ol{MW} \parallel \ol{CZ}$.
And let $O$ denote the center of $(ABC)$.

\begin{claim*}
  Points $M$, $E$, $O$, $W$ are cyclic.
\end{claim*}
\begin{proof}
  Note that
  \begin{align*}
    \dang MOE
    &= \dang(\ol{OM},\ol{BC}) + \dang(\ol{BC},\ol{AC}) + \dang(\ol{AC},\ol{OE}) \\
    &= 90\dg + \dang BCA + 90\dg \\
    &= \dang BCA = \dang CAD = \dang CZD = \dang MWD = \dang MWE. \qedhere
  \end{align*}
\end{proof}
To finish, note
\begin{align*}
  \dang MEB &= \dang MEW = \dang MOW \\
  &= \dang(\ol{MO}, \ol{BC}) + \dang(\ol{BC}, \ol{AB}) + \dang(\ol{AB}, \ol{OW}) \\
  &= 90\dg + \dang CBA + 90\dg = \dang CBA = \dang MBA.
\end{align*}
This implies the desired tangency.

\paragraph{A Menelaus-based approach (Kevin Ren).}
Let $P$ be on $\ol{BC}$ with $AP=PC$.
Let $Y$ be the point on line $AB$ such that $\angle ACY = 90\dg$;
as $\angle AYC = 90\dg - A$ it follows $BDYC$ is cyclic.
Let $K = \ol{AP} \cap \ol{CY}$,
so $\triangle ACK$ is a right triangle with $P$ the midpoint of its hypotenuse.

\begin{center}
\begin{asy}
size(12cm);
pair A = dir(185);
pair C = dir(355);
pair B = dir(115);
pair Q = A*C/B;
pair X = extension(A, B, Q, C);
pair Y = 2*X-A;
filldraw(A--B--C--cycle, opacity(0.1)+lightred, red);
draw(unitcircle, red);
filldraw(circumcircle(B, C, Y), opacity(0.1)+palecyan, deepcyan);
pair D = IP(A--Q, circumcircle(B, C, Y));
pair N = midpoint(A--C);
pair M = midpoint(B--C);
pair E = extension(N, origin, B, D);
pair P = extension(A, Q, B, C);
pair Y = extension(A, B, C, -A);
draw(B--Y--C, red);
pair K = extension(A, P, C, Y);
draw(A--K, blue);
filldraw(B--E--M--cycle, opacity(0.1)+yellow, deepgreen);
filldraw(Y--D--C--cycle, opacity(0.1)+yellow, deepgreen);
draw(Y--P, grey);
draw(P--N, brown);

dot("$A$", A, dir(225));
dot("$C$", C, dir(315));
dot("$B$", B, dir(160));
dot(Q);
dot("$D$", D, dir(180));
dot(N);
dot("$M$", M, dir(35));
dot("$E$", E, dir(225));
dot("$P$", P, dir(100));
dot("$Y$", Y, dir(Y));
dot("$K$", K, dir(20));

/* -----------------------------------------------------------------+
|                 TSQX: by CJ Quines and Evan Chen                  |
| https://github.com/vEnhance/dotfiles/blob/main/py-scripts/tsqx.py |
+-------------------------------------------------------------------+
!size(11cm);
A 225 = dir 185
C 315 = dir 355
B 160 = dir 115
Q 130 .= A*C/B
X := extension A B Q C
Y := 2*X-A
A--B--C--cycle / 0.1 lightred / red
unitcircle / red
circumcircle B C Y / 0.1 palecyan / deepcyan
D 180 = IP A--Q (circumcircle B C Y)
N .= midpoint A--C
M 35 = midpoint B--C
E 225 = extension N origin B D
P 100 = extension A Q B C
Y = extension A B C -A
B--Y--C / red
K 20 = extension A P C Y
A--K blue
B--E--M--cycle / 0.1 yellow / deepgreen
Y--D--C--cycle / 0.1 yellow / deepgreen
Y--P / grey
P--N / brown
*/
\end{asy}
\end{center}

\begin{claim*}
  Triangles $BPE$ and $DYK$ are similar.
\end{claim*}
\begin{proof}
  We have $\dang MPE = \dang CPE = \dang KCP = \dang PKC$
  and $\dang EBP = \dang DBC = \dang DYC = \dang DYK$.
\end{proof}
\begin{claim*}
  Triangles $BEM$ and $YDC$ are similar.
\end{claim*}
\begin{proof}
  By Menelaus $\triangle PCK$ with respect to collinear points $A$, $B$, $Y$ that
  \[ \frac{BP}{BC} \frac{YC}{YK} \frac{AK}{AP} = 1. \]
  Since $AK/AP = 2$ (note that $P$ is the midpoint of the hypotenuse of right triangle $ACK$)
  and $BC = 2BM$, this simplifies to
  \[ \frac{BP}{BM} = \frac{YK}{YC}. \qedhere \]
\end{proof}
To finish, note that
\[ \dang DBA = \dang DBY = \dang DCY = \dang BME \]
implying the desired tangency.

\paragraph{A spiral similarity approach (Hans Yu).}
As in the previous solution,
let $Y$ be the point on line $AB$ such that $\angle ACY = 90\dg$;
so $BDYC$ is cyclic.
Let $\Gamma$ be the circle through $B$ and $M$ tangent to $\ol{AB}$,
and let $\Omega \coloneqq (BCYD)$.
We need to show $E \in \Gamma$.

\begin{center}
\begin{asy}
size(11cm);
pair A = dir(185);
pair C = dir(355);
pair B = dir(110);
pair Q = A*C/B;
pair H = extension(A, B, Q, C);
pair Y = 2*H-A;
filldraw(A--B--C--cycle, opacity(0.1)+lightred, red);
draw(unitcircle, red);
filldraw(circumcircle(B, C, Y), opacity(0.1)+palecyan, deepcyan+1.2);
pair D = IP(A--Q, circumcircle(B, C, Y));
pair N = midpoint(A--C);
pair M = midpoint(B--C);
pair E = extension(N, origin, B, D);
pair P = extension(A, Q, B, C);
pair Y = extension(A, B, C, -A);
draw(C--Y, grey);
draw(B--Y, red);
draw(A--Q, red);
filldraw(circumcircle(B, M, E), opacity(0.1)+palecyan, deepcyan+1.2);
draw(B--E, red);
pair S = -B+2*foot(B, circumcenter(B, M, E), circumcenter(B, C, Y));
pair O = circumcenter(A, B, C);
filldraw(O--B--M--cycle, opacity(0.2)+yellow, deepgreen+1.2);
draw(P--O, red);
pair O_1 = circumcenter(B, M, E);
pair O_2 = circumcenter(B, C, Y);
label("$\Gamma$", O_1+abs(O_1-B)*dir(80), dir(80), deepcyan);
label("$\Omega$", O_2+abs(O_2-B)*dir(320), dir(320), deepcyan);

dot("$A$", A, dir(225));
dot("$C$", C, dir(315));
dot("$B$", B, dir(160));
dot(Q);
dot("$D$", D, dir(80));
dot("$M$", M, dir(20));
dot("$E$", E, dir(290));
dot("$P$", P, dir(90));
dot("$Y$", Y, dir(Y));
dot("$S$", S, dir(80));
dot("$O$", O, dir(180));

/* -----------------------------------------------------------------+
|                 TSQX: by CJ Quines and Evan Chen                  |
| https://github.com/vEnhance/dotfiles/blob/main/py-scripts/tsqx.py |
+-------------------------------------------------------------------+
!size(11cm);
A 225 = dir 185
C 315 = dir 355
B 160 = dir 110
Q 130 .= A*C/B
H := extension A B Q C
Y := 2*H-A
A--B--C--cycle / 0.1 lightred / red
unitcircle / red
circumcircle B C Y / 0.1 palecyan / deepcyan 1.2
D 80 = IP A--Q (circumcircle B C Y)
N := midpoint A--C
M 20 = midpoint B--C
E 290 = extension N origin B D
P 90 = extension A Q B C
Y = extension A B C -A
C--Y / grey
B--Y / red
A--Q / red
circumcircle B M E / 0.1 palecyan / deepcyan 1.2
B--E / red
S 80 = -B+2*foot B (circumcenter B M E) (circumcenter B C Y)
O 180 = circumcenter A B C
O--B--M--cycle / 0.2 yellow / deepgreen 1.2
P--O / red
O_1 := circumcenter B M E
O_2 := circumcenter B C Y
!label("$\Gamma$", O_1+abs(O_1-B)*dir(80), dir(80), deepcyan);
!label("$\Omega$", O_2+abs(O_2-B)*dir(320), dir(320), deepcyan);
*/
\end{asy}
\end{center}

Denote by $S$ the second intersection of $\Gamma$ and $\Omega$.
The main idea behind is to consider the spiral similarity
\[ \Psi : \Omega \to \Gamma \qquad C \mapsto M \text{ and } Y \mapsto B \]
centered at $S$ (due to the spiral similarity lemma), and show that $\Psi(D) = E$.
The spiral similarity lemma already promises $\Psi(D)$ lies on line $BD$.
\begin{claim*}
  We have $\Psi(A) = O$, the circumcenter of $ABC$.
\end{claim*}
\begin{proof}
  Note $\triangle OBM \overset{+}{\sim} \triangle AYC$;
  both are right triangles with $\dang BAC = \dang BOM$.
\end{proof}
\begin{claim*}
  $\Psi$ maps line $AD$ to line $OP$.
\end{claim*}
\begin{proof}
  If we let $P$ be on $\ol{BC}$ with $AP=PC$ as before,
  \[ \dang(\ol{AD}, \ol{OP}) = \dang APO = \dang OPC = \dang YCP = \dang(\ol{YC}, \ol{BM}). \]
  As $\Psi$ maps line $YC$ to line $BM$ and $\Psi(A) = O$, we're done.
\end{proof}
Hence $\Psi(D)$ should not only lie on $BD$ but also line $OP$.
This proves $\Psi(D) = E$, so $E \in \Gamma$ as needed.
\pagebreak


\end{document}
