Language: C++

#include <cstdio>
#include <iostream>
using namespace std;

static const int MAX_ELEM = 500000;

int MergeElem(int elem[], int start, int mid, int end)
{
#if 1
    int i, j, k, l;
    int num = 0;
    vector<int> left, right;

    i = mid - start;
    j = end - mid;
    l = (i > j) ? i : j;

    /* ???????????¢??????????????? */
    for (k = 0; k < l; k++) {
        left.push_back(elem[start + k]);
        right.push_back(elem[mid + k]);
    }
    /* ??????????????§????????\?????? */
    left.push_back(0x7FFFFFFF);
    right.push_back(0x7FFFFFFF);

    i = 0;
    j = 0;
    for (k = start; k < end; k++) {
        ++num; /* ?????? */

        if (left[i] <= right[j]) {
            elem[k] = left[i];
            ++i;
        }
        else {
            elem[k] = right[j];
            ++j;
        }
    }

    return num;
#else
    int i, j, k, l;
    int num = 0;
    int left[MAX_ELEM/2 + 1], right[MAX_ELEM/2 + 1];

    i = mid - start;
    j = end - mid;
    l = (i > j) ? i : j;

    /* ???????????¢??????????????? */
    for (k = 0; k < l; k++) {
        left[k]  = elem[start + k];
        right[k] = elem[mid + k];
    }
    /* ??????????????§????????\?????? */
    left[i]  = 0x7FFFFFFF;
    right[j] = 0x7FFFFFFF;

    i = 0;
    j = 0;
    for (k = start; k < end; k++) {
        ++num; /* ?????? */

        if (left[i] <= right[j]) {
            elem[k] = left[i];
            ++i;
        }
        else {
            elem[k] = right[j];
            ++j;
        }
    }

    return num;
#endif
}

/* end ???????±??????????????????????????????§???????´???°???????????? */
int MergeSort(int elem[], int start, int end)
{
    int mid;
    int cnt = 0;

    /* end ???????±????????????????????±????1????????´????????????????????? */
    if ((start + 1) >= end) {
        return 0;
    }

    mid = (start + end) / 2;
    cnt += MergeSort(elem, start, mid);
    cnt += MergeSort(elem, mid,   end);
    cnt += MergeElem(elem, start, mid, end);

    return cnt;
}

int main(void)
{
    int i;
    int num;
    int cnt;
    int elem[500002];

    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        scanf("%d", &elem[i]);
    }

    cnt = MergeSort(elem, 0, num);

    printf("%d", elem[0]);
    for (i = 1; i < num; i++) {
        printf(" %d", elem[i]);
    }
    printf("\n%d\n", cnt);

    return 0;
}

Compiler output:
a.cc: In function 'int MergeElem(int*, int, int, int)':
a.cc:12:5: error: 'vector' was not declared in this scope
   12 |     vector<int> left, right;
      |     ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <iostream>
  +++ |+#include <vector>
    3 | using namespace std;
a.cc:12:12: error: expected primary-expression before 'int'
   12 |     vector<int> left, right;
      |            ^~~
a.cc:20:14: error: request for member 'push_back' in 'std::left', which is of non-class type 'std::ios_base&(std::ios_base&)'
   20 |         left.push_back(elem[start + k]);
      |              ^~~~~~~~~
a.cc:21:15: error: request for member 'push_back' in 'std::right', which is of non-class type 'std::ios_base&(std::ios_base&)'
   21 |         right.push_back(elem[mid + k]);
      |               ^~~~~~~~~
a.cc:24:10: error: request for member 'push_back' in 'std::left', which is of non-class type 'std::ios_base&(std::ios_base&)'
   24 |     left.push_back(0x7FFFFFFF);
      |          ^~~~~~~~~
a.cc:25:11: error: request for member 'push_back' in 'std::right', which is of non-class type 'std::ios_base&(std::ios_base&)'
   25 |     right.push_back(0x7FFFFFFF);
      |           ^~~~~~~~~
a.cc:32:19: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   32 |         if (left[i] <= right[j]) {
      |                   ^
a.cc:32:31: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   32 |         if (left[i] <= right[j]) {
      |                               ^
a.cc:33:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   33 |             elem[k] = left[i];
      |                             ^
a.cc:33:29: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   33 |             elem[k] = left[i];
      |                       ~~~~~~^
      |                             |
      |                             std::ios_base& (*)(std::ios_base&)
a.cc:37:30: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   37 |             elem[k] = right[j];
      |                              ^
a.cc:37:30: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   37 |             elem[k] = right[j];
      |                       ~~~~~~~^
      |                              |
      |                              std::ios_base& (*)(std::ios_base&)