func_code_string: #include <bits/stdc++.h>   using namespace std;   constexpr long double pi{3.1415926535897932384};   constexpr long long mod{1000000007};   long long power(long long x, long long y) {     long long res = 1;     x = x % mod;     while (y > 0) {       if (y & 1) res = (res * x) % mod;       y = y >> 1;       x = (x * x) % mod;     }     return res;   }   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }   pair<long long, long long> v[3001];   long long n, dp[3001][3001];   const long long INF = 1000000000000000;   long long getAns(long long pos, long long pre) {     if (pos > n) return 0;     if (dp[pos][pre] != -INF) return dp[pos][pre];     long long x = v[pos].second + getAns(pos + 1, pos);     long long y = v[pos].first - v[pre].first + getAns(pos + 1, pre);     return dp[pos][pre] = min(x, y);   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     cin >> n;     for (long long i = 1; i <= n; i++) {       cin >> v[i].first >> v[i].second;     }     sort(v + 1, v + n + 1);     for (long long i = 0; i <= n; i++) {       for (long long j = 0; j <= n; j++) {         dp[i][j] = -INF;       }     }     long long ans = getAns(2, 1) + v[1].second;     cout << ans <<   n ;     return 0;   }   