// File: /workspace/github_cpp_makefile_star2_O1/sharmaeklavya2[P]ddos-on-anycast/src/segtree.cpp
// Function: main
int main(int argc, char* argv[]) {
    if(argc == 1) {
        fprintf(stderr, "usage: %s space_separated_list_of_numbers\n", argv[0]);
        return 2;
    }

    int n = argc - 1;
    vector<double> v(n);
    for(int i=1; i<argc; ++i) {
        v[i-1] = std::atof(argv[i]);
    }

    SegTree segtree(v);

    printf("commands: print, query i, update i x, cumsum_search x;  Ctrl+D to quit\n");

    char command[10];
    while(true) {
        printf(">> ");
        if(scanf("%s", command) == EOF) {
            printf("\r");
            break;
        }
        if(command[0] == 'p') {
            segtree.print(stdout);
        }
        else if(command[0] == 'u') {
            int i; double x;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
            scanf("%d%lf", &i, &x);
#pragma GCC diagnostic pop
            segtree.update(i, x);
        }
        else if(command[0] == 'q') {
            int i; double x;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
            scanf("%d", &i);
#pragma GCC diagnostic pop
            x = segtree.query(i);
            printf("%lf\n", x);
        }
        else if(command[0] == 'c') {
            int i; double x;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
            scanf("%lf", &x);
#pragma GCC diagnostic pop
            i = segtree.cumsum_search(x);
            printf("%d\n", i);
        }
        else {
            printf("Invalid command\n");
        }
    };
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rbx
cmpl $0x1, %edi
je 0x17ed
movl %edi, %r14d
leal -0x1(%r14), %eax
movslq %eax, %rsi
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x1830
cmpl $0x2, %r14d
jl 0x1633
movq 0x40(%rsp), %r15
movl %r14d, %r14d
decq %r14
xorl %r12d, %r12d
movq 0x8(%rbx,%r12,8), %rdi
callq 0x10c0
movsd %xmm0, (%r15,%r12,8)
incq %r12
cmpq %r12, %r14
jne 0x161b
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x18ba
leaq 0xa3e(%rip), %rdi       # 0x2087
callq 0x1100
leaq 0x9ed(%rip), %rdi       # 0x2042
xorl %eax, %eax
callq 0x1030
leaq 0x9e3(%rip), %rdi       # 0x2046
leaq 0x16(%rsp), %rsi
xorl %eax, %eax
callq 0x10b0
cmpl $-0x1, %eax
je 0x17b4
leaq 0x8(%rsp), %r14
leaq 0x20(%rsp), %r15
leaq 0x9b9(%rip), %r13       # 0x2042
leaq 0x9b6(%rip), %rbp       # 0x2046
leaq 0x16(%rsp), %rbx
leaq 0x10(%rsp), %r12
movzbl 0x16(%rsp), %eax
cmpl $0x70, %eax
jg 0x16d4
cmpl $0x63, %eax
je 0x1723
cmpl $0x70, %eax
jne 0x1715
movq 0x290b(%rip), %rax      # 0x3fc0
movq (%rax), %rsi
movl 0x20(%rsp), %r8d
decl %r8d
movq %r15, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r9d, %r9d
callq 0x134c
jmp 0x1794
cmpl $0x71, %eax
je 0x175e
cmpl $0x75, %eax
jne 0x1715
leaq 0x960(%rip), %rdi       # 0x2049
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x10b0
movl 0x10(%rsp), %r8d
movsd 0x8(%rsp), %xmm0
movl 0x20(%rsp), %ecx
decl %ecx
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x14b8
jmp 0x1794
leaq 0x9b2(%rip), %rdi       # 0x20ce
callq 0x1100
jmp 0x1794
leaq 0x921(%rip), %rdi       # 0x204b
movq %r14, %rsi
xorl %eax, %eax
callq 0x10b0
movsd 0x8(%rsp), %xmm0
movl 0x20(%rsp), %ecx
decl %ecx
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1576
leaq 0x8ff(%rip), %rdi       # 0x2052
movl %eax, %esi
xorl %eax, %eax
callq 0x1030
jmp 0x1794
leaq 0x8ea(%rip), %rdi       # 0x204f
movq %r14, %rsi
xorl %eax, %eax
callq 0x10b0
movl 0x8(%rsp), %r8d
movl 0x20(%rsp), %ecx
decl %ecx
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1426
leaq 0x885(%rip), %rdi       # 0x2012
movb $0x1, %al
callq 0x1030
movq %r13, %rdi
xorl %eax, %eax
callq 0x1030
movq %rbp, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10b0
cmpl $-0x1, %eax
jne 0x169a
movl $0xd, %edi
callq 0x10d0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x17cd
callq 0x1090
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x17dc
callq 0x1090
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x1140
movl $0x2, %eax
jmp 0x17de
movq %rax, %rbx
jmp 0x1819
jmp 0x1807
jmp 0x1807
jmp 0x1807
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x1819
callq 0x1090
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1828
callq 0x1090
movq %rbx, %rdi
callq 0x1110