// File: /workspace/github_cpp_makefile_star2_O3/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, 0x8(%rsp)
movq 0x8(%rdi), %r12
movq %rdi, 0x40(%rsp)
subq (%rdi), %r12
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)
testl %r12d, %r12d
jle 0x1690
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
xorl %r14d, %r14d
movq 0x2c7a(%rip), %rbp      # 0x3fd0
movq 0x40(%rsp), %rax
movq (%rax), %rax
movzbl (%rax,%r14), %eax
cmpl $0x61, %eax
je 0x144a
movb $0x1, %r13b
cmpl $0x72, %eax
jne 0x1488
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x58(%rsp), %r10
movq %r15, %rsi
testq %r10, %r10
je 0x13d2
movq (%rax,%r14,8), %rcx
movq %r15, %r8
movq %r8, %rdx
movq %r10, %rdi
movq 0x20(%r10), %r9
xorl %esi, %esi
cmpq %rcx, %r9
setl %sil
movq %r10, %r8
cmovlq %rdx, %r8
movq 0x10(%r10,%rsi,8), %r10
testq %r10, %r10
jne 0x1394
movq %r15, %rsi
cmpq %r15, %r8
je 0x13d2
cmpq %rcx, %r9
cmovlq %rdx, %rdi
cmpq 0x20(%rdi), %rcx
cmovlq %r15, %r8
movq %r8, %rsi
movq 0x20(%rsp), %r10
movq %rbx, %r9
testq %r10, %r10
je 0x1425
movq (%rax,%r14,8), %rax
movq %rbx, %rdi
movq %rdi, %rcx
movq %r10, %rdx
movq 0x20(%r10), %r8
xorl %r9d, %r9d
cmpq %rax, %r8
setl %r9b
movq %r10, %rdi
cmovlq %rcx, %rdi
movq 0x10(%r10,%r9,8), %r10
testq %r10, %r10
jne 0x13e6
movq %rbx, %r9
cmpq %rbx, %rdi
je 0x1425
cmpq %rax, %r8
cmovlq %rcx, %rdx
cmpq 0x20(%rdx), %rax
cmovlq %rbx, %rdi
movq %rdi, %r9
leaq 0x48(%rsp), %rdi
cmpq %r15, %rsi
jne 0x1440
leaq 0x10(%rsp), %rdi
movq %r9, %rsi
cmpq %rbx, %r9
je 0x1688
callq 0x19fc
movb $0x1, %r13b
jmp 0x1488
cmpq $0x0, 0x70(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rbx
je 0x146c
movq (%rbx,%r14,8), %r13
movq %r15, %rdi
callq 0x10c0
cmpq 0x20(%rax), %r13
jge 0x1477
leaq (%rbx,%r14,8), %rsi
leaq 0x48(%rsp), %rdi
jmp 0x1480
leaq (%rbx,%r14,8), %rsi
leaq 0x10(%rsp), %rdi
callq 0x1a38
movb $0x1, %r13b
movq 0x70(%rsp), %rax
movq 0x38(%rsp), %rcx
leaq 0x1(%rcx), %rdx
cmpq %rdx, %rax
jbe 0x1517
movq %r15, %rdi
callq 0x10c0
leaq 0x20(%rax), %rsi
leaq 0x10(%rsp), %rdi
callq 0x1a38
movq 0x58(%rsp), %rbx
movq %r15, %rsi
testq %rbx, %rbx
je 0x150b
movq %r15, %rdi
callq 0x10c0
movq 0x20(%rax), %rax
movq %r15, %rdi
movq %rdi, %rcx
movq %rbx, %rdx
movq 0x20(%rbx), %r8
xorl %esi, %esi
cmpq %rax, %r8
setl %sil
movq %rbx, %rdi
cmovlq %rcx, %rdi
movq 0x10(%rbx,%rsi,8), %rbx
testq %rbx, %rbx
jne 0x14cd
movq %r15, %rsi
cmpq %r15, %rdi
je 0x150b
cmpq %rax, %r8
cmovlq %rcx, %rdx
cmpq 0x20(%rdx), %rax
cmovlq %r15, %rdi
movq %rdi, %rsi
leaq 0x48(%rsp), %rdi
callq 0x19fc
jmp 0x1595
cmpq %rax, %rcx
jbe 0x1595
movq 0x28(%rsp), %rsi
addq $0x20, %rsi
leaq 0x48(%rsp), %rdi
callq 0x1a38
movq 0x20(%rsp), %r9
leaq 0x18(%rsp), %r10
movq %r10, %rsi
testq %r9, %r9
je 0x158b
movq 0x28(%rsp), %rax
movq 0x20(%rax), %rax
movq %r10, %rdi
movq %rdi, %rcx
movq %r9, %rdx
movq 0x20(%r9), %r8
xorl %esi, %esi
cmpq %rax, %r8
setl %sil
movq %r9, %rdi
cmovlq %rcx, %rdi
movq 0x10(%r9,%rsi,8), %r9
testq %r9, %r9
jne 0x154d
movq %r10, %rsi
cmpq %r10, %rdi
je 0x158b
cmpq %rax, %r8
cmovlq %rcx, %rdx
cmpq 0x20(%rdx), %rax
cmovlq %r10, %rdi
movq %rdi, %rsi
leaq 0x10(%rsp), %rdi
callq 0x19fc
testb %r13b, %r13b
je 0x15ac
movq 0x70(%rsp), %rbx
movq 0x38(%rsp), %r13
movq %rbx, %rax
addq %r13, %rax
jne 0x15fe
movl $0x6, %edx
movq %rbp, %rdi
leaq 0xa73(%rip), %rsi       # 0x202e
callq 0x1140
leaq 0x18(%rsp), %rbx
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 %r12, %r14
jne 0x1356
jmp 0x1690
movq %r15, %rdi
callq 0x10c0
movq 0x20(%rax), %rsi
cmpq %r13, %rbx
jbe 0x1648
movq %rbp, %rdi
callq 0x1080
leaq 0x18(%rsp), %rbx
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 0x15ed
movq 0x28(%rsp), %rax
addq 0x20(%rax), %rsi
testb $0x1, %sil
xorps %xmm0, %xmm0
cvtsi2sd %rsi, %xmm0
mulsd 0x9a3(%rip), %xmm0      # 0x2008
leaq 0x9b4(%rip), %rdi       # 0x2020
leaq 0x9b4(%rip), %rax       # 0x2027
cmoveq %rax, %rdi
movb $0x1, %al
callq 0x1040
leaq 0x18(%rsp), %rbx
jmp 0x15ed
xorl %r13d, %r13d
jmp 0x1488
leaq 0x10(%rsp), %rdi
callq 0x19ac
leaq 0x48(%rsp), %rdi
callq 0x19ac
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x16bf
jmp 0x16bf
jmp 0x16bf
jmp 0x16bf
jmp 0x16bf
jmp 0x16bf
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x19ac
leaq 0x48(%rsp), %rdi
callq 0x19ac
movq %rbx, %rdi
callq 0x11a0