Trying to do TACHSTK with making own sort function

Hello, I have been trying to do the problem TACHSTK without calling the qsort function, which is a part of stdlib.h. When I have tried it with quick sort, I get TLE, and when I try it with merge sort, I get WA. I have tried two implementations of merge sort and I can’t tell what’s wrong. Any help would be appreciated. Here is the link to my most recent try: CodeChef: Practical coding for everyone