criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N;
  cin>>N;
  vector<ll>A(N),sum(N+1);
  for(int i=0;i<N;i++){
    cin>>A[i];
    sum[i+1]=sum[i]+A[i];
  }
  ll ans=INFLL;
  ll a,b,c,d;
  int left=0, right=2;
  for(int i=1;i<N-1;i++){
    while(left<=i-1 && (sum[i+1]-sum[left+1]>=sum[left+1])){
      left++;
    }
    if(abs(2*sum[left]-sum[i+1])<abs(2*sum[left+1]-sum[i+1])){
      a=sum[left];
      b=sum[i+1]-sum[left];
      left--;
    }else{
      a=sum[left+1];
      b=sum[i+1]-sum[left+1];
    }
 
    while(right<=N-2 && (sum[N]-sum[right+1]>=sum[right+1]-sum[i+1])){
      right++;
    }
 
    if(abs(sum[N]+sum[i+1]-2*sum[right])<abs(sum[N]+sum[i+1]-2*sum[right+1])){
      c=sum[right]-sum[i+1];
      d=sum[N]-sum[right];
      right--;
    }else{
      c=sum[right+1]-sum[i+1];
      d=sum[N]-sum[right+1];
    }
    ans=min(ans,max({a,b,c,d})-min({a,b,c,d}));
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: 'INFLL' was not declared in this scope
   14 |   ll ans=INFLL;
      |          ^~~~~
Language: C++

#include "pch.h"
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<long long> su(100000);

int Search(int le, int ri,long long ta) {
	if (ri - le == 1)
		return le;
	if (su[(le + ri) / 2]*2 > ta) {
		return Search(le, (le + ri) / 2, ta);
	}
	else {
		return Search((le + ri) / 2, ri, ta);
	}
}

long long check(int n,int size) {
	int a = Search(0, n, su[n]);
	int b = Search(n + 1, size - 1, su[size - 1] + su[n]);
	long long MA = max(max(su[a], su[n] - su[a]), max(su[b] - su[n], su[size-1] - su[b]));
	long long MI = min(min(su[a], su[n] - su[a]), min(su[b] - su[n], su[size-1] - su[b]));
	return MA - MI;
}

int main() {
	int n;
	cin >> n;
	vector<long long> da(n);
	for (int i = 0;i < n;i++) {
		cin >> da[i];
		if (i == 0)
			su[i] = da[i];
		else
			su[i] = da[i] + su[i - 1];
	}
	long long ans = LLONG_MAX;
	for (int i = 1;i < n - 2;i++) {
		ans = min(ans, check(i, n));
	}
	cout << ans << endl;
}

Compiler output:
a.cc:1:10: fatal error: pch.h: No such file or directory
    1 | #include "pch.h"
      |          ^~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<long long> su(100000);

int Search(int le, int ri,long long ta) {
	if (ri - le == 1)
		return le;
	if (su[(le + ri) / 2]*2 > ta) {
		return Search(le, (le + ri) / 2, ta);
	}
	else {
		return Search((le + ri) / 2, ri, ta);
	}
}

long long check(int n,int size) {
	int a = Search(0, n, su[n]);
	int b = Search(n + 1, size - 1, su[size - 1] + su[n]);
	long long MA = max(max(su[a], su[n] - su[a]), max(su[b] - su[n], su[size-1] - su[b]));
	long long MI = min(min(su[a], su[n] - su[a]), min(su[b] - su[n], su[size-1] - su[b]));
	return MA - MI;
}

int main() {
	int n;
	cin >> n;
	vector<long long> da(n);
	for (int i = 0;i < n;i++) {
		cin >> da[i];
		if (i == 0)
			su[i] = da[i];
		else
			su[i] = da[i] + su[i - 1];
	}
	long long ans = LLONG_MAX;
	for (int i = 1;i < n - 2;i++) {
		ans = min(ans, check(i, n));
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:25: error: 'LLONG_MAX' was not declared in this scope
   37 |         long long ans = LLONG_MAX;
      |                         ^~~~~~~~~
a.cc:4:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <vector>
  +++ |+#include <climits>
    4 | using namespace std;
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){in(r...);return true;}
    else return false;
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
const int INF = 1e18, MOD = 1e9 + 7;
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

main(){
    INCANT;
    int n, a, l, c, r, res = INF, w, x, y, z;
    string s;
    in(n);
    int sum[n + 1] = {};
    rep(i, 1, n + 1){
        in(a);
        sum[i] = sum[i - 1] + a;
    }
    l = 1, r = 3
    rep(c, 2, n - 1){
        while(abs(sum[c] - 2 * sum[l]) > abs(sum[c] - 2 * sum[l + 1])){
            l++;
        }
        while(abs(sum[n] - sum[c] - 2 * (sum[r] - sum[c])) > abs(sum[n] - sum[c] - 2 * (sum[r + 1] - sum[c]))){
            r++;
        }
        w = sum[l], x = sum[c] - sum[l], y = sum[r] - sum[c], z = sum[n] - sum[r];
        chmin(res, max({w, x, y, z}) - min({w, x, y, z}));
    }
    print(res);
}

Compiler output:
a.cc:38:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   38 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:48:17: error: expected ';' before 'for'
   48 |     l = 1, r = 3
      |                 ^
      |                 ;
a.cc:10:62: error: expected ';' before ')' token
   10 | #define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
      |                                                              ^
a.cc:8:42: note: in expansion of macro 'repi'
    8 | #define _overload(_1, _2, _3, name, ...) name
      |                                          ^~~~
a.cc:11:18: note: in expansion of macro '_overload'
   11 | #define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
      |                  ^~~~~~~~~
a.cc:49:5: note: in expansion of macro 'rep'
   49 |     rep(c, 2, n - 1){
      |     ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
 
vll cumsum(vll& A){
  vll cum;
  int N=A.size();
  cum.push_back(0);
  for (int i=0;i<N;++i){
    cum.push_back(cum[i]+A[i]);
  }
  return cum;
}
 
//[low, high-1]から探す。
int b_search(vll& cum, int low, int high, ll c){
  int lb=low-1, ub=high;
  while(ub-lb>1){
    int mid=(ub+lb)/2;
    if(cum[mid]>=c){ub=mid;}
    else{lb=mid;}
  }
  return ub;
}
 
int main(){
  int N;cin>>N;
  vll A;
  for (int i=0;i<N;++i){
    ll a;cin>>a;A.push_back(a);
  }
 
  vll cum=cumsum(A);
 
  ll smallest=cum[N];
  //i,i+1の間でまんなかを切る
  for (int i=2;i<N-1;++i){
    ll lc=cum[i];
    ll hc=cum[N]+cum[i];
    int lub=b_search(cum, 1, i+1, lc/2);
    int hub=b_search(cum, i+1, N+1, hc/2);
    ll B=cum[lub];
    ll C=cum[i]-cum[lub];
    ll D=cum[hub]-cum[i];
    ll E=cum[N]-cum[hub];
    ll M=max(B,C);M=max(M,D);M=max(M,E);
    ll m=min(B,C);m=min(m,D);m=min(m, E);
    smallest=min(smallest, M-m);
    if(lub!=1){
      B_=cum[lub-1];
      C_=cum[i]-cum[lub-1];
      M=max(B_,C_);M=max(M,D);M=max(M,E);
      m=min(B_,C_);m=min(m,D);m=min(m, E);
      smallest=min(smallest, M-m);
    }
    if(hub!=i+1){
      D_=cum[hub-1]-cum[i];
      E_=cum[N]-cum[hub-1];
      M=max(B,C);M=max(M,D_);M=max(M,E_);
      m=min(B,C);m=min(m,D_);m=min(m, E_);
      smallest=min(smallest, M-m);
      if(lub!=1){
        B_=cum[lub-1];
        C_=cum[i]-cum[lub-1];
        M=max(B_,C_);M=max(M,D_);M=max(M,E_);
        m=min(B_,C_);m=min(m,D_);m=min(m, E_);
        smallest=min(smallest, M-m);
      }
    }
  }
 
  cout << smallest << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:7: error: 'B_' was not declared in this scope; did you mean 'B'?
   53 |       B_=cum[lub-1];
      |       ^~
      |       B
a.cc:54:7: error: 'C_' was not declared in this scope; did you mean 'C'?
   54 |       C_=cum[i]-cum[lub-1];
      |       ^~
      |       C
a.cc:60:7: error: 'D_' was not declared in this scope; did you mean 'D'?
   60 |       D_=cum[hub-1]-cum[i];
      |       ^~
      |       D
a.cc:61:7: error: 'E_' was not declared in this scope; did you mean 'E'?
   61 |       E_=cum[N]-cum[hub-1];
      |       ^~
      |       E
a.cc:66:9: error: 'B_' was not declared in this scope; did you mean 'B'?
   66 |         B_=cum[lub-1];
      |         ^~
      |         B
a.cc:67:9: error: 'C_' was not declared in this scope; did you mean 'C'?
   67 |         C_=cum[i]-cum[lub-1];
      |         ^~
      |         C
Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

vll cumsum(vll& A){
  vll cum;
  int N=A.size();
  cum.push_back(0);
  for (int i=0;i<N;++i){
    cum.push_back(cum[i]+A[i]);
  }
  return cum;
}

//[low, high-1]から探す。
int b_search(vll& cum, int low, int high, ll c){
  int lb=low-1, ub=high;
  while(ub-lb>1){
    int mid=(ub+lb)/2;
    if(cum[mid]>=c){ub=mid;}
    else{lb=mid;}
  }
  return ub;
}

int main(){
  int N;cin>>N;
  vll A;
  for (int i=0;i<N;++i){
    ll a;cin>>a;A.push_back(a);
  }

  vll cum=cumsum(A);

  ll smallest=cum[N];
  //i,i+1の間でまんなかを切る
  for (int i=2;i<N-1;++i){
    ll lc=cum[i];
    ll hc=cum[N]-cum[i];
    int lub=b_search(cum, 1, i+1, lc/2);
    int hub=b_search(cum, i+1, N+1, uc/2);
    ll B=cum[lub];
    ll C=cum[i]-cum[lub];
    ll D=cum[hub]-cum[i];
    ll E=cum[N]-cum[hub];
    ll M=max(B,C);M=max(M,D);M=max(M,E);
    ll m=min(B,C);m=min(m,D);m=min(m, E);
    smallest=min(smallest, M-m);
    if(lub!=1){
      B=cum[lub-1];
      C=cum[i]-cum[lub-1];
      M=max(B,C);M=max(M,D);M=max(M,E);
      m=min(B,C);m=min(m,D);m=min(m, E);
      smallest=min(smallest, M-m);
    }
    if(hub!=i+1){
      D=cum[hub-1]-cum[i];
      E=cum[N]-cum[hub-1];
      M=max(B,C);M=max(M,D);M=max(M,E);
      m=min(B,C);m=min(m,D);m=min(m, E);
      smallest=min(smallest, M-m);
    }
  }

  cout << smallest << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:37: error: 'uc' was not declared in this scope; did you mean 'hc'?
   44 |     int hub=b_search(cum, i+1, N+1, uc/2);
      |                                     ^~
      |                                     hc
Language: C++

#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;


long N;
vector<long> A(200000);


int main()
{
    cin >> N;
    for( int i = 0; i < N; ++i ) cin >> A[i];

    // 予め和の配列を求めていく
    vector<long> S(200000);  // S[i] = A[0]~A[i]の和
    for( int i = 0; i < N; ++i ){
        if( i == 0 ) S[i] = A[i];
        else S[i] = S[i-1] + A[i];
    }
    
    // 分割点は全て +1 との間で定義 (つまりinclusive) 
    int posl = 0, posr = 2;
    vector<long> P(4); 
    long ans = LONG_MAX;
    // 2番目の分割点についてしゃくとり法で全探索
    for( int middle = 1; middle < N-2; ++middle ){
        long diffl = LONG_MAX, diffr = LONG_MAX;
        
        for( int left = posl; left < middle; ++left ){
            if( diffl > abs(S[middle] - 2*S[left]) ){
                diffl = abs( (S[middle] - S[left]) - S[left] );
                posl = left;
            }else break;
        }
        
        for( int right = max(middle+1, posr); right < N-1; ++right ){
            if( diffr > abs(S[N-1] - 2*S[right] + S[middle]) ){
                diffr = abs( (S[N-1] - S[right]) - (S[right] - S[middle]) );
                posr = right;
            }else break;
        }

        P[0] = S[posl];
        P[1] = S[middle] - S[posl];
        P[2] = S[posr] - S[middle];
        P[3] = S[N-1] - S[posr];
        sort( P.begin(), P.end() );
        
        ans = min( ans, P[3] - P[0] );
    }

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:16: error: 'LONG_MAX' was not declared in this scope
   27 |     long ans = LONG_MAX;
      |                ^~~~~~~~
a.cc:5:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <numeric>
  +++ |+#include <climits>
    5 | using namespace std;
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll N, A[200000], ruiseki[200000];
int index;

ll nibun1(ll x, ll y, ll sum){
	if(2*A[0] >= sum){
		return sum - A[0];
	}
	if(y-x == 1){
		if(sum - 2*ruiseki[x] < 2*ruiseki[y] - sum){
			return ruiseki[x];
		}else{
			return sum - ruiseki[y];
		}
	}
	ll med = (x+y)/2;
	if(2*ruiseki[med] == sum){
		return sum/2;
	}else if(2*ruiseki[med] > sum){
		return nibun1(x, med, sum);
	}else{
		return nibun1(med, y, sum);
	}
}

ll nibun2(ll x, ll y, ll sum){
	if(2*A[index] >= sum){
		return sum - A[index];
	}
	if(y-x == 1){
		if(2*ruiseki[N-1] - 2*ruiseki[x] - sum < sum - 2*ruiseki[N-1] + 2*ruiseki[y]){
			return sum - ruiseki[N-1] + ruiseki[x];
		}else{
			return ruiseki[N-1] - ruiseki[y];
		}
	}
	int med = (x+y)/2;
	if(2*ruiseki[N-1] - 2*ruiseki[med] == sum){
		return ruiseki[N-1] - ruiseki[med];
	}else if(2*ruiseki[N-1] - 2*ruiseki[med] > sum){
		return nibun2(med, y, sum);
	}else{
		return nibun2(x, med, sum);
	}
}

int main(){
	cin >> N;
	ll ans[N-3];
	for(int i=0; i<N; i++){
		cin >> A[i];
		if(i == 0){
			ruiseki[0] = A[0];
		}else{
			ruiseki[i] = ruiseki[i-1] + A[i];
		}
	}
	ll n = ruiseki[N-1];
	index = 2;
	for(int i=1; i<N-2; i++){
		ll a = ruiseki[i];
		ans[i-1] = max(a - nibun1(0, i, a), n - a - nibun2(i+1, N-1, n-a)) - min(nibun1(0, i, a), nibun2(i+1, N-1, n-a));
		index++;
	}
	sort(ans, ans+N-3);
	cout << ans[0] << endl;
	return 0;
}

Compiler output:
a.cc:6:5: error: 'int index' redeclared as different kind of entity
    6 | int index;
      |     ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'll nibun2(ll, ll, ll)':
a.cc:30:15: error: invalid types 'll [200000] {aka long long int [200000]}[<unresolved overloaded function type>]' for array subscript
   30 |         if(2*A[index] >= sum){
      |               ^
a.cc:31:31: error: invalid types 'll [200000] {aka long long int [200000]}[<unresolved overloaded function type>]' for array subscript
   31 |                 return sum - A[index];
      |                               ^
a.cc: In function 'int main()':
a.cc:62:17: error: overloaded function with no contextual type information
   62 |         index = 2;
      |                 ^
a.cc:66:22: error: no post-increment operator for type
   66 |                 index++;
      |                      ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll N, A[200000], ruiseki[200000], index;

ll nibun1(ll x, ll y, ll sum){
	if(2*A[0] >= sum){
		return sum - A[0];
	}
	if(y-x == 1){
		if(sum - 2*ruiseki[x] < 2*ruiseki[y] - sum){
			return ruiseki[x];
		}else{
			return sum - ruiseki[y];
		}
	}
	ll med = (x+y)/2;
	if(2*ruiseki[med] == sum){
		return sum/2;
	}else if(2*ruiseki[med] > sum){
		return nibun1(x, med, sum);
	}else{
		return nibun1(med, y, sum);
	}
}

ll nibun2(ll x, ll y, ll sum){
	if(2*A[index] >= sum){
		return sum - A[index];
	}
	if(y-x == 1){
		if(2*ruiseki[N-1] - 2*ruiseki[x] - sum < sum - 2*ruiseki[N-1] + 2*ruiseki[y]){
			return sum - ruiseki[N-1] + ruiseki[x];
		}else{
			return ruiseki[N-1] - ruiseki[y];
		}
	}
	int med = (x+y)/2;
	if(2*ruiseki[N-1] - 2*ruiseki[med] == sum){
		return ruiseki[N-1] - ruiseki[med];
	}else if(2*ruiseki[N-1] - 2*ruiseki[med] > sum){
		return nibun2(med, y, sum);
	}else{
		return nibun2(x, med, sum);
	}
}

int main(){
	cin >> N;
	ll ans[N-3];
	for(int i=0; i<N; i++){
		cin >> A[i];
		if(i == 0){
			ruiseki[0] = A[0];
		}else{
			ruiseki[i] = ruiseki[i-1] + A[i];
		}
	}
	ll n = ruiseki[N-1];
	index = 2;
	for(int i=1; i<N-2; i++){
		ll a = ruiseki[i];
		ans[i-1] = max(a - nibun1(0, i, a), n - a - nibun2(i+1, N-1, n-a)) - min(nibun1(0, i, a), nibun2(i+1, N-1, n-a));
		index++;
	}
	sort(ans, ans+N-3);
	cout << ans[0] << endl;
	return 0;
}

Compiler output:
a.cc:5:35: error: 'll index' redeclared as different kind of entity
    5 | ll N, A[200000], ruiseki[200000], index;
      |                                   ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'll nibun2(ll, ll, ll)':
a.cc:29:15: error: invalid types 'll [200000] {aka long long int [200000]}[<unresolved overloaded function type>]' for array subscript
   29 |         if(2*A[index] >= sum){
      |               ^
a.cc:30:31: error: invalid types 'll [200000] {aka long long int [200000]}[<unresolved overloaded function type>]' for array subscript
   30 |                 return sum - A[index];
      |                               ^
a.cc: In function 'int main()':
a.cc:61:17: error: overloaded function with no contextual type information
   61 |         index = 2;
      |                 ^
a.cc:65:22: error: no post-increment operator for type
   65 |                 index++;
      |                      ^~
Language: C++

//#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector]";
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    int N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    // 累積和
    vector<ll> AC(N);
    AC[0] = A[0];
    FOR(i, 1, N){
        AC[i] = A[i] + AC[i-1];
    }

    ll minDiff = AC[N-1];

    // c : 中央カット位置
    FOR(c, 1, N-2){
        ll P, Q, R, S;
        // pn(c); ///

        // l : 左カット位置
        FOR(l, 0, c){
            ll leftSum = AC[l];
            ll rightSum = AC[c] - AC[l];
            ll sumDiff = abs(leftSum - rightSum);
            
            // 一歩先を見る
            ll leftSumNext = leftSum + A[l+1];
            ll rightSumNext = rightSum - A[l+1];
            ll sumDiffNext = abs(leftSumNext - rightSumNext);

            // diffが減るなら続ける
            if(sumDiff > sumDiffNext){
                continue;
            }else{
                // pn(l); /// 
                P = leftSum;
                Q = rightSum;
                break;
            }
        }

        // r : 右カット位置
        FOR(r, c+1, N-1){
            ll leftSum = AC[r] - AC[c];
            ll rightSum = AC[N-1] - AC[r];
            ll sumDiff = abs(leftSum - rightSum);

            // 一歩先を見る
            ll leftSumNext = leftSum + A[r+1];
            ll rightSumNext = rightSum - A[r+1];
            ll sumDiffNext = abs(leftSumNext - rightSumNext);

            // diffが減るなら続ける
            if(sumDiff > sumDiffNext){
                continue;
            }else{
                // pn(r); ///
                R = leftSum;
                S = rightSum;
                break;
            }
        }


        // cを決めたときにl, rを最適化した
        // ここで
        // cout << "PQRS " << P << " " << Q << " " << R << " " << S << endl; ///
        vector<ll> temp;
        temp.push_back(P);
        temp.push_back(Q);
        temp.push_back(R);
        temp.push_back(S);
        sort(ALL(temp));
        ll diff = temp[3] - temp[0];
        // pn(diff); ///
        if(diff < minDiff){
            minDiff = diff;
        }

        //p(""); /// 
    }

    p(minDiff);
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:118:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
  118 |         sort(ALL(temp));
      |         ^~~~
      |         sqrt
Language: C++

#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (ll i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

ll N;
ll A[200010];

ll get_sum (int l, int r) 
{
    ll p = A[r - 1];
    ll m = (l == 0) ? 0 : A[l - 1];
    return p - m;
}

// first = min, second = max
pair < ll, ll > get_diff (int l, int r)
{
    int lt = l + 1, rt = r - 1;
    ll sum = get_sum(l, r);
    sum = sum / 2 + sum % 2;
    while (rt - lt > 1) {
        int mid = (lt + rt) / 2;
        ll suml = get_sum(l, mid);
        ll sumr = get_sum(mid, r);
        if (suml >= sum) rt = mid;
        else lt = mid;
    }
    return get_sum(l, lt);
}

int main ()
{
    cin >> N;
    REP(i,N) cin >> A[i];
    REP(i,N) A[i + 1] = A[i] + A[i + 1];

    ll ans = 1e18;
    for (int i = 2; i <= N - 2; i++) {
        pair < ll,ll > diff_l = get_diff(0, i);
        pair < ll,ll > diff_r = get_diff(i, N);
        ans = min(ans, abs(min(diff_l.first, diff_r.first) - max(diff_l.second, diff_r.second)));
    }

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'std::pair<long long int, long long int> get_diff(int, int)':
a.cc:51:19: error: could not convert 'get_sum(l, lt)' from 'll' {aka 'long long int'} to 'std::pair<long long int, long long int>'
   51 |     return get_sum(l, lt);
      |            ~~~~~~~^~~~~~~
      |                   |
      |                   ll {aka long long int}
Language: C++

#include <bits/stdc++.h>
#define INF 999999999999999

using namespace std;

typedef long long ll;

int main(){
	ll n;
	cin >> n;
	ll a[n+1];a[0]=0;int aa;
	for(int i = 1; i <= n; i++){
		cin >> aa;
		a[i]=a[i-1]+aa;
	}
	ll ans = INF;
	ll num[4];
	ll fq=1;ll tq=3;
	for(ll i=2; i < n-1; i++){
		ll dif=INF;
		for(int j = fq; j < i; j++){
			if(dif > abs(a[j]-a[i]/2))fq=j,dif=abs(a[j]-a[i]/2);
			else break;
		}
		dif=INF
		for(int k = max(tq,i+1); k < n; k++){
			if(dif > abs(a[k]-a[i]-a[i]/2))tq=k,dif=abs(a[k]-a[i]-a[i]/2);
			else break;
		}
		num[0]=a[fq];
		num[1]=a[i]-a[fq];
		num[2]=a[tq]-a[i];
		num[3]=a[n]-a[tq];
		sort(num,num+4);
		ans = min(ans, num[3]-num[0]);
	}
	cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:17: error: expected ';' before 'for'
   26 |                 for(int k = max(tq,i+1); k < n; k++){
      |                 ^~~
a.cc:26:42: error: 'k' was not declared in this scope
   26 |                 for(int k = max(tq,i+1); k < n; k++){
      |                                          ^
Language: C++

#include <bits/stdc++.h>
#define INF 999999999999999

using namespace std;

typedef long long ll;

int main(){
	ll n;
	cin >> n;
	ll a[n+1];a[0]=0;int aa;
	for(int i = 1; i <= n; i++){
		cin >> aa;
		a[i]=a[i-1]+aa;
	}
	ll ans = INF;
	ll num[4];
	ll fq=1;ll tq=i+1;
	for(ll i=2; i < n-1; i++){
		ll pre=INF;
		dif=INF;int ch=999;
		for(int j = fq; j < i && ch; j++){
			if(dif > abs(a[j]-a[i]/2))fq=j,dif=abs(a[j]-a[i]/2);
			else ch=-2;
			ch++;
		}
		ll tq;dif=INF;ch=999;
		for(int k = tq; k < n && ch; k++){
			if(dif > abs(a[k]-a[i]-a[i]/2))tq=k,dif=abs(a[k]-a[i]-a[i]/2);
			else ch=-2;
			ch++;
		}
		num[0]=a[fq];
		num[1]=a[i]-a[fq];
		num[2]=a[tq]-a[i];
		num[3]=a[n]-a[tq];
		sort(num,num+4);
		ans = min(ans, num[3]-num[0]);
	}
	cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:23: error: 'i' was not declared in this scope
   18 |         ll fq=1;ll tq=i+1;
      |                       ^
a.cc:21:17: error: 'dif' was not declared in this scope; did you mean 'div'?
   21 |                 dif=INF;int ch=999;
      |                 ^~~
      |                 div
Language: C++

#include <bits/stdc++.h>
#define INF 999999999999999

using namespace std;

typedef long long ll;

int main(){
	ll n;
	cin >> n;
	ll a[n+1];a[0]=0;int aa;
	for(int i = 1; i <= n; i++){
		cin >> aa;
		a[i]=a[i-1]+aa;
	}
	ll ans = INF;
	ll num[4];
	ll fq=1;ll tq=i+1;
	for(ll i=2; i < n-1; i++){
		ll pre=INF;
		dif=INF;int ch=999;
		for(int j = fq; j < i && ch; j++){
			if(dif > abs(a[j]-a[i]/2))fq=j,dif=abs(a[j]-a[i]/2);
			else ch=-2;
			ch++;
		}
		ll tq;dif=INF;int ch=999;
		for(int k = tq; k < n && ch; k++){
			if(dif > abs(a[k]-a[i]-a[i]/2))tq=k,dif=abs(a[k]-a[i]-a[i]/2);
			else ch=-2;
			ch++;
		}
		num[0]=a[fq];
		num[1]=a[i]-a[fq];
		num[2]=a[tq]-a[i];
		num[3]=a[n]-a[tq];
		sort(num,num+4);
		ans = min(ans, num[3]-num[0]);
	}
	cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:23: error: 'i' was not declared in this scope
   18 |         ll fq=1;ll tq=i+1;
      |                       ^
a.cc:21:17: error: 'dif' was not declared in this scope; did you mean 'div'?
   21 |                 dif=INF;int ch=999;
      |                 ^~~
      |                 div
a.cc:27:35: error: redeclaration of 'int ch'
   27 |                 ll tq;dif=INF;int ch=999;
      |                                   ^~
a.cc:21:29: note: 'int ch' previously declared here
   21 |                 dif=INF;int ch=999;
      |                             ^~
Language: C++

#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int a[200005];
ll dp[200005];
ll b[4];
int main() {
	int n;
	cin >> n;
	rep(i , n)
		cin >> a[i];
	dp[0] = a[0];
	reps(i, n-1){
		dp[i] = dp[i-1] + a[i];	
	}
	ll ans = 1 << 30;
	int lf, rt;
	lf = 0;
	rt = 2;
	for(int i = 2; i < n-1; i++){
		ll lmn = 1 << 30;
		ll rmn = 1 << 30;
		for(int j = lf; j < i - 1; j++){
			if(lmn >= abs(dp[j] -abs(dp[i-1] - dp[j]))){
				b[0] = dp[j];
				b[1] = dp[i-1] -dp[j]);
				lmn =abs(dp[j] -abs(dp[i-1] - dp[j]));
				lf = j;
			}else{break;}
		}
        if(i == n - 1 && rmn > abs(dp[n-2] - dp[n-3] -( dp[n-1] -dp[n-2]))){
            b[2] = dp[n-2] - dp[n-3];
            b[3] = dp[n-1] - dp[n-2];
        }else{
            for(int j = rt; j < n; j++){
                if(rmn >= abs(abs(dp[j] - dp[i-1]) -abs(dp[n-1] - dp[j]))){
                    b[2] = dp[j] - dp[i-1];
                    b[3] = dp[n-1] - dp[j];
                    rmn = abs(abs(dp[j] - dp[i-1]) -abs(dp[n-1] - dp[j]));
                    rt  = j;
                }else{break;}
            }
        }
		sort(b, b+4);
		ans = min(ans, b[3] - b[0]);
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:54: error: expected ';' before ')' token
   52 |                                 b[1] = dp[i-1] -dp[j]);
      |                                                      ^
      |                                                      ;
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
	ll n;cin>>n;
	vector<ll> a(n);
	  
	rep(i,n){
	  cin>>a[i];
	}

  ll left = 0,right= 1e10,mid;
  ll ans=1e10;
  bool flg=true;
  while (right!=left+1) {
      mid =(right+left)/2;
      ll P=0,Q=0,R=0,S=0,index=0;
      while(x>P&&(a.size()>index)){
      	P+=a[index];
      	index++;
      }
      while(x>Q&&(a.size()>index)){
      	Q+=a[index];
      	index++;
      }
      while(x>R&&(a.size()>index)){
      	R+=a[index];
      	index++;
      }
      while(a.size()>index){
      	S+=a[index];
      	index++;
      }
      ll max_num=0,min_num=1e10;
      max_num=max(P,max(Q,max(R,S)));
      min_num=min(P,min(Q,min(R,S)));
      if(min_num==0){
      	flg=false;
      }else{
      	if(max_num-min_num<ans){
      		ans=max_num-min_num;
      		flg=true;
      	}else{
      		flg=false;
      	}
      }
      if(!flg){
      	left=mid;
      }else right=mid;
  }
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:13: error: 'x' was not declared in this scope
   43 |       while(x>P&&(a.size()>index)){
      |             ^
a.cc:47:13: error: 'x' was not declared in this scope
   47 |       while(x>Q&&(a.size()>index)){
      |             ^
a.cc:51:13: error: 'x' was not declared in this scope
   51 |       while(x>R&&(a.size()>index)){
      |             ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define Would
#define you
#define please

//やけくそすぎる
int main() {
	int N;
	cin >> N;
	long long A[200000];
	rep(i, N) {
		cin >> A[i];
	}
	rep1(i, N - 1) {
		A[i] = A[i - 1] + A[i];
	}

	long long kotae = 1e18;

	int l2 = 1;
	int r2 = N - 3;
	while (l2 != r2) {
		int mid2 = (l2 + r2) / 2 + 1;

		int l1 = 0;
		int r1 = r2 - 1;
		int l3 = r2 + 1;
		int r3 = N - 2;
		while (l1 != r1) {
			int mid1 = (l1 + r1) / 2 + 1;
			if (A[mid1] <= A[mid2] - A[mid1]) l1 = mid1;
			else r1 = mid1 - 1;
		}
		if (abs(2 * A[r1] - A[mid2]) > abs(2 * A[r1 + 1] - A[mid2])) r1++;
		while (l3 != r3) {
			int mid3 = (l3 + r3) / 2 + 1;
			if (A[mid3] - A[mid2] <= A[N - 1] - A[mid3]) l3 = mid3;
			else r3 = mid3 - 1;
		}
		if (abs(2 * A[r3] - A[mid2] - A[N - 1]) > abs(2 * A[r3 + 1] - A[mid2] - A[N - 1])) r3++;
		long long minimum = 1e18;
		long long maximum = 0;
		minimum = min(minimum, A[r1]);
		minimum = min(minimum, A[mid2] - A[r1]);
		minimum = min(minimum, A[r3] - A[mid2]);
		minimum = min(minimum, A[N - 1] - A[r3]);
		maximum = max(maximum, A[r1]);
		maximum = max(maximum, A[mid2] - A[r1]);
		maximum = max(maximum, A[r3] - A[mid2]);
		maximum = max(maximum, A[N - 1] - A[r3]);
		kotae = min(kotae, maximum - minimum);


		if (A[mid2] <= A[N - 1] - A[mid2]) l2 = mid2;
		else r2 = mid2 - 1;
	}

	int l1 = 0;
	int r1 = r2 - 1;
	int l3 = r2 + 1;
	int r3 = N - 2;
	while (l1 != r1) {
		int mid1 = (l1 + r1) / 2 + 1;
		if (A[mid1] <= A[r2] - A[mid1]) l1 = mid1;
		else r1 = mid1 - 1;
	}
	if (abs(2 * A[r1] - A[r2]) > abs(2 * A[r1 + 1] - A[r2])) r1++;
	while (l3 != r3) {
		int mid3 = (l3 + r3) / 2 + 1;
		if (A[mid3] - A[r2] <= A[N - 1] - A[mid3]) l3 = mid3;
		else r3 = mid3 - 1;
	}
	if (abs(2 * A[r3] - A[r2] - A[N - 1]) > abs(2 * A[r3 + 1] - A[r2] - A[N - 1])) r3++;
	long long minimum = 1e18;
	long long maximum = 0;
	minimum = min(minimum, A[r1]);
	minimum = min(minimum, A[r2] - A[r1]);
	minimum = min(minimum, A[r3] - A[r2]);
	minimum = min(minimum, A[N - 1] - A[r3]);
	maximum = max(maximum, A[r1]);
	maximum = max(maximum, A[r2] - A[r1]);
	maximum = max(maximum, A[r3] - A[r2]);
	maximum = max(maximum, A[N - 1] - A[r3]);
	kotae = min(kotae, maximum - minimum);

	cout << r1 << r2 << r3 << "\n";
	cout << kotae << "\n";


	Sleep(30000);

	Would you please return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:93:9: error: 'Sleep' was not declared in this scope; did you mean 'sleep'?
   93 |         Sleep(30000);
      |         ^~~~~
      |         sleep
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++) cin>>a[i];
  int s=0;
  for(int i=0;i<N;i++) s+=a[i];
  int t=0;
  s/=2;
  int b=0;
  int l,r;
  for(int i=0;i<N;i++){
    b+=a[i];
    if(b>=s){
      if(s-b<b+a[i+1]-s){
        l=t;
      }
      else{
        l=t+1;
      }
      break;
    }
    t++;
  }
  int left[l];
  int right[N-l];
  for(int i=0;i<l;i++) left.at(i)=a.at(i);
  for(int i=0;i<N-l;i++) right.at(i)=a.at(i+l);
  s=0;
  for(int i=0;i<N;i++) s+=left[i];
  t=0;
  int q=s/2;
  b=0;
  r=0;
  for(int i=0;i<l;i++){
    b+=left[i];
    if(b>=q){
      if(q-b<b+left[i+1]-q){
        for(int j=0;j<t+1;j++) r+=left[j];
      }
      else{
        for(int j=0;j<t+2;j++) r+=left[j];
      }
      break;
    }
    t++;
  }
  int y=0;
  for(int i=0;i<N;i++) y+=right[i];
  t=0;
  int z=s/2;
  b=0;
  int x=0;
  for(int i=0;i<N-l;i++){
    b+=right[i];
    if(b>=z){
      if(z-b<b+left[i+1]-z){
        for(int j=0;j<t+1;j++) x+=right[j];
      }
      else{
        for(int j=0;j<t+2;j++) x+=right[j];
      }
      break;
    }
    t++;
  }
  vector<int>vec={r,s-r,x,y-x};
  sort(vec.begin(),vec.end());
  cout<<vec[3]-vec[0]<<endl;
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:29:29: error: request for member 'at' in 'left', which is of non-class type 'int [l]'
   29 |   for(int i=0;i<l;i++) left.at(i)=a.at(i);
      |                             ^~
a.cc:29:37: error: request for member 'at' in 'a', which is of non-class type 'int [N]'
   29 |   for(int i=0;i<l;i++) left.at(i)=a.at(i);
      |                                     ^~
a.cc:30:32: error: request for member 'at' in 'right', which is of non-class type 'int [(N - l)]'
   30 |   for(int i=0;i<N-l;i++) right.at(i)=a.at(i+l);
      |                                ^~
a.cc:30:40: error: request for member 'at' in 'a', which is of non-class type 'int [N]'
   30 |   for(int i=0;i<N-l;i++) right.at(i)=a.at(i+l);
      |                                        ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++) cin>>a[i];
  int s=0;
  for(int i=0;i<N;i++) s+=a[i];
  s/=4;
  int t=0;
  int c[4];
  for(int i=0;;i++){
    int b=0;
    b+=a[i];
    t++;
    if(b>=s){
      if(s-b<=b+a[i+1]-s)
        c[0]=s-b;
      else
        c[0]=b+a[i+1]-s;
      break;
    }
  }
  for(int i=t;;i++){
    int b=0;
    b+=a[i];
    t++;
    if(b>=s){
      if(s-b<=b+a[i+1]-s)
        c[1]=s-b;
      else
        c[1]=b+a[i+1]-s;
      break;
    }
  }
  for(int i=t;;i++){
    int b=0;
    b+=a[i];
    t++;
    if(b>=s){
      if(s-b<=b+a[i+1]-s)
        c[2]=s-b;
      else
        c[2]=b+a[i+1]-s;
      break;
    }
  }
  c[3]=0;
  for(int i=t;i<N;i++) c[3]+=;
  vector<int> d={c[0],c[1],c[2],c[3]};
  sort(d.begin(),d.end());
  cout<<d.at(3)-d.at(0)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:30: error: expected primary-expression before ';' token
   50 |   for(int i=t;i<N;i++) c[3]+=;
      |                              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++) cin>>a[i];
  int s=0;
  for(int i=0;i<N;i++) s+=a[i];
  s/=4;
  int t=0;
  int c[4];
  for(int i=0;;i++){
    int b=0;
    b+=a[i];
    t++;
    if(b>=s){
      if(s-b<=b+a[i+1]-s)
        c[0]=s-b;
      else
        c[0]=b+a[i+1]-s
      break;
    }
  }
  for(int i=t;;i++){
    int b=0;
    b+=a[i];
    t++;
    if(b>=s){
      if(s-b<=b+a[i+1]-s)
        c[1]=s-b;
      else
        c[1]=b+a[i+1]-s
      break;
    }
  }
  for(int i=t;;i++){
    int b=0;
    b+=a[i];
    t++;
    if(b>=s){
      if(s-b<=b+a[i+1]-s)
        c[2]=s-b;
      else
        c[2]=b+a[i+1]-s
      break;
    }
  }
  c[3]=0;
  for(int i=t;i<N;i++) c[3]+=;
  vector<int> d={c[0],c[1],c[2],c[3]};
  sort(d.begin(),d.end());
  cout<<d.at(3)-d.at(0)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:24: error: expected ';' before 'break'
   21 |         c[0]=b+a[i+1]-s
      |                        ^
      |                        ;
   22 |       break;
      |       ~~~~~             
a.cc:33:24: error: expected ';' before 'break'
   33 |         c[1]=b+a[i+1]-s
      |                        ^
      |                        ;
   34 |       break;
      |       ~~~~~             
a.cc:45:24: error: expected ';' before 'break'
   45 |         c[2]=b+a[i+1]-s
      |                        ^
      |                        ;
   46 |       break;
      |       ~~~~~             
a.cc:50:30: error: expected primary-expression before ';' token
   50 |   for(int i=t;i<N;i++) c[3]+=;
      |                              ^
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
 
using namespace std;
 
int main(){
  int n, i, j, k, a, b, c, d, dif, ans = 1000000000;
  cin >> n;
  int a[n];
  long long sum[n], maxf, maxs, minf, mins;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(i) sum[i] = sum[i-1] + a[i];
    else sum[i] = a[i];
  }
  for(int i = 1; i < n-2; i++){
    a = 0;
    b = i;
    j = (a+b)/2;
    while(b-a > 1){
      j = (a+b)/2;
      if(sum[i]-sum[j]*2 >= 0) a = j;
      else b = j;
    }
    if((sum[i] - sum[j]*2) - (sum[j+1]*2 - sum[i]) > 0){
      j++;
      maxf = sum[j];
      minf = sum[i] - sum[j];
    }else{
      maxf = sum[i] - sum[j];
      minf = sum[j];
    }
      
    c = i+1;
    d = n-1;
    while(d-c > 1){
      j = (c-d)/2;
      if(sum[n-1]-sum[k]*2+sum[i] >= 0) c = k;
      else d = k;
    }
    if((sum[n-1]-sum[k]*2+sum[i]) - (sum[n-1]-sum[k+1]*2+sum[i]) > 0){
      k++;
      maxs = sum[k] - sum[i];
      mins = sum[n-1] - sum[k];
    }else{
      maxs = sum[n-1] - sum[k];
      mins = sum[k] - sum[i];
    }
    max = max(maxf, maxs);
    min = min(minf, mins);
    dif = max - min;
    if(ans > dif) ans = dif;
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: conflicting declaration 'int a [n]'
   10 |   int a[n];
      |       ^
a.cc:8:19: note: previous declaration as 'int a'
    8 |   int n, i, j, k, a, b, c, d, dif, ans = 1000000000;
      |                   ^
a.cc:13:13: error: invalid types 'int[int]' for array subscript
   13 |     cin >> a[i];
      |             ^
a.cc:14:32: error: invalid types 'int[int]' for array subscript
   14 |     if(i) sum[i] = sum[i-1] + a[i];
      |                                ^
a.cc:15:20: error: invalid types 'int[int]' for array subscript
   15 |     else sum[i] = a[i];
      |                    ^
a.cc:50:25: error: overloaded function with no contextual type information
   50 |     max = max(maxf, maxs);
      |                         ^
a.cc:51:25: error: overloaded function with no contextual type information
   51 |     min = min(minf, mins);
      |                         ^
a.cc:52:15: error: invalid operands of types '<unresolved overloaded function type>' and '<unresolved overloaded function type>' to binary 'operator-'
   52 |     dif = max - min;
      |           ~~~~^~~~~
Language: C++

#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

/*#define int ll*/
signed main(){
    int n;
    cin>>n;
    ll a[200020],s[200020];
    s[0]=0;
    ll ans=2e18,m,M;
	rep(i,n){ cin>>a[i]; s[i+1]=s[i]+a[i]; }
	int l=1,r=3;
	repe(i,2,n-2){
		while(s[l]*2<s[i]) ++l;
		while(s[r]-s[i]<s[n]-s[r]) ++r;
		rep(j,0,2)rep(k,0,2){
			M=max(max(s[l-j],s[i]-s[l-j]),max(s[r-k]-s[i],s[n]-s[r-k]));
			m=min(min(s[l-j],s[i]-s[l-j]),min(s[r-k]-s[i],s[n]-s[r-k]));
			ans=min(ans,M-m);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc:32:16: error: macro "rep" requires 3 arguments, but only 2 given
   32 |         rep(i,n){ cin>>a[i]; s[i+1]=s[i]+a[i]; }
      |                ^
a.cc:11:9: note: macro "rep" defined here
   11 | #define rep(i,s,n) for(int i = s;i<n;i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:32:9: error: 'rep' was not declared in this scope
   32 |         rep(i,n){ cin>>a[i]; s[i+1]=s[i]+a[i]; }
      |         ^~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
 
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N), S(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        int prev = 0;
        if (i > 0) {
            prev = S[i - 1];
        }
        S[i] = prev + A[i];
    }
    vector<int> F(N), G(N);
    int j = 1;
    for (int i = 2; i <= N - 2; i++) {
        while (j < i && abs(S[i - 1] - 2 * S[j - 1]) >= abs(S[i - 1] - 2 * S[j])) {
            j++;
        }
        F[i] = j;
    }
    j = N - 1;
    for (int i = N - 2; i >= 2; i--) {
        while (i < j && abs(S[N - 1] - 2 * S[j - 1] + S[i - 1]) >= abs(S[N - 1] - 2 * S[j - 2] + S[i - 1])) {
            j--;
        }
        G[i] = j;
    }
    int ans = INT_MAX;
    for (int i = 2; i <= N - 2; i++) {
        int j = F[i];
        int k = G[i];
        int S1 = S[i - 1] - S[j - 1];
        int S2 = S[j - 1];
        int S3 = S[N - 1] - S[k - 1];
        int S4 = S[k - 1] - S[i - 1];
        int diff = max(S1, max(S2, max(S3, S4))) - min(S1, min(S2, min(S3, S4)));
        ans = min(ans, diff);
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:15: error: 'INT_MAX' was not declared in this scope
   43 |     int ans = INT_MAX;
      |               ^~~~~~~
a.cc:11:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   10 | #include <cmath>
  +++ |+#include <climits>
   11 | using namespace std;
Language: C++

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef long long s64;

int main()
{
    s64 sumArray[200000];
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        int a;
        cin >> a;
        if (i == 0)
        {
            sumArray[i] = a;
        }
        else
        {
            sumArray[i] = sumArray[i - 1] + a;
        }
    }

    auto calc = [sumArray](int first, int last, s64* min, s64* max) {
        int leftLast = (first + last) / 2;

        auto calcLR = [sumArray](int first, int last, int leftLast, s64* left,
                                 s64* right) {
            *left = sumArray[leftLast];
            if (first != 0)
            {
                *left -= sumArray[first - 1];
            }
            *right = sumArray[last] - sumArray[leftLast];
        };

        s64 left, right;
        calcLR(first, last, leftLast, &left, &right);
        if (left < right)
        {
            while (leftLast + 1 < last)
            {
                *min = left;
                *max = right;
                ++leftLast;
                calcLR(first, last, leftLast, &left, &right);
                if (left >= right)
                {
                    if (left - right < *max - *min)
                    {
                        *min = right;
                        *max = left;
                    }
                    return;
                }
            }
            *min = left;
            *max = right;
            4
        }
        else
        {
            while (first <= leftLast - 1)
            {
                *min = right;
                *max = left;
                --leftLast;
                calcLR(first, last, leftLast, &left, &right);
                if (left < right)
                {
                    if (right - left < *max - *min)
                    {
                        *min = left;
                        *max = right;
                    }
                    return;
                }
            }
            *min = right;
            *max = left;
        }
    };

    s64 diffMin = -1;
    for (int leftLast = 1; leftLast <= N - 3; ++leftLast)
    {
        s64 leftMin, leftMax, rightMin, rightMax;
        calc(0, leftLast, &leftMin, &leftMax);
        calc(leftLast + 1, N - 1, &rightMin, &rightMax);
        s64 diff = max(leftMax, rightMax) - min(leftMin, rightMin);
        if (diffMin == -1 || diff < diffMin)
        {
            diffMin = diff;
        }
    }
    cout << diffMin << endl;

    return 0;
}


Compiler output:
a.cc: In lambda function:
a.cc:73:14: error: expected ';' before '}' token
   73 |             4
      |              ^
      |              ;
   74 |         }
      |         ~
Language: C++

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define REP(i,n) for(int i=0;i<signed(n);i++)
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
const ll MOD = 1000000007;
const ll INF = 9e9;
ll N,M,ans=INF;
ll A[300010],S[301000];
int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N;
  	REP(i, n*2){
      	S[i]=0;
    }
    REP(i,N){
        cin>>A[i];
        S[i]+=A[i];
        S[i+1]=S[i];
    }
    //a:右半分の区切り i:真ん中 b:左半分
    //s:右の和 t:左の和
    ll a=0,b=2,s,t;
    REP(i,N-2){
        if(i==b)b++;
        s=(S[i]-S[a])-S[a];
        t=(S[N-1]-S[b])-(S[b]-S[i]);
        bool f=true;
        if(i==0)continue;
        while(f){
            f=false;
            if(a+1==i)continue;
            if(abs(s)>abs(s-A[a+1]*2)){
                s-=A[a+1]*2;
                a++;f=true;
            }
        }
        f=true;
        while(f){
            f=false;
            if(b+1==N-1||b==N-1)continue;
            if(abs(t)>abs(t-A[b+1]*2)){
                t-=A[b+1]*2;
                b++;f=true;
            }
        }
        ans=min( ans,( max({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]})
        -min({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]}) ) );
    }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:16: error: 'n' was not declared in this scope
   30 |         REP(i, n*2){
      |                ^
a.cc:15:39: note: in definition of macro 'REP'
   15 | #define REP(i,n) for(int i=0;i<signed(n);i++)
      |                                       ^