"Victory has a thousand fathers, but defeat is an orphan" -JFK
"You all stink like poo poo" - Rich Davis
"That idea may just be crazy enough... TO GET US ALL KILLED!" -Squidward Tentacles
"My heart is always breaking for the ghosts that haunt this room." -Nate Ruess

Really impossible to choose on a rational basis. Success or failure for a given president depends a lot on external factors -probably more than individual prowess. If you look at the arch of US history from weak former colony to hegemonic superpower and then to decadent society supported by military over expenditure (where we stand today), presidents' individual actions don't look so relevant, their greatest decisions appear merely as local variations in an overall trend that barely flinches from one term to the next.

Take Lincoln for example. In the mid 19th century the North (as a society) was ready to jump from a coastal country of local influence only to a continental power (by going West). The South stood in the way -too comfy in its limited profit agribusiness model. So the North had to impose its will or languish -and I do believe that slavery was an excuse like any other, the North would have pushed the South out of the way no matter what. So to some extent, Lincoln was there at the right time -a capable person without doubt, but many others could have fulfilled that role and the outcome would have likely been very similar.

In terms of pure brainpower, I think the smartest (not the same as greatest of course) president we had was Dick Nixon. And I'm no Republican.