#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ nums;

/* Variables and functions */
scalar_t__ floor(int);
int /*<<< orphan*/ memcpy(int *, int *, int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int scanf(char *, int *);
int main() {
  int nums[10005], len = 0, n, i, m, c;
  memset(nums, 0, sizeof(nums));
  while (scanf("%d", &n) != -1) {
    for (i = 0; nums[i] > n;)
      i++;
    memcpy(&nums[i + 1], &nums[i], sizeof(int) * (len - i));
    nums[i] = n;
    c = (int)floor(len / 2);
    len++;
    if (len % 2 == 0)
      m = (nums[c] + nums[c + 1]) / 2;
    else
      m = nums[c];
    printf("%d\n", m);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x9c64(%rbp)
lea    -0x9c60(%rbp),%rdi
xor    %esi,%esi
mov    $0x9c54,%edx
call   1040 <memset@plt>
lea    0xe7a(%rip),%rdi
lea    -0x9c68(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0xffffffff,%eax
je     12ce <main+0x17e>
movl   $0x0,-0x9c6c(%rbp)
movslq -0x9c6c(%rbp),%rax
mov    -0x9c60(%rbp,%rax,4),%eax
cmp    -0x9c68(%rbp),%eax
jle    11d3 <main+0x83>
mov    -0x9c6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c6c(%rbp)
jmp    11a5 <main+0x55>
mov    -0x9c6c(%rbp),%eax
add    $0x1,%eax
cltq
lea    -0x9c60(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
movslq -0x9c6c(%rbp),%rax
lea    -0x9c60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x9c64(%rbp),%eax
sub    -0x9c6c(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x9c68(%rbp),%ecx
movslq -0x9c6c(%rbp),%rax
mov    %ecx,-0x9c60(%rbp,%rax,4)
mov    -0x9c64(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1070 <floor@plt>
mov    %eax,-0x9c74(%rbp)
mov    -0x9c64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c64(%rbp)
mov    -0x9c64(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12a3 <main+0x153>
movslq -0x9c74(%rbp),%rax
mov    -0x9c60(%rbp,%rax,4),%eax
mov    -0x9c74(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
add    -0x9c60(%rbp,%rcx,4),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x9c70(%rbp)
jmp    12b7 <main+0x167>
movslq -0x9c74(%rbp),%rax
mov    -0x9c60(%rbp,%rax,4),%eax
mov    %eax,-0x9c70(%rbp)
mov    -0x9c70(%rbp),%esi
lea    0xd3f(%rip),%rdi
call   1030 <printf@plt>
jmp    117f <main+0x2f>
xor    %eax,%eax
add    $0x9c80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x9c68,%rsp
lea    0x10(%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x9c54,%edx
call   1040 <memset@plt>
lea    0xe85(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0xffffffff,%eax
je     125d <main+0x10d>
mov    $0x4,%ebp
lea    0xe69(%rip),%r14
lea    0xe5f(%rip),%r15
lea    0xc(%rsp),%r12
jmp    11cf <main+0x7f>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
add    $0x4,%ebp
cmp    $0xffffffff,%eax
je     125d <main+0x10d>
mov    0xc(%rsp),%ecx
mov    %ebp,%edx
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
mov    %rax,%rsi
add    $0x1,%rax
add    $0xfffffffc,%edx
cmp    %ecx,0x10(%rsp,%rsi,4)
jg     11e0 <main+0x90>
lea    -0x1(%rax),%r13d
lea    (%rsp,%r13,4),%rsi
add    $0x10,%rsi
mov    %eax,%eax
lea    (%rsp,%rax,4),%rdi
add    $0x10,%rdi
call   1050 <memcpy@plt>
mov    0xc(%rsp),%eax
mov    %eax,0x10(%rsp,%r13,4)
mov    %ebx,%edi
shr    %edi
call   1070 <floor@plt>
add    $0x1,%ebx
shl    $0x20,%rax
mov    %rax,%rcx
sar    $0x1e,%rcx
mov    0x10(%rsp,%rcx,1),%esi
test   $0x1,%bl
jne    11b0 <main+0x60>
movabs $0x100000000,%rcx
add    %rcx,%rax
sar    $0x1e,%rax
add    0x10(%rsp,%rax,1),%esi
mov    %esi,%eax
shr    $0x1f,%eax
add    %esi,%eax
sar    %eax
mov    %eax,%esi
jmp    11b0 <main+0x60>
xor    %eax,%eax
add    $0x9c68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10005 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%8 = getelementptr inbounds [10005 x i32], [10005 x i32]* %2, i64 0, i64 0
%9 = call i32 @memset(i32* %8, i32 0, i32 40020)
br label %10
10: ; preds = %69, %0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %72
13: ; preds = %10
store i32 0, i32* %5
br label %14
14: ; preds = %21, %13
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [10005 x i32], [10005 x i32]* %2, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = load i32, i32* %4
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %14
24: ; preds = %14
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10005 x i32], [10005 x i32]* %2, i64 0, i64 %27
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [10005 x i32], [10005 x i32]* %2, i64 0, i64 %30
%32 = load i32, i32* %3
%33 = load i32, i32* %5
%34 = sub nsw i32 %32, %33
%35 = sext i32 %34 to i64
%36 = mul i64 4, %35
%37 = trunc i64 %36 to i32
%38 = call i32 @memcpy(i32* %28, i32* %31, i32 %37)
%39 = load i32, i32* %4
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [10005 x i32], [10005 x i32]* %2, i64 0, i64 %41
store i32 %39, i32* %42
%43 = load i32, i32* %3
%44 = sdiv i32 %43, 2
%45 = call i64 @floor(i32 %44)
%46 = trunc i64 %45 to i32
store i32 %46, i32* %7
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
%49 = load i32, i32* %3
%50 = srem i32 %49, 2
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %64
52: ; preds = %24
%53 = load i32, i32* %7
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [10005 x i32], [10005 x i32]* %2, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [10005 x i32], [10005 x i32]* %2, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = add nsw i32 %56, %61
%63 = sdiv i32 %62, 2
store i32 %63, i32* %6
br label %69
64: ; preds = %24
%65 = load i32, i32* %7
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [10005 x i32], [10005 x i32]* %2, i64 0, i64 %66
%68 = load i32, i32* %67
store i32 %68, i32* %6
br label %69
69: ; preds = %64, %52
%70 = load i32, i32* %6
%71 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %70)
br label %10
72: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [10005 x i32]
%2 = alloca i32
%3 = bitcast [10005 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [10005 x i32], [10005 x i32]* %1, i64 0, i64 0
%6 = call i32 @memset(i32* %5, i32 0, i32 40020)
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = icmp eq i32 %7, -1
br i1 %8, label %50, label %9
9: ; preds = %0, %45
%10 = phi i32 [ %31, %45 ], [ 0, %0 ]
%11 = load i32, i32* %2
br label %12
12: ; preds = %12, %9
%13 = phi i64 [ %17, %12 ], [ 0, %9 ]
%14 = getelementptr inbounds [10005 x i32], [10005 x i32]* %1, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = icmp sgt i32 %15, %11
%17 = add nuw i64 %13, 1
br i1 %16, label %12, label %18
18: ; preds = %12
%19 = trunc i64 %13 to i32
%20 = and i64 %13, 4294967295
%21 = getelementptr inbounds [10005 x i32], [10005 x i32]* %1, i64 0, i64 %20
%22 = add i64 %13, 1
%23 = and i64 %22, 4294967295
%24 = getelementptr inbounds [10005 x i32], [10005 x i32]* %1, i64 0, i64 %23
%25 = sub nsw i32 %10, %19
%26 = shl i32 %25, 2
%27 = call i32 @memcpy(i32* %24, i32* %21, i32 %26)
%28 = load i32, i32* %2
store i32 %28, i32* %21
%29 = lshr i32 %10, 1
%30 = call i64 @floor(i32 %29)
%31 = add nuw nsw i32 %10, 1
%32 = and i32 %31, 1
%33 = icmp eq i32 %32, 0
%34 = shl i64 %30, 32
%35 = ashr exact i64 %34, 32
%36 = getelementptr inbounds [10005 x i32], [10005 x i32]* %1, i64 0, i64 %35
%37 = load i32, i32* %36
br i1 %33, label %38, label %45
38: ; preds = %18
%39 = add i64 %34, 4294967296
%40 = ashr exact i64 %39, 32
%41 = getelementptr inbounds [10005 x i32], [10005 x i32]* %1, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = add nsw i32 %42, %37
%44 = sdiv i32 %43, 2
br label %45
45: ; preds = %18, %38
%46 = phi i32 [ %44, %38 ], [ %37, %18 ]
%47 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %9
50: ; preds = %45, %0
ret i32 0
}