Solution by jasperE3.
Claim: if x2+xf(y)∈f(R) for all x,y then f is surjective.
Proof. x=0 gives 0∈f(R) while f(y)=0 gives [0,∞)⊆f(R). Now for any x∈R we can choose a=−∣x∣−1 and b=−a+ax=∣x∣+1(∣x∣+1)2−x≥0, then x=a2+ab∈f(R).
f(f(x)2+f(xy))=x2+xf(y).
P(1,x)⇒f(f(1)2+f(x))=1+f(x)⇒f(f(1)2+x)=1+x by surjectivity, so f is linear. Testing, our only solution is f(x)=x.