Another resource you can look at is Algorithms by S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani.
It is a relatively recent book, and hence not one of the 'classics', but it is a good job of teaching algorithms from the ground up. The last few chapters look at "Dynamic Programming", "Linear programming and reductions", "NP-complete Search Problems" and "Coping with NP-completeness" - so exactly what you want. The code annotations are in pseudo-code, and are all cleanly reimplemented.
The primary advantage of this book is the authors distribute it's penultimate draft free on their site. I'm a new user and can't post hyperlinks, but google "algorithms vazirani" and it's the first and second link.
In regards to looking for working code "preferably in Python", I think that's the wrong approach, especially in algorithms. Implementing the algorithms yourself is a vital step in both learning the algorithm and feeling comfortable with the language. If you haven't yet worked out how the algorithm works, it's far better to actually look at the algorithm's steps rather than trying to find the algorithm's steps in the program's implementations.
After you learn these algorithms and techniques a great deal of the TopCoder problems can be sorted into a few sets, each expanding off of one idea or another. Once you're done with a more theoretical approach, you could move on to something like Programming Challenges by Steven S. Skiena and Miguel Revilla. It has a far briefer look at the algorithms themselves, instead focusing more on what sorts of competition problems can be solved by which of the standard algorithms. Almost always the solution to competition problems are re-imaginings or extensions of the original algorithms.