Confused with Unit Limit CCC to UC

So I found out I completed 25 qtr units at UCR which equals 16.666 semester units. My unit total would be 86.666 by the time i finish my prereqs at CC which is .111 above UCLA’s limit. I also found out that I got a C in gen chem 1 and a D in gen chem 2 at UCR. Does this mean my A in gen chem 1 at my CC wont benefit my GPA since you are only supposed retake courses you received a C- or lower in? My A in gen chem 2 should replace my D from UCR though right? What would happen to the duplicate units from taking gen chem 1 & 2 twice? Will they subtracted from my UCR unit total or the unit total from my CC?

I am also currently signed up to take recommended courses along with prereqs, but If I only take the prereqs, I will have a total of 67 units, putting me slightly under UCLA’s unit limit. Does this mean i shouldn’t take any recommended courses. This is incredibly stupid. I should have never gone to UCR in the first place.