For motivation, learn new stuff. For focus… well, thatʼs your game.
I learn new stuff pretty often. A new algorithm, a new library, a new service, a new language, a new whatever. Iʼm interested in everything new, even if itʼs just a temporary buzzword. Learn new stuff, and get your hands dirty with it. If you havenʼt already, allocate a few hours of your work week only for this. This can even give some ideas on the problem at hand, or some clues on where to go when it is finally solved.
Keeping focus is a much harder thing, and a lot of sites, Hashnode included, is full of tips and tricks on the subject. The problem is, it all depends on you. A friend of mine has a movie on one screen while coding; how it helps him focus is beyond me, but it works for him. I put on my headphones, big enough to keep noise out. I sometimes even turn on some music, but most of the time silence is much better.
What also helps me is taking a step back. When I have a hard problem at hand I cannot solve, I just stop trying. I switch to another task (usually a small and easy one) so my brain stops thinking about the old one. When that is done, I switch back to the original problem, and usually solve it within an hour.
Happy coding!