Changed costs to long in cut() to fix bug and pass all tests.

Added the editorial implementation (Solution2)