Ask police if you are free to leave. If the officer says yes, calmly and silently walk away. If you are under arrest, they should tell you.
You have the right to remain silent and cannot be punished for refusing to answer questions. If you wish to remain silent, tell the officer out loud. In some states, you must give your name if asked to identify yourself.
You do not have to consent to a search of yourself or your personal belongings. For officer safety reasons a Police officer can do a “pat down” search to look for possible weapons. This is a limited search and different from a more extensive search of your person, personal belongings, car, or home. You should not physically resist, but you have the right to refuse consent for any further search.