Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

const int INF = 1000000001;
int count;

void merge(int* A,int left,int mid,int right)
{
	int n1,n2,n,i,j;
	int L[250001] = {0},R[250001] = {0};
	n1 = mid - left;
	n2 = right - mid;

	for(int i = 0; i < n1; i++)
	{
		L[i] = A[left + i];
	}
	for(int i = 0; i < n2; i++)
	{
		R[i] = A[mid + i];
	}

	L[n1] = INF;
	R[n2] = INF;

	i = 0;
	j = 0;

	//cout << "right=" << right << "left=" << left << endl;
	//cout << "right - left= " << right << " - " << left << " = " << right - left << endl;

	for(int k = 0; k < right - left; k++)
	{
		if (L[i] < R[j] )
		{
			A[left + k] = L[i];
			i++;
		}else
		{
			A[left + k] = R[j];
			j++;
		}

		count++;
	}

	//return count;
}


void mergesort(int* A,int left,int right)
{
	int mid,sol = 0, sol_left, sol_right;

	if(left + 1 < right)
	{
		mid = (left + right) / 2;
		//cout << "mid=" << mid << endl;
		//sol_left = 
		mergesort(A,left,mid);
		//sol_right = 
		mergesort(A,mid,right);
		//sol = 
		merge(A,left,mid,right); //+ sol_right + sol_left;

		//cout << "sol= " << sol << endl;
	}

	//return sol;
}

int main()
{
	int N,S[500000] = {0},solution;

	count = 0;

	cin >> N;

	for(int i = 0; i < N; i++)
	{
		cin >> S[i];
	}

	solution = mergesort(S,0,N);

	for(int i = 0; i < N; i++)
	{
		if (i == N-1)
		{
			cout << S[i] <<endl;
		}else
		{
			cout << S[i] << " ";
		}
	}

	cout << solution << endl;

	return 0;
}
	

Compiler output:
a.cc: In function 'void merge(int*, int, int, int)':
a.cc:48:17: error: reference to 'count' is ambiguous
   48 |                 count++;
      |                 ^~~~~
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:3:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:9:5: note:                 'int count'
    9 | int count;
      |     ^~~~~
a.cc: In function 'int main()':
a.cc:80:9: error: reference to 'count' is ambiguous
   80 |         count = 0;
      |         ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:9:5: note:                 'int count'
    9 | int count;
      |     ^~~~~
a.cc:89:29: error: void value not ignored as it ought to be
   89 |         solution = mergesort(S,0,N);
      |                    ~~~~~~~~~^~~~~~~