Inclusion-Exclusion Principle on $3$ Sets

Scenario: Suppose that, in a group of students, $30$ study Math, $25$ study Physics, and $20$ study CS. Also, we are told that $12$ students study both Math and Physics, $10$ study both Math and CS, and $8$ study both Physics and CS. Finally, $5$ students study all three subjects.

We want to find how many students study at least one subject. Using the Inclusion-Exclusion Principle, we calculate:

$$|M \cup P \cup C| = |M| + |P| + |C| - |M \cap P| - |M \cap C| - |P \cap C| + |M \cap P \cap C|.$$

Once we substitute the values, we get:

$$|M \cup P \cup C| = 30 + 25 + 20 - 12 - 10 - 8 + 5 = 50.$$

Thus, there are $50$ students who study at least one of the three subjects.