Problem:
Problem G
  Placing Medals on a Binary Tree
You have drawn a chart of a perfect binary tree, like one shown in Figure G.1. The figure shows a finite tree, but, if needed, you can add more nodes beneath the leaves, making the tree arbitrarily deeper.
Figure G.1. A Perfect Binary Tree Chart
Tree nodes are associated with their depths, defined recursively. The root has the depth of zero, and the child nodes of a node of depth d have their depths $d + 1$.
You also have a pile of a certain number of medals, each engraved with some number. You want to know whether the medals can be placed on the tree chart satisfying the following conditions.
A medal engraved with $d$ should be on a node of depth $d$.
One tree node can accommodate at most one medal.
The path to the root from a node with a medal should not pass through another node with a medal.
You have to place medals satisfying the above conditions, one by one, starting from the top of the pile down to its bottom. If there exists no placement of a medal satisfying the conditions, you have to throw it away and simply proceed to the next medal.
You may have choices to place medals on different nodes. You want to find the best placement. When there are two or more placements satisfying the rule, one that places a medal upper in the pile is better. For example, when there are two placements of four medal, one that places only the top and the 2nd medal, and the other that places the top, the 3rd, and the 4th medal, the former is better.
In Sample Input 1, you have a pile of six medals engraved with 2, 3, 1, 1, 4, and 2 again respectively, from top to bottom.
The first medal engraved with 2 can be placed, as shown in Figure G.2 (A).
Then the second medal engraved with 3 may be placed , as shown in Figure G.2 (B).
The third medal engraved with 1 cannot be placed if the second medal were placed as stated above, because both of the two nodes of depth 1 are along the path to the root from nodes already with a medal. Replacing the second medal satisfying the placement conditions, however, enables a placement shown in Figure G.2 (C).
The fourth medal, again engraved with 1, cannot be placed with any replacements of the three medals already placed satisfying the conditions. This medal is thus thrown away.
The fifth medal engraved with 4 can be placed as shown in of Figure G.2 (D).
The last medal engraved with 2 cannot be placed on any of the nodes with whatever replacements.
Figure G.2. Medal Placements
Input
The input consists of a single test case in the format below.
$n$
$x_1$
.
.
.
$x_n$
The first line has $n$, an integer representing the number of medals ($1 \leq n \leq 5 \times 10^5$). The following $n$ lines represent the positive integers engraved on the medals. The $i$-th line of which has an integer $x_i$ ($1 \leq x_i \leq 10^9$) engraved on the $i$-th medal of the pile from the top.
Output
When the best placement is chosen, for each i from 1 through n, output
Yes
in a line if the i-th medal is placed; 
...(truncated)

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

set<pi> ss;

int main(){

  int n = in();
  bool one = false;
  REP( i , n ){
    int a = in();
    if( one ){
      puts( "No" );
    } else if( ss.empty() ){
      puts( "Yes" );
      ss.insert( pi( a , a+1 ) );
    } else {
      bool f = true;
      auto ite = ss.upper_bound( pi( a , INF ) );
      if( ite == ss.begin() ){
        puts( "Yes" );
      } else {
        ite--;
        if( (*ite).se <= a ){
          puts( "Yes" );
        } else {
          // kuriagari
          if( (*ite).fi == 1 ){
            f = false;
            if( a + 1 == (*ite).se && SZ(ss) == 1 ){
              puts( "Yes" );
              one = true;
            } else {
              puts( "No" );
            }
          } else {
            puts( "Yes" );
            pi x = (*ite);
            ss.erase( ite );
            if( x.se != a + 1 ){
              ss.insert( pi( a + 1 , x.se ) );
            }
            a = x.fi - 1;
          }
        }
      }
      if( f ){
        auto itea = ss.upper_bound( pi( a , INF ) );
        auto iteb = ss.upper_bound( pi( a , INF ) );
        bool fa = false;
        bool fb = false;
        pi pa, pb;
        if( itea != ss.begin() ){
          itea--;
          pa = (*itea);
          if( (*itea).se == a ){
            fa = true;
          }
        }
        if( iteb != ss.end() ){
          pb = (*iteb);
          if( a + 1 == (*iteb).fi ){
            fb = true;
          }
        }
        if( fa && fb ){
          ss.erase( itea );
          ss.erase( iteb );
          ss.insert( pi( pa.fi , pb.se ) );
        } else if( fa ){
          ss.erase( itea );
          ss.insert( pi( pa.fi , pa.se + 1 ) );
        } else if( fb ){
          ss.erase( iteb );
          ss.insert( pi( pb.fi - 1 , pb.se ) );
        } else {
          ss.insert( pi( a , a + 1 ) );
        }
      }
    }
    /*
    YYS( w , ss ){
      cout << w.fi << " " << w.se << endl;
    }
    */
  }

  return 0;
}
accuracy: 1
time_ms: 120
memory_kb: 10036
final_rank: 1

code_snippet: #include<bits/stdc++.h>
using namespace std;

using ll = long long;
set<ll> num;
set<pair<ll,ll>> sec;

bool in;

void insert_sec(ll x){
    if (in){
        auto it = sec.upper_bound({x,1e18});
        it = prev(it);
        ll l = (*it).first;
        ll r = (*it).second;
        sec.erase(it);
        in = false;
        if (x != r)sec.insert({x+1,r});
        insert_sec(l-1);
    }
    else {
        ll l=x,r=x;
        auto it = sec.upper_bound({x,1e18});
        if (it != sec.end() && (*it).first == x+1){
            r = (*it).second;
            sec.erase(it);
        }
        it = sec.upper_bound({x,1e18});
        if (it != sec.begin() && (*prev(it)).second == x-1){
            l = (*prev(it)).first;
            sec.erase(prev(it));
        }
        sec.insert({l,r});
    }
}

void insert_num(ll x){
    for (int i = x; i >= 0; i--){
        if (!num.count(i)){
            num.insert(i);
            break;
        }
        num.erase(i);
    }
}


int main(){
    int q;cin >> q;

    {
        q--;
        ll x;cin >> x;
        sec.insert({x,x});
        num.insert(x);
        cout << "Yes" << endl;
    }

    while(q--){
        ll x;cin >> x;
        if (*(num.begin())==0){
            cout << "No" << endl;
            continue;
        }

        in = num.count(x);

        if (in){
            auto it = sec.upper_bound({x,1e18});
            it = prev(it);
            ll l = (*it).first;
            ll r = (*it).second;
            if (l == 1 && (x != r || sec.size()!=1))cout << "No" << endl;
            else {
                cout << "Yes" << endl;
                insert_num(x);
                insert_sec(x);
            }
        }
        else {
            cout << "Yes" << endl;
            insert_num(x);
            insert_sec(x);
        }

        //for (auto [p,q]:sec)cout << "{" << p << ' ' << q << "} ";
        //cout << endl;
        //for (auto p:num)cout << p << ' ';
        //cout << endl;
    }
}
accuracy: 1
time_ms: 590
memory_kb: 20768
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename E>
struct LazySegmentTree {
   private:
    int n{}, sz{}, height{};
    vector<T> data;
    vector<E> lazy;
    T (*op)(T, T);
    T (*e)();
    T (*mapping)(E, T);
    E (*composition)(E, E);
    E (*id)();

