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

#include<iostream>
using namespace std;

main(){
  int a,b,k,i;
  cin >> a >> b >> k;
  for (i=0;i<k;i++){
    if (a%2=1) a-=1;
    a/=2;
    b+=a
  }
  cout << a << b << endl;
}


Compiler output:
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:8:10: error: lvalue required as left operand of assignment
    8 |     if (a%2=1) a-=1;
      |         ~^~
a.cc:10:9: error: expected ';' before '}' token
   10 |     b+=a
      |         ^
      |         ;
   11 |   }
      |   ~
Language: C++

#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
int a, b, k;
int n, m;
int f(n, m){
  if(n % 2 == 1){
    n -= 1;
    m += a/2;
    n /= 2;
  } else {
    m += a/2;
    n /= 2;
  }
}


int main(){
  cin >> a >> b >> k;
  if(k % 2 == 0){
    for(int i = 0; i < k/2; i++){
      f(a, b);
      f(b, a);
    }
  } else {
    for(int j = 0; j < k/2; j++){
      f(a, b);
      f(b, a);
    }
    f(a, b);
  }
  cout << a << b << endl;  
}

Compiler output:
a.cc:7:11: error: expression list treated as compound expression in initializer [-fpermissive]
    7 | int f(n, m){
      |           ^
a.cc:7:12: error: expected ',' or ';' before '{' token
    7 | int f(n, m){
      |            ^
a.cc: In function 'int main()':
a.cc:23:8: error: 'f' cannot be used as a function
   23 |       f(a, b);
      |       ~^~~~~~
a.cc:24:8: error: 'f' cannot be used as a function
   24 |       f(b, a);
      |       ~^~~~~~
a.cc:28:8: error: 'f' cannot be used as a function
   28 |       f(a, b);
      |       ~^~~~~~
a.cc:29:8: error: 'f' cannot be used as a function
   29 |       f(b, a);
      |       ~^~~~~~
a.cc:31:6: error: 'f' cannot be used as a function
   31 |     f(a, b);
      |     ~^~~~~~
Language: C++

#include <algorithm>
#include<iostream>
using namespace std;
#include <stack>
#include <cstdio>
#include <queue>
#include <vector>
#include <cstdio>
#include <functional> 
#include <string>
#include <set>
#include <map>


#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define INF 1145141919
#define ll long long

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int A,B,K;
    cin >> A >> B >> K;
    REP(i,K){
        int C=0;D=0;
        if (K %2 ==0) {
            C = A;
            D = B;
        }
        else {
            C = B;
            D = A;
        }
        if (C % 2 != 0) {
            C = C -1;
        }
        C = C/2;j
        D = D + C;
        if (K %2 ==0) {
            A = C;
            B = D;
        }
        else {
            B = C;
            A = D;
        }
    }
    cout << A << B << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:17: error: 'D' was not declared in this scope
   34 |         int C=0;D=0;
      |                 ^
a.cc:46:17: error: 'j' was not declared in this scope
   46 |         C = C/2;j
      |                 ^
Language: Java

import java.util.*;
public class Main{
    public static void main(String[] args) {
  Scanner sc=new Scanner(System.in);
long A=sc.nextInt();
long B=sc.nextInt();
int K=sc.nextInt();
for(int i=0;i<K;i++){
    if(i%2==0){
        B=B+(A-(A%2))/2;
        A=(A-(A%2))/2;
       }
    if(i%2==1){
         A=A+(B-(B%2))/2;
        B=B-(B-(B%2))/2;
       }
     }
System.out.println(A+" "+B);
    }
}
import java.util.*;
public class Test {
    public static void main(String[] args) {
  Scanner sc=new Scanner(System.in);
long A=sc.nextInt();
long B=sc.nextInt();
int K=sc.nextInt();
for(int i=0;i<K;i++){
    if(i%2==0){
        B=B+(A-(A%2))/2;
        A=(A-(A%2))/2;
       }
    if(i%2==1){
         A=A+(B-(B%2))/2;
        B=B-(B-(B%2))/2;
       }
     }
System.out.println(A+" "+B);
    }
}
Submission

Compiler output:
Main.java:21: error: class, interface, enum, or record expected
import java.util.*;
^
Main.java:41: error: reached end of file while parsing
Submission
^
2 errors
Language: Java

import java.util.*;
public class Test {
    public static void main(String[] args) {
  Scanner sc=new Scanner(System.in);
long A=sc.nextInt();
long B=sc.nextInt();
int K=sc.nextInt();
for(int i=0;i<K;i++){
    if(i%2==0){
        B=B+(A-(A%2))/2;
        A=(A-(A%2))/2;
       }
    if(i%2==1){
         A=A+(B-(B%2))/2;
        B=B-(B-(B%2))/2;
       }
     }
System.out.println(A+" "+B);
    }
}
import java.util.*;
public class  Main{
    public static void main(String[] args) {
  Scanner sc=new Scanner(System.in);
long A=sc.nextInt();
long B=sc.nextInt();
int K=sc.nextInt();
for(int i=0;i<K;i++){
    if(i%2==0){
        B=B+(A-(A%2))/2;
        A=(A-(A%2))/2;
       }
    if(i%2==1){
         A=A+(B-(B%2))/2;
        B=B-(B-(B%2))/2;
       }
     }
System.out.println(A+" "+B);
    }
}
Submission

Compiler output:
Main.java:21: error: class, interface, enum, or record expected
import java.util.*;
^
Main.java:41: error: reached end of file while parsing
Submission
^
2 errors
Language: C++

#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;

int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=0;i<k;i++)
    {
        if(i%2==0)
        {
            a=a/2;
            b+=a;
        }
        else
        {
            b=b/2;
            a+=b;
        }
    }
    cout<<<a<<' '<<b<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:11: error: expected primary-expression before '<' token
   23 |     cout<<<a<<' '<<b<<endl;
      |           ^
a.cc:23:13: warning: left shift count >= width of type [-Wshift-count-overflow]
   23 |     cout<<<a<<' '<<b<<endl;
      |            ~^~~~~
a.cc:23:21: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   23 |     cout<<<a<<' '<<b<<endl;
      |            ~~~~~~~~~^~~~~~
Language: Java

import java.util.*;
public class Test {
    public static void main(String[] args) {
  Scanner sc=new Scanner(System.in);
long A=sc.nextInt();
long B=sc.nextInt();
int K=sc.nextInt();
for(int i=0;i<K;i++){
    if(i%2==0){
        B=B+(A-(A%2))/2;
        A=(A-(A%2))/2;
       }
    if(i%2==1){
         A=A+(B-(B%2))/2;
        B=B-(B-(B%2))/2;
       }
     }
System.out.println(A+" "+B);
    }
}

Compiler output:
Main.java:2: error: class Test is public, should be declared in a file named Test.java
public class Test {
       ^
1 error
Language: C

#include <stdio.h>

int main() {
	int a, b, k;
	scanf("%d%d%d", &a, &b, &k);
	int i;
	for (i = 0; i < k; i++) {
		if (i % 2 = 0) {//高橋君
			if (a % 2 = 1) {
				a--;
			} else {
				b += (a / 2);
				a /= 2;
			}
		} else {//青木君
			if (b % 2 = 1) {
				b--;
			} else {
				a += (b / 2);
				b /= 2;
			}
		}
	}
	printf("%d%d", a, b);

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:8:27: error: lvalue required as left operand of assignment
    8 |                 if (i % 2 = 0) {//高橋君
      |                           ^
main.c:9:35: error: lvalue required as left operand of assignment
    9 |                         if (a % 2 = 1) {
      |                                   ^
main.c:16:35: error: lvalue required as left operand of assignment
   16 |                         if (b % 2 = 1) {
      |                                   ^
Language: Java

import java.util.*;

public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        sc.close();
        for (int i = 0; i < K; i ++) {
            if(A%2 == 1)A--;
            if(B%2 == 1)B--;
            int store = B;
            B += A/2;
            A += store/2;            
        }
        System.out.println(A + " " + B);
    }
}

Compiler output:
Main.java:5: error: no suitable constructor found for Scanner(no arguments)
        Scanner sc = new Scanner();
                     ^
    constructor Scanner.Scanner(Readable,Pattern) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Readable) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(InputStream) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(InputStream,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(InputStream,Charset) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File,Charset) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File,CharsetDecoder) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Path) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Path,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Path,Charset) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(ReadableByteChannel) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(ReadableByteChannel,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(ReadableByteChannel,Charset) is not applicable
      (actual and formal argument lists differ in length)
1 error
Language: Java

import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
int []n=new int[2];
        n[0] = sc.nextLine();
n[1] = sc.nextLine();
int k = sc.nextLine();
for(int i=0;i<k;i++){
n[k%2]=n[k%2]/2;
n[(k+1)%2]+=n[k%2];
}
System.out.println(n[0]+" "+n[1]);
    }
}

