One of five brothers baked a pie for their mother. Andrey said: "It's Vitya or Tolya". Vitya said: "It wasn't me or Yura". Tolya said: "You are both joking". Dima said: "No, one of them is telling the truth, and the other is lying". Yura said: "No, Dima, you are wrong". Mother knows that three of her sons always tell the truth. Who baked the pie?
Let's consider three possible cases separately.

1) Both Andrey and Vitya are lying. This means that Tolya is telling the truth, Dima is lying, and Yura is telling the truth.
2) One of the boys (Andrey or Vitya) is telling the truth, while the other is lying. In this case, Tolya is lying, Dima is telling the truth, and Yura is lying.
3) Both Andrey and Vitya are telling the truth. Then Tolya and Dima are lying, and Yura is telling the truth.

Only in the third case do three of the brothers tell the truth. Therefore, only this case could have occurred. Since Andrey is telling the truth, the pie was baked by either Vitya or Tolya. However, Vitya (who we have determined is also telling the truth) denies that he did it. Therefore, the pie was baked by Tolya. In this case, Andrey, Vitya, and Yura told the truth.