malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int read() {     bool f = 0;     int x = 0;     char c = getchar();     while (c <  0  ||  9  < c) {       if (c ==  - ) f = 1;       c = getchar();     }     while ( 0  <= c && c <=  9 )       x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();     return !f ? x : -x;   }   const int MAXN = 200000;   const int INF = 0x3f3f3f3f;   int fa[MAXN + 5], ch[MAXN + 5][2];   long long a[MAXN + 5], siz[MAXN + 5], sum[MAXN + 5], ans[MAXN + 5],       all[MAXN + 5], ad[MAXN + 5], de[MAXN + 5];   bool pan(int u) { return ch[fa[u]][1] == u; }   bool isroot(int u) { return (ch[fa[u]][0] != u && ch[fa[u]][1] != u); }   void PushUp(int u) {     sum[u] = sum[ch[u][0]] + sum[ch[u][1]] + siz[u];     all[u] = all[ch[u][0]] + all[ch[u][1]] + siz[u] * a[u];     ans[u] = ans[ch[u][0]] + ans[ch[u][1]] + ad[u] +              a[u] * (siz[u] * siz[u] - de[u]) +              2 * a[u] * siz[u] * sum[ch[u][1]] +              2 * all[ch[u][0]] * (sum[u] - sum[ch[u][0]]);     return;   }   void Rotate(int x) {     int y = fa[x], z = fa[y], dx = pan(x), dy = pan(y), w = ch[x][dx ^ 1];     if (!isroot(y)) ch[z][dy] = x;     ch[x][dx ^ 1] = y, ch[y][dx] = w;     if (w) fa[w] = y;     fa[y] = x, fa[x] = z;     PushUp(y);     return;   }   void Splay(int x) {     for (int y = fa[x]; !isroot(x); Rotate(x), y = fa[x])       if (!isroot(y)) Rotate(pan(x) == pan(y) ? y : x);     PushUp(x);     return;   }   int Access(int x) {     int y = 0;     while (x) {       Splay(x);       siz[x] -= sum[y];       ad[x] -= ans[y];       de[x] -= sum[y] * sum[y];       siz[x] += sum[ch[x][1]];       ad[x] += ans[ch[x][1]];       de[x] += sum[ch[x][1]] * sum[ch[x][1]];       ch[x][1] = y, PushUp(x), y = x, x = fa[x];     }     return y;   }   void Link(int x, int y) {     Access(y);     Splay(y);     Access(x);     Splay(x);     fa[y] = x;     siz[x] += sum[y];     ad[x] += ans[y];     de[x] += 1ll * sum[y] * sum[y];     PushUp(x);     return;   }   void Cut(int x, int y) {     Access(x);     Splay(x);     Splay(y);     siz[x] -= sum[y];     ad[x] -= ans[y];     de[x] -= 1ll * sum[y] * sum[y];     fa[y] = 0;     PushUp(x);     return;   }   char Re[5];   int f[MAXN + 5];   bool check(int x, int y) {     Access(y);     Splay(y), Splay(x);     return !isroot(y);   }   int main() {     int n = read();     for (int i = 2; i <= n; i++) f[i] = read();     for (int i = 1; i <= n; i++)       a[i] = read(), sum[i] = siz[i] = 1, ans[i] = all[i] = a[i];     for (int i = 2; i <= n; i++) Link(f[i], i);     Access(1), Splay(1);     printf( %.10f n , 1.0 * ans[1] / n / n);     int m = read();     for (int i = 1; i <= m; i++) {       scanf( %s , Re);       if (Re[0] ==  P ) {         int x = read(), y = read();         if (f[x] == y || f[y] == x) goto Break;         if (check(x, y)) swap(x, y);         Cut(f[x], x), f[x] = y;         Link(f[x], x);       } else {         int x = read(), y = read();         Access(x), Splay(x);         a[x] = y;         PushUp(x);       }     Break:       Access(1), Splay(1);       printf( %.10f n , 1.0 * ans[1] / n / n);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 200005;   const int MOD = 1000000007;   long long fun(long long a, long long b) {     if (a > b) return a;     return b;   }   void swp(long long *a, long long *b) {     long long temp = *a;     *a = *b;     *b = temp;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     ;     int n;     cin >> n;     char ch;     long long x, y;     cin >> ch >> x >> y;     if (x > y) swp(&x, &y);     long long mx = x, my = y;     n--;     while (n--) {       cin >> ch >> x >> y;       if (x > y) swp(&x, &y);       if (ch ==  + ) {         mx = fun(mx, x);         my = fun(my, y);       } else {         if ((x >= mx && y >= my) || (x >= my && y >= mx))           cout <<  YES n ;         else           cout <<  NO n ;       }     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   long long max(long long a, long long b) {     if (a > b) {       return a;     } else {       return b;     }   }   long long min(long long a, long long b) {     if (a < b) {       return a;     } else {       return b;     }   }   long long power(long long b, long long e) {     if (e == 0) return 1;     if (e % 2)       return ((b * power((b) * (b), (e - 1) / 2)));     else       return power((b) * (b), e / 2);   }   long long modpower(long long b, long long e, long long q) {     long long MOD = q;     if (e == 0) return 1;     if (e % 2)       return ((b % MOD) * modpower((b % MOD) * (b % MOD), (e - 1) / 2, q)) % MOD;     else       return modpower((b % MOD) * (b % MOD), e / 2, q) % MOD;   }   void dpv(vector<long long> v) {     for (long long i = 0; i < v.size(); i++) {       cout << v[i] <<    ;     }     cout <<   n ;   }   void dpv(vector<pair<long long, long long> > v) {     for (long long i = 0; i < v.size(); i++) {       cout << v[i].first <<     << v[i].second <<   n ;     }   }   void dpv(set<long long> v) {     for (auto i : v) {       cout << i <<    ;     }     cout <<   n ;   }   void oblivious() {     string s;     cin >> s;     long long p = 0, ans = 0, q = 1;     for (long long i = 0; i <= s.length(); i++) {       if (s[i] ==  +  || s[i] ==  -  || i == s.length()) {         ans += p * q;         p = 0;         if (i == s.length()) {           continue;         }         if (s[i] ==  + ) {           q = 1;         } else if (s[i] ==  - ) {           q = -1;         }       } else {         p = (10 * p + s[i] -  0 );       }     }     long long u = ans;     long long y = 0;     string s1;     if (u == 0) {       s1.push_back( 0 );     } else {       while (u != 0) {         s1.push_back(u % 10 +  0 );         u = u / 10;       }     }     reverse(s1.begin(), s1.end());     for (long long i = 0; i < s1.length(); i++) {       long long z = s1[i];       while (z--) {         cout <<  + ;       }       cout <<  .> ;       cout <<   n ;     }   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) {       oblivious();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     t = 1;     while (t--) {       int n;       cin >> n;       int cnt1 = 0, cnt2 = 0, x;       for (int i = 0; i < n; i++) {         cin >> x;         if (x % 2 == 0)           cnt1++;         else           cnt2++;       }       if (cnt2 % 2 == 0) {         cout << cnt1 << endl;       } else         cout << cnt2 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int test = 0; test < t; test++) {       bool answer = true;       int n;       cin >> n;       vector<int> a(n);       vector<int> b(n);       for (int i = 0; i < n; i++) cin >> a[i];       for (int i = 0; i < n; i++) cin >> b[i];       unordered_map<int, int> keys_to_counts;       keys_to_counts[1] = 0;       keys_to_counts[-1] = 0;       keys_to_counts[0] = 0;       for (int x : a) {         keys_to_counts[x]++;       }       keys_to_counts[a[n - 1]]--;       for (int i = n - 1; i >= 0; i--) {         if (b[i] > a[i]) {           answer &= (keys_to_counts[1] > 0);         } else if (b[i] < a[i]) {           answer &= (keys_to_counts[-1] > 0);         }         if (i != 0) keys_to_counts[a[i - 1]]--;       }       if (answer)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long arr[200000], cum[200000];   unsigned long long forone;   unsigned long long n;   unsigned long long make(unsigned long long st, unsigned long long mult,                           unsigned long long lim, unsigned long long level) {     if (st > n) return 0;     unsigned long long end = min(n, st + lim - 1);     return make(end + 1, mult, lim * mult, level + 1) +            (cum[end] - cum[st - 1]) * level;   }   bool comp(int p, int q) { return p > q; }   int main() {     while (cin >> n) {       unsigned long long i;       for (i = 1; i <= n; i++) cin >> arr[i];       sort(&arr[1], &arr[n + 1], comp);       cum[0] = 0;       forone = 0;       for (i = 1; i <= n; i++) {         forone += (i - 1) * arr[i];         cum[i] = cum[i - 1] + arr[i];       }       unsigned long long q;       cin >> q;       unsigned long long tem;       for (i = 1; i <= q; i++) {         cin >> tem;         if (tem == 1) {           cout << forone;           if (i != q) cout <<    ;           continue;         }         cout << make(2, tem, tem, 1);         if (i != q) cout <<    ;       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x, t, a, b, da, db, i, j, p, ans = 0;   int main() {     scanf( %d %d %d %d %d %d , &x, &t, &a, &b, &da, &db);     i = 0;     for (i = 0; i < t; i++)       for (j = 0; j < t; j++) {         if (a - i * da + b - j * db == x) ans = 1;       }     for (i = 0; i < t; i++)       if (a - i * da == x || b - i * db == x) ans = 1;     if (ans == 1 || x == 0)       printf( YES );     else       printf( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n, a, b;     cin >> n >> a >> b;     long long left = a;     long long right = n - b - 1;     long long end = max(left, right);     long long ans = n - end;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int n, p, start[390000], fin[390000];   map<pair<int, int>, int> mp;   int main() {     scanf( %d %d , &n, &p);     vector<int> cnt(n, 0);     for (int i = 0; i < n; i++) {       int x, y;       scanf( %d %d , &x, &y);       x--;       y--;       if (x > y) swap(x, y);       start[i] = x;       fin[i] = y;       cnt[x]++;       cnt[y]++;       mp[make_pair(x, y)]++;     }     vector<int> cnt2(cnt.begin(), cnt.end());     sort(cnt.begin(), cnt.end());     long long ans = 0;     int j = n;     for (int i = 0; i < n; i++) {       while (j - 1 >= i && cnt[i] + cnt[j - 1] >= p) j--;       if (j < i + 1) j = i + 1;       ans += n - j;     }     for (int i = 0; i < n; i++) {       if (cnt2[start[i]] + cnt2[fin[i]] < p) continue;       if (cnt2[start[i]] + cnt2[fin[i]] - mp[make_pair(start[i], fin[i])] < p)         ans--;       mp[make_pair(start[i], fin[i])] = 0;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000 + 5;   int main() {     int n, que[maxn];     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &que[i]);     sort(que, que + n);     if (n % 2 == 0) n--;     printf( %d n , que[n / 2]);   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 5;   int n, k, x, y;   set<pair<int, int> > s;   vector<pair<int, int> > a[MAXN];   vector<int> ans;   inline void start() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &x, &y);       a[x].push_back({y, i});     }   }   inline void solve() {     for (int i = 1; i <= 2e5 + 1; i++) {       for (int j = 0; j < a[i].size(); j++) s.insert(a[i][j]);       while (s.size() > k) {         ans.push_back((--s.end())->second);         s.erase(--s.end());       }       while (!s.empty() && s.begin()->first == i) s.erase(s.begin());     }     sort(ans.begin(), ans.end());     printf( %d n , ans.size());     for (int i = 0; i < ans.size(); i++) printf( %d  , ans[i]);     puts(  );   }   int main() {     start();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, j, k, sum = 0;     cin >> n;     pair<int, int> a[n];     for (i = 0; i < n; i++) {       cin >> a[i].first;       a[i].second = i;     }     sort(a, a + n);     for (i = 0; i < n; i++) {       sum = sum + ((a[n - i - 1].first * i) + 1);     }     cout << sum <<   n ;     for (i = 0; i < n; i++) cout << a[n - i - 1].second + 1 <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = +100500;   const long long INF = 4e18;   long long a[MAXN];   int main() {     long long n, k;     cin >> n >> k;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     if (k >= 3) {       sort(a + 1, a + n + 1);       cout << a[n];       return 0;     }     if (k == 1) {       sort(a + 1, a + n + 1);       cout << a[1];       return 0;     }     multiset<long long> b;     multiset<long long> c;     for (int i = 1; i <= n; i++) {       c.insert(a[i]);     }     long long ans = -INF;     long long pt = 1;     while (pt < n) {       b.insert(a[pt]);       c.erase(c.equal_range(a[pt]).first);       long long x = max(*c.begin(), *b.begin());       ans = max(ans, x);       pt++;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b;   bool check(int k, int x, int y) {     long long ca = 1LL * k * x;     long long cb = 1LL * k * y;     return ca <= a && cb <= b;   }   long long gcd(long long a, long long b) {     if (!b)       return a;     else       return gcd(b, a % b);   }   int main() {     int x, y;     cin >> a >> b >> x >> y;     int l = 1, r = 2 * 1e9;     long long ans = 2e9 + 1;     long long g = gcd(x, y);     x /= g;     y /= g;     while (l <= r) {       int mid = (l + r) >> 1;       if (check(mid, x, y)) {         ans = mid;         l = mid + 1;       } else         r = mid - 1;     }     if (ans == 2e9 + 1)       cout <<  0 0  << endl;     else       cout << x * ans <<     << y * ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000005;   int n, k;   int v[N], c[N], p[N];   double f[N];   double C(int n, int m) { return f[n] - f[m] - f[n - m]; }   struct Node {     int Max, Min;   } node[N * 4];   void pushup(int x) {     node[x].Max = max(node[((x << 1) + 1)].Max, node[((x << 1) + 2)].Max);     node[x].Min = min(node[((x << 1) + 1)].Min, node[((x << 1) + 2)].Min);   }   void build(int l, int r, int x = 0) {     if (l == r) {       node[x].Max = v[l];       node[x].Min = c[l];       return;     }     int mid = (l + r) >> 1;     build(l, mid, ((x << 1) + 1));     build(mid + 1, r, ((x << 1) + 2));     pushup(x);   }   int Max1, Min1;   void rmq(int l, int r, int L = 1, int R = n, int x = 0) {     if (L >= l && R <= r) {       Max1 = max(Max1, node[x].Max);       Min1 = min(Min1, node[x].Min);       return;     }     int mid = (L + R) >> 1;     if (l <= mid) rmq(l, r, L, mid, ((x << 1) + 1));     if (r > mid) rmq(l, r, mid + 1, R, ((x << 1) + 2));   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , &v[i]);     for (int i = 1; i <= n; i++) scanf( %d , &c[i]);     p[n] = min(v[n] * 100, c[n]);     int pre = n;     int Max = v[n], Min = c[n];     for (int i = n - 1; i >= 1; i--) {       Max = max(Max, v[i]);       Min = min(Min, c[i]);       if (min(Max * 100, Min) < min(v[i] * 100, c[i])) Max = v[i], Min = c[i];       p[i] = min(Max * 100, Min);     }     sort(p + 1, p + 1 + n);     for (int i = 1; i <= n; i++) f[i] = f[i - 1] + log(i * 1.0);     double ans = 0;     for (int i = 1; i <= n; i++) {       if (k - 1 > n - i) break;       ans += exp(log(p[i] * 1.0) + C(n - i, k - 1) - C(n, k));     }     printf( %.12f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int inv(long long int k) {     long long int vl = 1000000007 - 2;     long long int val = 1;     long long int b = k;     for (int i = 0; i < 63; i++) {       if ((vl >> i) & 1) {         val *= b;         val %= 1000000007;       }       b = b * b;       b %= 1000000007;     }     return val;   }   int main() {     string s;     cin >> s;     long long int l = s.size();     vector<long long int> vr(l + 1), op(l + 1);     vr[0] = 1;     for (int i = 1; i <= l; i++) {       vr[i] = i * vr[i - 1];       vr[i] %= 1000000007;     }     for (int i = 0; i < l; i++) {       if (s[i] ==  ( ) op[i + 1]++;       op[i + 1] += op[i];     }     long long int ans = 0;     for (int i = 0; i < l; i++) {       if (s[i] ==  ) ) continue;       long long int v = op[i + 1];       long long int v1 = op[l] - op[i + 1];       v1 = l - i - 1 - v1;       if (v1 == 0) continue;       long long int n = v + v1 - 1;       long long int k = v;       k = (vr[k] * vr[n - k]) % 1000000007;       k = inv(k);       k = (vr[n] * k) % 1000000007;       ans += k;       ans %= 1000000007;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, temp;     cin >> n;     long long int sum = 0, sum2 = 0;     for (int i = 0; i < n; i++) {       cin >> temp;       sum += temp;     }     for (int i = 0; i < n - 1; i++) {       cin >> temp;       sum2 += temp;     }     cout << sum - sum2 << endl;     sum = 0;     for (int i = 0; i < n - 2; i++) {       cin >> temp;       sum += temp;     }     cout << sum2 - sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int inf_int = 1e9;   long long inf_ll = 1e16;   const double pi = 3.1415926535898;   const int mod = 1e9 + 9;   const int MAXN = 2e5 + 100;   bool debug = false;   char a[1005][1005];   char used[1005][1005][4][3];   int dx[] = {0, 0, 1, -1};   int dy[] = {1, -1, 0, 0};   int n, m;   inline bool is_ok(int x, int y, int d, int z) {     return x >= 1 && x <= n && y >= 1 && y <= m && z <= 2 && a[x][y] !=  *  &&            !used[x][y][d][z];   }   void solve() {     cin >> n >> m;     int x1, y1;     for (int i = 1; i <= n; ++i) {       for (int e = 1; e <= m; ++e) {         cin >> a[i][e];         if (a[i][e] ==  S ) {           x1 = i;           y1 = e;         }       }     }     queue<pair<pair<int, int>, pair<int, int> > > q;     used[x1][y1][0][0] = 1;     used[x1][y1][1][0] = 1;     used[x1][y1][2][0] = 1;     used[x1][y1][3][0] = 1;     q.push({{x1, y1}, {0, 0}});     q.push({{x1, y1}, {1, 0}});     q.push({{x1, y1}, {2, 0}});     q.push({{x1, y1}, {3, 0}});     while (!q.empty()) {       int x = q.front().first.first, y = q.front().first.second;       int d = q.front().second.first, z = q.front().second.second;       q.pop();       if (is_ok(x + dx[d], y + dy[d], d, z)) {         q.push({{x + dx[d], y + dy[d]}, {d, z}});         used[x + dx[d]][y + dy[d]][d][z] = 1;       }       for (int i = 0; i < 4; ++i) {         if (is_ok(x + dx[i], y + dy[i], i, z + 1)) {           q.push({{x + dx[i], y + dy[i]}, {i, z + 1}});           used[x + dx[i]][y + dy[i]][i][z + 1] = 1;         }       }     }     for (int i = 1; i <= n; ++i) {       for (int e = 1; e <= m; ++e) {         if (a[i][e] ==  T ) {           for (int j = 0; j < 4; ++j) {             for (int f = 0; f <= 2; ++f) {               if (used[i][e][j][f]) {                 cout <<  YES ;                 return;               }             }           }         }       }     }     cout <<  NO ;   }   int main() {     if (!debug) {       ios_base::sync_with_stdio(0);       cin.tie(0);       cout.tie(0);     }     int t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300005;   int n, k, pos[N];   long long c[N], ans;   vector<int> v;   priority_queue<pair<long long, int> > q;   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %lld , &c[i]);     for (int i = 1; i <= n + k; i++) {       if (i <= n) q.push(make_pair(c[i], i));       if (k < i) {         int x = q.top().second;         long long w = q.top().first;         q.pop();         ans += w * ((long long)i - (long long)x);         v.push_back(x);       }     }     printf( %lld n , ans);     for (int i = 0; i < v.size(); i++) pos[v[i]] = i + k + 1;     for (int i = 1; i <= n; i++) printf( %d  , pos[i]);     return 0;   }
#include <bits/stdc++.h>   int mod = 1000000007;   const double pi = 3.141592653689793238460;   const int inf = 0x3f3f3f3f;   using namespace std;   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, k;     cin >> n >> k;     int a[10005];     for (int i = 0; i < n; i++) cin >> a[i];     vector<int> pos;     for (int i = 0; i < n; i++) {       int x = a[i];       while (x > 0) {         pos.push_back(x);         x /= 2;       }     }     int ans = inf;     for (auto x : pos) {       vector<int> cur;       for (int i = 0; i < n; i++) {         int cnt = 0;         int y = a[i];         while (y > x) {           y /= 2;           cnt++;         }         if (y == x) {           cur.push_back(cnt);         }       }       if (cur.size() < k) continue;       sort(cur.begin(), cur.end());       ans = min(ans, accumulate(cur.begin(), cur.begin() + k, 0));     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100000 + 6;   int g[N];   int main() {     int n, m, v, i;     cin >> n >> m >> v;     long long top = 1 + (n - 1) * (n - 2) / 2;     if (n - 1 > m || top < (long long)m) {       cout << -1;       return 0;     }     --v;     for (i = 0; i < n; ++i) g[i] = i;     swap(g[1], g[v]);     for (i = 0; i < n - 1; ++i) {       cout << g[i] + 1 <<     << g[i + 1] + 1 << endl;       --m;     }     int j;     for (i = 1; i < n - 1 && m; ++i) {       for (j = i + 2; j < n && m; ++j) {         cout << g[i] + 1 <<     << g[j] + 1 << endl;         --m;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double M;   struct E {     int x, y, z, tp, id;     bool operator<(const E yy) const {       double p1 = tp ? z : z + M, p2 = yy.tp ? yy.z : yy.z + M;       return p1 < p2;     }   } e[100005];   int n, m, k, fa[50005], p[50005], d[50005];   int gf(int x) { return fa[x] == x ? x : fa[x] = gf(fa[x]); }   int Calc(double mid, int r) {     for (int i = 1; i <= n; i++) fa[i] = i;     M = mid, sort(e + 1, e + m + 1);     int ans[2] = {0}, w = n - 1;     for (int i = 1; i <= m; i++) {       int fx = gf(e[i].x), fy = gf(e[i].y);       if (fx == fy) continue;       ans[1] += e[i].z, ans[0] += !e[i].tp;       if (r && ans[0] > k) {         ans[1] -= e[i].z, ans[0] -= !e[i].tp;         continue;       }       fa[fx] = fy, w--;       if (r) p[++p[0]] = e[i].id;     }     if (w) puts( -1 ), exit(0);     return ans[r];   }   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 1, x, y, z; i <= m; i++)       scanf( %d%d%d , &x, &y, &z), e[i] = {x, y, z, !(x == 1 || y == 1), i},                                    d[x]++, d[y]++;     if (d[1] < k || (n > 1 && !k)) return puts( -1 ), 0;     double l = -100001, r = 100001, ans = 0;     while (r - l > 1e-8) {       double mid = (l + r) / 2;       int w = Calc(mid, 0);       if (w == k) {         ans = mid;         break;       }       if (r - l < 0.1 && w > k) {         ans = mid;         break;       }       if (w < k)         r = mid;       else         ans = mid, l = mid;     }     Calc(ans, 1);     printf( %d n , n - 1);     while (p[0]) printf( %d  , p[p[0]--]);     return 0;   }