In HIMYM, there's a continual reference to the movie Departed in the dialogue between Ted and Marshall, which goes like: "-Are you a cop? -I'm not a cop."
You can watch the scene here, which is from the thirteenth episode of the season 8.
My question is that whether this specific (or a similar) dialogue appears in the movie, or it is merely an adaptation.