Students who perform better than most of their friends are called good. Let n be the number of good students, and k be the number of friends each student has. We will prove that n≤25. For this, we will consider two cases.
1) k≥8. Then the five worst students in the class are not good.
2) k≤7. The best student in the class is the best in k pairs of friends, and any other good student is the best in at least k+1/2 pairs. Therefore, good students are the best in at least k+(n−1))k+1/2 pairs. This number cannot exceed the number of all pairs of friends in the class, which is 15k. Hence, 2k+(n−1)(k+1)≤30k, which means n−1≤28⋅k/k+1=28−28/k+1≤28−28/8=24.5. Therefore, in this case, n≤25.
We will show that n can equal 25. Number the students from 1 to 30 in the order of decreasing performance and arrange the numbers in a 6×5 table as shown in the figure.
A pair of students is a pair of friends if their numbers are arranged in one of three ways: a) in adjacent rows and in different columns; b) in the same column and one of the numbers is in the bottom row; c) in the top row. In this case, as can be easily verified, all the required conditions are met.
## Answer
25 students.