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 = 2e6 + 69, mod = 1e9 + 7;
const ll INF = 1e18;

ll n, C, dp[200005];
int height[200005];


struct bla{
        ll k = INF, b = INF, 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);
}

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

void upd(int node, int l, int r, ll 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;

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

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

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

                //cout << endl;
        }

        cout << dp[n] << endl;

}



Compiler output:
a.cc:127:1: fatal error: error writing to /tmp/cczOJAoN.s: No space left on device
  127 | }
      | ^
compilation terminated.