Senuran Muthusamy and Kagiso Rabada hit fighting half-centuries as South Africa took a crucial 71-run lead over Pakistan on day three of the second Test in Rawalpindi on Wednesday.