func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 5;   int t, n, h, m, a[maxn], x;   int sum;   int main() {     ios::sync_with_stdio(0);     cin >> n >> h >> m;     for (int i = 1; i <= n; ++i) a[i] = h;     for (int i = 0; i < m; ++i) {       int l, r, w;       cin >> l >> r >> w;       for (int i = l; i <= r; ++i) {         a[i] = min(a[i], w);       }     }     long long ac = 0;     for (int i = 1; i <= n; ++i) {       ac += a[i] * a[i];     }     cout << ac << endl;     return 0;   }   