Language: C++

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long double mod = 1000000007;

const long long inf = 1000000000000000ll;

const int mxN = 100010;
long long dp[2][mxN];
long long A[mxN];
long long P[mxN];

int N,K;


vector<long long> ind[mxN];
vector<long long> rmd[mxN];
vector<long long> inp[mxN];

long long get(long long mn) {
	long long p = 0;
	for(int i = N-1;i >= 0;i--) {
		p += A[i];
		if(p >= mn) dp[1][i] = p;
		else dp[1][i] = inf;
	}
	for(int k = 2;k <= K;k++) {
		int d = k&1;
		int o = !d;
		multiset<long long> dpm;
		long long mnp = inf;
		for(int i = N-1;i >= 0;i--) {
			dp[d][i] = inf;
			while(!ind[i].empty()) {
				auto s = ind[i].back();
				ind[i].pop_back();
				dpm.insert(s);
			}
			while(!rmd[i].empty()) {
				auto s = rmd[i].back();
				rmd[i].pop_back();
				dpm.erase(dpm.find(s));
			}
			while(!inp[i].empty()) {
				auto s = inp[i].back();
				inp[i].pop_back();
				mnp = min(mnp,s);
			}
			if(!dpm.empty()) dp[d][i] = min(dp[d][i], *dpm.begin());
			if(mnp < inf) dp[d][i] = min(dp[d][i], mnp - (i?P[i-1]:0));
			if(i && P[i-1] >= mn) {
				int at = upper_bound(P,P+i,P[i-1] - mn) - P;
				assert(at < i);
				assert(P[i-1] - (at?P[at-1]:0) >= mn);
				ind[at].push_back(dp[o][i]);
				int to = upper_bound(P,P+at+1,P[i-1] - dp[o][i]) - P;
				if(dp[o][i] <= P[i-1]) {
					assert(to <= at);
					assert(P[i-1] - (to?P[to-1]:0) >= dp[o][i]);
					rmd[to].push_back(dp[o][i]), inp[to].push_back(P[i-1]);
				}
			}
		}
	}
	return dp[K&1][0];
}

int validate(long long mn) {
	int cnt = 0;
	for(int i = 0;i < N;) {
		int j = i;
		while(j < N && P[j] - (i?P[i-1]:0) < mn) j++;
		if(j != N) cnt++;
		i = j + 1;
	}
	return cnt;
}

int main(int argc, char** argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int T;
//	cin>>T;
	T = 1;
	while(T--) {
		cin>>N;
		K = 4;
		for(int i = 0;i < N;i++) cin>>A[i], P[i] = (i?P[i-1]:0) + A[i];
		long long lo = 1,hi = P[N-1],out = inf, mout = -inf;
		while(lo <= hi) {
			long long md = (lo + hi) >> 1;
			if(validate(md) >= K) {
				mout = md;
				lo = md + 1;
			} else {
				hi = md - 1;
			}
		}
		out = get(mout) - mout;
		cout<<<out<<'\n';
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:125:23: error: expected primary-expression before '<' token
  125 |                 cout<<<out<<'\n';
      |                       ^