    void update(int k) { data[k] = op(data[2 * k], data[2 * k + 1]); }

    void all_apply(int k, const E x) {
        data[k] = mapping(x, data[k]);
        if (k < sz) lazy[k] = composition(x, lazy[k]);
    }

    void propagate(int k) {
        if (lazy[k] != id()) {
            all_apply(2 * k, lazy[k]);
            all_apply(2 * k + 1, lazy[k]);
            lazy[k] = id();
        }
    }

   public:
    LazySegmentTree() = default;
    explicit LazySegmentTree(int n, T (*op)(T, T), T (*e)(), T (*mapping)(E, T),
                             E (*composition)(E, E), E (*id)())
        : n(n),
          op(op),
          mapping(mapping),
          composition(composition),
          e(e),
          id(id) {
        sz = 1;
        height = 0;
        while (sz < n) sz <<= 1, height++;
        data = vector<T>(2 * sz, e());
        lazy = vector<E>(sz, id());
    }

    explicit LazySegmentTree(const vector<T> &v, T (*op)(T, T), T (*e)(),
                             T (*mapping)(E, T), E (*composition)(E, E),
                             E (*id)())
        : LazySegmentTree(v.size(), op, e, mapping, composition, id) {
        build(v);
    }

    void build(const vector<T> &v) {
        assert(n == (int)v.size());
        for (int k = 0; k < n; k++) data[k + sz] = v[k];
        for (int k = sz - 1; k > 0; k--) update(k);
    }

    void set(int k, const T x) {
        assert(0 <= k && k < n);
        k += sz;
        for (int i = height; i > 0; i--) propagate(k >> i);
        data[k] = x;
        for (int i = 1; i <= height; i++) update(k >> i);
    }

    T get(int k) {
        assert(0 <= k && k < n);
        k += sz;
        for (int i = height; i > 0; i--) propagate(k >> i);
        return data[k];
    }

    T operator[](int k) { return get(k); }

    T prod(int l, int r) {
        assert(0 <= l && l <= r && r <= n);
        if (l >= r) return e();
        l += sz;
        r += sz;
        // 更新する区間を部分的に含んだ区間においてトップダウンで子ノードに伝搬させながらdataの値を更新
        for (int i = height; i > 0; i--) {
            if (((l >> i) << i) != l) propagate(l >> i);
            if (((r >> i) << i) != r) propagate((r - 1) >> i);
        }
        T L = e(), R = e();
        // 値をチェックする区間のdataの値をチェック
        for (; l < r; l >>= 1, r >>= 1) {
            if (l & 1) L = op(L, data[l++]);
            if (r & 1) R = op(data[--r], R);
        }
        return op(L, R);
    }

    T all_prod() const { return data[1]; }

    void apply(int k, const E &x) {
        assert(0 <= k && k < n);
        k += sz;
        for (int i = height; i > 0; i--) propagate(k >> i);
        data[k] = mapping(x, data[k]);
        for (int i = 1; i <= height; i++) update(k >> i);
    }

    void apply(int l, int r, E x) {
        if (l >= r) return;
        l += sz;
        r += sz;
        // 更新する区間を部分的に含んだ区間においてトップダウンで子ノードに伝搬させながらdataの値を更新
        for (int i = height; i > 0; i--) {
            if (((l >> i) << i) != l) propagate(l >> i);
            if (((r >> i) << i) != r) propagate((r - 1) >> i);
        }
        {
            // 値を更新する区間のdataとlazyの値を更新
            int l2 = l, r2 = r;
            for (; l < r; l >>= 1, r >>= 1) {
                if (l & 1) all_apply(l++, x);
                if (r & 1) all_apply(--r, x);
            }
            l = l2, r = r2;
        }
        // 更新する区間を部分的に含んだ区間においてボトムアップで子ノードに伝搬させながらdataの値を更新
        for (int i = 1; i <= height; i++) {
            if (((l >> i) << i) != l) update(l >> i);
            if (((r >> i) << i) != r) update((r - 1) >> i);
        }
    }
    template <typename C>
    int max_right(int l, const C &check) {
        if (l >= n) return n;
        l += sz;

        for (int i = height; i > 0; i--) propagate(l >> i);
        T sum = e();
        do {
            while ((l & 1) == 0) l >>= 1;
            if (!check(op(sum, data[l]))) {
                while (l < sz) {
                    propagate(l);
                    l <<= 1;
                    auto nxt = op(sum, data[l]);
                    if (check(nxt)) {
                        sum = nxt;
                        l++;
                    }
                }
                return l - sz;
            }
            sum = op(sum, data[l++]);
        } while ((l & -l) != l);
        return n;
    }

    template <typename C>
    int min_left(int r, const C &check) {
        if (r <= 0) return 0;
        r += sz;
        for (int i = height; i > 0; i--) propagate((r - 1) >> i);
        T sum = e();
        do {
            r--;
            while (r > 1 and (r & 1)) r >>= 1;
            if (!check(op(data[r], sum))) {
                while (r < sz) {
                    propagate(r);
                    r = (r << 1) + 1;
                    auto nxt = op(data[r], sum);
                    if (check(nxt)) {
                        sum = nxt;
                        r--;
                    }
                }
                return r - sz;
            }
            sum = op(data[r], sum);
        } while ((r & -r) != r);
        return 0;
    }
};
struct S {
    long long value;
    int size;
};
using F = long long;

const F ID = 8e18;

S op(S a, S b) { return {a.value + b.value, a.size + b.size}; }
S e() { return {0, 0}; }
S mapping(F f, S x) {
    if (f != ID) x.value = f * x.size;
    return x;
}
F composition(F f, F g) { return (f == ID ? g : f); }
F id() { return ID; }

