Can we use matrix to solve this inequality? Let $$f(x)=\begin{cases}
1&0\le x\le 1\\
0&\rm{others}
\end{cases}$$
Let $x_{i},a_{i}(i=1,2,\cdots,n)$ be positive real numbers, 
show that:
$$\sum_{i,j=1}^{n}a_{i}a_{j}f\left(\dfrac{|x_{i}-x_{j}|}{2}\right)\le 3\sum_{i,j=1}^{n}a_{i}a_{j}f(|x_{i}-x_{j}|)$$
 A: Edit: this is only a partial answer.
$$\sum_{i,j=1}^{n}a_{i}a_{j}f\left(\dfrac{|x_{i}-x_{j}|}{2}\right)\le 3\sum_{i,j=1}^{n}a_{i}a_{j}f(|x_{i}-x_{j}|)$$
$$\sum_{i,j=1,i\neq j}^{n}a_{i}a_{j}f\left(\dfrac{|x_{i}-x_{j}|}{2}\right)\le 3\sum_{i,j=1,i\neq j}^{n}a_{i}a_{j}f(|x_{i}-x_{j}|) + 2\sum_{i=1}^{n}a_{i}a_{i}$$
$$\sum_{i,j=1,i\neq j}^{n}a_{i}a_{j}\left(f\left(\dfrac{|x_{i}-x_{j}|}{2}\right)-3f(|x_{i}-x_{j}|)\right)\le 2\sum_{i=1}^{n}a_{i}a_{i}$$
If the $x_i$ are spread far out, such that all $|x_{i}-x_{j}|>2$, the lhs is $0$ and the inequality is trivial.
If the $x_i$ are packed together, such that all $|x_{i}-x_{j}|<1$, the lhs is negative and the inequality is trivial.
The question becomes interesting only if there are some $|x_{i}-x_{j}|$ between 1 and 2, for which 
$$\begin{matrix}f\left(\dfrac{|x_{i}-x_{j}|}{2}\right)-3f(|x_{i}-x_{j}|)=1& (1) \end{matrix}$$
When $n=2$, it is possible to choose $x_i$ such that (1) holds for all $i,j$, foe examle $x_1=1,x_2=3$. Then
$$\sum_{i,j=1,i\neq j}^{2}a_{i}a_{j}\le 2\sum_{i=1}^{2}a_{i}^2$$
$$2 a_{1}a_{1}\le 2 a_{1}^2 +  2 a_{2}^2$$
$$a_{1}a_{1}\le 2\frac{a_{1}^2 + a_{2}^2}{2}$$
By the inequality of arithmetic and geometric means, we have
$$\frac{a_{1}^2 + a_{2}^2}{2}\geq a_1 a_2$$
So the inequality holds at least for $n=2$.
As pointed out by Winther in comments, for $n>3$ it is not generally true that
$$\sum_{i,j=1,i\neq j}^{n}a_{i}a_{j}\le 2\sum_{i=1}^{n}a_{i}^2$$
The issue is that the lhs grows quadratically in $n$, while the rhs grows linearly in $n$.
However, when $n>3$ it is also not possible to select $x_i$ such that (1) holds for all of them. Likely, the largest number of pairs $(i,j)$ that obey (1) is $(n-1)$.
