Language: C++

template<typename V> struct ConvexHull {
	deque<pair<V,V>> Q;
	V calc(pair<V,V> p, V x) {
		return p.first*x+p.second;
	}
	int dodo(pair<V,V> A,pair<V,V> B, pair<V,V> C) { // max or min
		return ((A.second-C.second)*(B.first-A.first)<=(A.second-B.second)*(C.first-A.first));
	}
	void add(V a, V b) { // add ax+b
		Q.push_back({a,b});
		int v;
		while((v=Q.size())>=3 && dodo(Q[v-3],Q[v-2],Q[v-1]))
			Q[v-2]=Q[v-1], Q.pop_back();
	}
	V query(V x) {
		int L=-1,R=Q.size()-1;
		while(R-L>1) {
			int M=(L+R)/2;
			(((calc(Q[M],x)>=calc(Q[M+1],x)))?L:R)=M;
		}
		return calc(Q[R],x);
	}
};

int N;
ll C,H[202020],R[202020];
ConvexHull<ll> cht;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>C;
	FOR(i,N) {
		cin>>H[i];
		if(i) {
			R[i]=cht.query(H[i])+H[i]*H[i];
		}
		cht.add(-2*H[i],H[i]*H[i]+R[i]+C);
	}
	
	cout<<R[N-1]<<endl;
}

Compiler output:
a.cc:2:9: error: 'deque' does not name a type
    2 |         deque<pair<V,V>> Q;
      |         ^~~~~
a.cc:3:16: error: 'pair' has not been declared
    3 |         V calc(pair<V,V> p, V x) {
      |                ^~~~
a.cc:3:20: error: expected ',' or '...' before '<' token
    3 |         V calc(pair<V,V> p, V x) {
      |                    ^
a.cc:6:18: error: 'pair' has not been declared
    6 |         int dodo(pair<V,V> A,pair<V,V> B, pair<V,V> C) { // max or min
      |                  ^~~~
a.cc:6:22: error: expected ',' or '...' before '<' token
    6 |         int dodo(pair<V,V> A,pair<V,V> B, pair<V,V> C) { // max or min
      |                      ^
a.cc: In member function 'V ConvexHull<V>::calc(int)':
a.cc:4:24: error: 'p' was not declared in this scope
    4 |                 return p.first*x+p.second;
      |                        ^
a.cc:4:32: error: 'x' was not declared in this scope
    4 |                 return p.first*x+p.second;
      |                                ^
a.cc: In member function 'int ConvexHull<V>::dodo(int)':
a.cc:7:26: error: 'A' was not declared in this scope
    7 |                 return ((A.second-C.second)*(B.first-A.first)<=(A.second-B.second)*(C.first-A.first));
      |                          ^
a.cc:7:35: error: 'C' was not declared in this scope
    7 |                 return ((A.second-C.second)*(B.first-A.first)<=(A.second-B.second)*(C.first-A.first));
      |                                   ^
a.cc:7:46: error: 'B' was not declared in this scope
    7 |                 return ((A.second-C.second)*(B.first-A.first)<=(A.second-B.second)*(C.first-A.first));
      |                                              ^
a.cc: In member function 'void ConvexHull<V>::add(V, V)':
a.cc:10:17: error: 'Q' was not declared in this scope
   10 |                 Q.push_back({a,b});
      |                 ^
a.cc: In member function 'V ConvexHull<V>::query(V)':
a.cc:16:28: error: 'Q' was not declared in this scope
   16 |                 int L=-1,R=Q.size()-1;
      |                            ^
a.cc: At global scope:
a.cc:26:1: error: 'll' does not name a type
   26 | ll C,H[202020],R[202020];
      | ^~
a.cc:27:12: error: 'll' was not declared in this scope
   27 | ConvexHull<ll> cht;
      |            ^~
a.cc:27:14: error: template argument 1 is invalid
   27 | ConvexHull<ll> cht;
      |              ^
a.cc: In function 'void solve()':
a.cc:30:28: error: 'string' was not declared in this scope
   30 |         int i,j,k,l,r,x,y; string s;
      |                            ^~~~~~
a.cc:32:9: error: 'cin' was not declared in this scope
   32 |         cin>>N>>C;
      |         ^~~
a.cc:32:17: error: 'C' was not declared in this scope
   32 |         cin>>N>>C;
      |                 ^
a.cc:33:9: error: 'FOR' was not declared in this scope
   33 |         FOR(i,N) {
      |         ^~~
a.cc:41:9: error: 'cout' was not declared in this scope
   41 |         cout<<R[N-1]<<endl;
      |         ^~~~
a.cc:41:15: error: 'R' was not declared in this scope
   41 |         cout<<R[N-1]<<endl;
      |               ^
a.cc:41:23: error: 'endl' was not declared in this scope
   41 |         cout<<R[N-1]<<endl;
      |                       ^~~~