int main() {
    int n, m;
    cin >> n;
    LazySegmentTree<S, F> seg(500101, op, e, mapping, composition, id);
    int sum = 0;
    for (int i = 0; i < 500101; i++) {
        seg.set(i, {0, 1});
    }
    int other = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (seg.get(0).value != 0) {
            cout << "No" << '\n';
            continue;
        }
        if (a > 500100) {
            cout << "Yes" << '\n';
            other++;
        }

        else {
            if (seg.get(a).value == 0) {
                cout << "Yes" << '\n';
                seg.set(a, {1, 1});
            } else {
                auto han = [&](S cur) -> bool { return cur.value == cur.size; };
                int l = seg.min_left(a, han);
                if (l == 0) {
                    if (seg.prod(a + 1, 500101).value > 0 || other) {
                        cout << "No" << '\n';
                        continue;
                    }
                }
                cout << "Yes" << '\n';
                seg.set(l, {1, 1});
                seg.apply(l + 1, a + 1, 0);
            }
        }
    }
}
accuracy: 1
time_ms: 580
memory_kb: 23668
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename E>
struct LazySegmentTree {
   private:
    int n{}, sz{}, height{};
    vector<T> data;
    vector<E> lazy;
    T (*op)(T, T);
    T (*e)();
    T (*mapping)(E, T);
    E (*composition)(E, E);
    E (*id)();

    void update(int k) { data[k] = op(data[2 * k], data[2 * k + 1]); }

    void all_apply(int k, const E x) {
        data[k] = mapping(x, data[k]);
        if (k < sz) lazy[k] = composition(x, lazy[k]);
    }

    void propagate(int k) {
        if (lazy[k] != id()) {
            all_apply(2 * k, lazy[k]);
            all_apply(2 * k + 1, lazy[k]);
            lazy[k] = id();
        }
    }

   public:
    LazySegmentTree() = default;
    explicit LazySegmentTree(int n, T (*op)(T, T), T (*e)(), T (*mapping)(E, T),
                             E (*composition)(E, E), E (*id)())
        : n(n),
          op(op),
          mapping(mapping),
          composition(composition),
          e(e),
          id(id) {
        sz = 1;
        height = 0;
        while (sz < n) sz <<= 1, height++;
        data = vector<T>(2 * sz, e());
        lazy = vector<E>(sz, id());
    }

    explicit LazySegmentTree(const vector<T> &v, T (*op)(T, T), T (*e)(),
                             T (*mapping)(E, T), E (*composition)(E, E),
                             E (*id)())
        : LazySegmentTree(v.size(), op, e, mapping, composition, id) {
        build(v);
    }

    void build(const vector<T> &v) {
        assert(n == (int)v.size());
        for (int k = 0; k < n; k++) data[k + sz] = v[k];
        for (int k = sz - 1; k > 0; k--) update(k);
    }

    void set(int k, const T x) {
        assert(0 <= k && k < n);
        k += sz;
        for (int i = height; i > 0; i--) propagate(k >> i);
        data[k] = x;
        for (int i = 1; i <= height; i++) update(k >> i);
    }

    T get(int k) {
        assert(0 <= k && k < n);
        k += sz;
        for (int i = height; i > 0; i--) propagate(k >> i);
        return data[k];
    }

    T operator[](int k) { return get(k); }

    T prod(int l, int r) {
        assert(0 <= l && l <= r && r <= n);
        if (l >= r) return e();
        l += sz;
        r += sz;
        // 更新する区間を部分的に含んだ区間においてトップダウンで子ノードに伝搬させながらdataの値を更新
        for (int i = height; i > 0; i--) {
            if (((l >> i) << i) != l) propagate(l >> i);
            if (((r >> i) << i) != r) propagate((r - 1) >> i);
        }
        T L = e(), R = e();
        // 値をチェックする区間のdataの値をチェック
        for (; l < r; l >>= 1, r >>= 1) {
            if (l & 1) L = op(L, data[l++]);
            if (r & 1) R = op(data[--r], R);
        }
        return op(L, R);
    }

    T all_prod() const { return data[1]; }

    void apply(int k, const E &x) {
        assert(0 <= k && k < n);
        k += sz;
        for (int i = height; i > 0; i--) propagate(k >> i);
        data[k] = mapping(x, data[k]);
        for (int i = 1; i <= height; i++) update(k >> i);
    }

    void apply(int l, int r, E x) {
        if (l >= r) return;
        l += sz;
        r += sz;
        // 更新する区間を部分的に含んだ区間においてトップダウンで子ノードに伝搬させながらdataの値を更新
        for (int i = height; i > 0; i--) {
            if (((l >> i) << i) != l) propagate(l >> i);
            if (((r >> i) << i) != r) propagate((r - 1) >> i);
        }
        {
            // 値を更新する区間のdataとlazyの値を更新
            int l2 = l, r2 = r;
            for (; l < r; l >>= 1, r >>= 1) {
                if (l & 1) all_apply(l++, x);
                if (r & 1) all_apply(--r, x);
            }
            l = l2, r = r2;
        }
        // 更新する区間を部分的に含んだ区間においてボトムアップで子ノードに伝搬させながらdataの値を更新
        for (int i = 1; i <= height; i++) {
            if (((l >> i) << i) != l) update(l >> i);
            if (((r >> i) << i) != r) update((r - 1) >> i);
        }
    }
    template <typename C>
    int max_right(int l, const C &check) {
        if (l >= n) return n;
        l += sz;

        for (int i = height; i > 0; i--) propagate(l >> i);
        T sum = e();
        do {
            while ((l & 1) == 0) l >>= 1;
            if (!check(op(sum, data[l]))) {
                while (l < sz) {
                    propagate(l);
                    l <<= 1;
                    auto nxt = op(sum, data[l]);
                    if (check(nxt)) {
                        sum = nxt;
                        l++;
                    }
                }
                return l - sz;
            }
            sum = op(sum, data[l++]);
        } while ((l & -l) != l);
        return n;
    }

    template <typename C>
    int min_left(int r, const C &check) {
        if (r <= 0) return 0;
        r += sz;
        for (int i = height; i > 0; i--) propagate((r - 1) >> i);
        T sum = e();
        do {
            r--;
            while (r > 1 and (r & 1)) r >>= 1;
            if (!check(op(data[r], sum))) {
                while (r < sz) {
                    propagate(r);
                    r = (r << 1) + 1;
                    auto nxt = op(data[r], sum);
                    if (check(nxt)) {
                        sum = nxt;
                        r--;
                    }
                }
                return r - sz;
            }
            sum = op(data[r], sum);
        } while ((r & -r) != r);
        return 0;
    }
};
struct S {
    long long value;
    int size;
};
using F = long long;

const F ID = 8e18;

S op(S a, S b) { return {a.value + b.value, a.size + b.size}; }
S e() { return {0, 0}; }
S mapping(F f, S x) {
    if (f != ID) x.value = f * x.size;
    return x;
}
F composition(F f, F g) { return (f == ID ? g : f); }
F id() { return ID; }

