Edinburgh is still in level 2 as well, as are quite a few areas of Scotland. There is a map showing the areas at levels 0, 1 and 2 at inews.co.uk/news/scotland/scotland-level-map-covid-restrictions-what-tier-areas-postcode-checker-lockdown-update-1029118
St Andrews is at the extreme eastern end of Fife, the chunk of land to the North of Edinburgh.
The fastest bus from Edinburgh normally takes 1h 55m, and the Edinburgh to St. Andrews train on average 55 minutes, but the train terminus is at Leuchars, about 6 miles away, the rest of the journey is by bus and takes 14 minutes, so the total time, including a possible wait for the bus, is about 1 hr 25 minutes.
St Andrews is in level 1,
At Level 1 you can meet socially in groups:
of up to 6 people from 3 households in your home or theirs – and can stay overnight
of up to 8 people from 3 households in an indoor public place like a café, pub or restaurant
of up to 12 people from 12 households outdoors in your garden or a public place (but I for one wouldn't recommend eating in a public place in St Andrews unless the weather is exceptional)