The Selberg trace formula for congruence subgroups