I also favour UMD PHD. UMD is a top cs school, quite worth going. A MS degree does not necessarily increase the chance for you to get into the top 4. As I know, it's even very hard for a Stanford MS student to stay and continue a PhD degree in Stanford. Some MS programs are course based, aiming preparing you for the future job seeking. Some MS programs are thesis based, which may focus more on research, and help you in the future application of PhD. I don't know what the UCSD MS program is like, but they seem to admit quite a few people, which means it might be difficult to find an advisor to work with. Also, the fianance of UC is not that good, I don't think you can get some financial aid for the MS program.