I have a statement which I'd have needed to solve a textbook exercice. I found a way around it, but I'm still curious about it - it seems reasonable, but I can't find the right argument for it. Here it is.
Let $a_1, \ldots, a_n, b_1, \ldots, b_n$ be non-negative real numbers. If $$ \sum_{i = 1}^n a_i b_i = \sum_{i = 1}^n a_i^2 = \sum_{i = 1}^n b_i^2 $$
then $a_i = b_i$ for each $1 \leq i \leq n$.
Also, does that work if we drop the second equality?
Consider the sum $$\sum_i (a_i - b_i)^2 = \sum_i a_i^2 - 2 \sum_i a_ib_i + \sum b_i^2 = 0$$
If the sum of non negative numbers is equal to $0$ then each one is singularly equal to $0$, and this implies $$a_i = b_i $$ for every $i$
Note that you don't need any assumption on the sign of $a_i$, $b_i$
If you drop the second equality it's still true if you have $a_i > 0$, $a_i \le b_i$ as you can check looking at the sum $$\sum _i a_i(b_i - a_i)=0$$
But in general it's not true; for example take $a_1 = a_2 = 1$, $b_1 = 2, b_2 = 0$.