At a certain dance class, each student must pick exactly one partner. Each pair of dancers must consist of one advanced student and one beginner student. At first, after everyone pairs up, there are 4 extra beginner students. Then, after half of the beginner students have left, there are 5 extra advanced students. How many advanced students are in the class?

b = a+4

a = b/2 + 5
a = (a+4)/2 + 5
2a = a+14
a = 14
b = 18

To solve this problem, let's analyze the given information step by step:

Let's assume the number of advanced students in the class is "A" and the number of beginner students is "B".

According to the problem statement, after everyone pairs up, there are 4 extra beginner students. This means that there are B + 4 beginner students and A advanced students in total.

Since each pair consists of one advanced student and one beginner student, we can conclude that:

(A advanced students) + (B + 4 beginner students) = Total number of students = A + B + 4

Now let's move on to the next piece of information. After half of the beginner students leave, there are 5 extra advanced students. This means that the number of beginner students remaining is (B + 4) / 2 (half of the initial number of beginner students), and the number of advanced students is A + 5 (5 more advanced students than before).

We can now use this information to set up another equation:

(A + 5 advanced students) + [(B + 4) / 2 beginner students] = Total number of students = (A + B + 4)

We have two equations representing the total number of students before and after half of the beginners leave. We can now solve these equations to find the value of A (the number of advanced students).

Equation 1: A + B + 4 = A + B + 4
Equation 2: A + 5 + (B + 4) / 2 = A + B + 4

Simplifying Equation 2:
2A + 10 + B + 4 = 2A + 2B + 8
2A + B + 14 = 2A + 2B + 8
B - 2B = 8 - 14
-B = -6
B = 6

Now that we know B (the number of beginner students), we can substitute it back into Equation 1 to find the value of A (the number of advanced students):

A + 6 + 4 = A + 6 + 4
A + 10 = A + 10
A = A

The number of advanced students, A, is undefined in this case. This means that there is not enough information given to determine the exact number of advanced students in the class.