Codeforces Round 1065 (Div. 3) Upsolving (finished)