int main() {
    int n, m;
    cin >> n;
    LazySegmentTree<S, F> seg(1000101, op, e, mapping, composition, id);
    int sum = 0;
    for (int i = 0; i < 1000101; i++) {
        seg.set(i, {0, 1});
    }
    int other = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (seg.get(0).value != 0) {
            cout << "No" << '\n';
            continue;
        }
        if (a > 1000100) {
            cout << "Yes" << '\n';
            other++;
        }

        else {
            if (seg.get(a).value == 0) {
                cout << "Yes" << '\n';
                seg.set(a, {1, 0});
            } else {
                auto han = [&](S cur) -> bool { return cur.value == cur.size; };
                int l = seg.min_left(a, han);
                if (l == 0) {
                    if (seg.prod(a + 1, 1000101).value || other) {
                        cout << "No" << '\n';
                        continue;
                    }
                }
                cout << "Yes" << '\n';
                seg.set(l, {1, 1});
                seg.apply(l + 1, a + 1, 0);
            }
        }
    }
}
accuracy: 0.02564102564102564
time_ms: 360
memory_kb: 44372
final_rank: 20

code_snippet: #include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename E>
struct LazySegmentTree {
   private:
    int n{}, sz{}, height{};
    vector<T> data;
    vector<E> lazy;
    T (*op)(T, T);
    T (*e)();
    T (*mapping)(E, T);
    E (*composition)(E, E);
    E (*id)();

    void update(int k) { data[k] = op(data[2 * k], data[2 * k + 1]); }

    void all_apply(int k, const E x) {
        data[k] = mapping(x, data[k]);
        if (k < sz) lazy[k] = composition(x, lazy[k]);
    }

    void propagate(int k) {
        if (lazy[k] != id()) {
            all_apply(2 * k, lazy[k]);
            all_apply(2 * k + 1, lazy[k]);
            lazy[k] = id();
        }
    }

   public:
    LazySegmentTree() = default;
    explicit LazySegmentTree(int n, T (*op)(T, T), T (*e)(), T (*mapping)(E, T),
                             E (*composition)(E, E), E (*id)())
        : n(n),
          op(op),
          mapping(mapping),
          composition(composition),
          e(e),
          id(id) {
        sz = 1;
        height = 0;
        while (sz < n) sz <<= 1, height++;
        data = vector<T>(2 * sz, e());
        lazy = vector<E>(sz, id());
    }

    explicit LazySegmentTree(const vector<T> &v, T (*op)(T, T), T (*e)(),
                             T (*mapping)(E, T), E (*composition)(E, E),
                             E (*id)())
        : LazySegmentTree(v.size(), op, e, mapping, composition, id) {
        build(v);
    }

    void build(const vector<T> &v) {
        assert(n == (int)v.size());
        for (int k = 0; k < n; k++) data[k + sz] = v[k];
        for (int k = sz - 1; k > 0; k--) update(k);
    }

    void set(int k, const T x) {
        assert(0 <= k && k < n);
        k += sz;
        for (int i = height; i > 0; i--) propagate(k >> i);
        data[k] = x;
        for (int i = 1; i <= height; i++) update(k >> i);
    }

    T get(int k) {
        assert(0 <= k && k < n);
        k += sz;
        for (int i = height; i > 0; i--) propagate(k >> i);
        return data[k];
    }

    T operator[](int k) { return get(k); }

    T prod(int l, int r) {
        assert(0 <= l && l <= r && r <= n);
        if (l >= r) return e();
        l += sz;
        r += sz;
        // 更新する区間を部分的に含んだ区間においてトップダウンで子ノードに伝搬させながらdataの値を更新
        for (int i = height; i > 0; i--) {
            if (((l >> i) << i) != l) propagate(l >> i);
            if (((r >> i) << i) != r) propagate((r - 1) >> i);
        }
        T L = e(), R = e();
        // 値をチェックする区間のdataの値をチェック
        for (; l < r; l >>= 1, r >>= 1) {
            if (l & 1) L = op(L, data[l++]);
            if (r & 1) R = op(data[--r], R);
        }
        return op(L, R);
    }

    T all_prod() const { return data[1]; }

    void apply(int k, const E &x) {
        assert(0 <= k && k < n);
        k += sz;
        for (int i = height; i > 0; i--) propagate(k >> i);
        data[k] = mapping(x, data[k]);
        for (int i = 1; i <= height; i++) update(k >> i);
    }

    void apply(int l, int r, E x) {
        if (l >= r) return;
        l += sz;
        r += sz;
        // 更新する区間を部分的に含んだ区間においてトップダウンで子ノードに伝搬させながらdataの値を更新
        for (int i = height; i > 0; i--) {
            if (((l >> i) << i) != l) propagate(l >> i);
            if (((r >> i) << i) != r) propagate((r - 1) >> i);
        }
        {
            // 値を更新する区間のdataとlazyの値を更新
            int l2 = l, r2 = r;
            for (; l < r; l >>= 1, r >>= 1) {
                if (l & 1) all_apply(l++, x);
                if (r & 1) all_apply(--r, x);
            }
            l = l2, r = r2;
        }
        // 更新する区間を部分的に含んだ区間においてボトムアップで子ノードに伝搬させながらdataの値を更新
        for (int i = 1; i <= height; i++) {
            if (((l >> i) << i) != l) update(l >> i);
            if (((r >> i) << i) != r) update((r - 1) >> i);
        }
    }
    template <typename C>
    int max_right(int l, const C &check) {
        if (l >= n) return n;
        l += sz;

        for (int i = height; i > 0; i--) propagate(l >> i);
        T sum = e();
        do {
            while ((l & 1) == 0) l >>= 1;
            if (!check(op(sum, data[l]))) {
                while (l < sz) {
                    propagate(l);
                    l <<= 1;
                    auto nxt = op(sum, data[l]);
                    if (check(nxt)) {
                        sum = nxt;
                        l++;
                    }
                }
                return l - sz;
            }
            sum = op(sum, data[l++]);
        } while ((l & -l) != l);
        return n;
    }

    template <typename C>
    int min_left(int r, const C &check) {
        if (r <= 0) return 0;
        r += sz;
        for (int i = height; i > 0; i--) propagate((r - 1) >> i);
        T sum = e();
        do {
            r--;
            while (r > 1 and (r & 1)) r >>= 1;
            if (!check(op(data[r], sum))) {
                while (r < sz) {
                    propagate(r);
                    r = (r << 1) + 1;
                    auto nxt = op(data[r], sum);
                    if (check(nxt)) {
                        sum = nxt;
                        r--;
                    }
                }
                return r - sz;
            }
            sum = op(data[r], sum);
        } while ((r & -r) != r);
        return 0;
    }
};
struct S {
    long long value;
    int size;
};
using F = long long;

