// File: /workspace/github_cpp_makefile_star2_O1/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, (%rsp)
movq 0x8(%rdi), %rcx
movq %rdi, 0x40(%rsp)
subq (%rdi), %rcx
leaq 0x50(%rsp), %r15
xorl %eax, %eax
movl %eax, (%r15)
movq %rax, 0x8(%r15)
movq %r15, 0x10(%r15)
movq %r15, 0x18(%r15)
movq %rax, 0x20(%r15)
leaq 0x18(%rsp), %rbx
movl %eax, (%rbx)
movq %rax, 0x8(%rbx)
movq %rbx, 0x10(%rbx)
movq %rbx, 0x18(%rbx)
movq %rax, 0x20(%rbx)
movq %rcx, 0x8(%rsp)
testl %ecx, %ecx
jle 0x1656
movq 0x8(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x8(%rsp)
xorl %r14d, %r14d
movq 0x2c6f(%rip), %rbp      # 0x3fd0
movq 0x40(%rsp), %rax
movq (%rax), %rax
movzbl (%rax,%r14), %eax
cmpl $0x61, %eax
je 0x1436
movb $0x1, %r13b
cmpl $0x72, %eax
jne 0x147e
movq (%rsp), %rax
movq (%rax), %rax
movq 0x58(%rsp), %rdx
movq %r15, %rcx
testq %rdx, %rdx
je 0x13b6
movq (%rax,%r14,8), %rsi
movq %r15, %rcx
xorl %edi, %edi
cmpq %rsi, 0x20(%rdx)
setl %dil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rdi,8), %rdx
testq %rdx, %rdx
jne 0x139e
movq %r15, %rsi
cmpq %r15, %rcx
je 0x13cd
movq (%rax,%r14,8), %rdx
cmpq 0x20(%rcx), %rdx
cmovlq %r15, %rcx
movq %rcx, %rsi
movq 0x20(%rsp), %rdx
movq %rbx, %rcx
testq %rdx, %rdx
je 0x13fa
movq (%rax,%r14,8), %rdi
movq %rbx, %rcx
xorl %r8d, %r8d
cmpq %rdi, 0x20(%rdx)
setl %r8b
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%r8,8), %rdx
testq %rdx, %rdx
jne 0x13e1
movq %rbx, %rdx
cmpq %rbx, %rcx
je 0x1411
movq (%rax,%r14,8), %rax
cmpq 0x20(%rcx), %rax
cmovlq %rbx, %rcx
movq %rcx, %rdx
leaq 0x48(%rsp), %rdi
cmpq %r15, %rsi
jne 0x142c
leaq 0x10(%rsp), %rdi
movq %rdx, %rsi
cmpq %rbx, %rdx
je 0x164e
callq 0x19b4
movb $0x1, %r13b
jmp 0x147e
cmpq $0x0, 0x70(%rsp)
je 0x1457
movq (%rsp), %rax
movq (%rax), %r12
movq (%r12,%r14,8), %r13
movq %r15, %rdi
callq 0x10c0
cmpq 0x20(%rax), %r13
jge 0x146d
leaq (,%r14,8), %rsi
movq (%rsp), %rax
addq (%rax), %rsi
leaq 0x48(%rsp), %rdi
jmp 0x1476
leaq (%r12,%r14,8), %rsi
leaq 0x10(%rsp), %rdi
callq 0x19f0
movb $0x1, %r13b
movq 0x70(%rsp), %rax
movq 0x38(%rsp), %rcx
leaq 0x1(%rcx), %rdx
cmpq %rdx, %rax
jbe 0x14fe
movq %r15, %rdi
callq 0x10c0
leaq 0x20(%rax), %rsi
leaq 0x10(%rsp), %rdi
callq 0x19f0
movq %r15, %rdi
callq 0x10c0
movq 0x58(%rsp), %rdx
movq %r15, %rcx
testq %rdx, %rdx
je 0x14db
movq 0x20(%rax), %rsi
movq %r15, %rcx
xorl %edi, %edi
cmpq %rsi, 0x20(%rdx)
setl %dil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rdi,8), %rdx
testq %rdx, %rdx
jne 0x14c3
movq %r15, %rsi
cmpq %r15, %rcx
je 0x14f2
movq 0x20(%rax), %rax
cmpq 0x20(%rcx), %rax
cmovlq %r15, %rcx
movq %rcx, %rsi
leaq 0x48(%rsp), %rdi
callq 0x19b4
jmp 0x1568
cmpq %rax, %rcx
jbe 0x1568
movq 0x28(%rsp), %rsi
addq $0x20, %rsi
leaq 0x48(%rsp), %rdi
callq 0x19f0
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rax
movq %rbx, %rcx
testq %rdx, %rdx
je 0x1547
movq 0x20(%rax), %rsi
movq %rbx, %rcx
xorl %edi, %edi
cmpq %rsi, 0x20(%rdx)
setl %dil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rdi,8), %rdx
testq %rdx, %rdx
jne 0x152f
movq %rbx, %rsi
cmpq %rbx, %rcx
je 0x155e
movq 0x20(%rax), %rax
cmpq 0x20(%rcx), %rax
cmovlq %rbx, %rcx
movq %rcx, %rsi
leaq 0x10(%rsp), %rdi
callq 0x19b4
testb %r13b, %r13b
je 0x157f
movq 0x70(%rsp), %r13
movq 0x38(%rsp), %r12
movq %r13, %rax
addq %r12, %rax
jne 0x15ce
movl $0x6, %edx
movq %rbp, %rdi
leaq 0xaa0(%rip), %rsi       # 0x202e
callq 0x1140
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x1110
movsbl %al, %esi
movq %rbp, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10e0
incq %r14
cmpq 0x8(%rsp), %r14
jne 0x1361
jmp 0x1656
movq %r15, %rdi
callq 0x10c0
movq 0x20(%rax), %rsi
cmpq %r12, %r13
jbe 0x1613
movq %rbp, %rdi
callq 0x1080
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x1110
movsbl %al, %esi
movq %r13, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10e0
jmp 0x15bb
movq 0x28(%rsp), %rax
addq 0x20(%rax), %rsi
testb $0x1, %sil
xorps %xmm0, %xmm0
cvtsi2sd %rsi, %xmm0
mulsd 0x9d8(%rip), %xmm0      # 0x2008
leaq 0x9e9(%rip), %rdi       # 0x2020
leaq 0x9e9(%rip), %rax       # 0x2027
cmoveq %rax, %rdi
movb $0x1, %al
callq 0x1040
jmp 0x15bb
xorl %r13d, %r13d
jmp 0x147e
leaq 0x10(%rsp), %rdi
callq 0x1964
leaq 0x48(%rsp), %rdi
callq 0x1964
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1685
jmp 0x1685
jmp 0x1685
jmp 0x1685
jmp 0x1685
jmp 0x1685
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x1964
leaq 0x48(%rsp), %rdi
callq 0x1964
movq %rbx, %rdi
callq 0x11a0