// File: /workspace/github_cpp_makefile_star2_O2/vividvilla[P]hackerrank/src/median.cpp
// Function: outputMedians(std::vector<char, std::allocator<char>>, std::vector<long long, std::allocator<long long>>)
void outputMedians(vector<char> ops, vector<long long> ints) {
    int N = ops.size();

    multiset<long long> left;
    multiset<long long> right;

    for (int i = 0; i < N; i++) {
        bool valid = true;

        if (ops[i] == 'r') {
            multiset<long long>::iterator li = left.find(ints[i]);
            multiset<long long>::iterator ri = right.find(ints[i]);
            if (li != left.end())
                left.erase(li);
            else if (ri != right.end())
                right.erase(ri);
            else
                valid = false;
        } else if (ops[i] == 'a') {
            if (left.size() == 0 || ints[i] < *left.rbegin())
                left.insert(ints[i]);
            else
                right.insert(ints[i]);
        }

        if (left.size() > right.size() + 1) {
            right.insert(*left.rbegin());
            left.erase(left.find(*left.rbegin()));
        } else if (right.size() > left.size()) {
            left.insert(*right.begin());
            right.erase(right.find(*right.begin()));
        }

        if (valid && left.size() + right.size() > 0) {
            if (left.size() > right.size())
                cout << *left.rbegin() << endl;
            else {
                long long m = *left.rbegin() + *right.begin();
                if (m % 2)
                    printf("%.1lf\n", m / 2.);
                else
                    printf("%.0lf\n", m / 2.);
            }
        } else {
            cout << "Wrong!" << endl;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r14
movq %rdi, %r13
movl 0x8(%rdi), %r15d
subl (%rdi), %r15d
leaq 0x20(%rsp), %r12
andl $0x0, (%r12)
andq $0x0, 0x8(%r12)
movq %r12, 0x10(%r12)
movq %r12, 0x18(%r12)
andq $0x0, 0x20(%r12)
leaq 0x50(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
xorl %ebp, %ebp
testl %r15d, %r15d
cmovlel %ebp, %r15d
xorl %ebx, %ebx
cmpq %rbx, %r15
je 0x1537
movq (%r13), %rax
movzbl (%rax,%rbx), %eax
movb $0x1, %cl
movl %ecx, 0xc(%rsp)
cmpl $0x61, %eax
movq %rbp, 0x10(%rsp)
je 0x1378
cmpl $0x72, %eax
jne 0x13f2
movq (%r14), %rsi
addq %rbp, %rsi
leaq 0x18(%rsp), %rdi
callq 0x17ec
movq %rbp, %rcx
movq %rax, %rbp
movq (%r14), %rsi
addq %rcx, %rsi
leaq 0x48(%rsp), %rdi
callq 0x17ec
cmpq %r12, %rbp
je 0x13bb
leaq 0x18(%rsp), %rdi
jmp 0x13d1
cmpq $0x0, 0x40(%rsp)
movq (%r14), %rbp
je 0x13af
movq %r15, %r12
movq %r13, %r15
movq %r14, %r13
movq 0x10(%rsp), %rax
movq (%rbp,%rax), %r14
leaq 0x20(%rsp), %rdi
callq 0x10c0
cmpq 0x20(%rax), %r14
movq %r13, %r14
movq %r15, %r13
movq %r12, %r15
jge 0x13db
leaq (%rbp,%rbx,8), %rbp
leaq 0x18(%rsp), %rdi
jmp 0x13e5
leaq 0x50(%rsp), %rcx
cmpq %rcx, %rax
je 0x152a
leaq 0x48(%rsp), %rdi
movq %rax, %rbp
movq %rbp, %rsi
callq 0x1842
jmp 0x13f2
addq 0x10(%rsp), %rbp
leaq 0x48(%rsp), %rdi
movq %rbp, %rsi
callq 0x1890
leaq 0x20(%rsp), %r12
movq 0x40(%rsp), %rax
movq 0x70(%rsp), %rcx
leaq 0x1(%rcx), %rdx
cmpq %rdx, %rax
jbe 0x1440
movq %r12, %rdi
callq 0x10c0
leaq 0x20(%rax), %rsi
leaq 0x48(%rsp), %rdi
callq 0x1890
movq %r12, %rdi
callq 0x10c0
leaq 0x20(%rax), %rsi
leaq 0x18(%rsp), %rdi
callq 0x17ec
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x1842
jmp 0x1478
cmpq %rax, %rcx
jbe 0x1478
movq 0x60(%rsp), %rsi
addq $0x20, %rsi
leaq 0x18(%rsp), %rdi
callq 0x1890
movq 0x60(%rsp), %rsi
addq $0x20, %rsi
leaq 0x48(%rsp), %rdi
callq 0x17ec
leaq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0x1842
cmpb $0x0, 0xc(%rsp)
je 0x1491
movq 0x40(%rsp), %r12
movq 0x70(%rsp), %rbp
movq %r12, %rax
addq %rbp, %rax
jne 0x14c2
movq 0x2b38(%rip), %rdi      # 0x3fd0
leaq 0xb7f(%rip), %rsi       # 0x201e
callq 0x1100
leaq 0x20(%rsp), %r12
movq %rax, %rdi
callq 0x1090
incq %rbx
movq 0x10(%rsp), %rbp
addq $0x8, %rbp
jmp 0x131c
leaq 0x20(%rsp), %rdi
callq 0x10c0
movq 0x20(%rax), %rsi
cmpq %rbp, %r12
jbe 0x14f0
movq 0x2af4(%rip), %rdi      # 0x3fd0
callq 0x1070
leaq 0x20(%rsp), %r12
movq %rax, %rdi
callq 0x1090
jmp 0x14b1
movq 0x60(%rsp), %rax
addq 0x20(%rax), %rsi
testb $0x1, %sil
cvtsi2sd %rsi, %xmm0
mulsd 0xafe(%rip), %xmm0      # 0x2008
leaq 0xaff(%rip), %rdi       # 0x2010
leaq 0xaff(%rip), %rax       # 0x2017
cmoveq %rax, %rdi
movb $0x1, %al
callq 0x1030
leaq 0x20(%rsp), %r12
jmp 0x14b1
movl $0x0, 0xc(%rsp)
jmp 0x13f2
leaq 0x48(%rsp), %rdi
callq 0x1794
leaq 0x18(%rsp), %rdi
callq 0x1794
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1568
jmp 0x1568
jmp 0x1568
jmp 0x1568
jmp 0x1568
jmp 0x1568
jmp 0x1568
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x1794
leaq 0x18(%rsp), %rdi
callq 0x1794
movq %rbx, %rdi
callq 0x1180