yeah, public bathrooms have to be free. But as always it tends to come with an asterisk: for various reasons they may lock the doors and require a customer to ask for a key. IDK how legal it is but it's not uncommon to require purchasing food before using some public restrooms (not necessarily for fast food/grocery chains, but not unusual in either higher class dining or smaller mom and pop shops).