Codeforces Round #536 (Div. 2) E dp + set

NoSuchKey