const F ID = 8e18;

S op(S a, S b) { return {a.value + b.value, a.size + b.size}; }
S e() { return {0, 0}; }
S mapping(F f, S x) {
    if (f != ID) x.value = f * x.size;
    return x;
}
F composition(F f, F g) { return (f == ID ? g : f); }
F id() { return ID; }

int main() {
    int n, m;
    cin >> n;
    LazySegmentTree<S, F> seg(500101, op, e, mapping, composition, id);
    int sum = 0;
    for (int i = 0; i < 500101; i++) {
        seg.set(i, {0, 1});
    }
    int other = 0;
    for (int i = 0; i < n; i++) {
       
        int a;
        cin >> a;
        if (seg.get(0).value != 0) {
            cout << "No" << '\n';
            continue;
        }
        if (a > 500100) {
            cout << "Yes" << '\n';
            other++;
        }

        else {
            if (seg.get(a).value == 0) {
                cout << "Yes" << '\n';
                seg.set(a, {1, 0});
            } else {
                auto han = [&](S cur) -> bool { return cur.value == cur.size; };
                int l = seg.min_left(a, han);
                if (l == 0) {
                    if (seg.prod(a + 1, 500101).value || other) {
                        cout << "No" << '\n';
                        continue;
                    }
                }
                cout << "Yes" << '\n';
                seg.set(l, {1, 1});
                seg.apply(l + 1, a + 1, 0);
            }
        }
    }
}
accuracy: 0.02564102564102564
time_ms: 340
memory_kb: 23896
final_rank: 18

code_snippet: #include<bits/stdc++.h>
using namespace std;

using ll = long long;
set<ll> num;
set<pair<ll,ll>> sec;

bool in;

void insert_sec(ll x){
    if (in){
        auto it = sec.upper_bound({x,1e18});
        it = prev(it);
        ll l = (*it).first;
        ll r = (*it).second;
        sec.erase(it);
        in = false;
        if (x != r)sec.insert({x+1,r});
        insert_sec(l);
    }
    else {
        ll l=x,r=x;
        auto it = sec.upper_bound({x,1e18});
        if (it != sec.end() && (*it).first == x+1){
            r = (*it).second;
            sec.erase(it);
        }
        it = sec.upper_bound({x,1e18});
        if (it != sec.begin() && (*prev(it)).second == x-1){
            l = (*prev(it)).first;
            sec.erase(prev(it));
        }
        sec.insert({l,r});
    }
}

void insert_num(ll x){
    for (int i = x; i >= 0; i--){
        if (!num.count(i)){
            num.insert(i);
            break;
        }
        num.erase(i);
    }
}


int main(){
    int q;cin >> q;

    {
        q--;
        ll x;cin >> x;
        sec.insert({x,x});
        num.insert(x);
        cout << "Yes" << endl;
    }

    while(q--){
        ll x;cin >> x;
        if (*(num.begin())==0){
            cout << "No" << endl;
            continue;
        }

        in = num.count(x);

        if (in){
            auto it = sec.upper_bound({x,1e18});
            it = prev(it);
            ll l = (*it).first;
            ll r = (*it).second;
            if (l == 1 && (x != r || sec.size()!=1))cout << "No" << endl;
            else {
                cout << "Yes" << endl;
                insert_num(x);
                insert_sec(x);
            }
        }
        else {
            cout << "Yes" << endl;
            insert_num(x);
            insert_sec(x);
        }
    }
}
accuracy: 0.02564102564102564
time_ms: 330
memory_kb: 3312
final_rank: 15

code_snippet: #include<bits/stdc++.h>
using namespace std;

using ll = long long;
set<ll> num;
set<pair<ll,ll>> sec;

bool in;

void insert_sec(ll x){
    if (in){
        auto it = sec.upper_bound({x,x});
        it = prev(it);
        ll l = (*it).first;
        ll r = (*it).second;
        sec.erase(it);
        in = false;
        if (x != r)sec.insert({x+1,r});
        insert_sec(l);
    }
    else {
        ll l=x,r=x;
        auto it = sec.upper_bound({x,x});
        if (it != sec.end() && (*it).first == x+1){
            r = (*it).second;
            sec.erase(it);
        }
        it = sec.upper_bound({x,x});
        if (it != sec.begin() && (*prev(it)).second == x-1){
            l = (*prev(it)).first;
            sec.erase(prev(it));
        }
        sec.insert({l,r});
    }
}

void insert_num(ll x){
    for (int i = x; i >= 0; i--){
        if (!num.count(i)){
            num.insert(i);
            break;
        }
        num.erase(i);
    }
}


int main(){
    int q;cin >> q;

    {
        q--;
        ll x;cin >> x;
        sec.insert({x,x});
        num.insert(x);
        cout << "Yes" << endl;
    }

    while(q--){
        ll x;cin >> x;
        if (*num.begin()==0){
            cout << "No" << endl;
            continue;
        }

        in = num.count(x);

        if (in){
            auto it = sec.upper_bound({x,x});
            it = prev(it);
            ll l = (*it).first;
            ll r = (*it).second;
            if (l == 1 && (x != r || sec.size()!=1))cout << "No" << endl;
            else {
                cout << "Yes" << endl;
                insert_num(x);
                insert_sec(x);
            }
        }
        else {
            cout << "Yes" << endl;
            insert_num(x);
            insert_sec(x);
        }
    }
}
accuracy: 0.02564102564102564
time_ms: 170
memory_kb: 3276
final_rank: 14

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define si(a) scanf("%d",&a)
#define MX 35

long long vorti[MX+5];

int main()
{
    //freopen("input.txt","r",stdin);
    int n;
    si(n);
    for(int i=0;i<n;i++){
        int x;
        si(x);
        if(x<=MX){
            int j;
            for(j=x;j<=MX;j++)
                if((1ll<<(j-x))>(1ll<<j)-vorti[j])break;
            if(j>MX){
                printf("Yes\n");
                for(j=x;j<=MX;j++)vorti[j]+=(1ll<<(j-x));
            }
            else printf("No\n");
        }
        else{
            if(vorti[MX]==(1ll<<MX))printf("No\n");
            else printf("Yes\n");
        }
    }
}
accuracy: 0.02564102564102564
time_ms: 20
memory_kb: 3496
final_rank: 12

