Hi there,
I have been living in York for the past 4 years and I will be honest, it isn't cheap. If your plan is to live alone then you will have to cover the cost of your bills alone which could amount to 100-160£ as a rough estimate each month (depending on the ratings and the companies you go with). Some places have bills included in the rent price. Rent for a studio that is furnished can be around 1000£ per month but would be cheaper for you in shared accommodations. In terms of groceries, I typically spend ~40£ per week just for me. If you are hesitant about who you may live with in share accommodation then a possible solution would be to rent a private studio the first year and then look for people that you would want to live with for the following years. It would just make living in York much more affordable and would potentially allow for better savings.
I don't know how this compares to St Andrews but York is a great place to live and there are so many opportunities around here for things to do and places to visit.
Just to be clear, these are just some estimates based on my experience and prices change all the time so be aware that they won't reflect exactly what you may encounter.