## A. Contest Start

### Solution:

Each participant will make the following $\frac{t}{x}$ participants dissatisfied. But for last few participants, because no more participants following, so need subtract it.

### Code:

Java

C++

## B. Love Song

### Solution:

Just count the prefix sum of each letter.

### Code:

Java

C++

## C. Stable Groups

### Solution:

Let us consider the case that we do not add additional student, group the students directly. We can get this with brute force.

So, the difference between two groups is larger than x. If the difference is less than x after we add some additional students, we can merge these two groups. So, naturally, we sort the differences from small to large, and merge them one by one.

### Code:

Java

C++

## D. PriceFixed

We found that the total number of items that we bought will is the sum of a. So, it is just a matter of reversing the order of purchase.

Then we found whether have discount or not is depends on the b and the position of the item.