Start with backing up your files. Disassociate the machine from your iCloud an iTunes accounts.
You'll need an internet connection to reinstall the OS.
Reboot the machine and hold down the command R keys on your keyboard as soon as mac starts to turn on. This should bring you to the recovery mode.
Open Disk Utility. Select Macintosh HD (or if you renamed the startup drive, select it). Click the Erase tab. Click Erase. Once done quit out of Disk Utility. Select Reinstall OSX, click Continue, and Continue again. Skip the iTunes account sync as do don't want to associate at it back with your account.