Id say resitting and doing better will do more to help you than it will to harm you. Medicine is one of the most competitive degrees and a D in maths would hurt your chances quite a bit if i were to guess.
tbh I'm not even convinced people actually notice you resat a year later. I mean, you have to declare it but i doubt people even check when you got the results and probably just look at the grades.