/*
Given set of points in 2d grid space. Find a grid point such that sum of distance from all the points
to this given common point is minimum.
*/
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct Point{
int x;
int y;
Point(int a, int b) : x(a), y(b) {}
};
Point minDistance(vector<Point> points) {
vector<int> xes;
vector<int> yes;
for(int i = 0; i < points.size(); ++i) {
xes.push_back(points[i].x);
yes.push_back(points[i].y);
}
sort(xes.begin(), xes.end());
sort(yes.begin(), yes.end());
int n = xes.size();
return {xes[n / 2], yes[n / 2]};
}
int main(void) {
vector<Point> points{{0, 0}, {0, 4}, {2, 2}};
Point x = minDistance(points);
cout << x.x << " " << x.y << endl;
}