Improve performance (?) and memory usage

I changed this to C only because the only things making it C++ were the `using namespace std`, `#include <iostream>`, and `#include <ostream>` (none of which were being used, might I add).