#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

//点a,bの距離の2乗
ld dist2(pdd a, pdd b){
    ld x = b.first - a.first;
    ld y = b.second - a.second;
    return x*x + y*y;
}

//点a,bの距離
ld dist(pdd a, pdd b){
    return sqrt(dist2(a, b));
}

//aのノルムの2乗
ld norm2(pdd a){
    return(a.first*a.first + a.second*a.second);
}

//aのノルム
ld norm(pdd a){
    return sqrt(norm2(a));
}

//内積a・b
ld dot(pdd a, pdd b){
    ld x = a.first * b.first;
    ld y = a.second * b.second;
    return x+y;
}

//a,bを横に並べた行列の行列式
ld det(pdd a, pdd b){
    ld x = a.first * b.second;
    ld y = a.second * b.first;
    return x-y;
}

//b-a
pdd dif(pdd a, pdd b){
    pdd p;
    p.first = b.first - a.first;
    p.second = b.second - a.second;
    return p;
}

//点a,bの中点
pdd mid(pdd a, pdd b){
    pdd p;
    p.first = (a.first + b.first)/2;
    p.second = (a.second + b.second)/2;
    return p;
}

//点a,bをs:tに内分する点
pdd ind(pdd a, pdd b, ld s, ld t){
    pdd p;
    p.first = (t*a.first+s*b.first)/(s+t);
    p.second = (t*a.second+s*b.second)/(s+t);
    return p;
}

//点a,bをs:tに外分する点
pdd exd(pdd a, pdd b, ld s, ld t){
    return ind(a, b, s, -t);
}

typedef vector<pdd> vec;

//直線a1x+b1y=c1と直線a2x+b2y=c2の交点
vec l_l(ld a1, ld b1, ld c1, ld a2, ld b2, ld c2){
    vec res;
    if(a1*b2 == a2*b1) return res;
    ld x = (c1*b2-c2*b1)/(a1*b2-a2*b1);
    ld y = (c1*a2-c2*a1)/(b1*a2-b2*a1);
    res.pb(pdd(x, y));
    return res;
}

//直線ax+by=cと円(x-p)^2+(y-q)^2=r^2の交点
vec l_c(ld a, ld b, ld c, ld p, ld q, ld r){
    vec res;
    //直線と円の中心の距離
    ld d = abs(a*p+b*q-c)/sqrt(a*a+b*b);
    if(d > r) return res;
    //hx,hy:=円の中心から直線に下ろした垂線の足の座標
    ld hx = (a*c-b*(a*q-b*p))/(a*a+b*b);
    ld hy = (b*c+a*(a*q-b*p))/(a*a+b*b);
    if(d == r){
        res.pb(pdd(hx, hy));
        return res;
    }
    //d2:=垂線の足hと交点の距離
    ld d2 = sqrt(r*r-d*d);
    //ex,ey:=直線と同じ向きの単位ベクトル
    ld ex = -b/sqrt(a*a+b*b), ey = a/sqrt(a*a+b*b);
    res.pb(pdd(hx+d2*ex, hy+d2*ey));
    res.pb(pdd(hx-d2*ex, hy-d2*ey));
    return res;
}

//円(x-p1)^2+(y-q1)^2=r1^2と円(x-p2)^2+(y-q2)^2=r2^2の交点
vec c_c(ld p1, ld q1, ld r1, ld p2, ld q2, ld r2){
    vec res;
    //r:=(p1,q1)と(p2,q2)の距離
    ld r = dist(pdd(p1, q1), pdd(p2, q2));
    if(r > r1+r2) return res;
    if(r < abs(r1-r2)) return res;
    if(p1 == p2 && q1 == q2) return res;
    //直線ax+by=c:=２つの円の交点を通る直線
    ld a = 2*(p1-p2), b = 2*(q1-q2), c = (p1*p1+q1*q1-r1*r1)-(p2*p2+q2*q2-r2*r2);
    return l_c(a, b, c, p1, q1, r1);
}

vector<ld> ver(pdd a, pdd b){
    ld p = a.first, q = a.second, r = b.first, s = b.second;
    vector<ld> res(3);
    res[0] = r-p;
    res[1] = s-q;
    res[2] = (r*r-p*p+s*s-q*q)/2;
    return res;
}

int main(){
    int N, K;
    cin >> N >> K;
    ld c[N];
    pdd p[N];
    rep(i, N){
        cin >> p[i].first >> p[i].second >> c[i];
    }
    ld ans = 1e10;
    rep(i, N){
        ld t[N];
        rep(j, N){
            t[j] = c[j]*dist(p[j], p[i]);
        }
        sort(t, t+N);
        ans = min(ans, t[K-1]);
    }
    rep(i, N){
        rep2(j, i+1, N-1){
            pdd o = ind(p[i], p[j], c[j], c[i]);
            ld t[N];
            rep(k, N){
                t[k] = c[k]*dist(p[k], o);
            }
            sort(t, t+N);
            ans = min(ans, t[K-1]);
        }
    }
    rep(i, N){
        rep(j, N){
            rep(k, N){
              	if((j-i)*(k-j)*(i-k)==0) continue;
                vec res;
                if(c[i] == c[k] && c[j] == c[k]){
                    vector<ld> l1 = ver(p[i], p[k]), l2 = ver(p[j], p[k]);
                    res = l_l(l1[0], l1[1], l1[2], l2[0], l2[1], l2[2]);                    
                }
                elif(c[i] == c[k]){
                    vector<ld> l1 = ver(p[i], p[k]);
                    pdd r1 = ind(p[j], p[k], c[k], c[j]), r2 = exd(p[j], p[k], c[k], c[j]);
                    pdd m = mid(r1, r2);
                    ld r = dist(r1, r2)/2;
                    res = l_c(l1[0], l1[1], l1[2], m.first, m.second, r);
                }
                elif(c[j] == c[k]){
                    vector<ld> l1 = ver(p[j], p[k]);
                    pdd r1 = ind(p[i], p[k], c[k], c[i]), r2 = exd(p[i], p[k], c[k], c[i]);
                    pdd m = mid(r1, r2);
                    ld r = dist(r1, r2)/2;
                    res = l_c(l1[0], l1[1], l1[2], m.first, m.second, r);
                }
                else{
                    pdd r1 = ind(p[i], p[k], c[k], c[i]), r2 = exd(p[i], p[k], c[k], c[i]);
                    pdd r3 = ind(p[j], p[k], c[k], c[j]), r4 = exd(p[j], p[k], c[k], c[j]);
                    pdd m1 = mid(r1, r2), m2 = mid(r3, r4);
                    ld R1 = dist(r1, r2)/2, R2 = dist(r3, r4)/2;
                    res = c_c(m1.first, m1.second, R1, m2.first, m2.second, R2);
                }
                for(auto &e: res){
                    ld t[N];
                    rep(l, N){
                        t[l] = c[l]*dist(e, p[l]);
                    }
                    sort(t, t+N);
                    ans = min(ans, t[K-1]);
                }
            }
        }
    }
    cout << fixed << sp(20) << ans << endl;
}

Measured memory_bytes: 384