I want to improve my speed while performing cardio such as running and swimming

What to do to increase my stamina?

Is there any thing like diet ..or anything else?