func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /STACK:200000000 )   using namespace std;   const long long oo = 1LL << 60;   const long long kNumMoves = 4;   const long long kMoves[kNumMoves][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}};   struct Line {     Line() : m(0), c(0) {}     Line(long long slope, long long yOrd) : m(slope), c(yOrd) {}     long long m;     long long c;   };   class ConvexHullOptimization {    public:     ConvexHullOptimization(int n) : cur(0), lines(n), count(0) {}     void Add(long long m, long long c) {       Line newLine(m, c);       while (!KeepCurrentTop(newLine)) --count;       lines[count++] = newLine;     }     void Reset() { cur = count = 0; }     long long GetValue(long long x) {       if (cur >= count) cur = count - 1;       while ((cur < count - 1) && ((lines[cur].m * x + lines[cur].c) >=                                    (lines[cur + 1].m * x + lines[cur + 1].c)))         ++cur;       return lines[cur].m * x + lines[cur].c;     }       private:     bool KeepCurrentTop(const Line& l3) {       if ((count - cur) < 2) return true;       Line l2 = lines[count - 1];       Line l1 = lines[count - 2];       long double newCost = (l3.c - l1.c) * (long double)(l1.m - l2.m);       long double oldCost = (l2.c - l1.c) * (long double)(l1.m - l3.m);       return newCost > oldCost;     }     int cur;     int count;     vector<Line> lines;   };   int n, m, p;   vector<long long> d, t, accum;   long long GetMinWaitingTime() {     vector<vector<long long> > dp(m, vector<long long>(2, 0));     for (int i = 0; i < int(m); ++i) dp[i][0] = (i + 1) * t[i] - accum[i];     long long res = oo;     ConvexHullOptimization chOpt(m + 1);     for (int i = 1; i < int(p); ++i) {       int curIdx = (i & 1);       int prevIdx = curIdx ^ 1;       chOpt.Reset();       chOpt.Add(-1, accum[0] + dp[0][prevIdx]);       for (int k = 1; k < int(m); ++k) {         dp[k][curIdx] = dp[k][prevIdx];         dp[k][curIdx] =             min(dp[k][curIdx], (k + 1) * t[k] - accum[k] + chOpt.GetValue(t[k]));         chOpt.Add(-(k + 1), accum[k] + dp[k][prevIdx]);       }       res = min(res, dp[m - 1][curIdx]);     }     return res;   }   int main() {     cin >> n >> m >> p;     d.resize(n, 0);     for (int i = 0; i < int(n - 1); ++i) cin >> d[i + 1];     accum.resize(n, 0);     for (int i = 0; i < int(n - 1); ++i) accum[i + 1] = accum[i] + d[i + 1];     t.resize(m);     for (int i = 0; i < int(m); ++i) {       int h;       cin >> h >> t[i];       t[i] -= accum[--h];     }     sort(t.begin(), t.end());     long long mn = t.front();     for (int i = 0; i < int(m); ++i) t[i] -= mn;     accum.clear();     accum.resize(m, 0);     accum[0] = t[0];     for (int i = 0; i < int(m - 1); ++i) accum[i + 1] = accum[i] + t[i + 1];     long long res = GetMinWaitingTime();     cout << res;     int i;     cin >> i;     return 0;   }   