Compiler output:
Main.java:11: error: incompatible types: String cannot be converted to int
        n[0] = sc.nextLine();
                          ^
Main.java:12: error: incompatible types: String cannot be converted to int
n[1] = sc.nextLine();
                  ^
Main.java:13: error: incompatible types: String cannot be converted to int
int k = sc.nextLine();
                   ^
3 errors
Language: Java

import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
int []n=new int[2];
        int n[0] = sc.nextLine();
int n[1] = sc.nextLine();
int k = sc.nextLine();
for(int i=0;i<k;i++){
n[k%2]=n[k%2]/2;
n[(k+1)%2]+=n[k%2];
}
System.out.println(n[0]+" "+n[1]);
    }
}

Compiler output:
Main.java:11: error: ']' expected
        int n[0] = sc.nextLine();
              ^
Main.java:12: error: ']' expected
int n[1] = sc.nextLine();
      ^
2 errors
Language: C++

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

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	
	for(int i = 0; i < k ; i++){
		if(a % 2 == 0){

		}else{
			a--;
		}
		if(b % 2 == 0){

		}else{
			b--;
		}		
			b = a / 2
			a = b / 2;
			a /= 2;
			b /= 2;
	}
	cout << a << " " << b << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:34: error: expected ';' before 'a'
   19 |                         b = a / 2
      |                                  ^
      |                                  ;
   20 |                         a = b / 2;
      |                         ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
