Let $p(x)$ and $q(x)$ be two polynomials such that $p(2)=5$, $p(3)=12$ and $p(q(x))=p(x)q(x)-p(x)$. Find the value of $q(10)$. 
Let $p(x)$ and $q(x)$ be two polynomials such that $p(2)=5$, $p(3)=12$ and $p(q(x))=p(x)q(x)-p(x)$. Find the value of $q(10)$.

The question is from a local mock contest that took place a few days ago. Here is my attempt to solve the problem:
Since $p(2)=5$ and $p(3)=12$, we have that $$p(x)=(x-2)r(x)+5\\ p(x)=(x-3)s(x)+12$$
where $r(x)$ and $s(x)$ are two polynomials.
Then I substituted $x=10$ in the constraint $$p(q(x))=p(x)q(x)-p(x)$$
and replaced $p(10)$ in terms of $r(10)$ and $s(10)$. But that makes the problem more complicated as there gets too many polynomials involved.
So how do I solve the question?
 A: Assuming the polynomials are not constant, it has been hinted in comments and established in another answer that both polynomials must be quadratics (by degree considerations), and $q$ must be monic (by identification of coefficients).
From the identity $p(q(x))=p(x)q(x)-p(x)\,$:

*

*if $a$ is a root of $q(x)$, then $a$ is a root of $p(x)+p(0)$ since $p(\,\underbrace{q(a)}_{=0}\,)=p(a)\,\underbrace{q(a)}_{=0}-p(a)$


*if $b$ is a double root of $q(x)$ then $b$ is a root of $p'(x)$ since $p'\left(q(b)\right)\,q'(b) = p'(b)q(b)+p(b)q'(b)-p'(b)$
It follows that $p(x)+p(0)$ has the same roots with $q(x)$, whether they are distinct or not, so $\,p(x) +p(0)= \lambda q(x)\,$ for some $\lambda \ne 0$.
Leaving aside the other two numeric constraints for now, the polynomial identity alone is homogeneous in $p$ so, for the purpose of solving it, it can be assumed WLOG that $\lambda=1$. Then, also using that $p(0)=\frac{1}{2}q(0)$, let $q(x)=x^2+bx+2c$ and $p(x)=q(x)-c=x^2 + bx+c\,$:
$$
\require{cancel}
\begin{align}
p(q(x))=p(x)q(x)-p(x) &\;\;\iff\;\; \cancel{q^2(x)} + bq(x)+\bcancel{c} = \left(\cancel{q(x)}-c\right)q(x) - \left(q(x)-\bcancel{c}\right)
\\ &\;\;\iff\;\; (b+c+1)q(x) = 0
\\ &\;\;\iff\;\; b = -c-1
\end{align}
$$
It follows that the general solution of the polynomial identity is:
$$
\begin{cases}
p(x) = \lambda\left(x^2-(c+1)x+c\right)
\\ q(x) = x^2 - (c+1)x+2c
\end{cases}
$$
Solving the two conditions $p(2)=5, p(3)=12$ for $\lambda,c$ gives $\,\lambda=1, c=-3\,$, so in the end $\,p(x) = x^2+2x-3\,$ and $q(x)=x^2+2x-6$.

[ EDIT ] Alternative solution (also assuming non-constant polynomials, with $p(x)$ having been determined to be a quadratic): let $a$ be a (possibly complex) root of $q(x) - 1$, so $q(a)=1$ and the equality $p(q(a))=p(a)q(a)-p(a) \implies p(1) = 0\,$. It follows that $p(x)$ is the unique quadratic that interpolates $\,(1,0),(2,5),(3,12)\,$, which is $\,p(x)=x^2+2x-3\,$.
Then $\,q^2(x)+2q(x)-3 = (x^2+2x-3)q(x) - (x^2+2x-3)\,$, which is a quadratic in $q(x)$ with the only non-constant solution $\,q(x)=x^2+2x-6\,$.
A: A brief sketch of a possible method:
First, suppose $q$ is a constant $q(x) = k$. Then $(\forall x) p(k) = (k-1) p(x)$, which is only possible if (a) $k = 2$ and $p$ is a constant (ruled out by the conditions), or (b) $k = 1$ and $p(1) = 0$. This possibility gives $q(10) = 1$.
Second, suppose $p$ and $q$ are both not constant but have leading terms $a x^m$ and $b x^n$, where $m, n \geq 1$ and $a, b \neq 0$. Then $p(x) q(x) - p(x)$ has leading term $ab x^{m+n}$ and $p(q(x))$ has leading term $ab^m x^{mn}$. If these are equal, then $m + n = mn$ (i.e. $m = n = 2$), and $ab = ab^2$; that is, $b = 1$. So $p$ and $q$ are quadratics and $q$ is monic.
So $p$ has the form $p(x) = a(x-2)(x-3) + 7x - 9 = ax^2 + (7-5a) x + (6a-9)$ and $q(x)$ has the form $x^2 + bx + c$, and using this, you could write out (ugly) expressions for $p(q(x))$ and $p(x) q(x) - p(x)$ and solve for $a, b, c$ by comparing coefficients.
