Let $G$ be a simple graph with $95$ vertices,$2021$ edges,and vertex degrees $d_{1},d_{2},\cdots,d_{95}$,show that $$d^2_{1}+d^2_{2}+\cdots+d^2_{95}\le 300000$$
My attempt: Using Euler's theorem $$d_{1}+d_{2}+\cdots+d_{95}=2\cdot 2021=4042$$,and note $d_{i}\in N^{+}$.By the nature of the inequality, as if by an adjustment, but then How to prove $$d^2_{1}+d^2_{2}+\cdots+d^2_{95}\le 300000$$
A solution for a weaker inequality:
We know that $\sum d_i = 2\cdot 2021$, and $0\le d_i \le 94$. Now you can try to solve $\max \sum d_i^2$, where the conditions are as above. The numbers have to be as extreme as possible, since $a^2 + b^2 \le (a-\epsilon)^2 + (b+\epsilon)^2$, if $a\le b$. Therefore, we get as many numbers as possible to be $94$, and the rest $0$, and whatever is left. The fact is $4042 = 94 \cdot 43$, so the remainder is $0$.
We conclude $\sum d_i^2 = 43 \cdot 94^2 = 379948$
Now, the sequence of numbers $(0,0,\cdot, 0, 94, 94, \ldots 94)$ cannot be the degree sequence of a graph with $95$ vertices and $2021$ edges, so more analysis is needed.
$\bf{Added:}$
Consider a graph with $n$ vertices and $e$ edges that is a maximizer for $\sum d_i^2$. Let $k$, $l$ vertices that are not joined, and $i$, $j$ vertices that are joined. Let's alter the graph by moving the edge $(i,j)$ to edge $(k,l)$. The sequence of degrees changes only locally as
$$ d_k, d_k, d_i, d_j \mapsto d_k+1, d_l+1, d_i-1, d_j-1$$
and the objective changes from
$$ S + d_k^2 + d_l^2 + d_i^2 + d_j^2 \mapsto S+ (d_k+1)^2 + (d_l+1)^2 + (d_i-1)^2 + (d_j-1)^2$$
The change is $$\Sigma' - \Sigma = 2( (d_k + d_l) -(d_i+d_j) + 2)\le 0$$ that is $$d_k + d_l +2 \le d_i + d_j$$
An important conclusion:
if $i$, $j$ are joined, and $d_k + d_l \ge d_i+ d_j$, then $k$, $l$ are also joined.
How does the matrix of a graph with this property look like? Assume that the vertices are ordered such that $$d_1\ge d_2 \ge \ldots d_n$$
Then the matrix of the graph with the above property is such that the $1$ entries form a symmetric Young diagram (except the diagonal entries). Let's keep this in mind. Now, how to get $\sum d_i^2$ maximized? Build the graph matrix ( the Young diagram) by adding figure $L$ shapes of thickness $1$ and maximal size, starting from upper left corner and going down the diagonal ( basically because $a^2+b^2 < (a-1)+(b+1)^2$), skipping details). It's a fern growing in layers of thickness $1$, and maximal size, root being the top left corner.
Now, to our concrete case. We have $n=95$ and $e=2021$. Now, the optimal graph has the shape of $\Gamma$ with maximal thickness and edge $95$, and to it, from the inside, we add another $\Gamma$ shape of thickness $1$.
Now, the number of $1$ in an $\Gamma$ of edge $95$ and thickness $k$ is
$$2 \cdot k \cdot 95 - k^2 -k = k(189-k)$$
This should not exceed $2 e = 2\cdot 2021 = 4042$. For $k=24$ we get $24(198-24) =3960 < 4042$, while for $k=25$ we get $25(198-25)=4100>4042$. Hence $k=24$.
Now, there are $4042- 3960= 82$, $1$'s left, which will get us a $\Gamma$ shape of thickness $1$ and edge $42$ containing $2\cdot 41 = 82$ $1$'s.
Let's list the degrees of the graph (the left multiplier is the number of times it appears)
$$24 \cdot 94,\ 1\cdot (24+41=65),\ 41(24+1=25),\ 29\cdot 24$$
We get $$\sum_{i=1}^{95} d_i^2 = 24\cdot 94^2 + 65^2 + 41 \cdot 25^2 + 29\cdot 24^2= 258618$$
the maximum possible.