The first code can go in the create event of a persistent game controller object.
The second code can go in the step event of a persistent game controller object, or in a mouse button pressed event for a button to buy the next level, or whatever. It just has to run when you want to buy the next level.
The third one would probably go in a mouse button pressed event for a 'load' button object, or just in the create event or game start event of the persistent game controller object if you want it to automatically load data right from the start.
The fourth one can be in the mouse pressed event for a 'save' button object, the game end event for your game controller object, or, if you want to do some kind of auto-save system, you could put it in a code that runs on a timer, runs whenever you pause the game, runs whenever you enter a new room, runs whenever you buy anything or do anything, et cetera. This is mostly up to you where you want to put it. Each location will have slightly different results.