func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 400000 + 1000;   struct node {     int l, r, dir;     long long w;   } temp;   vector<node> v;   long long vis[N];   bool cmp(node a, node b) {     if (a.l == b.l) return a.dir < b.dir;     return a.l < b.l;   }   int main() {     int n, x, i, l, w, r, time;     long long ans;     memset(vis, 0, sizeof(vis));     ans = 1e11;     scanf( %d%d , &n, &x);     for (i = 0; i < n; i++) {       scanf( %d%d%d , &l, &r, &w);       temp.w = w;       temp.l = l;       temp.r = r;       temp.dir = -1;       v.push_back(temp);       temp.l = r;       temp.r = l;       temp.dir = 1;       v.push_back(temp);     }     sort(v.begin(), v.end(), cmp);     for (i = 0; i < v.size(); i++) {       time = abs(v[i].r - v[i].l) + 1;       if (time >= x) continue;       if (v[i].dir == -1) {         if (vis[x - time] != 0) ans = min(ans, vis[x - time] + v[i].w);       } else {         if (!vis[time])           vis[time] = v[i].w;         else           vis[time] = min(vis[time], v[i].w);       }     }     if (ans == 1e11)       printf( -1 n );     else       printf( %lld n , ans);     return 0;   }   