Interesting problem in combinatorics There are $100$ students in a classroom. Let $a_i$ denote the number of friends of the $i^{th}$ student. Let $c_j$ denote the number of students having at least $j$ number of friends. Prove that
$$\sum_{i=1}^{100} a_i = \sum_{j=1}^{99} c_j$$
I have a few doubts regarding the problem statement. Suppose $2$ is a friend of $1$, does that necessarily mean $1$ is a friend of $2$? Will $c_0$ be always $100$, or rather what does having at least $0$ friends mean?
 A: Something seems incorrect here (and it may be my understanding of the problem and counterexample). Counterexample: Suppose that the only friend of $a_1$ is $a_2$, the only friend of $a_2$ is $a_1$, the only friend of $a_3$ is $a_4$, the only friend of $a_4$ is $a_3$, etc.
Then $\sum_{i=1}^{100}a_i=100$ because each student has only one friend. However, $\sum_{j=0}^{99}c_j = c_0 + c_1 + \dots c_{99} = 100 + 100 + 0 + \dots + 0 = 200$.
Maybe we are trying to prove that $\sum_{i=1}^{100}a_i = \sum_{j=1}^{99}c_j$ instead.
A: Define a graph $\Gamma=(V,E)$ on the vertices $V=\{1,\dots,100\}$, with $\{i,j\}\in E$ if and only if $i$ and $j$ are friends. The number $a_i$ is the valency of the vertex $i$, a well-known fact, known as the degree sum formula states
$$\sum_{k=1}^{100} a_k=2|E|.$$
Using your definition of $c_j$ try to argue that $\sum\limits_{j=1}^{99}c_j=2|E|$.
A: Prove that 
$$
\sum_{i=1}^{100} a_i = \sum_{j=1}^{99} c_j.
$$
Here is "visual explanation":

Shortly, it is based on rearrangement of summation.
Let there is sequence $a_1,a_2, \ldots, a_n$ of nonnegative integer numbers. 
Denote $A=\max\limits_{1\le i \le n} a_i$.
Then one can write
$$
a_i = \sum_{\Large{1\le j \le A,}\atop\Large{ j\le a_i}} 1; \qquad (i=1,2,\ldots,n);
$$
$$
c_j = \sum_{\Large{1\le i \le n,}\atop\Large{ a_i\ge j}} 1; \qquad (j=1,2,\ldots,A);
$$
then
$$
\sum_{i=1}^n a_i 
\qquad = \qquad \sum_{i=1}^n \sum_{\Large{1\le j \le A,}\atop\Large{ j\le a_i}} 1
\qquad = \qquad \sum_{j=1}^A \sum_{\Large{1\le i \le n,}\atop\Large{ a_i\ge j}} 1 
\quad = \qquad \sum_{j=1}^A c_j.
$$
