func_code_string: #include <bits/stdc++.h>   using namespace std;   long long test(vector<long long>& h, int l, int r) {     long long ret = 0;     for (int i = l; i < r; i++) {       long long tmp = 0;       for (int j = i + 1; j < r; j++) {         tmp = max(tmp, abs(h[j] - h[j - 1]));         ret += tmp;       }     }     return ret;   }   int main() {     int n, q;     cin >> n >> q;     vector<long long> h(n);     for (int i = 0; i < n; i++) {       scanf( %I64d , &h[i]);     }     while (q--) {       int l, r;       scanf( %d%d , &l, &r);       l--;       long long ans = 0;       long long last = 0;       deque<pair<long long, int>> dq;       for (int i = l + 1; i < r; i++) {         long long tmp = abs(h[i] - h[i - 1]);         long long len = 1;         while (dq.size() && dq.back().first <= tmp) {           auto val = dq.back();           dq.pop_back();           len += val.second;           last -= val.first * val.second;         }         dq.push_back({tmp, len});         last += tmp * len;         ans += last;       }       printf( %I64d n , ans);     }     return 0;   }   