Hinode observations of flares and active region emergence