Language: C++

#include <vector>
#include <iostream>
#include <algorithm>

#pragma warning(disable : 4996)

using namespace std;

int H, W, N, A, B;

long long LX, LY, RX, RY; // rotate

vector<int> X;
vector<int> Y;
vector<int> EX; // sorted X
vector<int> EY; // sorted Y
vector<int> UX; // unique X
vector<int> UY; // unique Y

vector<long long> DX; // distance sum from UX
vector<long long> DY; // distance sum from UY

int main()
{
	// ------ Input ------ //

	scanf("%d", &W);
	scanf("%d", &H);
	scanf("%d", &N);

	X = vector<long long>(N);
	Y = vector<long long>(N);

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &X[i]);
		scanf("%d", &Y[i]);
	}


	// ------ Sort & Unique ------ //

	EX = X;
	EY = Y;

	sort(EX.begin(), EX.end()); UX.push_back(EX[0]);
	sort(EY.begin(), EY.end()); UY.push_back(EY[0]);

	for (int i = 1; i < N; i++)
	{
		if (EX[i] != EX[i - 1])
		{
			UX.push_back(EX[i]);
		}

		if (EY[i] != EY[i - 1])
		{
			UY.push_back(EY[i]);
		}
	}

	A = UX.size();
	B = UY.size();


	// ------ Rotate ------ //

	LX = 999999999999999999LL;
	LY = 999999999999999999LL;
	RX = -999999999999999999LL;
	RY = -999999999999999999LL;

	for (int i = 0; i < N; i++)
	{
		long long tx = X[i] + Y[i];
		long long ty = X[i] - Y[i];

		LX = min(LX, tx);
		LY = min(LY, ty);
		RX = max(RX, tx);
		RY = max(RY, ty);
	}


	// ------ Distance Calculation ------ //

	for (int i = 0; i < A; i++)
	{
		long long sum = 0;

		for (int j = 0; j < N; j++)
		{
			sum += abs(UX[i] - X[j]);
		}

		DX.push_back(sum);
	}

	for (int i = 0; i < B; i++)
	{
		long long sum = 0;

		for (int j = 0; j < N; j++)
		{
			sum += abs(UY[i] - Y[j]);
		}

		DY.push_back(sum);
	}


	// ------ Calculate ------ //

	long long ret = 999999999999999999LL;

	int x = -1, y = -1, pl = 0, pr = B, l, r;

	for (int i = 0; i < A; i++)
	{
		long long res = 999999999999999999LL;
		
		for (int j = pl; j < pr; j++)
		{
			long long rx = UX[i] + UY[j];
			long long ry = UX[i] - UY[j];

			long long maxs = max(max(rx - LX, RX - rx), max(ry - LY, RY - ry));

			long long sum = 2LL * (DX[i] + DY[j]) - maxs;

			if (sum < res)
			{
				res = sum;
				
				l = j;
				r = j + 1;

				if (sum < ret)
				{
					x = UX[i];
					y = UY[j];
				}
			}
			else if (sum == res)
			{
				r++;
			}
		}

		pl = max(l - 1, 0);
		pr = min(r + 1, B);

		ret = min(ret, res);
	}


	// ------ Output ------ //

	printf("%lld\n", ret);

	printf("%d %d\n", x, y);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:32: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'std::vector<long long int>')
   31 |         X = vector<long long>(N);
      |                                ^
In file included from /usr/include/c++/14/vector:72,
                 from a.cc:1:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const std::vector<int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::vector<int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::initializer_list<int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:32:32: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'std::vector<long long int>')
   32 |         Y = vector<long long>(N);
      |                                ^
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const std::vector<int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::vector<int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::initializer_list<int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~