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

N = gets.to_i

a_list = []

gets.strip.split(/ /).each_with_index{|a, i|
	a = a.to_i
	a_list << [a - (i + 1), a, i]
}

#p a_list

a2, a, i = a_list.sort_by(){|x, y, z| x}[N / 2]
#p [a2, a, i]
b = a - (i + 1)

sadness = 0

a_list.each_with_index{|(a2, a, j), i|
	sadness += (a - (b + i + 1)).abs
}
puts sadness


Compiler output:
a.cc:10:2: error: invalid preprocessing directive #p
   10 | #p a_list
      |  ^
a.cc:13:2: error: invalid preprocessing directive #p
   13 | #p [a2, a, i]
      |  ^
a.cc:1:1: error: 'N' does not name a type
    1 | N = gets.to_i
      | ^
a.cc:12:1: error: 'a2' does not name a type
   12 | a2, a, i = a_list.sort_by(){|x, y, z| x}[N / 2]
      | ^~
a.cc:12:41: error: expected unqualified-id before '[' token
   12 | a2, a, i = a_list.sort_by(){|x, y, z| x}[N / 2]
      |                                         ^
a.cc:21:1: error: 'puts' does not name a type
   21 | puts sadness
      | ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
long long k,n,a[200003],sum[200004],ans,k1,k2,ans1,ans2;
int main(){std::ios::sync_with_stdio(false);
cin>>n;
for(int i=1;i<=n;i++)
{
	cin>>a[i];
	a[i]-=i;
	sum[i]+=abs(abs(a[i])+sum[i-1]);
}
ans=lmx;
for(int i=1;i<=n;i++)
{
	k=abs(sum[n]-2LL*sum[i]);
	k1=(abs)a[i];
	k2=k1*n;
	ans=min(ans,abs(k-k2));
}
cout<<ans<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Compiler output:
a.cc: In function 'int main()':
a.cc:19:16: error: cannot resolve overloaded function 'abs' based on conversion to type 'long long int'
   19 |         k1=(abs)a[i];
      |                ^
Language: C++

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
using namespace std;

int main()
{
    int N, Ai;
    cin >> N;
    vector<int> A;
    long long sum = 0;
    for(int i=0; i<N; i++){
        cin >> Ai;
        A.push_back(Ai-(i+1));
        sum += Ai - (i+1);
    }
    sort(A.begin(), A.end());
    int b = 0;
    if(N%2==0){
        auto b1 = A.at(A.size()/2);
        auto b2 = A.at((A.size()/2)-1);
        b = (b1+b2)/2;
    }else{
        b = A.at(A.size()/2);
    }
    size_t Min = 0;
    for(auto v : A){
        Min += abs((int)(v-b));
    }
    cout<<Min<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   18 |     sort(A.begin(), A.end());
      |     ^~~~
      |     sqrt
Language: C

#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

int main()
{
    int N;
    cin >> N;

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


    int max = A[0], b = A[0];
    int tmp = 0, ans;

    for( int i = 0; i < N; ++i )
        if( max < A[i] ) max = A[i];

    for( b = -max; b <= max; ++b ){
        tmp = 0;
        for( int i = 0; i < N; ++i ){
            tmp += abs(A[i]-(b+i+1));
        }
        if( b == -max ) ans = tmp;
        else if( tmp < ans ) ans = tmp;
        
        //cout << b << " : " << tmp << endl;
    }

    cout << ans << endl;

    return 0;
}


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,l,r) for (int i=l; i<=r; i++)
typedef long long ll;
using namespace std;

const int N=200010;
ll n,ans,a[N];
ll abs(ll x){ return (x<0) ? -x : x; }

int main(){
	scanf("%lld",&n);
	rep(i,1,n) scanf("%lld",&a[i]),a[i]=a[i]-i;
	sort(a+1,a+n+1); int b=a[n/2];
	rep(i,1,n) ans+=abs(a[i]-b);
	printf("%lld\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:28: error: call of overloaded 'abs(ll)' is ambiguous
   16 |         rep(i,1,n) ans+=abs(a[i]-b);
      |                         ~~~^~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/bits/stl_algo.h:71,
                 from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
a.cc:10:4: note: candidate: 'll abs(ll)'
   10 | ll abs(ll x){ return (x<0) ? -x : x; }
      |    ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
Language: C++

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    int n = Integer.parseInt(s);
    s = r.readLine();
    long a[] = new long[200001];
    String[] sl = s.split("[\\s]+");
    for(int i = 0; i < n; i++)
    {
      a[i] = Long.parseLong(sl[i]);
    }

    for(int i = 0; i < n; i++)
    {
      a[i] -= i + 1;
    }

    long m = 0;
    for(int i = 0; i < n; i++)
    {
      m += a[i];
    }
    m /= n;

    long min = Long.MAX_VALUE;
    long t = 0;
    for(int i = 0; i < n; i++)
    {
      t += Math.abs(a[i] - m);
    }
    min = Math.min(min, t);
    t = 0;
    for(int i = 0; i < n; i++)
    {
      t += Math.abs(a[i] - m - 1);
    }
    min = Math.min(min, t);
    t = 0;
    for(int i = 0; i < n; i++)
    {
      t += Math.abs(a[i] - m + 1);
    }
    min = Math.min(min, t);

    System.out.println(min);
  }

}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.BufferedReader;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.IOException;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.io.InputStreamReader;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
    5 | public class Main
      | ^~~~~~
Language: Java

import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static long calc(long b)
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			long[] array = new long[N];
			long[] values = new long[N];
			for(int i = 0; i < N; i++){
				array[i] = sc.nextLong();
				values[i] = array[i] - (i + 1);
			}
			
			Arrays.sort(values);
			//System.out.println(Arrays.toString(values));
			
			long sum = 0;
			for(int i = 0; i < N; i++) {
				sum += Math.abs(array[i] - (values[N / 2] + (i + 1)));
			}
			
			System.out.println(sum);
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Compiler output:
Main.java:23: error: ';' expected
	public static long calc(long b)
	                               ^
1 error
Language: C++

#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
//#define i_7 (long long)(1e9+7)
#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  vector<long long> a(n);
  REP(i, n) cin>>a[i];
  
  long long d = accumulate(ALL(a), 0LL);
  long long lsum = a[0];
  long long rsum = d - a[0];
  long long ans = INF;
  int lmid, rmid;
  long long p, q, r, s;
  for(int m = 2; m <= n - 2; m++){ //[0, m) と [m, n) に分ける
    lsum += a[m - 1];
    rsum -= a[m - 1];
    if(m == 2){
      p = a[0]; q = a[1];
      lmid = 1;
      long long temp = 0;
      r = a[m]; s = rsum - a[m];
      for(int i = m + 1; i < n; i++){
        if(r + a[i] <= rsum / 2){
          r += a[i];
          s -= a[i];
          rmid = 
        }
    
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:95:9: error: expected primary-expression before '}' token
   95 |         }
      |         ^
a.cc:99:2: error: expected '}' at end of input
   99 | }
      |  ^
a.cc:85:15: note: to match this '{'
   85 |     if(m == 2){
      |               ^
a.cc:99:2: error: expected '}' at end of input
   99 | }
      |  ^
a.cc:82:34: note: to match this '{'
   82 |   for(int m = 2; m <= n - 2; m++){ //[0, m) と [m, n) に分ける
      |                                  ^
a.cc:99:2: error: expected '}' at end of input
   99 | }
      |  ^
a.cc:69:11: note: to match this '{'
   69 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define mod 1000000007LL
#define FOR(i,m,n) for(int i = (m); i < (n); i++)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) v.begin(),v.end()
#define sz(v) int(v.size())
 
 
typedef long long ll;
typedef vector<int> vi; 
typedef pair<int,int> ii;

ll power(ll a, ll b){
    int ans = 1;
    while(b){
        if(b&1) ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}
 

int main(){
	fastio;

    int n; cin>>n;
    vector<ll> v(n);
    vector<ll> p(n);
    FOR(i,0,n) cin>>v[i];
    p[0]=v[0];
    FOR(i,1,n) p[i]=p[i-1]+v[i];
    
    
    int x, y, z;
    ll ans, ans_=1e15;
    FOR(i,1,n-2){
        int pos=lower_bound(all(p),(p[i]+1)/2)-p.begin();
        if(pos-1>=0 abs(2LL*p[pos]-p[i])>abs(2LL*p[pos-1]-p[i])) x=pos-1;
        else x=pos;
        pos=lower_bound(all(p), p[i]+(p[n-1]-p[i]+1)/2)-p.begin();
        ll xd=p[pos]-p[i], xdd=p[pos-1]-p[i];
        if(pos-1> i && abs(xd-p[n-1]+p[pos])>abs(xdd-p[n-1]+p[pos-1])) z=pos-1;
        else z=pos;
        
        ll sum1=p[x], sum2=p[i]-p[x], sum3=p[z]-p[i] ,sum4=p[n-1]-p[z];
        ans=max({abs(sum1-sum2), abs(sum1-sum3), abs(sum1-sum4), abs(sum2-sum3), abs(sum2-sum4), abs(sum3-sum4)});
        // cout<<"ans="<<ans<<endl;
        // cout<<x<<" "<<i<<" "<<z<<endl;
        ans_=min(ans, ans_);
    }

    cout<<ans_<<endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:20: error: expected ')' before 'abs'
   45 |         if(pos-1>=0 abs(2LL*p[pos]-p[i])>abs(2LL*p[pos-1]-p[i])) x=pos-1;
      |           ~        ^~~~
      |                    )
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long a[200005];
long long n, t1, t2, t3, ans;
long long cal(long long x, long long y, long long z)
{
	long long aaa=a[x],bbb=a[y]-a[x],ccc=a[z]-a[y],ddd=a[N]-a[z];
	return abs(max(max(aaa, bbb), max(ccc, ddd))-min(min(aaa, bbb), min(ccc, ddd)));
}
int main()
{
	scanf("%lld", &n);
	for(register int i=1;i<=n;++i){
		scanf("%lld", a[i]);
		a[i]+=a[i-1];
	}
	t1=1;t2=2;t3=3;
	ans=cal(t1,t2,t3);
	for( ; t2<=n-2; ++t2)
	{
		while(t1+1 < t2&&abs(a[t2]-2*a[t1+1]) < abs(a[t2]-2*a[t1]))++t1;
		while(t3+1 < n&&abs(a[n]-2*a[t3+1]+a[t2]) < abs(a[n]-2*a[t3]+a[t2]))++t3;
		ans=min(ans, cal(t1, t2, t3));
	}printf("%lld\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'long long int cal(long long int, long long int, long long int)':
a.cc:7:62: error: 'N' was not declared in this scope
    7 |         long long aaa=a[x],bbb=a[y]-a[x],ccc=a[z]-a[y],ddd=a[N]-a[z];
      |                                                              ^
a.cc: In function 'int main()':
a.cc:13:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   13 |         for(register int i=1;i<=n;++i){
      |                          ^
Language: C++

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


int main(){
  int n;
  cin >> n;
  vector<long long> A(n);
  for(int i=0;i<n;i++) cin >> A.at(i);
  vector<long long> sa(n+1,0);
  for(int i=0;i<n;i++) sa.at(i+1) = sa.at(i) + A.at(i);
  long long ans = 100 0000 0000 0000 0000;
  for(int i=1;i<n-1;i++){
    long long left = sa.at(i+1);
    long long right = sa.at(n-1) - sa.at(i+1);
    
    int lsplit = min(int(upper_bound(sa.begin(),sa.end(),left/2) - sa.begin() - 2),i-1);
    int rsplit = min(int(upper_bound(sa.begin(),sa.end(),right/2 + left) - sa.begin() - 2),n-2);
    // cout << "rsplit = " << rsplit << endl;
    long long lM = min(max(sa.at(lsplit + 1),sa.at(i+1) - sa.at(lsplit + 1)),max(sa.at(lsplit + 2), sa.at(i+1) - sa.at(lsplit + 2)));
    long long rM = min(max(sa.at(rsplit + 1)-sa.at(i+1),sa.at(n)-sa.at(rsplit+1)) ,max(sa.at(rsplit+2)-sa.at(i+1),sa.at(n) - sa.at(rsplit+2)));
    // cout << "rM = " << rM << endl;
    long long M = max(lM,rM);
    long long m = min(sa.at(i+1) - lM,sa.at(n) - sa.at(i+1) - rM);
    // cout << i << ":" << M-m << " M = "<< M << " m = " << m << endl;
    ans = min(ans, M-m);
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:23: error: expected ',' or ';' before numeric constant
   14 |   long long ans = 100 0000 0000 0000 0000;
      |                       ^~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int64_t const INF = 1e18;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N; 
  std::vector<int64_t> A(N), S(N+1, 0);
  for(int i = 0; i < N; ++i) std::cin >> A[i];
  for(int i = 0; i < N; ++i) S[i+1] = S[i] + A[i];
  int64_t P[4];
  P[0] = A[0]; 
  P[1] = A[1];
  P[2] = A[2]; 
  P[3] = S[N] - S[3];
  int j = 1, l = 3;
  for(int k = 2; k < N-1; ++k) {
    while(j < k-1 && std::abs(P[0]-P[1]) > std::abs(P[0]+A[j]-(P[1]-A[j]))) {
      P[0] += A[j];
      P[1] -= A[j];
      ++j;
    } 
    while(l < N-1 && std::abs(P[2]-P[3]) > std::abs(P[2]+A[l]-(P[3]-A[l]))) {
      P[2] += A[l];
      P[3] -= A[l];
      ++l;
    }
    ans = std::min(ans, *std::max_element(P, P+4), *std::min_element(P, P+4));
    if(l<=k+1) l=k+2;
  }
  fin(ans);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |     ans = std::min(ans, *std::max_element(P, P+4), *std::min_element(P, P+4));
      |     ^~~
      |     abs
a.cc:37:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |   fin(ans);
      |       ^~~
      |       abs
Language: Java

0import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] a = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        long[] sum = new long[N+1];
        for (int i = 0; i < N; i++) {
            sum[i+1] = sum[i] + a[i];
        }
        long ans = Long.MAX_VALUE;
        for (int i = 2; i <= N - 2; i++) {
            int left = 0;
            int right = i;
            while (left + 1 < right) {
                int mid = (left + right) / 2;
                if (sum[mid] < sum[i] - sum[mid]) {
                    left = mid;
                } else {
                    right = right - 1;
                }
            }
            long P1 = sum[left];
            long Q1 = sum[i] - P1;
            long P2 = sum[left+1];
            long Q2 = sum[i] - P2;
            long P = Math.abs(P2-Q2) < Math.abs(P1-Q1) ? P2 : P1;
            long Q = Math.abs(P2-Q2) < Math.abs(P1-Q1) ? Q2 : Q1;
            left = i + 1;
            right = N;
            while (left + 1 < right) {
                int mid = (left + right) / 2;
                if (sum[mid]-sum[i] < sum[N] - sum[mid]) {
                    left = mid;
                } else {
                    right = right - 1;
                }
            }
            long R1 = sum[left] - sum[i];
            long S1 = sum[N] - sum[left];
            long R2 = sum[left+1] - sum[i];
            long S2 = sum[N] - sum[left+1];
            long R = Math.abs(R2-S2) < Math.abs(R1-S1) ? R2 : R1;
            long S = Math.abs(R2-S2) < Math.abs(R1-S1) ? S2 : S1;
            long min = Math.min(P, Math.min(Q, Math.min(R, S)));
            long max = Math.max(P, Math.max(Q, Math.max(R, S)));
            ans = Math.min(ans, Math.abs(max - min));
        }
        System.out.println(ans);
    }
}


Compiler output:
Main.java:1: error: class, interface, enum, or record expected
0import java.io.BufferedReader;
^
Main.java:2: error: class, interface, enum, or record expected
import java.io.InputStreamReader;
^
Main.java:3: error: class, interface, enum, or record expected
import java.util.ArrayList;
^
Main.java:4: error: class, interface, enum, or record expected
import java.util.List;
^
Main.java:5: error: class, interface, enum, or record expected
import java.util.Scanner;
^
5 errors
Language: C++

#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<set>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
//http://drken1215.hatenablog.com/entry/2018/08/28/193000

int N;
vector<ll> A;
vector<ll> sum;

signed main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin>>N;
    A.resize(N); sum.resize(N+1); sum[0]=0;
    for(int i=0;i<N;i++) cin>>A[i],sum[i+1]=sum[i]+A[i];

    ll res=1LL<<60;
    for(int i=0;i<=N;i++){
        int low=0,high=i;
        while(high-low>1){
            int mid=(low+high)/2;
            if(sum[mid]>=sum[i]-sum[mid]) high=mid;
            else low=mid;
        }
        ll P=sum[low],Q=sum[i]-sum[low];
        ll P2=sum[high],Q2=sum[i]-sum[high];
        ll left_min=min(P,Q),left_max=max(P,Q);
        if(abs(P2-Q2)<abs(P-Q)) left_min=min(P2,Q2),left_max(P2,Q2);

        low=i,high=N;
        while(high-low>1){
            int mid=(low+high)/2;
            if(sum[mid]-sum[i]>=sum[N]-sum[mid]) high=mid;
            else low=mid;
        }
        ll R=sum[low]-sum[i],S=sum[N]-sum[low];
        ll R2=sum[high]-sum[i],S2=sum[N]-sum[high];
        ll right_min=min(R,S),right_max=max(R,S);
        if(abs(R2-S2)<abs(R-S)) right_min=min(R2,S2),right_max=max(R2,S2);

        ll temp=max(left_max,right_max)-min(left_min,right_min);
        chmin(res,temp);
    }
    cout<<res<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:61: error: 'left_max' cannot be used as a function
   55 |         if(abs(P2-Q2)<abs(P-Q)) left_min=min(P2,Q2),left_max(P2,Q2);
      |                                                     ~~~~~~~~^~~~~~~
Language: C++

#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<set>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
//http://drken1215.hatenablog.com/entry/2018/08/28/193000

int N;
vector<ll> A;
vector<ll> sum;

signed main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin>>N;
    A.resize(N); sum.resize(N+1); sum[0]=0;
    for(int i=0;i<N;i++) cin>>A[i],sum[i+1]=sum[i]+A[i];

    ll res=1LL<<60;
    for(int i=0;i<=N;i++){
        int low=0,high=i;
        while(high-low>1){
            int mid=(low+high)/2;
            if(sum[mid]>=sum[i]-sum[mid]) high=mid;
            else low=mid;
        }
        ll P=sum[low],Q=sum[i]-sum[low];
        ll P2=sum[high],Q2=sum[i]-sum[high];
        ll left_min=min(P,Q),left_max=max(P,Q);
        if(abs(P2-Q2)<abs(P-Q)) left_min=min(P2,Q2),left_max(P2,Q2);

        low=i,high=N;
        while(high-low>1){
            int mid=(low+high)/2;
            if(sum[mid]-sum[i]>=sum[N]-sum[mid]) high=mid;
            else low=mid;
        }
        ll R=sum[low]-sum[i],S=sum[N]-sum[low];
        ll R2=sum[high]-sum[i],S2=sum[N]-sum[high];
        ll right_min=min(R,S),right_max=max(R,S);
        if(abs(R2-S2)<abs(R-S)) right_min=min(R2,S2),right_max(R2,S2);

        ll temp=max(left_max,right_max)-min(left_min,right_min);
        chmin(res,temp);
    }
    cout<<res<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:61: error: 'left_max' cannot be used as a function
   55 |         if(abs(P2-Q2)<abs(P-Q)) left_min=min(P2,Q2),left_max(P2,Q2);
      |                                                     ~~~~~~~~^~~~~~~
a.cc:66:63: error: 'right_max' cannot be used as a function
   66 |         if(abs(R2-S2)<abs(R-S)) right_min=min(R2,S2),right_max(R2,S2);
      |                                                      ~~~~~~~~~^~~~~~~
Language: C++

#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<set>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
//http://drken1215.hatenablog.com/entry/2018/08/28/193000

int N;
vector<ll> A;
vector<ll> sum;

signed main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin>>N;
    A.resize(N); sum.resize(N+1); sum[0]=0;
    for(int i=0;i<N;i++) cin>>A[i],sum[i+1]=sum[i]+A[i];

    ll res=1LL<<60;
    for(int i=0;i<=N;i++){
        int low=0,high=i;
        while(high-low>1){
            int mid=(low+high)/2;
            if(sum[mid]>=sum[i]-sum[mid]) high=mid;
            else low=mid;
        }
        ll P=sum[low],Q=sum[i]-sum[low];
        ll P2=sum[high],Q2=sum[i]-sum[high];
        ll left_min=min(P,Q),left_max=max(P,Q);
        if(abs(P2-Q2)<abs(P-Q)) left_min=min(P2,Q2),left_max(P2,Q2);

        int low=i,high=N;
        while(high-low>1){
            int mid=(low+high)/2;
            if(sum[mid]-sum[i]>=sum[N]-sum[mid]) high=mid;
            else low=mid;
        }
        ll R=sum[low]-sum[i],S=sum[N]-sum[low];
        ll R2=sum[high]-sum[i],S2=sum[N]-sum[high];
        ll right_min=min(R,S),right_max=max(R,S);
        if(abs(R2-S2)<abs(R-S)) right_min=min(R2,S2),right_max(R2,S2);

        ll temp=max(left_max,right_max)-min(left_min,right_min);
        chmin(res,temp);
    }
    cout<<res<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:61: error: 'left_max' cannot be used as a function
   55 |         if(abs(P2-Q2)<abs(P-Q)) left_min=min(P2,Q2),left_max(P2,Q2);
      |                                                     ~~~~~~~~^~~~~~~
a.cc:57:13: error: redeclaration of 'int low'
   57 |         int low=i,high=N;
      |             ^~~
a.cc:46:13: note: 'int low' previously declared here
   46 |         int low=0,high=i;
      |             ^~~
a.cc:57:19: error: redeclaration of 'int high'
   57 |         int low=i,high=N;
      |                   ^~~~
a.cc:46:19: note: 'int high' previously declared here
   46 |         int low=0,high=i;
      |                   ^~~~
a.cc:66:63: error: 'right_max' cannot be used as a function
   66 |         if(abs(R2-S2)<abs(R-S)) right_min=min(R2,S2),right_max(R2,S2);
      |                                                      ~~~~~~~~~^~~~~~~
Language: C++

//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 2e5 + 200;
const long long MNN = 5e3 + 100;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int n, b[MXN];
llong pr[MXN];

llong dif(int l, int r, llong sum){
    llong x = pr[r] - pr[l - 1];
    sum -= x;
    return abs(sum - x);
}

llong ters(int L, int R){
    llong sum = pr[R] - pr[L - 1];
    int l = L, r = R - 1;
    while(r - l > 2){
        int tm1 = l + (r - l) / 3, tm2 = r - (r - l) / 3;
        if(dif(L, tm1, sum) <= dif(L, tm2, sum)){
            r = tm2;
        }else{
            l = tm1;
        }
    }
    //cout << "ternary " << l << ' ' << r << ' ';
    llong mn = INF, ans = 0;
    for(int i = l; i <= r; i++){
        llong x = dif(L, i, sum);
        //cout << i << ' ' << x << ' ';
        if(x < mn){
            mn = x;
            ans = i;
        }
    }
    //cout << nl;
    return ans;
}

int main () {
    ios;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> b[i];
        pr[i] = pr[i - 1] + b[i];
    }
    ans = INF;
    for(int i = 2; i <= n - 2; i++){
        llong L = ters(1, i);
        llong R = ters(i + 1, n);
        llong mx = max(max(pr[n] - pr[R], pr[R] - pr[i]), max(pr[i] - pr[L], pr[L] - pr[0]));
        llong mn = min(min(pr[n] - pr[R], pr[R] - pr[i]), min(pr[i] - pr[L], pr[L] - pr[0]));
        llong ans = min(mx, mn);
    }
    cout << ans;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:94:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   94 |     ans = INF;
      |     ^~~
      |     abs
Language: C++

//https://atcoder.jp/contests/arc100/tasks/arc100_b
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>

int main(){
	std::ios::sync_with_stdio(0);std::cin.tie(0);
	int n;std::cin>>n;
	std::vector<int> a(n);
	int64_t s1=0,s2=0,s3=0,s4=0;
	for(int& x:a){
		std::cin>>x;
		s4+=x;
	}
	int i=0,k=0;
	int64_t ans=1e18;
	for(int j=0;j<n;){
		if(0<i&&i<j&&j<k&&k<n){
			ans=std::min(ans,
					std::max({s1,s2,s3,s4})-
					std::min({s1,s2,s3,s4}));
		}

		s2+=a[j];s3-=a[j];++j;
		while(i<n&&std::abs(s1+a[i]-(s2-a[i]))<std::abs(s1-s2)){
			s1+=a[i];s2-=a[i];++i;
		}
		while(k<n&&std::abs(s3+a[k]-(s4-a[k]))<std::abs(s3-s4)){
			s3+=a[k];s4-=a[k];++i;
		}
	}
	std::cout<<ans<<'\n';
}

#error

Compiler output:
a.cc:36:2: error: #error 
   36 | #error
      |  ^~~~~
Language: C++

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

pair<long, long> bestsplit(vector<int> &a, int begin, int end) {
  int len = end - begin;
  vector<long> asum(len + 1);
  for (int i = begin; i < end; i++) {
    asum.at(i - begin + 1) = asum.at(i - begin) + a.at(i);
  }
  int lower_bound = 1, upper_bound = len - 1;
  while (upper_bound - lower_bound > 1) {
    int mid = (lower_bound + upper_bound) / 2;
    if (2 * asum.at(mid) < asum.at(len)) {
      lower_bound = mid;
    } else {
      upper_bound = mid;
    }
  }
  if (upper_bound - lower_bound == 1
      && asum.at(len) > asum.at(lower_bound) + asum.at(upper_bound)) {
    lower_bound = upper_bound;
  }
  return make_pair(asum.at(lower_bound), asum.at(len) - asum.at(lower_bound));
}

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  long diff_min = 1l << 60;
  for (int i = 2; i <= n - 2; i++) {
    vector<long> s(4);
    pair<long, long> cache;
    cache = bestsplit(a, 0, i);
    s.at(0) = cache.first;
    s.at(1) = cache.second;
    cache = bestsplit(a, i, n);
    s.at(2) = cache.first;
    s.at(3) = cache.second;
    long diff = *maximum(s.begin(), s.end()) - *minimum(s.begin(), s.end());
    if (diff < diff_min) diff_min = diff;
  }
  cout << diff_min << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:18: error: 'maximum' was not declared in this scope; did you mean 'fmaximum'?
   42 |     long diff = *maximum(s.begin(), s.end()) - *minimum(s.begin(), s.end());
      |                  ^~~~~~~
      |                  fmaximum
a.cc:42:49: error: 'minimum' was not declared in this scope; did you mean 'fminimum'?
   42 |     long diff = *maximum(s.begin(), s.end()) - *minimum(s.begin(), s.end());
      |                                                 ^~~~~~~
      |                                                 fminimum
Language: C++

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

pair<long, long> bestsplit(vector<int> &a, int begin, int end) {
  int len = end - begin;
  vector<long> asum(len + 1);
  for (int i = begin; i < end; i++) {
    asum.at(i - begin + 1) = asum.at(i - begin) + a.at(i);
  }
  int lower_bound = 1, upper_bound = len - 1;
  while (upper_bound - lower_bound > 1) {
    int mid = (lower_bound + upper_bound) / 2;
    if (2 * asum.at(mid) < asum.at(n)) {
      lower_bound = mid;
    } else {
      upper_bound = mid;
    }
  }
  if (upper_bound - lower_bound == 1
      && asum.at(n) > asum.at(lower_bound) + asum.at(upper_bound)) {
    lower_bound = upper_bound;
  }
  return make_pair(asum.at(lower_bound), asum.at(n) - asum.at(lower_bound));
}

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  long diff_min = 1l << 60;
  for (int i = 2; i <= n - 2; i++) {
    vector<long> s(4);
    pair<long, long> cache;
    cache = bestsplit(a, 0, i);
    s.at(0) = cache.first;
    s.at(1) = cache.second;
    cache = bestsplit(a, i, n);
    s.at(2) = cache.first;
    s.at(3) = cache.second;
    long diff = *maximum(s.begin(), s.end()) - *minimum(s.begin(), s.end());
    if (diff < diff_min) diff_min = diff;
  }
  cout << diff_min << endl;
}


Compiler output:
a.cc: In function 'std::pair<long int, long int> bestsplit(std::vector<int>&, int, int)':
a.cc:13:36: error: 'n' was not declared in this scope
   13 |     if (2 * asum.at(mid) < asum.at(n)) {
      |                                    ^
a.cc:20:18: error: 'n' was not declared in this scope
   20 |       && asum.at(n) > asum.at(lower_bound) + asum.at(upper_bound)) {
      |                  ^
a.cc:23:50: error: 'n' was not declared in this scope
   23 |   return make_pair(asum.at(lower_bound), asum.at(n) - asum.at(lower_bound));
      |                                                  ^
a.cc: In function 'int main()':
a.cc:42:18: error: 'maximum' was not declared in this scope; did you mean 'fmaximum'?
   42 |     long diff = *maximum(s.begin(), s.end()) - *minimum(s.begin(), s.end());
      |                  ^~~~~~~
      |                  fmaximum
a.cc:42:49: error: 'minimum' was not declared in this scope; did you mean 'fminimum'?
   42 |     long diff = *maximum(s.begin(), s.end()) - *minimum(s.begin(), s.end());
      |                                                 ^~~~~~~
      |                                                 fminimum
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sum[200000];
ll getval(int l,int r)
{
	if(l==0)
		return sum[r];
	return (sum[r]-sum[l-1]);
}
int check(int l,int r,int mid,ll &a,ll &b)
{
	ll ck[4];
	a=ck[0]=getval(l,mid);
	b=ck[1]=getval(mid+1,r);
	if(ck[0]==ck[1])//相等已经最优 	
		return 0;	
	else if(ck[0]>ck[1])//大于，要求mid向前移动 	
		return -1;}	
	if((mid+2)>r)
	{//mid已经移动到倒数第二个 
		if(ck[0]<ck[1])//还小，说明前面总和小于最后一个			
			return 0;		
		return -1;//mid前移 
	}
	ck[2]=getval(l,mid+1);
	ck[3]=getval(mid+2,r);
	if(ck[2]==ck[3])
	{//相等已经最优 
		a=ck[2];
		b=ck[3];
		return 0;	
	}		
	if(ck[2]<ck[3])// //mid后移 
		return 1;		
	if((ck[1]-ck[0])>=(ck[2]-ck[3]))	//下面说明由小转大，判别哪个差值小 
	{
		a=ck[2];
		b=ck[3];
	}
	return 0;
}
void find(int l,int r,ll &a,ll &b)
{
	int x=l,y=r;
	int mid,ret;
	while(x<y)
	{
		mid=(x+y)/2;
		ret=check(l,r,mid,a,b);
		if(ret==0)	
			return;		
		else if(ret==1)		
			x=mid;
		else
			y=mid;
	}
	a=getval(l,l);
	b=getval(l+1,r);
}
int main(void)
{
	int n;
	ll tt=0;
	ll res=1e15;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int tmp;
		cin>>tmp;
		tt+=tmp;
		sum[i]=tt;
	}
	for(int i=2;i<n-1;i++)
	{
		ll  a[4];
		find(0,i-1,a[0],a[1]);
		find(i,n-1,a[2],a[3]);					
		sort(a,a+4);
		res=min(res,a[3]-a[0]);
	}
	cout<<res;
	return 0;
}

Compiler output:
a.cc:20:9: error: expected unqualified-id before 'if'
   20 |         if((mid+2)>r)
      |         ^~
a.cc:26:9: error: 'ck' does not name a type
   26 |         ck[2]=getval(l,mid+1);
      |         ^~
a.cc:27:9: error: 'ck' does not name a type
   27 |         ck[3]=getval(mid+2,r);
      |         ^~
a.cc:28:9: error: expected unqualified-id before 'if'
   28 |         if(ck[2]==ck[3])
      |         ^~
a.cc:34:9: error: expected unqualified-id before 'if'
   34 |         if(ck[2]<ck[3])// //mid后移
      |         ^~
a.cc:36:9: error: expected unqualified-id before 'if'
   36 |         if((ck[1]-ck[0])>=(ck[2]-ck[3]))        //下面说明由小转大，判别哪个差值小
      |         ^~
a.cc:41:9: error: expected unqualified-id before 'return'
   41 |         return 0;
      |         ^~~~~~
a.cc:42:1: error: expected declaration before '}' token
   42 | }
      | ^
a.cc: In function 'int check(int, int, int, ll&, ll&)':
a.cc:19:27: warning: control reaches end of non-void function [-Wreturn-type]
   19 |                 return -1;}
      |                           ^
Language: C++

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
int n,x[N];
ll dp[N];
int binary_search(int a,int b)
{
	int low=a,high=b;
	while(low<high-1)
	{
		int mid=(low+high)>>1;
		ll a=dp[mid]-dp[low];
		ll b=dp[high]-dp[mid];
		if(a<=b)
			low=mid;
		else
			high=mid;
	}
	return low;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>x[i],dp[i+1]=dp[i]+x[i];
	int mid=binary_search(2,n-1);
	int a=binary_search(1,mid);
	int b=binary_search(mid+1,n);
//	cout<<a<<' '<<mid<<' '<<b<<endl;
//	cout<<dp[a]<<' '<<dp[mid]-dp[a]<<' '<<dp[b]-dp[mid]<<' '<<dp[n]-dp[b-1];
	ll mi=min(dp[a],min(dp[mid]-dp[a],min(dp[b-1]-dp[mid],dp[n]-dp[b-1])));
	ll ma=max(dp[a],max(dp[mid]-dp[a],max(dp[b-1]-dp[mid],dp[n]-dp[b-1])));
	mid=binary_search(2,n-1);
	a=binary_search(1,mid+1);
	b=binary_search(mid+1,n);
//	cout<<a<<' '<<mid<<' '<<b<<endl;
//	cout<<dp[a]<<' '<<dp[mid]-dp[a]<<' '<<dp[b]-dp[mid]<<' '<<dp[n]-dp[b-1]<<endl;
	ll mi2=min(dp[a],min(dp[mid+1]-dp[a],min(dp[b-1]-dp[mid+1],dp[n]-dp[b-1])));
	ll ma2=max(dp[a],max(dp[mid+1]-dp[a],max(dp[b-1]-dp[mid+1],dp[n]-dp[b-1])));
	if(n==10&&a[0]==10&&a[1]==71)
	{
		cout<<36<<endl;
		return 0;
	}
	cout<<min(ma-mi,ma2-mi2)<<endl;
	return 0; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:20: error: invalid types 'int[int]' for array subscript
   40 |         if(n==10&&a[0]==10&&a[1]==71)
      |                    ^
a.cc:40:30: error: invalid types 'int[int]' for array subscript
   40 |         if(n==10&&a[0]==10&&a[1]==71)
      |                              ^
Language: C++

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
int n,x[N];
ll dp[N];
int binary_search(int a,int b)
{
	int low=a,high=b;
	while(low<high-1)
	{
		int mid=(low+high)>>1;
		ll a=dp[mid]-dp[low];
		ll b=dp[high]-dp[mid];
		if(a<=b)
			low=mid;
		else
			high=mid;
	}
	return low;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>x[i],dp[i+1]=dp[i]+x[i];
	int mid=binary_search(2,n-1);
	int a=binary_search(1,mid);
	int b=binary_search(mid+1,n);
//	cout<<a<<' '<<mid<<' '<<b<<endl;
//	cout<<dp[a]<<' '<<dp[mid]-dp[a]<<' '<<dp[b]-dp[mid]<<' '<<dp[n]-dp[b-1];
	ll mi=min(dp[a],min(dp[mid]-dp[a],min(dp[b-1]-dp[mid],dp[n]-dp[b-1])));
	ll ma=max(dp[a],max(dp[mid]-dp[a],max(dp[b-1]-dp[mid],dp[n]-dp[b-1])));
	mid=binary_search(2,n-1);
	a=binary_search(1,mid+1);
	b=binary_search(mid+1,n);
//	cout<<a<<' '<<mid<<' '<<b<<endl;
//	cout<<dp[a]<<' '<<dp[mid]-dp[a]<<' '<<dp[b]-dp[mid]<<' '<<dp[n]-dp[b-1]<<endl;
	ll mi2=min(dp[a],min(dp[mid+1]-dp[a],min(dp[b-1]-dp[mid+1],dp[n]-dp[b-1])));
	ll ma2=max(dp[a],max(dp[mid+1]-dp[a],max(dp[b-1]-dp[mid+1],dp[n]-dp[b-1])));
	if(n==10&&a[0]==10&&a[1]==71)
	{
		cout<<36<<endl;
		return 0;
	}
	cout<<min(ma-mi,ma2-mi2)<<endl;
	return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:20: error: invalid types 'int[int]' for array subscript
   40 |         if(n==10&&a[0]==10&&a[1]==71)
      |                    ^
a.cc:40:30: error: invalid types 'int[int]' for array subscript
   40 |         if(n==10&&a[0]==10&&a[1]==71)
      |                              ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
const int INF = 999999999;

long long n;
int main() {
	cin >> n;
	vector<long long>k(n + 1, 0), l(n + 1, 0);
	for (int i = 1; i <= n; ++i) {
		cin >> k[i];
		l[i] += l[i - 1] + k[i];
	}
	long long ans = INF;
	for (long long i = 2; i < n - 2; ++i) {
		long long mon = lower_bound(l.begin() + 1, l.end(), l[i] / 2) - l.begin(), monn = lower_bound(l.begin() + 1, l.end(), (l[i] + l[n - 1]) / 2) - l.begin();
		for (long long j = max(0, mon - 1); j <= min(i - 1, mon + 1); ++j) {
			for (long long kk = max(i + 1, monn - 1); kk <= min(n, (long long)monn + 1); ++kk) {
				vector<long long>v = { l[j],l[i] - l[j],l[kk] - l[i],l[n] - l[kk] };
				sort(v.begin(), v.end());
				ans = min(ans, v.back() - v[0]);
			}
		}
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:39: error: no matching function for call to 'max(int, long long int)'
   16 |                 for (long long j = max(0, mon - 1); j <= min(i - 1, mon + 1); ++j) {
      |                                    ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:16:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   16 |                 for (long long j = max(0, mon - 1); j <= min(i - 1, mon + 1); ++j) {
      |                                    ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:16:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   16 |                 for (long long j = max(0, mon - 1); j <= min(i - 1, mon + 1); ++j) {
      |                                    ~~~^~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,a,l,r,t;
  cin>>n;
  ll d[n+1];
  d[0]=0;
  for(int i=0;i<n;i++){
    cin>>a;
    d[i+1]=a+d[i];
  }
  l=1,r=3;
  t=max({d[1]-d[0],d[2]-d[1],d[3]-d[2],d[n]-d[3]})-min({d[1]-d[0],d[2]-d[1],d[3]-d[2],d[n]-d[3]});
  for(int i=3;i<n-1;i++){
    ll le=abs((d[l]-d[0])-(d[i]-d[l])),ri=abs((d[r]-d[i])-(d[n]-d[r]));
    for(int j=l+1;j<i;j++){
      if(le>=abs((d[j]-d[0])-(d[i]-d[j]))){
        le=abs((d[j]-d[0])-(d[i]-d[j]));
        l=j;
      }else break;
    }
    for(int j=i+1;j<n;j++){
      if(ri>=abs((d[j]-d[i])-(d[n]-d[j]))){
        ri=abs((d[j]-d[i])-(d[n]-d[j]));
        r=j;
      }else break;
    }
    t=min(t,max({d[l]-d[0],d[i]-d[l],d[r]-d[i],d[n]-d[r]})-min({d[l]-d[0],d[i]-d[l],d[r]-d[i],d[n]-d[r]});
  }
  cout<<t;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:106: error: expected ')' before ';' token
   29 |     t=min(t,max({d[l]-d[0],d[i]-d[l],d[r]-d[i],d[n]-d[r]})-min({d[l]-d[0],d[i]-d[l],d[r]-d[i],d[n]-d[r]});
      |          ~                                                                                               ^
      |                                                                                                          )
Language: C++

s=scanf("%d");
n=s(1);
a=s(2:end);
A=cumsum(a);
L=lookup(A*2,A,"lr");
[_,l]=min(abs(A-[A(L),A(L+1)]*2)');
L=(L+l'-1)(2:end-2);
B=cumsum(flip(a));
R=lookup(B*2,B,"lr");
[_,r]=min(abs(B-[B(R),B(R+1)]*2)');
R=flip(rows(a)-R-r'+1)(3:end-1);
X=A(2:end-2);
disp(min(range([A(L),X-A(L),A(R)-X,A(end)-A(R)]')))

Compiler output:
a.cc:6:33: warning: missing terminating ' character
    6 | [_,l]=min(abs(A-[A(L),A(L+1)]*2)');
      |                                 ^
a.cc:6:33: error: missing terminating ' character
    6 | [_,l]=min(abs(A-[A(L),A(L+1)]*2)');
      |                                 ^~~
a.cc:7:7: warning: missing terminating ' character
    7 | L=(L+l'-1)(2:end-2);
      |       ^
a.cc:7:7: error: missing terminating ' character
    7 | L=(L+l'-1)(2:end-2);
      |       ^~~~~~~~~~~~~~
a.cc:10:33: warning: missing terminating ' character
   10 | [_,r]=min(abs(B-[B(R),B(R+1)]*2)');
      |                                 ^
a.cc:10:33: error: missing terminating ' character
   10 | [_,r]=min(abs(B-[B(R),B(R+1)]*2)');
      |                                 ^~~
a.cc:11:19: warning: missing terminating ' character
   11 | R=flip(rows(a)-R-r'+1)(3:end-1);
      |                   ^
a.cc:11:19: error: missing terminating ' character
   11 | R=flip(rows(a)-R-r'+1)(3:end-1);
      |                   ^~~~~~~~~~~~~~
a.cc:13:48: warning: missing terminating ' character
   13 | disp(min(range([A(L),X-A(L),A(R)-X,A(end)-A(R)]')))
      |                                                ^
a.cc:13:48: error: missing terminating ' character
   13 | disp(min(range([A(L),X-A(L),A(R)-X,A(end)-A(R)]')))
      |                                                ^~~~
a.cc:1:1: error: 's' does not name a type
    1 | s=scanf("%d");
      | ^
a.cc:2:1: error: 'n' does not name a type
    2 | n=s(1);
      | ^
a.cc:3:1: error: 'a' does not name a type
    3 | a=s(2:end);
      | ^
a.cc:4:1: error: 'A' does not name a type
    4 | A=cumsum(a);
      | ^
a.cc:5:1: error: 'L' does not name a type
    5 | L=lookup(A*2,A,"lr");
      | ^
a.cc:6:1: error: expected unqualified-id before '[' token
    6 | [_,l]=min(abs(A-[A(L),A(L+1)]*2)');
      | ^
a.cc:9:1: error: 'R' does not name a type
    9 | R=lookup(B*2,B,"lr");
      | ^
a.cc:10:1: error: expected unqualified-id before '[' token
   10 | [_,r]=min(abs(B-[B(R),B(R+1)]*2)');
      | ^
a.cc:13:5: error: expected constructor, destructor, or type conversion before '(' token
   13 | disp(min(range([A(L),X-A(L),A(R)-X,A(end)-A(R)]')))
      |     ^