HC study abroad students may apply to stay in University accommodation; further information will be provided with your offer (acceptance letter) from St. Andrews.
This said, University halls of residence are all co-ed, with mixed nationalities and age groups. When you apply for accommodation, you will indicate your preferences for:
shared or single bedroom
shared or private (ensuite) bathroom facilities
catered (meal plans) or self-catered.
You are not guaranteed your preferred choice of residence.
Once you've accepted your room offer, look at What Can I Bring?
Some residence halls include catering; others do not. Depending on where you live, you may be charged partial board, or none.
In either case, knowing the cost of food in St Andrews is helpful to prepare a budget accordingly. Check out the website Numbeo:
https://www.numbeo.com/cost-of-living/in/St-Andrews-United-Kingdom?displayCurrency=USD