Placement of key signature and repeat bars

One closely related example from the archives: