func_code_string: #include <bits/stdc++.h>   using namespace std;   class trio {    public:     long long first, second, third;   };   const long long MOD = 163577857;   long long gcdExtended(long long a, long long b, long long *x, long long *y) {     if (a == 0) {       *x = 0, *y = 1;       return b;     }     long long x1, y1;     long long gcd = gcdExtended(b % a, a, &x1, &y1);     *x = y1 - (b / a) * x1;     *y = x1;     return gcd;   }   long long modInverse(long long a, long long m) {     long long x, y;     long long g = gcdExtended(a, m, &x, &y);     long long res = (x % m + m) % m;     return res;   }   long long power(long long x, long long y) {     long long ans = 1, second = x;     while (y) {       if (y & 1) {         ans *= second;         ans %= MOD;       }       second *= second;       second %= MOD;       y >>= 1;     }     return ans;   }   bool comp(trio &a, trio &b) { return a.first < b.first; }   vector<long long> a;   long long m, n, k, third;   vector<trio> trap;   bool func(long long mid) {     if (mid == m + 1) return 0;     if (mid <= 0) return 1;     long long val = a[mid - 1];     long long ans = 0;     long long j = 1, i = 0, tr = 0;     while (i <= n) {       bool fl = 0;       while (tr < k && trap[tr].first <= j) {         if (trap[tr].third <= val) {           tr++;           continue;         }         j = max(trap[tr].second, j);         fl = 1;         tr++;       }       if (!fl)         ans += 1;       else {         ans += (j - i) * 3;       }       i = j;       j++;     }     return ans <= third;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     cin >> m >> n >> k >> third;     a.resize(m);     trap.resize(k);     for (long long i = 0; i < m; ++i) {       cin >> a[i];     }     for (long long i = 0; i < k; ++i) {       cin >> trap[i].first >> trap[i].second >> trap[i].third;     }     sort(a.begin(), a.end(), greater<long long>());     sort(trap.begin(), trap.end(), comp);     long long l = 0, h = m, mid;     while (l <= h) {       mid = (l + h) / 2;       bool t1 = func(mid);       bool t2 = func(mid + 1);       if (t1 && !t2) break;       if (t1)         l = mid + 1;       else         h = mid - 1;     }     cout << mid;     return 0;   }   