How does the ability Costar work?
Does the Pokémon with Costar copy the stat changes of its ally that it replaces when it switches in? Or does it copy the stat changes of its doubles ally that it did not replace? Or something else?
Flamigo would copy the stat boosts of the ally it did not replace.
Replay
Flamigo switched in after Breloom used Swords Dance and Ceruledge used Bulk Up. Breloom switched out. Flamigo copied the stat changes for Ceruledge, gaining a +1 to Attack and Defense rather than a +2 to Attack.
Hope this helped.
Lets say you have a pikachu and an eevee both on the field, pikachu nasty plots and had it's Sp.Atk at x2 and then eevee does some random move, the next turn if you switch eevee into Flamigo it's costar ability will copy Pikachu's x2 Sp.Atk.