code_snippet: #include <iostream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <tuple>
#include <ranges>
namespace ranges = std::ranges;
namespace views = std::views;
// #include "Src/Number/IntegerDivision.hpp"
// #include "Src/Utility/BinarySearch.hpp"
// #include "Src/Sequence/CompressedSequence.hpp"
// #include "Src/Sequence/RunLengthEncoding.hpp"
// #include "Src/Algebra/Group/AdditiveGroup.hpp"
// #include "Src/DataStructure/FenwickTree/FenwickTree.hpp"
// #include "Src/DataStructure/SegmentTree/SegmentTree.hpp"
// using namespace zawa;
// #include "atcoder/modint"
// using mint = atcoder::modint998244353;
#include <set>
struct BINARY {
    int sz = 0;
    std::set<std::pair<int, int>> set;
    void insert_internal(int l, int r) {
        auto it = set.lower_bound({l, -1});
        if (it != set.end() and it->first == l) {
            const auto [rr, ll] = *it;
            erase_internal(ll, rr);
            insert_internal(ll, r);
        }
        else if (it != set.end() and it->second == r) {
            const auto [rr, ll] = *it;
            erase_internal(ll, rr);
            insert_internal(l, rr);
        }
        else {
            sz += r - l;
            set.insert({r, l});
        }
    }
    void erase_internal(int l, int r) {
        auto it = set.find({r, l});
        assert(it != set.end());
        sz -= r - l;
        set.erase(it);
    }
    void insert(int x) {
        auto it = set.lower_bound({x+1, -1});
        if (it != set.end() and it->second <= x) {
            const auto [r, l] = *it;
            erase_internal(l, r);
            insert_internal(x + 1, r);
            insert(l - 1);
        }
        else {
            insert_internal(x, x + 1);
        }
    }
    bool check(int x) {
        if (sz >= 1 and set.begin()->second == 0) return false;
        auto it = set.lower_bound({x+1, -1});
        if (it == set.end() or x < it->second) return true;
        const auto [r, l] = *it;
        const int new_sz = sz - (x - l + 1) + 1;
        // std::cout << new_sz << " " << x << "!\n";
        if (l - 1 == 0 and new_sz >= 2) return false;
        return true;
    }
    void print() const {
        std::cout << sz << " : ";
        for (const auto& [r, l] : set) std::cout << '[' << l << ',' << r << ')';
        std::cout << std::endl;
    }
};
int N;
int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cin >> N;
    BINARY binary;
    while (N--) {
        int x;
        std::cin >> x;
        const bool ans = binary.check(x);
        std::cout << (ans ? "Yes\n" : "No\n");
        if (ans) binary.insert(x);
        // binary.print();
    }
}
accuracy: 1
time_ms: 130
memory_kb: 11136
final_rank: 2

code_snippet: #include<bits/stdc++.h>
using namespace std;

struct BIT{
	BIT(int _n){
		n = _n+1;
		vec.assign(n, 0);
	}

	void add(int i, int x){
		++i;
		while(i < n) {
			vec[i] += x;
			i += i&(-i);
		}
	}

	int sum(int i){
		int ret = 0;
		while(i > 0) {
			ret += vec[i];
			i -= i & (-i);
		}
		return ret;
	}

	int query(int l, int r){
		return sum(r)-sum(l);
	}

	int n;
	vector<int> vec;
};

