A Comprehensive Survey of AI-Driven Advancements and Techniques in Automated Program Repair and Code Generation