Comments

I misunderstand that he said div1C is different from div2E.

what's the difference?

Can you explain this one? A shorter solution. https://codeforces.me/blog/entry/105164?#comment-935234

I found another more elegant solution, but I don't know why it works.

    int wh = 0, cnt = 0;
    for (char c : s) {
        if (c == '(')cnt++;
        if (c == ')')cnt--;
        if (c == '?')wh++;
        if (cnt + wh == 1) {
            cnt = 1;
            wh = 0;
        }
    }
    if (abs(cnt) == wh) YES
    else NO

let '(' be 1, ')' be -1, then a parentheses sequence is regular iff the prefix sum off this sequence is nonnegtive at every position and the sum is zero.

You can use this conclusion to proof the correctness.

n |= n << 1  

How to solve problem F?