#include <bits/stdc++.h>

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef unsigned long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;

const int N = 2e6 + 10;
const int B = 1e9 + 9;
const int P = 31;

int f[N];

void u(int x, int d) {
    for (; x < N; x |= x + 1) f[x] += d;
}

int g(int x) {
    int ans = 0;
    for (; x >= 0; x = (x & (x + 1)) - 1) ans += f[x];
    return ans;
}

set <int> st;
    
void add(int x) {
    if (!st.size() || !st.count(x)) {
        st.insert(x);
        if (x < N) u(x, 1);
        return;
    }
    assert(x != 0);
    st.erase(x);
    u(x, -1);
    add(x - 1);
}

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
    #endif
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    forn(i, 1, n) {
        if (st.count(0)) {
            cout << "No\n";
            continue;
        }
        int x;
        cin >> x;
        if (!st.size() || x > N) {
            add(x);
            cout << "Yes\n";
            continue;
        }    
        bool shit = 0;
        if (g(x) == x && st.size() > x) shit = 1;
        if (!shit) add(x);
        cout << (shit ? "No" : "Yes") << "\n";
    }
    
    
    return 0;
}

### Prompt

Please create a solution in Cpp to the following problem:

Example

Input

6
2
3
1
1
4
2


Output

Yes
Yes
Yes
No
Yes
No

### Response

```cpp
#include <bits/stdc++.h>

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef unsigned long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;

const int N = 2e6 + 10;
const int B = 1e9 + 9;
const int P = 31;

int f[N];

void u(int x, int d) {
    for (; x < N; x |= x + 1) f[x] += d;
}

int g(int x) {
    int ans = 0;
    for (; x >= 0; x = (x & (x + 1)) - 1) ans += f[x];
    return ans;
}

set <int> st;
    
void add(int x) {
    if (!st.size() || !st.count(x)) {
        st.insert(x);
        if (x < N) u(x, 1);
        return;
    }
    assert(x != 0);
    st.erase(x);
    u(x, -1);
    add(x - 1);
}

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
    #endif
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    forn(i, 1, n) {
        if (st.count(0)) {
            cout << "No\n";
            continue;
        }
        int x;
        cin >> x;
        if (!st.size() || x > N) {
            add(x);
            cout << "Yes\n";
            continue;
        }    
        bool shit = 0;
        if (g(x) == x && st.size() > x) shit = 1;
        if (!shit) add(x);
        cout << (shit ? "No" : "Yes") << "\n";
    }
    
    
    return 0;
}

```