Codeforces Round #598 (Div. 3) E. Yet Another Division Into Teams dp

NoSuchKey