func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int in() {     int x;     scanf( %d , &x);     return x;   }   template <typename T>   inline istream& operator>>(istream& i, vector<T>& v) {     for (int j = 0; j < ((int)(v).size()); ++j) i >> v[j];     return i;   }   template <typename T>   string join(const vector<T>& v) {     stringstream s;     for (int i = 0; i < ((int)(v).size()); ++i) s <<     << v[i];     return s.str().substr(1);   }   template <typename T>   inline ostream& operator<<(ostream& o, const vector<T>& v) {     if ((int)(v).size()) o << join(v);     return o;   }   template <typename T1, typename T2>   inline istream& operator>>(istream& i, pair<T1, T2>& v) {     return i >> v.first >> v.second;   }   template <typename T1, typename T2>   inline ostream& operator<<(ostream& o, const pair<T1, T2>& v) {     return o << v.first <<  ,  << v.second;   }   template <typename T>   inline long long int suma(const vector<T>& a) {     long long int res(0);     for (auto&& x : a) res += x;     return res;   }   const double eps = 1e-10;   const long long int LINF = 1001002003004005006ll;   const int INF = 1001001001;   const int MX = 200005;   int n, m;   int dp[55][55][55];   struct Q {     int l, r, x, c;     int cost(int i, int h) {       if (l <= i && i < r && h > x) return c;       return 0;     }   };   vector<Q> q;   int dfs(int l, int r, int h) {     if (l == r) return 0;     int& now = dp[l][r][h];     if (now != -1) return now;     now = 0;     if (h) now = dfs(l, r, h - 1);     for (int i = l; i < r; ++i) {       int c = h * h;       for (int k = 0; k < (m); ++k) {         if (l <= q[k].l && q[k].r <= r) c -= q[k].cost(i, h);       }       c += dfs(l, i, h) + dfs(i + 1, r, h);       (now = max(now, c));     }     return now;   }   int main() {     int h;     cin >> n >> h >> m;     q = vector<Q>(m);     for (int i = 0; i < (m); ++i) {       int l, r, x, c;       scanf( %d%d%d%d , &l, &r, &x, &c);       --l;       q[i] = (Q){l, r, x, c};     }     for (int i = 0; i < (n); ++i)       for (int j = 0; j < (n + 1); ++j)         for (int k = 0; k < (h + 1); ++k) dp[i][j][k] = -1;     int ans = dfs(0, n, h);     cout << ans << endl;     return 0;   }   