While teaching how should I give justice equally to both female and male students?
If you really can't change your actions, find a different profession.

You're aware of the issue - you admit you spend more time helping the females than the males.  Find a way to equalize that problem.  Be sure that you make your time available to all genders - use office hours, or clarify to all students how to get help from you.  Look for the patterns where you realize that you cut off help from the men and continued to help the women - there's like an unconscious bias that you may be able to over come with a pattern.

Changing a pattern like this may not be easy - but it's what's rightfully expected.

Also ponder - why - why do you give women more time?  Are you hoping for something more than a teacher/student relationship?  Is something more pleasing about them? What's causing the problem, and can you reduce the factors that lead up to it?

I suppose the other alternative is to find a place where you teach only one gender.  Then you don't treat your students unequally.  Personally, that seems like taking a short cut.