Question: how did tywin know arya was a girl?
Answer: He figured out about Arya after one look at her. But then again, he was specifically tasked by Cersei to look for the "Stark girl". He had seen Arya running around in the Red Keep before. He knew she was on the run.