Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<deque>
#include<string>
#include<stack>
#define int long long
#define P pair<int,int>
using namespace std;

P a[100000];
int b[100000], c[100000];
int dis = LLONG_MAX;
P ans = { LLONG_MAX,LLONG_MAX };
P w;//x??§?¨???????
P x;//x??§?¨?????????¢
P y;//y??§?¨???????
P z;//y??§?¨?????????¢
signed main() {
	int n; cin >> n >> n >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
		b[i] = a[i].first, c[i] = a[i].second;
	}
	sort(b, b + n); sort(c, c + n);
	if (n & 1) {
		w.first = b[n / 2];
		int k = 0;
		for (int i = 0; i < n; i++) {
			k += abs(b[i] - b[n / 2]) * 2;
		}
		x.first = k;
		k = 0;
		y.first = c[n / 2];
		for (int i = 0; i < n; i++) {
			k += abs(c[i] - c[n / 2]) * 2;
		}
		z.first = k;
	}
	else {
		w.first = b[n / 2];
		int k = 0;
		for (int i = 0; i < n; i++) {
			k += abs(b[i] - b[n / 2]) * 2;
		}
		x.first = k;
		k = 0;
		w.second = b[n / 2 - 1];
		for (int i = 0; i < n; i++) {
			k += abs(b[i] - b[n / 2 - 1]) * 2;
		}
		x.second = k;
		k = 0;

		y.first = c[n / 2];
		for (int i = 0; i < n; i++) {
			k += abs(c[i] - c[n / 2]) * 2;
		}
		z.first = k;
		k = 0;

		y.second = c[n / 2 - 1];
		for (int i = 0; i < n; i++) {
			k += abs(c[i] - c[n / 2 - 1]) * 2;
		}
		z.second = k;
	}
	for (int i = 0; i < n; i++) {
		b[i] = a[i].first, c[i] = a[i].second;
	}
	for (int i = 0; i < n; i++) {//i???????????????
		int l = x.first - abs(w.first - b[i]);
		if (n % 2 == 0)l = min(l, x.second - abs(w.second - b[i]));
		int r = z.first - abs(y.first - c[i]);
		if (n % 2 == 0)r = min(r, z.second - abs(y.second - c[i]));
		dis = min(dis, l + r);
	}
	for (int i = 0; i < n; i++) {//i???????????????
		int l = x.first - abs(w.first - b[i]);
		if (n % 2 == 0)l = min(l, x.second - abs(w.second - b[i]));
		int r = z.first - abs(y.first - c[i]);
		if (n % 2 == 0)r = min(r, z.second - abs(y.second - c[i]));
		if (dis == l + r) {
			if (n % 2 == 0 && x.first - abs(w.first - b[i])!=l) {
				ans.first = min(ans.first, w.second);
		}
			else {
				ans.first = min(ans.first, w.first);
			}
			if (n % 2 == 0 && z.first - abs(y.first - c[i]) != r) {
				ans.second = min(ans.second, y.second);
			}
			else {
				ans.second = min(ans.second, y.first);
			}
		}
	}
	cout << dis << endl;
	cout << ans.first << " " << ans.second << endl;
}

Compiler output:
a.cc:22:11: error: 'LLONG_MAX' was not declared in this scope
   22 | int dis = LLONG_MAX;
      |           ^~~~~~~~~
a.cc:16:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   15 | #include<stack>
  +++ |+#include <climits>
   16 | #define int long long
a.cc:23:11: error: 'LLONG_MAX' was not declared in this scope
   23 | P ans = { LLONG_MAX,LLONG_MAX };
      |           ^~~~~~~~~
a.cc:23:11: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:23:21: error: 'LLONG_MAX' was not declared in this scope
   23 | P ans = { LLONG_MAX,LLONG_MAX };
      |                     ^~~~~~~~~
a.cc:23:21: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:23:31: error: could not convert '{<expression error>, <expression error>}' from '<brace-enclosed initializer list>' to 'std::pair<long long int, long long int>'
   23 | P ans = { LLONG_MAX,LLONG_MAX };
      |                               ^
      |                               |
      |                               <brace-enclosed initializer list>