For me it is: all of the above
I spent last week trying to fix a bug with no results. Today I went to the offices for a code review.
While I was waiting for my boss I though I take another look at the code and then, something told me "look at the templates files". I did and there was the problem...
That's why I can't really tell for sure when do I write my best code. it can be anytime, anywhere.