Crime & Punishment :
Generally Madrid is a safe place to live and visit with very low crime rates compared to similar sized cities in Europe.
However you do need to be on your guard for petty thieves especially gipsy street urchins, both boys and girls who are particularly adept at relieving you of your wallet /bag.
At night the area around Gran Via can be dangerous with general low life on the look out for easy foreign pickings. Street Prostitutes abound on Gran Via after 2am and should be avoided like the plague.
In the event that you are a victim of crime, the centrally located Police Station in Calle Leganitos 19 behind the Gran Via at the Plaza Espaņa end provide a multi lingual help service for reporting crime
If you have been charged with an offence your embassy or consulate will have a list of lawyers that you can consult.