int main(){
	int n;
	cin >> n;
	int MX = 1000000;
	BIT bt(MX);
	bool flag = false;
	vector<int> x(n);
	vector<int> ans(n);
	for(int i = 0; i < n; ++i) cin >> x[i];
	for(int i = 0; i < n; ++i){
		if(x[i] >= MX){
			flag = true;
			ans[i] = true;
			continue;
		}
		if(bt.sum(x[i]+1) < x[i]){
			while(bt.query(x[i], x[i]+1) == 1){
				bt.add(x[i], -1);
				x[i]--;
			}
			bt.add(x[i], 1);
			ans[i] = 1;
		}else if(bt.sum(x[i]+1) == x[i]){
			if(flag){
				continue;
			}
			if(bt.query(x[i]+1, MX) > 0){
				continue;
			}
			ans[i] = 1;
			break;
		}
	}
	for(int i: ans){
		if(i){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}
accuracy: 1
time_ms: 250
memory_kb: 11148
final_rank: 4

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

/**
 * @brief template
 */

template<typename T>struct BIT{
    int n; T all=0; vector<T> val;
    BIT(int _n=0):n(_n),val(_n+10){}
    void clear(){val.assign(n+10,0); all=T();}
    void add(int i,T x){
        for(i++;i<=n;i+=(i&-i))val[i]=val[i]+x;
        all+=x;
    }
    T sum(int i){
        T res=0;
        for(;i;i-=(i&-i))res+=val[i];
        return res;
    }
    T sum(int L,int R){return sum(R)-sum(L);} // [L,R)

    int lower_bound(T x){
        int ret=0,len=1;
        while(2*len<=n)len<<=1;
        for(;len>=1;len>>=1){
            if(ret+len<=n and val[ret+len]<x){
                ret+=len;
                x-=val[ret];
            }
        }
        return ret;
    }
};

/**
 * @brief Binary Indexed Tree
 */

int main() {
    int N;
    cin >> N;
    BIT<int> Seg(N+1);
    map<int,int> mp;
    bool One = false;
    int COUNT = 0;
    rep(i,0,N) {
        int X;
        cin >> X;
        if (One) {
            cout << "No" << endl;
            continue;
        }
        if (X <= N) {
            if (Seg.sum(1,X+1) == X) {
                if (COUNT == X) {
                    cout << "Yes" << endl;
                    One = true;
                    continue;
                }
                else {
                    cout << "No" << endl;
                    continue;
                }
            }
        }
        cout << "Yes" << endl;
        while(1) {
            if (!mp.count(X) || mp[X] == 0) {
                COUNT++;
                mp[X] = 1;
                if (X <= N) Seg.add(X,1);
                break;
            }
            COUNT--;
            mp[X] = 0;
            if (X <= N) Seg.add(X,-1);
            X--;
        }
    }
}
accuracy: 1
time_ms: 490
memory_kb: 16624
final_rank: 6

code_snippet: #include <bits/stdc++.h>

#define rep(i,s,n) for(int i = int(s); i < int(n); i++)
#define rrep(i,s,n) for(int i = int(n) - 1; i >= int(s); i--)
#define all(v) (v).begin(), (v).end()

using ll = long long;
using ld = long double;
using ull = unsigned long long;

template<class T>
bool chmin(T &a, T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

template<class T>
bool chmax(T &a, T b) {
    if(a >= b) return false;
    a = b;
    return true;
}

using namespace std;

template <class S, S(*op)(S, S), S(*e)(), class F, S(*mapping)(F, S), F(*composition)(F, F), F(*id)()>
struct lazysegtree {
    private:
        int n, lg2, sz;
        vector<S> d;
        vector<F> lz;

        void update(int i){
            d[i] = op(d[2*i], d[2*i+1]);
        }

        void all_apply(int i, F f){
            d[i] = mapping(f, d[i]);
            if (i < sz) lz[i] = composition(f, lz[i]);
        }

        void push(int i){
            all_apply(2*i, lz[i]);
            all_apply(2*i+1, lz[i]);
            lz[i] = id();
        }

    public:
        lazysegtree(int _n): lazysegtree(vector<S>(_n, e())){}
        lazysegtree(const vector<S> &v): n(v.size()){
            lg2 = 0;
            while((1<<lg2)<n) lg2++;
            sz = 1 << lg2;
            d = vector<S>(2*sz, e());
            lz = vector<F>(2*sz, id());
            rep(i,0,n) d[sz+i] = v[i];
            rrep(i,1,sz) update(i);
        }

        void set(int p, S x){
            assert(0 <= p && p < n);
            p += sz;
            rrep(i,1,lg2+1) push(p>>i);
            d[p] = x;
            rep(i,1,lg2+1) update(p>>i);
        }

        S get(int p){
            assert(0<= p && p < n);
            p += sz;
            rrep(i,1,lg2+1) push(p>>i);
            return d[p];
        }

        S prod(int l, int r){
            assert(0<=l && l<=r && r<=n);
            if (l == r) return e();
            l += sz;
            r += sz;
            rrep(i,1,lg2+1){
                if(((l>>i)<<i)!=l)push(l>>i);
                if(((r>>i)<<i)!=r)push((r-1)>>i);
            }
            S sml = e(), smr = e();
            while(l < r){
                if (l & 1) sml = op(sml, d[l++]);
                if (r & 1) smr = op(d[--r], smr);
                l>>=1;
                r>>=1;
            }
            return op(sml, smr);
        }

        S all_prod(){
            return d[1];
        }

        void apply(int p, F f){
            assert(0<=p&&p<n);
            p+=sz;
            rrep(i,1,lg2+1)push(p>>i);
            d[p] =mapping(f,d[p]);
            rep(i,1,lg2+1)update(p>>i);
        }

        void apply(int l, int r, F f){
            assert(0<=l&&l<=r&&r<=n);
            if (l==r) return;
            l+=sz;
            r+=sz;
            rrep(i,1,lg2+1){
                if(((l>>i)<<i)!=l) push(l>>i);
                if(((r>>i)<<i)!=r) push((r-1)>>i);
            }

            {
                int l2=l,r2=r;
                while(l<r){
                    if(l&1)all_apply(l++,f);
                    if(r&1)all_apply(--r,f);
                    l>>=1;
                    r>>=1;
                }
                l = l2;
                r = r2;

            }
            rep(i,1,lg2+1){
                if(((l>>i)<<i)!=l)update(l>>i);
                if(((r>>i)<<i)!=r)update((r-1)>>i);
            }
        }

        template<class G>int min_left(int r, G g){
            assert(0<=r && r<=n);
            assert(g(e()));
            if(r==0) return 0;
            r+=sz;
            for (int i=lg2; i>=1;i--) push((r-1)>>i);
            S sm = e();
            do {
                r--;
                while(r>1 && (r%2)) r>>=1;
                if (!g(op(d[r],sm))){
                    while(r<sz){
                        push(r);
                        r=(2*r+1);
                        if(g(op(d[r],sm))){
                            sm=op(d[r],sm);
                            r--;
                        }
                    }
                    return r+1-sz;
                }
                sm = op(d[r],sm);
            }while((r&-r)!=r);
            return 0;
        }
};



ll op(ll a, ll b){
    return max(a, b);
}

ll e() {
    return 0;
}

ll mapping(ll f, ll x){
    return x + f;
}

ll composition(ll f, ll g){
    return f + g;
}

ll id(){
    return 0;
}


int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int n; cin >> n;
    vector<int> x(n);
    rep(i,0,n) cin >> x[i];
    
    const int border = 550000;

    lazysegtree<ll,op,e,ll,mapping,composition,id> seg(vector<ll>(border, 0));
    seg.set(0, 1);

    auto f = [&](ll x){
        return x == 0;
    };

    vector<bool> ans(n);
    int eps = 0;
    rep(i,0,n){
        if (x[i] >= border){
            if (eps == 0){
                int g = seg.min_left(border, f) - 1;
                if (g == -1){
                    ans[i] = 0;                    
                }else{
                    ans[i] = 1;
                    seg.apply(g, -1);
                    eps = 1;
                    seg.apply(g+1, border, 1);
                }
            }else{
                ans[i] = 1;
                continue;
            }
        }else{
            int g = seg.min_left(x[i] + 1, f) - 1;
            if (g == -1){
                ans[i] = 0;  
            }else{
                ans[i] = 1;
                seg.apply(g, -1);
                seg.apply(g+1, x[i] + 1, 1);
            }
        }
    }
    rep(i,0,n){
        if (ans[i]){
            cout << "Yes\n";
        }else{
            cout << "No\n";
        }
    }

}
accuracy: 1
time_ms: 130
memory_kb: 41944
final_rank: 10

code_snippet: #include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
#define ALL(v) v.begin(),v.end()

string S,T;

int main(void) {
  const int xmax = 1e9;
  int n;
  cin >> n;
  set<pair<int, int>> st;
  st.insert({xmax, xmax + 1});
  for (int i = 0; i < n; ++i)
  {
    int x;
    cin >> x;
    if (st.empty())
    {
      cout << "No" << endl;
      continue;
    }
    auto itr = st.upper_bound({xmax - x, xmax + 2});
    if (itr == st.begin())
    {
      st.erase(itr);
      auto tmp = *itr;
      ++tmp.first;
      st.insert({xmax - x, itr->first});
      if (tmp.first < tmp.second) st.insert(tmp);
      cout << "Yes" << endl;
      continue;
    }
    --itr;
    if (itr->second > xmax - x)
    {
      auto l = *itr, r = *itr;
      l.second = xmax - x;
      r.first = xmax - x + 1;
      st.erase(itr);
      if (l.first < l.second) st.insert(l);
      if (r.first < r.second) st.insert(r);
    }
    else
    {
      ++itr;
      if (itr == st.end())
      {
        cout << "No" << endl;
        continue;
      }
      pair<int, int> r = *itr, l = {xmax - x, itr->first};
      ++r.first;
      st.erase(itr);
      if (l.first < l.second) st.insert(l);
      if (r.first < r.second) st.insert(r);
    }
    cout << "Yes" << endl;
  }
}
accuracy: 1
time_ms: 450
memory_kb: 10936
final_rank: 5

code_snippet: #include <bits/stdc++.h>

int main() {
    constexpr int MAX_X = 1e9;
    int n;
    std::cin >> n;
    std::set<int> s;
    std::set<int> t;

    for (int i = 1; i <= n; i++) {
        t.insert(MAX_X - i);
    }

    auto is_one = [&]() {
        return s.find(MAX_X) != s.end();
    };

    auto enable_add = [&](int l) {
        if (s.empty()) return true;
        if (t.lower_bound(l) != t.end()) return true;
        return *s.begin() == l;
    };

    auto add = [&](auto self, int x) -> void {
        if (s.find(x) != s.end()) {
            s.erase(x);
            if (MAX_X - n <= x && x < MAX_X) {
                t.insert(x);
            }
            self(self, x + 1);
        } else {
            s.insert(x);
            if (MAX_X - n <= x && x < MAX_X) {
                t.erase(x);
            }
        }
    };

    for (int i = 0; i < n; i++) {
        int x;
        std::cin >> x;
        x = MAX_X - x;
        if (!is_one() && enable_add(x)) {
            std::cout << "Yes" << std::endl;
            add(add, x);
        } else {
            std::cout << "No" << std::endl;
        }
    }
}
accuracy: 1
time_ms: 740
memory_kb: 42260
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define per(i, n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define per2(i, l, r) for (int i = (r)-1; i >= (l); i--)
#define each(e, x) for (auto &e : x)
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define eb emplace_back
#define MM << ' ' <<
#define TT template <typename T>
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

TT bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; }
TT bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; }

TT using minheap = priority_queue<T, vector<T>, greater<T>>;
TT using maxheap = priority_queue<T>;

TT void print(vector<T> v, T x = 0) {
    int n = sz(v);
    rep(i, n) cout << v[i] + x << (i == n - 1 ? '\n' : ' ');
    if (n == 0) cout << '\n';
}

TT void printn(vector<T> v, T x = 0) {
    int n = sz(v);
    rep(i, n) cout << v[i] + x << '\n';
}

TT void rearrange(vector<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), end(v));
}

