// File: /workspace/github_cpp_makefile_star2_O2/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 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
movq 0x4bf5(%rip), %rdi      # 0x6fd8
leaq 0x50(%rsp), %rsi
callq 0x2050
cmpq $0x0, 0x58(%rsp)
je 0x269c
leaq 0x50(%rsp), %rdi
pushq $0x9
popq %rsi
leaq 0x20(%rsp), %rdx
callq 0x3348
leaq 0xe8(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0xb8(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x4b78(%rip), %rdi      # 0x6fd8
leaq 0x70(%rsp), %rsi
callq 0x2050
leaq 0x70(%rsp), %r14
leaq 0xe0(%rsp), %r12
leaq 0xb0(%rsp), %r13
cmpq $0x0, 0x78(%rsp)
je 0x251a
leaq 0x130(%rsp), %rdi
movq %r14, %rsi
pushq $0x9
popq %rdx
callq 0x33ed
movq 0x20(%rsp), %r15
xorl %ebx, %ebx
leaq (%r15,%rbx), %rbp
cmpq 0x28(%rsp), %rbp
je 0x24f9
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2768
incl (%rax)
movq 0x130(%rsp), %rax
movq (%rax,%rbx), %rdi
callq 0x21c0
movsd %xmm0, 0x10(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x27ce
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
fldt (%rax)
faddl 0x48(%rsp)
fstpt (%rax)
addq $0x20, %rbx
jmp 0x24a5
movq 0x4ad8(%rip), %rdi      # 0x6fd8
movq %r14, %rsi
callq 0x2050
leaq 0x130(%rsp), %rdi
callq 0x2834
jmp 0x247f
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %rbx
andq $0x0, 0x10(%rbx)
movaps %xmm0, (%rbx)
movq 0x20(%rsp), %r14
leaq 0xe0(%rsp), %r13
leaq 0x130(%rsp), %rbp
leaq 0xb0(%rsp), %r15
leaq 0x110(%rsp), %r12
cmpq 0x28(%rsp), %r14
je 0x25e6
movq %r13, %rdi
movq %r14, %rsi
callq 0x2768
cmpl $0x0, (%rax)
je 0x25dd
movq %rbp, %rdi
callq 0x20f0
movq %r15, %rdi
movq %r14, %rsi
callq 0x27ce
fldt (%rax)
fstpt 0x10(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0x2768
movl (%rax), %eax
movq %rax, 0x40(%rsp)
fildll 0x40(%rsp)
fldt 0x10(%rsp)
fdivp %st, %st(1)
fstpt (%rsp)
leaq 0x140(%rsp), %rdi
callq 0x20c0
movq %r12, %rdi
leaq 0x148(%rsp), %rsi
callq 0x2220
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3180
movq %r12, %rdi
callq 0x20a0
movq %rbp, %rdi
callq 0x2110
addq $0x20, %r14
jmp 0x2552
movq 0x49db(%rip), %rdi      # 0x6fc8
leaq 0x50(%rsp), %rsi
callq 0x2150
movq %rax, %rdi
callq 0x20b0
movq %rax, %rbx
leaq 0x1a15(%rip), %rdx      # 0x401e
leaq 0x130(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x2855
leaq 0x130(%rsp), %rsi
movq %rbx, %rdi
callq 0x2150
movq %rax, %rdi
callq 0x20b0
leaq 0x130(%rsp), %rdi
callq 0x20a0
leaq 0x90(%rsp), %rdi
callq 0x2834
leaq 0x70(%rsp), %rdi
callq 0x20a0
leaq 0xb0(%rsp), %rdi
callq 0x2900
leaq 0xe0(%rsp), %rdi
callq 0x2964
leaq 0x20(%rsp), %rdi
callq 0x2834
leaq 0x50(%rsp), %rdi
callq 0x20a0
xorl %eax, %eax
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x494d(%rip), %rdi      # 0x6ff0
leaq 0x195a(%rip), %rsi      # 0x4004
callq 0x2170
movq %rax, %rdi
callq 0x20b0
pushq $0x1
popq %rdi
callq 0x21b0
jmp 0x26f2
jmp 0x26f9
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x20a0
jmp 0x270e
jmp 0x26f2
movq %rax, %rbx
jmp 0x274c
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x20a0
jmp 0x2701
jmp 0x26f2
jmp 0x26fe
movq %rax, %rbx
jmp 0x270e
jmp 0x2718
movq %rax, %rbx
jmp 0x2728
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x2110
leaq 0x90(%rsp), %rdi
jmp 0x2723
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x2834
leaq 0x70(%rsp), %rdi
callq 0x20a0
leaq 0xb0(%rsp), %rdi
callq 0x2900
leaq 0xe0(%rsp), %rdi
callq 0x2964
leaq 0x20(%rsp), %rdi
callq 0x2834
leaq 0x50(%rsp), %rdi
callq 0x20a0
movq %rbx, %rdi
callq 0x2250