#include <bits/stdc++.h>   using namespace std;   const long long K = 401, MAX = 1e18;   int n, m, k, f;   vector<pair<int, int>> adj[2 * K];   vector<pair<int, pair<int, int>>> E;   vector<long long> sp;   long long dist[2 * K];   bool vis[2 * K];   unordered_map<int, int> tb;   priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>       pq;   void dijkstra(int s) {     memset(vis, 0, sizeof(vis));     for (int i = 0; i < f; i++) dist[i] = MAX;     dist[s] = 0;     pq.push({0, s});     while (!pq.empty()) {       int v = pq.top().second, d = pq.top().first;       vis[v] = 1;       pq.pop();       for (pair<int, int> p : adj[v]) {         int u = p.second, w = p.first;         if (vis[u]) continue;         if (dist[v] + w < dist[u]) {           dist[u] = dist[v] + w;           pq.push({dist[u], u});         }       }     }     for (int i = s + 1; i < f; i++)       if (dist[i] < MAX) {         sp.push_back(dist[i]);       }   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m >> k;     for (int i = 0; i < m; i++) {       int x, y, w;       cin >> x >> y >> w;       E.push_back({w, {x, y}});     }     sort(E.begin(), E.end());     for (int i = 0; i < min(k, m); i++) {       int x = E[i].second.first, y = E[i].second.second, w = E[i].first;       if (tb.find(x) == tb.end()) tb[x] = f++;       if (tb.find(y) == tb.end()) tb[y] = f++;       adj[tb[x]].push_back({w, tb[y]});       adj[tb[y]].push_back({w, tb[x]});     }     for (int i = 0; i < f; i++) dijkstra(i);     sort(sp.begin(), sp.end());     cout << sp[k - 1];   }   