Language: C++

#include "bits/stdc++.h"
using namespace std;

// Inserted snippets: io, root, vector
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
template<class T, int S>
struct GVector {
	T val[S];
	
	GVector() { rep(i, 0, S) val[i] = 0; }
	GVector(array<T, S> init_val) { rep(i, 0, S) val[i] = init_val[i]; }

	GVector& operator+=(GVector v) { rep(i, 0, S) val[i] += v.val[i]; return *this; }
	GVector& operator-=(GVector v) { rep(i, 0, S) val[i] -= v.val[i]; return *this; }
	GVector& operator*=(T v) { rep(i, 0, S) val[i] *= v; return *this; }
	GVector& operator/=(T v) { rep(i, 0, S) val[i] /= v; return *this; }

	GVector operator+(GVector v) { GVector<T, S> tmp(*this); return tmp += v; }
	GVector operator-(GVector v) { GVector<T, S> tmp(*this); return tmp -= v; }
	GVector operator*(T v) { GVector<T, S> tmp(*this); return tmp *= v; }
	GVector operator/(T v) { GVector<T, S> tmp(*this); return tmp /= v; }

	double norm2() { double r = 0; rep(i, 0, S) r += val[i] * val[i]; return r; }
	double norm() { return sqrt(norm2()); }	
	
	GVector unit() { double scale = norm(); return scale == 0.0 ? *this : (*this / scale); }

	friend istream& operator>>(istream &is, GVector &v) {
		rep(i, 0, S) is >> v.val[i];
		return is;
	}
	friend ostream& operator<<(ostream &os, const GVector& v) {
		rep(i, 0, S - 1) os << v.val[i] << ' ';
		os << v.val[S - 1];
		return os;
	}
};

using Vector2 = GVector<double, 2>;
using Vector3 = GVector<double, 3>;
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, k; read(n, k);

	if (n == 1)
		die(0);

	vector<Vector2> v(n);
	vector<double> c(n);
	rep(i, 0, n) read(v[i], c[i]);

	double ans = 1e100;

	auto calc = [n, k, &v, &c](const Vector2 centre) -> double {
		vector<double> t;
		t.reserve(n);
		rep(i, 0, n) {
			t.push_back(c[i] * (v[i] - centre).norm());
		}
		sort(all(t));
		return t[k - 1];
	};

	rep(i, 0, n) {
		chmin(ans, calc(v[i]));
		rep(j, 0, n) {
			chmin(ans, calc((v[i] * c[i] + v[j] * c[j]) / (c[i] + c[j]));
			rep(k, 0, n) {
				chmin(ans, calc((v[i] * c[i] + v[j] * c[j] + v[k] * c[k]) / (c[i] + c[j] + c[k])));
			}
		}
	}

	cout << fixed << setprecision(9);
	write(ans);
}



Compiler output:
a.cc: In function 'int main()':
a.cc:83:85: error: expected ')' before ';' token
   83 |                         chmin(ans, calc((v[i] * c[i] + v[j] * c[j]) / (c[i] + c[j]));
      |                              ~                                                      ^
      |                                                                                     )