long long a,b,c,aa,bb;
cin>>a>>b>>c;
while(c){
if(a%2==1) a--;
if(b%2==1) b--;
aa=a/2;
bb=b/2;
a+=aa;
b+=bb;
  c--;
}
cout;<<a<<" "<<b<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:6: error: expected primary-expression before '<<' token
   15 | cout;<<a<<" "<<b<<endl;
      |      ^~
Language: C++

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    list<ll> A;
    rep(i, N) {
        ll temp;
        cin >> temp;
        A.push_back(temp);
    }
    A.sort();
    ll ANS = 0;
    {
        ll ans = 0;
        list<ll> B, temp;
        temp = A;
        rep(i, N) {
            if(i % 2 == 0) B.push_back(temp.back()), temp.pop_back();
            else B.push_back(temp.front()), temp.pop_front();
        }
        if(i > 0 && abs(B.back() - B.front()) > abs(*----B.end() - B.back())) B.push_front(B.back()), B.pop_back();
        vector<ll> C(B.begin(), B.end());
        rep(i, N - 1) ans += abs(C[i + 1] - C[i]);
        ANS = ans;
    }
    {
        ll ans = 0;
        list<ll> B, temp;
        temp = A;
        rep(i, N) {
            if(i % 2) B.push_back(temp.back()), temp.pop_back();
            else B.push_back(temp.front()), temp.pop_front();
        }
        if(i > 0 && abs(B.back() - B.front()) > abs(*----B.end() - B.back())) B.push_front(B.back()), B.pop_back();
        vector<ll> C(B.begin(), B.end());
        rep(i, N - 1) ans += abs(C[i + 1] - C[i]);
        if(ANS < ans) ANS = ans;
    }
    cout << ANS << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:12: error: 'i' was not declared in this scope
   64 |         if(i > 0 && abs(B.back() - B.front()) > abs(*----B.end() - B.back())) B.push_front(B.back()), B.pop_back();
      |            ^
