spoj0; solve "Cakes" from Contest 120