space is adding up the variables by size in bytes. sizeof(run)*nruns + size*2*sizeof(int) + 8*sizeof(int) (line 12) gets you close. Typically you only care about the variable sized entities, the size and nruns memory allocations.
time is N*N .. remember its not exact, and your biggest loop is line 52 (by number of iterations).
I mean more precisely (but not big-O approach) its size*nruns + size*5 ... the for loops' iteration counts. Big-O only keeps the dominate term.
remember this stuff can get weird.
what are you counting? conditions that bypass the work sometimes affect big-O. For example shell-sort LOOKS like N*N if you do the drive-by 'well, its got 2 nested for loops' approach to analysis. You do that too: if you want to count the assignments, that if condition that blocks them makes it a bit more hairy than just N*N. But if you assume that the if statement does MORE WORK (it does) than the assignment itself, and you want to know how long the thing will run, and the if executes every time (it does) ... then N*N works.