<s>[INST] Maximize $P=a^2+b^2+c^2+ab+ac+bc$ 
For real numbers $a, b, c$ that  satisfy $a + b + c = 6$ and $0\leq a,b,c \leq 4$, 
  maximize $P=a^2+b^2+c^2+ab+ac+bc$. 

My try:

$$\begin{align} \begin{cases} a+b+c=6(1) \\ 0\leq a,b,c\leq4(2) \end{cases} \end{align}$$ $$(1)\Rightarrow \begin{align} \begin{cases} b+c=(6-a) \\b^2+c^2+bc=(6-a)^2-bc \end{cases} \end{align}$$ $$P=a^2+(b^2+c^2+bc)+a(b+c)=a^2+[(6-a)^2-bc]+a(6-a)$$ $$P=(a^2-12a+36)-bc=(a-6)^2-bc (2)\Rightarrow bc\leq 0 \Rightarrow P\geq (a-6)^2$$ When $bc=0 \Rightarrow [{\begin{matrix}b=0\\c=0\end{matrix}}(3)$. From  $(1)$ and $(3)$,  $\Rightarrow 2\leq a\leq 4(4)$ $P_{max} \implies |a-6|$ max satisfy $(4)$ $\implies a=2$ from $(1)$ and $(3)$ $\implies b=c=4$ $\implies P_{max}(a,b,c)=P(4;2;0)=28$

 [/INST] Let $f(x)=x^2$ and $a\geq b\geq c$. 
Hence, $f$ is a convex function and $(4,2,0)\succ(a,b,c)$. 
Thus, by Karamata
$$\sum_{cyc}(a^2+ab)=a^2+b^2+c^2+\frac{36-a^2-b^2-c^2}{2}=\frac{1}{2}(a^2+b^2+c^2)+18\leq$$
$$\leq\frac{1}{2}(4^2+2^2+0^2)+18=28.$$
Done!
</s>