Find all real-valued functions $f$ defined on pairs of real numbers, having the following property: for all real numbers $a, b, c$, the median of $f(a,b), f(b,c), f(c,a)$ equals the median of $a, b, c$. (The median of three real numbers, not necessarily distinct, is the number that is in the middle when the three numbers are arranged in nondecreasing order.)
2011 USA TSTST
Day 1
Two circles $\omega_1$ and $\omega_2$ intersect at points $A$ and $B$. Line $\ell$ is tangent to $\omega_1$ at $P$ and to $\omega_2$ at $Q$ so that $A$ is closer to $\ell$ than $B$. Let $X$ and $Y$ be points on major arcs $\overarc{PA}$ (on $\omega_1$) and $AQ$ (on $\omega_2$), respectively, such that $AX/PX = AY/QY = c$. Extend segments $PA$ and $QA$ through $A$ to $R$ and $S$, respectively, such that $AR = AS = c\cdot PQ$. Given that the circumcenter of triangle $ARS$ lies on line $XY$, prove that $\angle XPA = \angle AQY$.
Prove that there exists a real constant $c$ such that for any pair $(x,y)$ of real numbers, there exist relatively prime integers $m$ and $n$ satisfying the relation \[ \sqrt{(x-m)^2 + (y-n)^2} < c\log (x^2 + y^2 + 2). \]
Day 2
Acute triangle $ABC$ is inscribed in circle $\omega$. Let $H$ and $O$ denote its orthocenter and circumcenter, respectively. Let $M$ and $N$ be the midpoints of sides $AB$ and $AC$, respectively. Rays $MH$ and $NH$ meet $\omega$ at $P$ and $Q$, respectively. Lines $MN$ and $PQ$ meet at $R$. Prove that $OA\perp RA$.
At a certain orphanage, every pair of orphans are either friends or enemies. For every three of an orphan's friends, an even number of pairs of them are enemies. Prove that it's possible to assign each orphan two parents such that every pair of friends shares exactly one parent, but no pair of enemies does, and no three parents are in a love triangle (where each pair of them has a child).
Let $a, b, c$ be positive real numbers in the interval $[0, 1]$ with $a+b, b+c, c+a \ge 1$. Prove that \[ 1 \le (1-a)^2 + (1-b)^2 + (1-c)^2 + \frac{2\sqrt{2} abc}{\sqrt{a^2+b^2+c^2}}. \]
Day 3
Let $ABC$ be a triangle. Its excircles touch sides $BC, CA, AB$ at $D, E, F$, respectively. Prove that the perimeter of triangle $ABC$ is at most twice that of triangle $DEF$.
Let $x_0, x_1, \dots , x_{n_0-1}$ be integers, and let $d_1, d_2, \dots, d_k$ be positive integers with $n_0 = d_1 > d_2 > \cdots > d_k$ and $\gcd (d_1, d_2, \dots , d_k) = 1$. For every integer $n \ge n_0$, define \[ x_n = \left\lfloor{\frac{x_{n-d_1} + x_{n-d_2} + \cdots + x_{n-d_k}}{k}}\right\rfloor. \] Show that the sequence $\{x_n\}$ is eventually constant.
Let $n$ be a positive integer. Suppose we are given $2^n+1$ distinct sets, each containing finitely many objects. Place each set into one of two categories, the red sets and the blue sets, so that there is at least one set in each category. We define the symmetric difference of two sets as the set of objects belonging to exactly one of the two sets. Prove that there are at least $2^n$ different sets which can be obtained as the symmetric difference of a red set and a blue set.
These problems are copyright $\copyright$ Mathematical Association of America.