I think Maylene is there for no reason
In contrary to the previous answer, I cannot find anything which gives hard evidence that Maylene ever leaves the contest or anything. There are some random videos like this showing her battling you, but that is a hack. All bulbapedia says is;
>Maylene appears in HeartGold and SoulSilver in Celadon City's restaurant, having entered what appears to be an eating contest; piles of empty bowls surround her, amazing her onlookers. In addition, she will occasionally participate in the Pokéathlon's Supreme Cup in the Power Course with her Lucario, Meditite, and Machoke.