Stocks gain and Buffet's Berkshire swings a big profit