In town $ A,$ there are $ n$ girls and $ n$ boys, and each girl knows each boy. In town $ B,$ there are $ n$ girls $ g_1, g_2, \ldots, g_n$ and $ 2n - 1$ boys $ b_1, b_2, \ldots, b_{2n-1}.$ The girl $ g_i,$ $ i = 1, 2, \ldots, n,$ knows the boys $ b_1, b_2, \ldots, b_{2i-1},$ and no others. For all $ r = 1, 2, \ldots, n,$ denote by $ A(r),B(r)$ the number of different ways in which $ r$ girls from town $ A,$ respectively town $ B,$ can dance with $ r$ boys from their own town, forming $ r$ pairs, each girl with a boy she knows. Prove that $ A(r) = B(r)$ for each $ r = 1, 2, \ldots, n.$
2023 Romania EGMO TST
Day 1
Let $ b, m, n$ be positive integers such that $ b > 1$ and $ m \neq n.$ Prove that if $ b^m - 1$ and $ b^n - 1$ have the same prime divisors, then $ b + 1$ is a power of 2.
Let $D{}$ be a point inside the triangle $ABC$. Let $E{}$ and $F{}$ be the projections of $D{}$ onto $AB$ and $AC$, respectively. The lines $BD$ and $CD$ intersect the circumcircle of $ABC$ the second time at $M{}$ and $N{}$, respectively. Prove that \[\frac{EF}{MN}\geqslant \frac{r}{R},\]where $r{}$ and $R{}$ are the inradius and circumradius of $ABC$, respectively.
Consider fractions $\frac{a}{b}$ where $a$ and $b$ are positive integers. (a) Prove that for every positive integer $n$, there exists such a fraction $\frac{a}{b}$ such that $\sqrt{n} \le \frac{a}{b} \le \sqrt{n+1}$ and $b \le \sqrt{n}+1$. (b) Show that there are infinitely many positive integers $n$ such that no such fraction $\frac{a}{b}$ satisfies $\sqrt{n} \le \frac{a}{b} \le \sqrt{n+1}$ and $b \le \sqrt{n}$.
Day 2
A square with side $2008$ is broken into regions that are all squares with side $1$. In every region, either $0$ or $1$ is written, and the number of $1$'s and $0$'s is the same. The border between two of the regions is removed, and the numbers in each of them are also removed, while in the new region, their arithmetic mean is recorded. After several of those operations, there is only one square left, which is the big square itself. Prove that it is possible to perform these operations in such a way, that the final number in the big square is less than $\frac{1}{2^{10^6}}$.
Suppose that $f : \mathbb{N} \rightarrow \mathbb{N}$ is a function for which the expression $af(a)+bf(b)+2ab$ for all $a,b \in \mathbb{N}$ is always a perfect square. Prove that $f(a)=a$ for all $a \in \mathbb{N}$.
In a cyclic quadrilateral $ABCD$ with $AB=AD$ points $M$,$N$ lie on the sides $BC$ and $CD$ respectively so that $MN=BM+DN$ . Lines $AM$ and $AN$ meet the circumcircle of $ABCD$ again at points $P$ and $Q$ respectively. Prove that the orthocenter of the triangle $APQ$ lies on the segment $MN$ .
Let $n\geqslant 3$ be an integer and $a_1,\ldots,a_n$ be nonzero real numbers, with sum $S{}$. Prove that \[\sum_{i=1}^n\left|\frac{S-a_i}{a_i}\right|\geqslant\frac{n-1}{n-2}.\]