3. (1994 20th Russian Olympiad Final Problem) A class has a total of 30 students, and each student has the same number of friends within the class. How many students at most can there be who are better than the majority of their friends (assuming that for any two students in the class, it can be determined who is better)?

将上面的文本翻译成英文，请保留源文本的换行和格式，直接输出翻译结果。
3. Answer: 25 students.

In fact, a student who performs better than the majority of their classmates is called a "good student." Let the class have $x$ "good students," and each student has $k$ friends in the class.

Obviously, the student with the best grades is the better one in $k$ "friend pairs"; and by the given condition, each of the other "good students" is the better one in at least $\left[\frac{k}{2}\right]+1 \geqslant \frac{k+1}{2}$ "friend pairs." Therefore, the "good students" are the better ones in at least
$$
k+(x-1) \cdot \frac{k+1}{2}
$$

"friend pairs," but the total number of "friend pairs" in the class is $\frac{30 k}{2}=15 k$, so
$$
k+(x-1) \frac{k+1}{2} \leqslant 15 k, x \leqslant 28 \cdot \frac{k}{k+1}+1 \text {. }
$$

Noting that the number of students who perform worse than the worst "good student" is at most $30-x$, therefore
$$
\frac{k+1}{2} \leqslant 30-x, k \leqslant 59-2 x \text {. }
$$

From (1) and (2), we get
$$
x \leqslant 28 \cdot \frac{59-2 x}{60-2 x}+1 \text {, i.e., } x^{2}-59 x+856 \geqslant 0 .
$$

Noting that $x \leqslant 30$, it can be seen that the largest integer $x$ satisfying (3) is $x=25$. That is, the total number of "good students" does not exceed 25.
On the other hand, all students in the class can be numbered from 1 to 30 according to their grades from best to worst, and the numbers 1 to 30 can be arranged in a $6 \times 5$ table (as shown in the figure). If two students in the class are friends if and only if their numbers fall into one of the following three cases in the table:
(1) in adjacent rows but different columns;
(2) in the same column with one at the bottom of the column;
(3) in the top row.
At this time, each person in the class has 9 friends, and each of the students numbered 1 to 25 is better than 5 of their friends, so the total number of "good students" is 25.
In summary, the maximum number of students who perform better than the majority of their friends is 25.