The congruence subgroup problem for algebraic groups and strong approximation in affine varieties