TT int lb(vector<T> &v, T x) { return lower_bound(all(v), x) - begin(v); }
TT int ub(vector<T> &v, T x) { return upper_bound(all(v), x) - begin(v); }

const int inf = (1 << 30) - 1;
const ll INF = (1LL << 60) - 1;

struct io_setup {
    io_setup() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(15);
    }
} io_setup;

int main() {
    int n;
    cin >> n;
    int lim = n + 1;
    vector<int> f(lim, 0);
    int b = 0;
    set<int> s;
    rep(i, n) {
        int x;
        cin >> x;
        if (x <= b) {
            cout << "No\n";
            continue;
        }
        cout << "Yes\n";
        s.insert(x);
        if (x < lim) {
            f[x]++;
            while (f[x] == 2) {
                f[x - 1]++, f[x] = 0;
                s.insert(x - 1), s.erase(x);
                x--;
            }
        }
        assert(!empty(s));
        while (b < lim && f[b + 1] && *(--end(s)) > b + 1)
            b++;
        if (f[0])
            b = 2e9;
    }
}
accuracy: 1
time_ms: 80
memory_kb: 16708
final_rank: 3

code_snippet: #include<bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;

    set<int> used;
    // x can be used if bound <= x
    int bound = 1;

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;

        if(used.count(0)) {
            cout << "No" << endl;
            continue;
        }

        if(x < bound) {
            cout << "No" << endl;
            continue;
        }

        while (1 <= x && used.count(x)) {
                used.erase(x);
                x--;
        }
        
        used.insert(x);
        while(used.count(bound) && used.upper_bound(bound) != used.end()) bound++;

        cout << "Yes" << endl;
    }
}
accuracy: 1
time_ms: 590
memory_kb: 15160
final_rank: 7

code_snippet: #include<bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;

    map<int,bool> used;
    // x can be used if bound <= x
    int bound = 1;

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;

        if(used[0]) {
            cout << "No" << endl;
            continue;
        }

        if(x < bound) {
            cout << "No" << endl;
            continue;
        }

        while (1 <= x && used[x]) {
                used[x] = false;
                x--;
        }
        used[x] = true;
        while(used[bound] && used[bound+1]) bound++;

        cout << "Yes" << endl;
    }
}
accuracy: 0.02564102564102564
time_ms: 330
memory_kb: 3344
final_rank: 16

code_snippet: #include<bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;

    map<int,bool> used;
    // x can be used if bound <= x
    int bound = 1;

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;

        if(used[0]) {
            cout << "No" << endl;
            continue;
        }

        if(x < bound) {
            cout << "No" << endl;
            continue;
        }

        while (1 <= x && used[x]) {
                used[x] = false;
                x--;
        }
        used[x] = true;
        while(used[bound] && bound < x) bound++;

        cout << "Yes" << endl;
    }
}
accuracy: 0.02564102564102564
time_ms: 330
memory_kb: 3388
final_rank: 17

code_snippet: #include<bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;

    bool used[500010];
    // x can be used if bound <= x
    int bound = 1;

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;

        if(used[0]) {
            cout << "No" << endl;
            continue;
        }

        if(x < bound) {
            cout << "No" << endl;
            continue;
        }

        while (1 <= x && used[x]) {
                used[x] = false;
                x--;
        }
        used[x] = true;
        while(used[bound] && bound < x) bound++;

        cout << "Yes" << endl;
    }
}
accuracy: 0.02564102564102564
time_ms: 150
memory_kb: 3320
final_rank: 13

code_snippet: #include<bits/stdc++.h>
using namespace std;

using ld = long double;

int main() {
    int n;
    cin >> n;

    ld sum = 0;
    vector<int> v;

    for (int i = 0; i < n; i++) {
        if(i%5000 == 0) {
            vector<ld> vals;
            for (auto x: v) vals.push_back(powl(0.5l, x));
            sort(vals.begin(), vals.end());
            sum = accumulate(vals.begin(),vals.end(), 0.0l);
        }

        int x;
        cin >> x;

        ld val = powl(0.5l,x);
        if(sum + val <= 1.0l + 1e-9) {
            v.push_back(x);
            sum += val;
            cout << "Yes" << endl;
            continue;
        }

        cout << "No" << endl;
    }
}
accuracy: 0.02564102564102564
time_ms: 1140
memory_kb: 7648
final_rank: 19