The physical relationship between flares and surges observed in the extreme ultraviolet