Investors do best when they look beyond the stock market's short-term gyrations and focus instead on investing for the long haul. That's because long-term investing has been shown to generate bigger returns than short-term prognosticating. With that in mind, we asked some of our top Motley Fool contributors to weigh in with some beat-up stocks they think investors ought to pick up in the portfolios for the years ahead. Read on to see what three companies they think are bargain-bin buys.

Evan Niu, CFA: Some companies simply don't get a lot of love. However, the thing with Apple (AAPL 0.31%) is that sometimes the market loves the Mac maker, while other times investors utterly hate the company. Right now, the market sentiment embodies the latter.

Apple is currently trading near two-year lows after posting its first-ever decline in iPhone unit sales. Apple has always been an emotionally charged stock, with strong correlations to how the iPhone business is faring at any given moment. While the iPhone does represent the majority of the business and is incredibly important, investors often overlook how incredibly resilient and profitable the overall business is in absolute terms. You'd be hard-pressed to find any company that can put up net income of over $10 billion in a single quarter, much less consistently.

Yet, with fears of slowing growth, it seems the market hates Apple right now. Apple shares are not priced for growth and haven't been for many years; Apple's earnings multiple hasn't broken 20 in the past five years. So, we're talking about the most profitable business on the face of the planet that enjoys industry-leading margins while still paying a solid dividend yield -- and also trades at a substantial discount to the market. What's there to hate?

Image source: Flickr user stockmonkeys.com.

Todd Campbell: Worries that its best days are behind it have led to shares in Gilead Sciences (GILD -2.37%) falling 18.7% this year. While Gilead Sciences faces challenges to growth, I think they'll be temporary. If I'm right, then buying shares in this biotech giant when they're trading at less than 8 times forward earnings estimates is wise.

The company has enjoyed a tripling of sales since the launch of its hepatitis C drugs Sovaldi and Harvoni. However, with hepatitis's C market share of 90% and new competitors entering the market, sales in the indication are flattening out. As a result, management targets total sales of between $30 billion and $31 billion this year, down from $32.2 billion in 2015.

Although new competition is pushing net prices on its hep C drugs lower, the FDA could approve Gilead Sciences' next-generation HCV drug in June. If it does, then that drug could insulate market share and firm up prices. The once-daily pill would be the first pan-genotype HCV therapy approved by the FDA, and in trials, cure rates were nearly 100%.

Meanwhile, Gilead Sciences is refurbishing its top-selling HIV drug portfolio with new combination therapies that include TAF, a reformulation of Viread that is less risky to a patient's kidneys. Those new therapies should provide additional pop for the company over time. In Q1, Gilead Sciences HIV drug sales were $2.8 billion, up 18.5% year over year.

Studies evaluating multiple therapies for NASH, a liver disease that's increasingly the cause of transplant, are under way, as are trials evaluating cancer and autoimmune therapies. Those studies could also move the needle someday. 

Overall, since Gilead Sciences boasts an envy-inspiring balance sheet, and its shares yield a respectable 2.3%, this is one of my favorite bargain-bin buys.

John Rosevear: It's not just the market that hates General Motors (GM 1.28%). America's biggest carmaker is disdained by many who remember the General's decades-long legacy of substandard products and oblivious-to-reality business strategies.

But here's the thing many investors have missed: That General Motors doesn't exist anymore. It has been replaced by a new, post-bankruptcy GM -- and this GM is very different.

Quality? J.D. Power ranks GM right up with Toyota now -- and ahead of Honda. GM's global profits aren't yet in the same league as those of rivals Toyota and Volkswagen, but margins are growing quickly, and CEO Mary Barra has a solid, credible plan to close that profit gap by early next decade. Sales? GM leads China and the U.S. in profitable retail sales, and its (also profitable) commercial-fleet business is growing nicely

CEO Mary Barra has GM on a very strong course. Image source: General Motors.

As traditional automakers go, GM is doing great. But lots of investors worry the traditional automakers will soon be "disrupted" by tech-savvy newcomers like Uber, Tesla Motors, and Alphabet's Google Self-Driving Car crew. 

Some will be. But while most of its rivals are still talking up "mobility" without much to show for it, GM has backed its talk with impressive action: It's surging ahead in the race to a self-driving car, building its own ride-sharing business, and taking big stakes in mobility innovators like ride-hailing service Lyft. 

But GM is still old-school enough to pay a strong dividend, yielding almost 5% at current prices. And that's where we get to the investment story: Right now, GM is trading at less than 5 times its trailing-12-month earnings, in part because investors are worried that the U.S. new-car market might be near a peak. (To be clear, that's very cheap: Big automakers like GM traditionally trade at more like 10 to 12 times earnings.) 

If that turns out to be true, GM's profits might thin out for a few quarters. But that discount already seems to be built into GM's stock price. Given the General's new lease on life, and the trajectory Barra has laid out to boost profit growth over the next several years, it's hard not to think of this one as a compelling buy at current prices.