Cube Summing, Approximate Inference with Non-Local Features, and Dynamic Programming without Semirings