Typically there are two modes in my computing: (1) Scripting / Command-line get stuff done and throw-away, and (2) Serious applications that are heavily used, need to process lots of data and be as fast as possible (e.g. processing millions of files like this one where the algorithm constant factor really matters).
In case 1: Hack something together with shell or python and get an answer. If it takes 100-1000x of the equivalent C program, than fine..
In case 2: Custom special purpose C or C++ code
I really don't understand the middle ground here. The equivalent C version that does the same job runs in ~250 millis on my slow Yoga 2 Pro laptop. Total line count 83 of pure C (no other libraries).
Is it "elegant"? Depends who you ask.. But, at the end of the day, "elegant" doesn't pay the bills..