Hard Puzzle

Ick, some prankster messed up the captain's coding. Can you sort it out for her?

Thanks to Virtual_Max.