Stanley Kubrick co-wrote almost every film he directed, usually adapting a novel and usually with the novelist involved. Arthur C Clarke worked alongside him on 2001, with the book and film developing together, which is a rare arrangement.
The adaptations argue with their sources. Stephen King has been vocal for decades that The Shining misrepresents his novel, and Anthony Burgess objected to A Clockwork Orange using the American edition that omits the final chapter, which changes the ending entirely.
Dr. Strangelove began as a straight thriller adapted from Red Alert and turned into farce during writing when Kubrick concluded the material was inherently absurd. Terry Southern was brought in for that shift.