Language: C++

#include <bits/stdc++.h>

typedef long long ll;
typedef long double lb;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair

using namespace std;

const int N = 1e6 + 69, mod = 1e9 + 7;
const ll INFLL = 1e18;
const int INF = 1e9;

ll n, C;
int height[200005];


struct bla{
        int k = INF; ll b;
        int left = INF, right = INF;
};

int tot = 1;
bla tree[N+1];

lb cross(lb k1, lb b1, lb k2, lb b2){
        return (b2 - b1) / (k1 - k2);
}

ll point(ll x, int k, ll b){
        return x*k + b;
}

void upd(int node, int l, int r, int new_k, ll new_b){
        //cout << node << " " << l << " " << r << " " << tree[node].left << " " << tree[node].right << endl;

        if(tree[node].k == INF){
                tree[node].k = new_k;
                tree[node].b = new_b;
                return ;
        }

        ll old_k = tree[node].k, old_b = tree[node].b;

        lb cross_point = cross(new_k, new_b, old_k, old_b);
        bool smaller_left_new = ( point(cross_point-1, new_k, new_k) < point(cross_point-1, new_k, new_k) );
        int mid = ((l + r) >> 1);

        if(tree[node].left == INF){
                tree[node].left = ++tot;
                tree[node].right = ++tot;
        }

        if(mid >= cross_point){
                if(!smaller_left_new){
                        tree[tree[node].right].k = new_k;
                        tree[tree[node].right].b = new_b;
                        upd(tree[node].left, l, mid, new_k, new_b);
                } else {
                        tree[tree[node].right].k = old_k;
                        tree[tree[node].right].b = old_b;
                        upd(tree[node].left, l, mid, new_k, new_b);
                }
        } else {
                if(smaller_left_new){
                        tree[tree[node].left].k = new_k;
                        tree[tree[node].left].b = new_b;
                        upd(tree[node].right, mid + 1, r, new_k, new_b);
                } else {
                        tree[tree[node].left].k = old_k;
                        tree[tree[node].left].b = old_b;
                        upd(tree[node].right, mid + 1, r, new_k, new_b);
                }
        }
}


ll get(int node, int l, int r, int x){

        //cout << node << " " << l << ''
        if(tree[node].left == INF){
                return tree[node].k*x + tree[node].b;
        }

        int mid = ((l+r) >> 1);

        ll y = point(x,tree[node].k,tree[node].b);

        if(mid >= x){
                ll y1 = get(tree[node].left, l, mid, x);
                return min(y, y1);
        } else {
                ll y1 = get(tree[node].right, mid+1, r, x);
                return min(y, y1);
        }
}

int main(){

        ios::sync_with_stdio(0);

        cin >> n >> C;

        for(int i = 1 ; i <= n; i++){
                cin >> height[i];
        }

        upd(1, 1, N, -2*height[1], height[1]*height[1]);

        for(int i = 2; i <= n; i++){
                ll answer = get(1, 1, N, height[i]);

                //cout <<"answer : " << answer << endl;

                answer = height[i]*height[i] + answer + C;

                if(i == n) {
                        cout << answer << endl;
                        return 0;
                }

                //cout << "update ------------------" << endl;

                upd(1, 1, N, -2*height[i], height[i]*height[i] + answer);

                //cout << endl;
        }

        cout << dp[n] << endl;

}



Compiler output:
a.cc: In function 'int main()':
a.cc:132:17: error: 'dp' was not declared in this scope; did you mean 'dup'?
  132 |         cout << dp[n] << endl;
      |                 ^~
      |                 dup