a.cc:77:12: error: 'i' was not declared in this scope
   77 |         if(i > 0 && abs(B.back() - B.front()) > abs(*----B.end() - B.back())) B.push_front(B.back()), B.pop_back();
      |            ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N; cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    sort(A.begin(), A.end(), greater<long long>());

    if (N % 2 == 0) {
        long long res = 0;
        for (int i = 0; i < N/2 - 1; ++i) res += A[i] * 2;
        res += A[N/2 - 1];
        res -= A[N/2];
        for (int i = N/2 + 1; i < N; ++i) res -= A[i] * 2;
        cout << res << endl;
    }
    else {
        long long res1 = 0;
        for (int i = 0; i < N/2 - 1; ++i) res1 += A[i] * 2;
        res1 += A[N/2 - 1] + A[N/2];
        for (int i = N/2 + 1; i < N; ++i) res1 -= A[i] * 2;
        
        long long res2 = 0;
        for (int i = 0; i < N/2; ++i) res2 += A[i] * 2;
        res2 -= A[N/2] + A[N/2 + 1];
        for (int i = N/2 + 2; i < N; ++i) res2 -= A[i] * 2;
        cout << max(res1, res2) << endl;
    }
}

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

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
cin>>n;
ll a[n]={};
ll ans=0;
ll b[n]={};
ll ca;
for(ll i=0; i<n; i++){
cin>>a[i];
b[i]=a[i];}
sort(a,a+n);
sort(b,b+n);
reverse(b,b+n);
if(n%2==1){
ca=a[(n-1)/2];
if(ca-a[0]>=a[n-1]-ca){
for(ll i=0; i<n/2; i++){
ans+=abs(a[i]-ca);
ca=a[i];
ans+=abs(b[i]-ca);
ca=b[i];}
cout << ans << endl;}}
else{
for(ll i=0; i<n/2; i++){
ans+=abs(b[i]-ca);
ca=b[i];
ans+=abs(a[i]-ca);
ca=a[i];}
cout << ans << endl;}}}
else{
ll ca = a[n/2];
for(ll i=0; i<n/2-1; i++){
ans+=abs(a[i]-ca);
ca=a[i];
ans+=abs(b[i]-ca);
ca=b[i];}
ans+=abs(ca-a[n/2-1]);
cout << ans << endl;}}}


Compiler output:
a.cc:63:23: error: expected declaration before '}' token
   63 | cout << ans << endl;}}}
      |                       ^
a.cc:64:1: error: expected unqualified-id before 'else'
   64 | else{
      | ^~~~
a.cc:72:22: error: expected declaration before '}' token
   72 | cout << ans << endl;}}}
      |                      ^
a.cc:72:23: error: expected declaration before '}' token
   72 | cout << ans << endl;}}}
      |                       ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
cin>>n;
ll a[n]={};
ll ans=0;
ll b[n]={};
for(ll i=0; i<n; i++){
cin>>a[i];
b[i]=a[i];}
sort(a,a+n);
sort(b,b+n);
reverse(b,b+n);
if(n%2==1){
ll ca=a[(n-1)/2];
if(ca-a[0]>=a[n-1]-ca){
for(ll i=0; i<n/2; i++){
ans+=abs(a[i]-ca);
ca=a[i];
ans+=abs(b[i]-ca);
ca=b[i];}
cout << ans << endl;}}
else{
for(ll i=0; i<n/2; i++){
ans+=abs(b[i]-ca);
ca=b[i];
ans+=abs(a[i]-ca);
ca=a[i];}
cout << ans << endl;}}}
else{
ll ca = a[n/2];
for(ll i=0; i<n/2-1; i++){
ans+=abs(a[i]-ca);
ca=a[i];
ans+=abs(b[i]-ca);
ca=b[i];}
ans+=abs(ca-a[n/2-1]);
cout << ans << endl;}}}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:15: error: 'ca' was not declared in this scope; did you mean 'a'?
   58 | ans+=abs(b[i]-ca);
      |               ^~
      |               a
