Yes. By purchasing the Windows XP disk. Before installing it, you should
remove the pirated version. If it was me, I would do a clean install (remove
all partitions on that hard drive, create a new partition, format the hard
drive, then install the legal copy of XP).
By the way, a "CPU" is the Central Processing Unit" that mounts on the
motherboard. It is the "brains" of the computer, but it is NOT the computer
itself. A computer is the whole works: the CPU, motherboard, memory, hard
drive, CD-ROM drive, case, etc..
So calling a computer a "CPU" is like calling a car an "engine".