1. Janica had several candies. She gave half of the candies to her brother, and ate a sixth of the remaining candies. She lost 2 or 3 candies on the way, and gave 6 candies to her friend Petra. In the end, she had 21 candies left. How many candies did Janica have?
First method:

Let $x$ be the number of candies Janica had.

She gave $\frac{x}{2}$ candies to her brother, so she had $\frac{x}{2}$ candies left.

She ate $\frac{1}{6} \cdot \frac{x}{2}=\frac{x}{12}$ candies, and after that, she had $\frac{x}{2}-\frac{x}{12}=\frac{5 x}{12}$ candies left.

Since she lost 2 or 3 candies and gave 6 candies to Petra, there are two possibilities:

$\frac{5 x}{12}-8=21$ or $\frac{5 x}{12}-9=21$

From $\frac{5 x}{12}-8=21$ it follows that $x=\frac{29 \cdot 12}{5} \notin \mathbb{N}$.

From $\frac{5 x}{12}-9=21$ it follows that $x=\frac{30 \cdot 12}{5}=72$.

Janica had 72 candies.