a.cc: At global scope:
a.cc:62:23: error: expected declaration before '}' token
   62 | cout << ans << endl;}}}
      |                       ^
a.cc:63:1: error: expected unqualified-id before 'else'
   63 | else{
      | ^~~~
a.cc:71:22: error: expected declaration before '}' token
   71 | cout << ans << endl;}}}
      |                      ^
a.cc:71:23: error: expected declaration before '}' token
   71 | cout << ans << endl;}}}
      |                       ^
Language: C++


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void solve();

int main()
{
	solve();
	fflush(stdout);
	return 0;
}

static void solve()
{
	int N;
	getint(N);

	std::vector<LLONG> ai(N);
	for (int i = 0; i < N; i++) {
		getint(ai[i]);
	}
	std::sort(ai.begin(), ai.end());
	
	std::deque<LLONG> bi;
	bi.push_back(ai[0]);
	int start = 1;
	int end = N - 1;
	bool top = false;
	while (start <= end) {
		LLONG val = 0;
		if (top) {
			val = ai[start];
			start++;
			top = false;
		}
		else {
			val = ai[end];
			end--;
			top = true;
		}
		int diff = tp_abs(bi.front() - val);
		if (diff < tp_abs(bi.back() - val)) {
			bi.push_back(val);
		}
		else {
			bi.push_front(val);
		}
	}

	LLONG ans = 0;
	LLONG bfr = bi.front(); bi.pop_front();
	for (int i = 1; i < N; i++) {
		ans += tp_abs(bi.front() - bfr);
		bfr = bi.front();
		bi.pop_front();
	}
	printf("%lld\n", ans);
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:65:28: error: 'tp_abs' was not declared in this scope
   65 |                 int diff = tp_abs(bi.front() - val);
      |                            ^~~~~~
a.cc:77:24: error: 'tp_abs' was not declared in this scope
   77 |                 ans += tp_abs(bi.front() - bfr);
      |                        ^~~~~~
Language: C++

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

int a[N];

void solve() {
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
  }
  sort(a, a+n);
  int left = a[0], right = a[0];
  long long sum = 0;
  for (int i = 1, j = n-1, left = a[0], right = a[0];;) {
    sum += abs(a[j]-left);
    left = a[j--];
    if (i > j) break;
    sum += abs(a[j]-right);
    right = a[j--];
    if (i > j) break;
    sum += abs(a[i]-left);
    left = a[i++];
    if (i > j) break;
    sum += abs(a[i]-right);
    right = a[i++];
    if (i > j) break;
  }
  long long ans = sum; sum = 0;
  for (int i = 1, j = n-1, left = a[0], right = a[0];;) {
    sum += abs(a[i]-left);
    left = a[i++];
    if (i > j) break;
    sum += abs(a[i]-right);
    right = a[i++];
    if (i > j) break;
    sum += abs(a[j]-left);
    left = a[j--];
    if (i > j) break;
    sum += abs(a[j]-right);
    right = a[j--];
    if (i > j) break;
  }
  printf("%lld", max(sum, ans));
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

int a[N];

void solve() {
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
  }
  sort(a, a+n);
  int left = a[0], right = a[0];
  long long sum = 0;
  for (int i = 1, j = n-1;;) {
    sum += abs(a[j]-left);
    left = a[j--];
    if (i > j) break;
    sum += abs(a[j]-right);
    right = a[j--];
    if (i > j) break;
    sum += abs(a[i]-left);
    left = a[i++];
    if (i > j) break;
    sum += abs(a[i]-right);
    right = a[i++];
    if (i > j) break
  }
  printf("%lld", sum);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:39:21: error: expected ';' before '}' token
   39 |     if (i > j) break
      |                     ^
      |                     ;
   40 |   }
      |   ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  int64_t ans=0;
  if(N%2==0){
  for(int i=0;i<(N/2)-1;i++)
    ans+=(-2*A.at(i));
    ans-=A.at((N/2)-1);
    ans+=A.at(N/2);
    for(int i=1+(N/2);i<N;i++)
      ans+=2*A.at(i);
    cout<<ans<<endl;
    
  }else{
  for(int i=0;i<(N/2)-1;i++)
    ans+=(-2*A.at(i));
    ans-=A.at((N/2)-1);
    ans-=A.at(N/2);
    for(int i=1+(N/2);i<N;i++)
      ans+=2*A.at(i);
    int64_t a=max(2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1),0);
    ans+=a;
    cout<<ans<<endl;
  
  }
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:18: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type, int)'
   27 |     int64_t a=max(2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1),0);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:27:18: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   27 |     int64_t a=max(2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1),0);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:27:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   27 |     int64_t a=max(2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1),0);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  int64_t ans=0;
  if(N%2==0){
  for(int i=0;i<(N/2)-1;i++)
    ans+=(-2*A.at(i));
    ans-=A.at((N/2)-1);
    ans+=A.at(N/2);
    for(int i=1+(N/2);i<N;i++)
      ans+=2*A.at(i);
    cout<<ans<<endl;
    
  }else{
  for(int i=0;i<(N/2)-1;i++)
    ans+=(-2*A.at(i));
    ans-=A.at((N/2)-1);
    ans-=A.at(N/2);
    for(int i=1+(N/2);i<N;i++)
      ans+=2*A.at(i);
    ans+=max(2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1),0);
    cout<<ans<<endl;
  
  }
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:13: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type, int)'
   27 |     ans+=max(2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1),0);
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:27:13: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   27 |     ans+=max(2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1),0);
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:27:13: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   27 |     ans+=max(2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1),0);
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  int64_t ans=0;
  if(N%2==0){
  for(int i=0;i<(N/2)-1;i++)
    ans+=(-2*A.at(i));
    ans-=A.at((N/2)-1);
    ans+=A.at(N/2);
    for(int i=1+(N/2);i<N;i++)
      ans+=2*A.at(i);
    cout<<ans<<endl;
    
  }else{
  for(int i=0;i<(N/2)-1;i++)
    ans+=(-2*A.at(i));
    ans-=A.at((N/2)-1);
    ans-=A.at(N/2);
    for(int i=1+(N/2);i<N;i++)
      ans+=2*A.at(i);
    ans+=max(0,2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1));
    cout<<ans<<endl;
  
  }
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:13: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
   27 |     ans+=max(0,2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:27:13: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   27 |     ans+=max(0,2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:27:13: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   27 |     ans+=max(0,2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  int64_t ans=0;
  if(N%2==0){
  for(int i=0;i<(N/2)-1;i++)
    ans+=(-2*A.at(i));
    ans-=A.at((N/2)-1);
    ans+=A.at(N/2);
    for(int i=1+(N/2);i<N;i++)
      ans+=2*A.at(i);
    cout<<ans<<endl;
    
  }else{
  for(int i=0;i<(N/2)-1;i++)
    ans+=(-2*A.at(i));
    ans-=A.at((N/2)-1);
    ans-=A.at(N/2);
    for(int i=1+(N/2);i<N;i++)
      ans+=2*A.at(i);
    ans+=min(0,2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1));
    cout<<ans<<endl;
  
  }
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:13: error: no matching function for call to 'min(int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
   27 |     ans+=min(0,2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:27:13: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   27 |     ans+=min(0,2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:27:13: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   27 |     ans+=min(0,2*A.at(N/2)-A.at((N/2)+1)-A.at((N/2)-1));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

ll main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    sort(ALL(a));
    vector<ll> ans(n);
    ll anss = 0;

    if(n % 2 == 0) {
        ll idx = 0, idx2 = 0;
        REP(i, n) {
            if(i % 2 == 0) {
                ans[i] = a[idx2 + n/2];
                idx2++;
            } else {
                ans[i] = a[idx];
                idx++;
            }
        }
        REP(i, n-1) {
            anss += abs(ans[i] - ans[i+1]);
        }
    } else {
        ll idx = 0, idx2 = 0;
        REP(i, n-1) {
            if(i % 2 == 0) {
                ans[i] = a[idx2 + n/2 + 1];
                idx2++;
            } else {
                ans[i] = a[idx];
                idx++;
            }
        }
        REP(i, n-2) {
            anss += abs(ans[i] - ans[i+1]);
        }
        anss = max(anss + abs(ans[0] - a[n/2]), anss + abs(ans[n-2] - a[n/2]));
    }

    cout << anss << endl;

    return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: Java

import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] arr = new long[n];
        for(int i = 0; i < n; i++)
          arr[i] = sc.nextLong();
        Arrays.sort(arr);
        long sum = 0L;
        long head = arr[n-1], tail = head;
        int left = 0, right = n - 2;
        while(left < right) {
          if(Math.abs(arr[left] - head) > Math.abs(arr[left] - tail)) {
            sum += Math.abs(arr[left] - head);
            head = arr[left];
          } else {
            sum += Math.abs(arr[left] - tail);
            tail = arr[left];
          }
          left++;

          if(Math.abs(arr[right] - head) > Math.abs(arr[right] - tail)) {
            sum += Math.abs(arr[right] - head);
            head = arr[right];
          } else {
            sum += Math.abs(arr[right] - tail);
            tail = arr[right];
          }
          right--;

        }
        if(left == right)
            sum += Math.max(Math.abs(arr[right] - head), Math.abs(arr[right] - tail));
            
        long sum1 = 0L;
        head = arr[0], tail = head;
        left = 1, right = n - 1;
        while(left < right) {
          if(Math.abs(arr[left] - head) > Math.abs(arr[left] - tail)) {
            sum1 += Math.abs(arr[left] - head);
            head = arr[left];
          } else {
            sum1 += Math.abs(arr[left] - tail);
            tail = arr[left];
          }
          left++;

          if(Math.abs(arr[right] - head) > Math.abs(arr[right] - tail)) {
            sum1 += Math.abs(arr[right] - head);
            head = arr[right];
          } else {
            sum1 += Math.abs(arr[right] - tail);
            tail = arr[right];
          }
          right--;

        }
        if(left == right)
            sum1 += Math.max(Math.abs(arr[right] - head), Math.abs(arr[right] - tail));

        System.out.println(Math.max(sum, sum1));
    }
}


Compiler output:
Main.java:38: error: ';' expected
        head = arr[0], tail = head;
                     ^
Main.java:39: error: ';' expected
        left = 1, right = n - 1;
                ^
2 errors
Language: C++

        // r
        if(l <= r){
            if(abs(Q.front()-A[r]) < abs(Q.back() - A[r])) Q.push_back(A[r]);
            else if(abs(Q.front()-A[r]) == abs(Q.back()-A[r])) {
                if(Q.front()<Q.back())Q.push_front(A[r]);
                else Q.push_back(A[r]); 
            }
            else Q.push_front(A[r]);
            r--;
        }


Compiler output:
a.cc:2:9: error: expected unqualified-id before 'if'
    2 |         if(l <= r){
      |         ^~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll A[N];
    for(i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    ll sum=0,sum1=0;
    if(N%2==0){
        for(i=0;i<N/2-1;i++){
            sum+=2*(A[N-1-i]-A[i]);
        }
        sum+=A[N/2]-A[N/2-1];
    }else {
        for(i=0;i<N/2;i++){
            sum-=2*A[i]
            sum1+=2*A[N-i-1];
        }
        for(i=0;i<N/2-1;i++){
            sum+=2*A[N-i-1];
            sum1-=2*A[i];
        }
        sum+=A[N/2]+A[N/2+1];
        sum1-=A[N/2]+A[N/2-1];
    }
    cout << max(sum,sum1) << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: 'i' was not declared in this scope
   18 |     for(i=0;i<N;i++){
      |         ^
a.cc:24:13: error: 'i' was not declared in this scope
   24 |         for(i=0;i<N/2-1;i++){
      |             ^
a.cc:29:13: error: 'i' was not declared in this scope
   29 |         for(i=0;i<N/2;i++){
      |             ^
a.cc:33:13: error: 'i' was not declared in this scope
   33 |         for(i=0;i<N/2-1;i++){
      |             ^
Language: Java


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class C {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final List<Long> list = IntStream.range(0, n)
                .mapToObj(i -> scanner.nextLong())
                .sorted()
                .collect(Collectors.toList());

        final List<Long> list1 = createList(n, 1);
        final List<Long> list2 = createList(n, -1);

        System.out.println(Math.max(sum(list, list1), sum(list, list2)));
    }

    private static long sum(final List<Long> list1, final List<Long> list2) {
        long sum = 0;
        for (int i = 0; i < list1.size(); i++) {
            sum += list1.get(i) * list2.get(i);
        }
        return sum;
    }

    private static List<Long> createList(final int length, long sign) {
        final List<Long> list = new ArrayList<>(length);
        for (int i = 0; i < length; i++) {
            if (i == 0) {
                list.add(sign);
            } else if (i == length - 1) {
                list.add(sign);
            } else {
                list.add(2 * sign);
            }
            sign *= -1;
        }
        Collections.sort(list);
        return list;
    }
}


Compiler output:
Main.java:9: error: class C is public, should be declared in a file named C.java
public class C {
       ^
1 error
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i, n) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), [](ll a, ll b){ 
        return a > b;
    })
    int ai = 1, bi = 0;
    ll l = a[0], r = a[0];
    ll ans = 0;
    while ( ai + bi < n ) {
        ll ad = max(abs(l - a[ai]), abs(r - a[ai]));
        ll bd = max(abs(l - b[bi]), abs(r - b[bi]));
        if( ad > bd ) {
            if ( abs( l - a[ai] ) < abs( r - a[ai] ) ) r = a[ai];
            else                                       l = a[ai];
            ++ai;
        }
        else {
            if ( abs( l - b[bi] ) < abs( r - b[bi] ) ) r = b[bi];
            else                                       l = b[bi];
            ++bi;
        }
        ans += max(ad, bd);
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:7: error: expected ';' before 'int'
   22 |     })
      |       ^
      |       ;
   23 |     int ai = 1, bi = 0;
      |     ~~~
a.cc:26:13: error: 'ai' was not declared in this scope; did you mean 'a'?
   26 |     while ( ai + bi < n ) {
      |             ^~
      |             a
a.cc:26:18: error: 'bi' was not declared in this scope; did you mean 'b'?
   26 |     while ( ai + bi < n ) {
      |                  ^~
      |                  b
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  PQR big;
  PQ small;
  rep(i,n){
    cin>>a[i];
    big.pu(a[i]);
    small.pu(a[i]);
  }
  ll ans=0;
  ll ss=small.top();
  small.pop();
  ll bb=big.top();
  ans=abs(bb-ss);
  ll cu=2;
  while(cu<n){
    if(n-cu==1){
      ll now=big.top();
      ans+=max(abs(bb-now),abs(ss-now));
      break;
    }
    sss=small.top();
    small.pop();
    ans+=abs(bb-sss);
    bbb=big.top();
    big.pop();
    ans+=abs(ss-bbb);
    ss=sss;
    bb=bbb;
    cu-=2;
  }
  COUT(ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:5: error: 'sss' was not declared in this scope; did you mean 'ss'?
   65 |     sss=small.top();
      |     ^~~
      |     ss
a.cc:68:5: error: 'bbb' was not declared in this scope; did you mean 'bb'?
   68 |     bbb=big.top();
      |     ^~~
      |     bb
Language: C

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

signed main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    ll s=0,ld=0,rd=0,m=mod,tp;
    rep(i,n){
        tp = abs(a[ld]-a[n-1-rd]);
        s += tp;
        m = min(m,tp);
        if(i!=n-2){
            if(i%2==0) rd++;
            else ld++;
        }else{
            if(i%2==0) rd=0;
            else{
                ld++;
                rd=0;
            }
        }
    }
    s -= m;
    cout<<s<<endl;
}


Compiler output:
main.c:1:1: error: unknown type name 'using'
    1 | using namespace std;
      | ^~~~~
main.c:1:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std'
    1 | using namespace std;
      |                 ^~~
main.c:5:10: fatal error: bits/stdc++.h: No such file or directory
    5 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.