func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long N = 2005;   const long long mod = 1e9 + 7;   const long long INF = 1e18 + 1;   long long goal, n, m;   long long umbrella[N], rain[N], cache[N][N];   pair<long long, long long> a[N], b[N];   long long dp(long long x, long long y) {     if (x == goal) return 0;     long long &ans = cache[x][y];     if (ans != -1) return ans;     ans = INF;     if (umbrella[x]) ans = dp(x, x);     if (rain[x] and y == goal + 1) return ans;     if (rain[x]) {       ans = min(ans, umbrella[y] + min(dp(x + 1, y), dp(x + 1, goal + 1)));     } else       ans = min({ans, dp(x + 1, goal + 1),                  umbrella[y] + min(dp(x + 1, y), dp(x + 1, goal + 1))});     return ans;   }   void solve() {     memset(cache, -1, sizeof(cache));     cin >> goal >> n >> m;     for (long long i = 1; i < n + 1; i++) {       cin >> a[i].first >> a[i].second;       for (long long j = a[i].first; j < a[i].second; j++) rain[j] = 1;     }     for (long long i = 1; i < m + 1; i++) {       cin >> b[i].first >> b[i].second;       if (umbrella[b[i].first] == 0)         umbrella[b[i].first] = b[i].second;       else         umbrella[b[i].first] = min(b[i].second, umbrella[b[i].first]);     }     sort(a + 1, a + n + 1);     sort(b + 1, b + m + 1);     if (a[1].first < b[1].first) {       cout << -1;       return;     }     cout << dp(0, goal + 1);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) {       solve();     }   }   