Is it easier to get into UCSD and UCD undeclared and then switch into CS if accepted?

You aren’t the first person to think of this. I would guess the complexity is slightly greater at UCSD but, that’s a guess.

Please don’t take this as rude but, it won’t matter. With a 3.72 UCGPA there really isn’t a major you can select that will make your admission to either of these schools likely.

I am not suggesting you not apply. I don’t play a role in UC admission so my opinion is just that - and people with your stats do make it into both of these schools. Just understand they are unlikely.

IMHO

UCR and SDSU will be a coin toss but, certainly worth applications.

For CS, I would point you to UCM CSULB, CPP, and perhaps Fullerton, Sac and Chico as very solid CS programs that are very likely to admit you.

Cast a wide net - and good luck.