// File: /workspace/github_cpp_makefile_star2_O1/ekg[P]tsvtools/tsvavg.cpp
// Function: main
int main(void) {

    string header;
    vector<string> header_fields;
    getline(cin, header);

    if (header.empty()) {
        cerr << "could not get header line" << endl;
        exit(1);
    }

    split(header, '\t', header_fields);
    map<string, unsigned int> counts;
    map<string, long double> totals;

    string line;
    getline(cin, line);
    while (!line.empty()) {
        vector<string> fields = split(line, '\t');
        int i = 0;
        for (vector<string>::iterator f = header_fields.begin(); f != header_fields.end(); ++f) {
            const string& field = *f;
            ++counts[field];
            totals[field] += atof(fields[i++].c_str());
        }
        getline(cin, line);
    }

    vector<string> averages;
    for (vector<string>::iterator f = header_fields.begin(); f != header_fields.end(); ++f) {
        const string& field = *f;
        if (counts[field] != 0) {
            stringstream s;
            s << totals[field] / counts[field];
            averages.push_back(s.str());
        }
    }

    cout << header << endl
         << join(averages, "\t") << endl;

    return 0;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
leaq 0x70(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x3be5(%rip), %rdi      # 0x5fd8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %edx
movq 0x3bca(%rip), %rbx      # 0x5fd8
leaq 0x60(%rsp), %rsi
movq %rbx, %rdi
callq 0x2260
cmpq $0x0, 0x68(%rsp)
je 0x27ef
leaq 0x60(%rsp), %rdi
leaq 0x10(%rsp), %rdx
movl $0x9, %esi
callq 0x35fc
leaq 0x108(%rsp), %rax
xorl %ecx, %ecx
movl %ecx, (%rax)
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq 0xd8(%rsp), %rax
movl %ecx, (%rax)
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
movq %rcx, -0x8(%rax)
movb $0x0, (%rax)
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %edx
movq 0x3b39(%rip), %rbx      # 0x5fd8
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x2260
cmpq $0x0, 0x48(%rsp)
je 0x2597
leaq 0x130(%rsp), %r14
leaq 0x40(%rsp), %rbp
leaq 0x100(%rsp), %r12
leaq 0xd0(%rsp), %r13
movq %r14, %rdi
movq %rbp, %rsi
movl $0x9, %edx
callq 0x36f6
movq 0x10(%rsp), %r14
cmpq 0x18(%rsp), %r14
je 0x2554
xorl %r15d, %r15d
leaq (%r14,%r15), %rbp
movq %r12, %rdi
movq %rbp, %rsi
callq 0x292e
incl (%rax)
movq 0x130(%rsp), %rax
movq (%rax,%r15), %rdi
callq 0x21d0
movsd %xmm0, 0x30(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x29aa
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0xa8(%rsp)
fldt (%rax)
faddl 0xa8(%rsp)
fstpt (%rax)
leaq (%r14,%r15), %rax
addq $0x20, %rax
addq $0x20, %r15
cmpq 0x18(%rsp), %rax
jne 0x24f4
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2170
leaq 0x40(%rsp), %rbp
movsbl %al, %edx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2260
leaq 0x130(%rsp), %r14
movq %r14, %rdi
callq 0x2a26
cmpq $0x0, 0x48(%rsp)
jne 0x24d5
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movq $0x0, 0x90(%rsp)
movq 0x10(%rsp), %rbx
cmpq 0x18(%rsp), %rbx
je 0x26b0
leaq 0x100(%rsp), %r13
leaq 0x130(%rsp), %rbp
leaq 0xb0(%rsp), %r15
leaq 0x80(%rsp), %r12
movq 0x39cb(%rip), %r14      # 0x5fb0
movq %r13, %rdi
movq %rbx, %rsi
callq 0x292e
cmpl $0x0, (%rax)
je 0x26a1
movq %rbp, %rdi
callq 0x2100
leaq 0xd0(%rsp), %rdi
movq %rbx, %rsi
callq 0x29aa
fldt (%rax)
fstpt 0x30(%rsp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x292e
movl (%rax), %eax
movq %rax, 0xa0(%rsp)
fildll 0xa0(%rsp)
fldt 0x30(%rsp)
fdivp %st, %st(1)
fstpt (%rsp)
leaq 0x140(%rsp), %rdi
callq 0x20c0
movq %r15, %rdi
leaq 0x148(%rsp), %rsi
callq 0x2210
movq %r12, %rdi
movq %r15, %rsi
callq 0x3394
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x2689
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x2190
movq %rbp, %rdi
movq %r14, %rsi
callq 0x2120
leaq 0x1b0(%rsp), %rdi
callq 0x2070
addq $0x20, %rbx
cmpq 0x18(%rsp), %rbx
jne 0x25e5
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq 0x3907(%rip), %rdi      # 0x5fc8
callq 0x21b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0x1924(%rip), %rdx      # 0x401e
leaq 0x130(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x2a81
movq 0x130(%rsp), %rsi
movq 0x138(%rsp), %rdx
movq %rbx, %rdi
callq 0x21b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
leaq 0x140(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2772
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0x80(%rsp), %rdi
callq 0x2a26
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x279b
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0xd0(%rsp), %rdi
callq 0x2b6a
leaq 0x100(%rsp), %rdi
callq 0x2be2
leaq 0x10(%rsp), %rdi
callq 0x2a26
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x27db
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x2190
xorl %eax, %eax
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x37fa(%rip), %rdi      # 0x5ff0
leaq 0x1807(%rip), %rsi      # 0x4004
movl $0x19, %edx
callq 0x21b0
movq 0x37e2(%rip), %rdi      # 0x5ff0
callq 0x20b0
movl $0x1, %edi
callq 0x21c0
jmp 0x2884
jmp 0x287f
movq %rax, %rbx
jmp 0x28ff
movq %rax, %rbx
leaq 0x140(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28ad
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x28ad
jmp 0x2884
jmp 0x2884
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x288c
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x288c
jmp 0x2889
movq %rax, %rbx
jmp 0x28c9
movq %rax, %rbx
jmp 0x28ad
movq %rax, %rbx
movq 0x371d(%rip), %rsi      # 0x5fb0
leaq 0x130(%rsp), %rdi
callq 0x2120
leaq 0x1b0(%rsp), %rdi
callq 0x2070
leaq 0x80(%rsp), %rdi
jmp 0x28c4
jmp 0x28b9
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x2a26
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x28e5
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0xd0(%rsp), %rdi
callq 0x2b6a
leaq 0x100(%rsp), %rdi
callq 0x2be2
leaq 0x10(%rsp), %rdi
callq 0x2a26
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x2925
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x2190
movq %rbx, %rdi
callq 0x2240
nop