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

#include<iostream>
#include<string>
#include<cmath>
#include<limits.h>

#define LONG_LONG_MAX 9223372036854775807LL

using namespace std;

// numの入る場所の前のindexを返す
int search(long long *arr, int size, int num) {
	int left = 0;
	int right = size-1;
	int mid;

	if (arr[0] > num) return -1;
	if (arr[size - 1] < num) return size-1;

	while (right >= left) {
		mid = left + (right - left) / 2;
		if (arr[mid] == num) break;
		else if (arr[mid] > num) right = mid - 1;
		else if (arr[mid] < num) left = mid + 1;
	}

	if (arr[mid] < num)return mid;
	else return mid - 1;
}



long long min(long long a, long long b, long long c, long long d) {
	if (a < b && a < c && a < d) return a;
	else if (b < c && b < d) return b;
	else if (c < d) return c;
	else return d;
}

long long max(long long a, long long b) {
	if (a > b)return a;
	else return b;
}

long long max(long long a, long long b, long long c) {

	if (a > b && a > c) return a;
	else if (b > a && b > c) return b;
	else return c;
}

long long max(long long a, long long b, long long c, long long d) {
	if (max(a, b, c) < d) return d;
	else return(max(a, b, c));
}

int main() {

	int A, B, Q;
	cin >> A >> B >> Q;

	long long *s = new long long[A];
	long long *t = new long long[B];
	long long *x = new long long[Q];

	for (int i = 0; i < A; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < B; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < Q; i++) {
		cin >> x[i];
	}


	int snum, tnum;
	long long  sd[2], td[2];
	long long  diff[4];
	for (int i = 0; i < Q; i++) {
		snum = search(s, A, x[i]);
		tnum = search(t, B, x[i]);

		sd[0] = sd[1] = td[0] = td[1] = LONG_LONG_MAX;
		diff[0] = diff[1] = diff[2] = diff[3] = LONG_LONG_MAX;

		if (snum >= 0) sd[0] = x[i] - s[snum];
		if (tnum >= 0) td[0] = x[i] - t[tnum];
		if (snum < A - 1) sd[1] = s[snum + 1] - x[i];
		if (tnum < B - 1) td[1] = t[tnum + 1] - x[i];

		diff[0] = max(sd[0], td[0]);
		diff[1] = max(sd[1], td[1]);


		if (snum >= 0 && tnum < B - 1) {
			if (sd[0] < td[1]) sd[0] *= 2;
			else td[1] *= 2;
			diff[2] = sd[0] + td[1];
		}

		if (tnum >= 0 && snum < A - 1) {
			if (td[0] < sd[1]) td[0] *= 2;
			else sd[1] *= 2;
			diff[3] = td[0] + sd[1];
		}

		cout << dec <<  min(diff[0], diff[1], diff[2], diff[3]) << endl;
	}
	





	return 0;



Compiler output:
a.cc:6:9: warning: "LONG_LONG_MAX" redefined
    6 | #define LONG_LONG_MAX 9223372036854775807LL
      |         ^~~~~~~~~~~~~
In file included from a.cc:4:
/usr/lib/gcc/x86_64-linux-gnu/14/include/limits.h:154:10: note: this is the location of the previous definition
  154 | # define LONG_LONG_MAX __LONG_LONG_MAX__
      |          ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:115:18: error: expected '}' at end of input
  115 |         return 0;
      |                  ^
a.cc:56:12: note: to match this '{'
   56 | int main() {
      |            ^
Language: C++

#include<iostream>
#include<string>
#include<cmath>

using namespace std;

// numの入る場所の前のindexを返す
int search(long *arr, int size, int num) {
	int left = 0;
	int right = size-1;
	int mid;

	if (arr[0] > num) return -1;
	if (arr[size - 1] < num) return size-1;

	while (right >= left) {
		mid = left + (right - left) / 2;
		if (arr[mid] == num) break;
		else if (arr[mid] > num) right = mid - 1;
		else if (arr[mid] < num) left = mid + 1;
	}

	if (arr[mid] < num)return mid;
	else return mid - 1;
}



long min(long a, long b, long c, long d) {
	if (a < b && a < c && a < d) return a;
	else if (b < c && b < d) return b;
	else if (c < d) return c;
	else return d;
}

long max(long a, long b) {
	if (a > b)return a;
	else return b;
}

long max(long a, long b, long c) {

	if (a > b && a > c) return a;
	else if (b > a && b > c) return b;
	else return c;
}

long max(long a, long b, long c, long d) {
	if (max(a, b, c) < d) return d;
	else return(max(a, b, c));
}

int main() {

	int A, B, Q;
	cin >> A >> B >> Q;

	long *s = new long[A];
	long *t = new long[B];
	long *x = new long[Q];

	for (int i = 0; i < A; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < B; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < Q; i++) {
		cin >> x[i];
	}


	int snum, tnum;
	long sd[2], td[2];
	long diff[4];
	for (int i = 0; i < Q; i++) {
		snum = search(s, A, x[i]);
		tnum = search(t, B, x[i]);

		sd[0] = sd[1] = td[0] = td[1] = LONG_MAX;
		diff[0] = diff[1] = diff[2] = diff[3] = LONG_MAX;

		if (snum >= 0) sd[0] = x[i] - s[snum];
		if (tnum >= 0) td[0] = x[i] - t[tnum];
		if (snum < A - 1) sd[1] = s[snum + 1] - x[i];
		if (tnum < B - 1) td[1] = t[tnum + 1] - x[i];

		diff[0] = max(sd[0], td[0]);
		diff[1] = max(sd[1], td[1]);


		if (snum >= 0 && tnum < B - 1) {
			if (sd[0] < td[1]) sd[0] *= 2;
			else td[1] *= 2;
			diff[2] = sd[0] + td[1];
		}

		if (tnum >= 0 && snum < A - 1) {
			if (td[0] < sd[1]) td[0] *= 2;
			else sd[1] *= 2;
			diff[3] = td[0] + sd[1];
		}

		cout << dec <<  min(diff[0], diff[1], diff[2], diff[3]) << endl;
	}
	





	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:80:49: error: 'LONG_MAX' was not declared in this scope
   80 |                 sd[0] = sd[1] = td[0] = td[1] = LONG_MAX;
      |                                                 ^~~~~~~~
a.cc:4:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include<cmath>
  +++ |+#include <climits>
    4 |
Language: C++

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

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
typedef long long ll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
}

int n,m;
int a, b, q;
const ll inf = 1LL<<58;


signed main(){
    cin >> a >> b >> q;
    vector<ll> s(a), t(b), x(q);

    rep(i, a){
        cin >> s[i];
    }
    rep(i,b){
        cin >> t[i];
    }

    s.push_back(-inf);s.push_back(inf);sort(s.begin(), s.end());
    t.push_back(-inf);t.push_back(inf);sort(t.begin(), t.end());

    for(int i = 0; i < q; ++i){
        cin >> x[i];
    }

    int sup, tup;
    for(int i = 0; i < q; ++i){
        long long kyori=inf;
        sup=lower_bound(s.begin(), s.end(), x[i])- s.begin();//=<のやつをみつける
        tup=lower_bound(t.begin(), t.end(), x[i])- t.begin();
        rep(j,2){
            rep(k,2){
                rep(l,2){
                    amin(kyori, j ? abs(t[tup-k]-x[i]) + abs(s[sup-l]-t[tup-k]) : abs(s[sup-k]-x[i]) + abs(s[sup-k]-t[tup-l]));
                }
            }
        }
        cc(kyori);
    }
}

Compiler output:
a.cc:11:1: error: expected declaration before '}' token
   11 | }
      | ^
Language: C++

#include<bits/stdc++.h>
#define INF 1e10
typedef long long llong;
using namespace std;

int main(){
	int a,b,q;
	cin>>a>>b>>q;
	llong s[1002],t[1002];
	for(int i=1;i<=a;++i) cin>>s[i];
	for(int i=1;i<=b;++i) cin>>t[i];
	s[0]=-INF,s[a+1]=INF;
	t[0]=-INF,t[b+1]=INF;
	
	REP(i,q){
		llong x;
		cin>>x;
		
		auto itr_s=lower_bound(s,s+a+1,x);
		auto itr_t=lower_bound(t,t+b+1,x);
		
		llong ans=INF; 
		ans=min(ans,max(*itr_s,*itr_t)-x);//最適の神社と寺がともに東にある時.
		ans=min(ans,x-min(*(itr_s-1),*(itr_t-1)));//最適の神社と寺がともに西にある時.
		ans=min(ans,*(itr_t)-*(itr_s-1)+min(x-*(itr_s-1),*(itr_t)-x));//西に神社、東に寺.
		ans=min(ans,*(itr_s)-*(itr_t-1)+min(x-*(itr_t-1),*(itr_s)-x));//西に寺、東に神社.
		
		cout<<ans<<endl;
	}
}//解説参考.

Compiler output:
a.cc: In function 'int main()':
a.cc:15:13: error: 'i' was not declared in this scope
   15 |         REP(i,q){
      |             ^
a.cc:15:9: error: 'REP' was not declared in this scope
   15 |         REP(i,q){
      |         ^~~
Language: C++

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

long long dist_modoru(long long x, long long s, long long t) {
  return min(abs(s - x), abs(t - x)) * 2 + max(abs(s - x), abs(t - x));
}

long long min(long long a, long long b) {
  if (a - b > 0)
    return b;
  else
    return a;
}

int main() {
  int A, B, Q;
  cin >> A >> B >> Q;
  long long s[A] + 1, t[B + 1], x;
  long long *si, *ti;
  long long ans;
  for (int i = 0; i < A; i++) cin >> s[i];
  s[A] = LLONG_MAX;
  for (int i = 0; i < B; i++) cin >> t[i];
  t[B] = LLONG_MAX;
  for (int i = 0; i < Q; i++) {
    // si = A - 1;
    // ti = B - 1;
    cin >> x;
    // while (s[si] > x) {
    //   si--;
    //   if (si < 0) {
    //     break;
    //   }
    // }
    si = lower_bound(s, s + (sizeof(s) / sizeof(long long)), x);
    //if (si == s + (sizeof(s) / sizeof(long long)) - 1 && *si > x) si = s - 1;

    // while (t[ti] > x) {
    //   ti--;
    //   if (ti < 0) {
    //     break;
    //   }
    // }
    ti = lower_bound(t, t + (sizeof(t) / sizeof(long long)), x);
    //if (ti == t + (sizeof(t) / sizeof(long long)) - 1 && *ti > x) ti = t - 1;
    ans = LLONG_MAX;
    if (si >= s && ti >= t) {
      ans = min(ans, max(x - *si, x - *ti));
    }
    if (si >= s && *(ti + 1) >= x) {
      ans = min(ans, dist_modoru(x, *si, *(ti + 1)));
    }
    if (*(si + 1) >= x && ti >= t) {
      ans = min(ans, dist_modoru(x, *(si + 1), *ti));
    }
    if (*(si + 1) >= x && *(ti + 1) >= x) {
      ans = min(ans, max(*(si + 1) - x, *(ti + 1) - x));
    }
    cout << ans << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:18: error: expected initializer before '+' token
   18 |   long long s[A] + 1, t[B + 1], x;
      |                  ^
a.cc:21:38: error: 's' was not declared in this scope
   21 |   for (int i = 0; i < A; i++) cin >> s[i];
      |                                      ^
a.cc:22:3: error: 's' was not declared in this scope; did you mean 'si'?
   22 |   s[A] = LLONG_MAX;
      |   ^
      |   si
a.cc:23:38: error: 't' was not declared in this scope
   23 |   for (int i = 0; i < B; i++) cin >> t[i];
      |                                      ^
a.cc:24:3: error: 't' was not declared in this scope; did you mean 'ti'?
   24 |   t[B] = LLONG_MAX;
      |   ^
      |   ti
a.cc:28:12: error: 'x' was not declared in this scope
   28 |     cin >> x;
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long s[100007],t[100007];
int main(){
    long long n,m,q;
    scanf("%lld%lld%lld",&n,&m,&q);
    for(int i=1;i<=n;i++)
        scanf("%lld",&s[i]);
    s[n+1]=1e18;
    s[0]=-1e18;
    sort(s,s+n+2);
    for(int i=1;i<=m;i++)
        scanf("%lld",&t[i]);
    t[m+1]=1e18;
    t[0]=-1e18;
    sort(t,t+m+2);
    long long x=0;
    long long tmp1=0,tmp2=0;
    long long ans=0;
    for(int i=1;i<=q;i++){
        scanf("%lld",&x);
        tmp1=lower_bound(s,s+n+2,x)-s;
        tmp2=lower_bound(t,t+m+2,x)-t;
        ans=1e18;
        for(int j=tmp1-1;j<tmp1+1;j++){
            for(int k=tmp2-1;k<tmp2+1;k++){
                ans=min(ans,labs(x-s[j])+labs(s[j]-t[k]););
                ans=min(ans,labs(x-t[k])+labs(s[j]-t[k]););
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:57: error: expected ')' before ';' token
   27 |                 ans=min(ans,labs(x-s[j])+labs(s[j]-t[k]););
      |                        ~                                ^
      |                                                         )
a.cc:27:58: error: expected primary-expression before ')' token
   27 |                 ans=min(ans,labs(x-s[j])+labs(s[j]-t[k]););
      |                                                          ^
a.cc:28:57: error: expected ')' before ';' token
   28 |                 ans=min(ans,labs(x-t[k])+labs(s[j]-t[k]););
      |                        ~                                ^
      |                                                         )
a.cc:28:58: error: expected primary-expression before ')' token
   28 |                 ans=min(ans,labs(x-t[k])+labs(s[j]-t[k]););
      |                                                          ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  int A,B,Q;
  cin >> A >> B >> Q;
  
  vector<int> jin(A+2);
  vector<int> tera(B+2);
  //int qu[Q];
  
  long long INF = std::pow(10, 18);
  
  jin[0] = -INF;
  jin[A+1] = INF;
    
  tera[0] = -INF;
  tera[B+1] = -INF;
  
  for (int i=1; i<A+1;i++){
    cin >> jin[i]
  }
  for (int i=1; i<B+1;i++){
    cin >> tera[i]
  }
  
  long long qu;
  int b,d;
  
  for (int i; i<Q;i++){
    //cin >> qu[i];
    cin >> qu;
    b = 
    d = 
    
  }
  
  int ans[a];
  for (int i; i<c;i++){
     int terad,teraa;
     int jindd,jinda,jinad,jinaa;
     for (int j; j<b;j++){
       if(tera[j]-qu[i]>0){
         
         
       }
  }
    
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:25:18: error: expected ';' before '}' token
   25 |     cin >> jin[i]
      |                  ^
      |                  ;
   26 |   }
      |   ~               
a.cc:28:19: error: expected ';' before '}' token
   28 |     cin >> tera[i]
      |                   ^
      |                   ;
   29 |   }
      |   ~                
a.cc:40:3: error: expected primary-expression before '}' token
   40 |   }
      |   ^
a.cc:42:11: error: 'a' was not declared in this scope
   42 |   int ans[a];
      |           ^
a.cc:43:17: error: 'c' was not declared in this scope
   43 |   for (int i; i<c;i++){
      |                 ^
a.cc:47:21: error: invalid types 'long long int[int]' for array subscript
   47 |        if(tera[j]-qu[i]>0){
      |                     ^
a.cc:53:4: error: expected '}' at end of input
   53 |   }
      |    ^
a.cc:8:12: note: to match this '{'
    8 | int main() {
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll A,B,Q;
int main(){
    cin >> A >> B >> Q;
    ll s[100100], t[100100], x;
    ll d[8];
    s[0] = -INF; s[A+1] = INF;
    t[0] = -INF; t[B+1] = INF;
    for(ll i = 1; i <= A; i++) cin >> s[i];
    for(ll i = 1; i <= B; i++) cin >> t[i];
    for(ll i = 0; i < Q; i++){
        cin >> x;
        ll* u = lower_bound(s,s+a+2,x);
        ll* v = lower_bound(t,t+b+2,x);

        d[0] = x - min(*(u-1), *(v-1));
        d[1] = x - *(u-1) + *v - *(u-1);
        d[2] = x - *(v-1) + *u - *(v-1);
        d[3] = max(*v,*u)-x;
        d[4] = *v - x + *v - *(u-1);
        d[5] = *u - x + *u - *(v-1);

        ll mini = d[0];
        for(ll j = 1; j <= 5; j++){
            mini = min(d[j], mini);
        }
        cout << mini << endl;
    }
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:26:33: error: 'a' was not declared in this scope
   26 |         ll* u = lower_bound(s,s+a+2,x);
      |                                 ^
a.cc:27:33: error: 'b' was not declared in this scope
   27 |         ll* v = lower_bound(t,t+b+2,x);
      |                                 ^
Language: Java

import java.util.*;

public class lazyfaith
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt(), b = in.nextInt(), q = in.nextInt();
        long[] s = new long[a], t = new long[b];
        
        for (int i = 0; i < a; i++)
            s[i] = in.nextLong();
        for (int i = 0; i < b; i++)
            t[i] = in.nextLong();
        for (int i = 0; i < q; i++)
        {
            long x = in.nextLong();
            int xs = nearer(x, s);
            int st = nearer(s[xs], t);
            long xst = Math.abs(s[xs] - x) + Math.abs(t[st] - s[xs]);
            int xt = nearer(x, t);
            int ts = nearer(t[xt], s);
            long xts = Math.abs(t[xt] - x) + Math.abs(s[ts] - t[xt]);
            System.out.println(Math.min(xst, xts));
        }
        
        in.close();
    }
    
    public static int nearer(long x, long[] a)
    {
        int lo = 0, hi = a.length-1, mid = 0;
        while (lo != hi)
        {
            mid = (lo + hi)/2;
            if (a[mid] > x) hi = mid - 1;
            else if (x - a[mid] < x + a[lo]) lo = mid + 1;
        }
        if (lo + 1 < a.length && Math.abs(x - a[lo+1]) < Math.abs(x - a[lo]))
                lo++;
        return lo;
    }
}

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

#include <iostream>
#include <vector>
#include <cmath>
int change(int ss,int tt,int xx);

int main(){
  int a,b,q;
  std::cin>>a>>b>>q;

  std::vector<long> s(a);
  std::vector<long> t(b);
  std::vector<long> x(q),ans(q);

  for (int i = 0; i < a; i++){
    std::cin>>s[i];
  }
  for (int i = 0; i < b; i++){
    std::cin>>t[i];
  }
  for (int i = 0; i < q; i++){
    std::cin>>x[i];
  }
  std::sort(s.begin(),s.end());
  std::sort(t.begin(),t.end());

  std::vector<int> amin(q);


  for(int i = 0; i < q; i++){
    int mins = 0;
    int mint = 0;
    int l = 0;
    int r = a-1;
    while (r-1 >= l) {
      int temp = (l+r)/2;
      if(s[temp] == x[i]){
          mins = temp;
      }else if(s[temp] < x[i]){
        l = temp+1;
      }else{
        r = temp;
      }
    }
    if(s[r] >= x[i] || r == a-1){
      mins = r;
    }else{
      mins = r+1;
    }

    int l1 = 0;
    int r1 = b-1;
    while (r1-1 >= l1) {
      int temp = (l1+r1)/2;
      if(s[temp] == x[i]){
          mint = temp;
      }else if(s[temp] < x[i]){
        l1 = temp+1;
      }else{
        r1 = temp;
      }
    }
    if(s[r1] >= x[i] || r1 == b-1){
      mint = r1;
    }else{
      mint = r1+1;
    }

    for(int j = 0; j < 4; j++){
      switch (j) {
        case 0:
          amin[i] = change(s[mins],t[mint],x[i]);
          break;
        case 1:
          if(mins > 0){
            amin[i] = std::min(amin[i],change(s[mins-1],t[mint],x[i]));
          }
          break;
        case 2:
          if(mint > 0){
            amin[i] = std::min(amin[i],change(s[mins],t[mint-1],x[i]));
          }
          break;
        case 3:
          if(mins > 0 && mint > 0){
            amin[i] = std::min(amin[i],change(s[mins-1],t[mint-1],x[i]));
          }
          break;

      }
      std::cout<<mins<<" "<<mint<<std::endl;

    }



  }

  for(int i = 0; i < q; i++){
    std::cout<<amin[i]<<std::endl;
  }

  return 0;


}


int change(int ss,int tt,int xx){
  if(ss-xx >= 0 && tt - xx >= 0 || ss-xx <= 0 && tt-xx <= 0){
    return std::max(std::abs(ss-xx),std::abs(tt-xx));
  }else{
    return std::max(std::abs(ss-xx),std::abs(tt-xx))+2*std::min(std::abs(ss-xx),std::abs(tt-xx));
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:8: error: 'sort' is not a member of 'std'; did you mean 'sqrt'?
   23 |   std::sort(s.begin(),s.end());
      |        ^~~~
      |        sqrt
a.cc:24:8: error: 'sort' is not a member of 'std'; did you mean 'sqrt'?
   24 |   std::sort(t.begin(),t.end());
      |        ^~~~
      |        sqrt
Language: C++

//解説読了後の実装
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;

vector<long long int> s;
vector<long long int> t;

// index が条件を満たすかどうか
bool isOKs(int index, long long key) {
    if (s[index] > key) return true;
    else return false;
}

bool isOKt(int index, long long key) {
    if (t[index] > key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
int binary_searchs(long long key) {
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = (int)s.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOKs(mid, key)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

int binary_searcht(long long key) {
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = (int)t.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOKt(mid, key)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}



int main(){
    int A,B,Q;

    cin>>A>>B>>Q;
    long long st,tt;
    for(int i=0;i<A;i++){
        cin>>st;
        s.push_back(st);
    }
    for(int i=0;i<B;i++){
        cin>>tt;
        t.push_back(tt);
    }

    long long x;
    for(int i=0;i<Q;i++){
        cin>>x;
        int idxs = binary_searchs(x);        
        int idxt = binary_searcht(x);

        long long answer=1000000000000000000;
        for(int j = idxs - 1;j <= idxs; j++){
            for(int k = idxt - 1;k <= idxt; k++){
                if(j >= s.size() || k >= t.size()) continue;
                long long d1 = abs(s[j] - x) + abs(t[k] - s[j]);
                long long d2 = abs(t[k] - x) + abs(s[j] - t[k]);
                min({answer, d1, d2})
            }
        }
        cout<<answer<<endl;
    }
    return 0;    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:83:38: error: expected ';' before '}' token
   83 |                 min({answer, d1, d2})
      |                                      ^
      |                                      ;
   84 |             }
      |             ~
Language: C++

//解説読了後の実装
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;

vector<long long int> s;
vector<long long int> t;

// index が条件を満たすかどうか
bool isOKs(int index, long long key) {
    if (s[index] > key) return true;
    else return false;
}

bool isOKt(int index, long long key) {
    if (t[index] > key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
int binary_searchs(long long key) {
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = (int)s.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOKs(mid, key)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

int binary_searcht(long long key) {
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = (int)t.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOKt(mid, key)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}



int main(){
    int A,B,Q;

    cin>>A>>B>>Q;
    long long st,tt;
    for(int i=0;i<A;i++){
        cin>>st;
        s.push_back(st);
    }
    for(int i=0;i<B;i++){
        cin>>tt;
        t.push_back(tt);
    }

    long long x;
    for(int i=0;i<Q;i++){
        cin>>x;
        int idxs = binary_searchs(x);        
        int idxt = binary_searcht(x);

        long long answer=1000000000000000000;
        for(int j = idxs - 1;j <= idxs; j++){
            for(int k = idxt - 1;k <= idxt; k++){
                if(j >= s.size() || k >= t.size()) continue;
                long long d1 = abs(s[j] - x) + abs(t[k] - s[j]);
                long long d2 = abs(t[k] - x) + abs(s[j] - t[k]);
                if answer > d1 answer = d1;
                if answer > d2 answer = d2;
            }
        }
        cout<<answer<<endl;
    }
    return 0;    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:83:20: error: expected '(' before 'answer'
   83 |                 if answer > d1 answer = d1;
      |                    ^~~~~~
      |                    (
a.cc:84:20: error: expected '(' before 'answer'
   84 |                 if answer > d2 answer = d2;
      |                    ^~~~~~
      |                    (
Language: C++

//解説読了後の実装
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

vector<long long int> s;
vector<long long int> t;

// index が条件を満たすかどうか
bool isOKs(int index, int key) {
    if (s[index] > key) return true;
    else return false;
}

bool isOKt(int index, int key) {
    if (t[index] > key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
int binary_searchs(int key) {
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = (int)s.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOKs(mid, key)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

int binary_searcht(int key) {
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = (int)t.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOKt(mid, key)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}



int main(){
    int A,B,Q;

    cin>>A>>B>>Q;
    long long st,tt;
    for(int i=0;i<A;i++){
        cin>>st;
        s.push_back(st);
    }
    for(int i=0;i<B;i++){
        cin>>tt;
        t.push_back(tt);
    }

    long long x;
    for(int i=0;i<Q;i++){
        cin>>x;
        int idxs = binary_searchs(x);        
        int idxt = binary_searcht(x);

        long long answer=1000000000000000000;
        for(int j = idxs - 1;j <= idxs; j++){
            for(int k = idxt - 1;k <= idxt; k++){
                if(j < 0 || k < 0) continue;
                long long d1, d2 = abs(s[j] - x) + abs(t[k] - s[j]), abs(t[k] - x) + abs(s[j] - t[k]);
                answer = min({answer, d1, d2});
            }
        }
        cout<<answer<<endl;
    }
    
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:80:84: error: expected ',' or ';' before '+' token
   80 |                 long long d1, d2 = abs(s[j] - x) + abs(t[k] - s[j]), abs(t[k] - x) + abs(s[j] - t[k]);
      |                                                                                    ^
Language: C++

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,q,x;
    cin>>a>>b>>q;
    ll s[a+2],t[b+2];
    s[a+1]=1e16;
    t[b+1]=1e16;
    s[0]=-s[a+1];
    t[0]=s[0];
    for(int i=1;i<=a;i++){
        cin>>s[i];
    }
    for(int i=1;i<=b;i++){
        cin>>t[i];
    }
    for(int i=0;i<q;i++){
        cin>>x;
        ll c=lower_bound(s,s+a+2,x);
        ll d=lower_bound(t,t+b+2,x);
        ll ans1,ans2,ans3;
        ans1=min(s[c]*2-x-t[d-1],s[c]+x-t[d-1]*2)-s;
        ans2=min(s[d]*2-x-t[c-1],s[d]+x-t[c-1]*2)-t;
        ans3=min(max(s[c],t[d])-x,x-min(s[c-1],t[d-1]));
        ans1=min(ans1,ans2);
        cout << min(ans1,ans3)<<endl;
    }
    return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:25:25: error: invalid conversion from 'long long int*' to 'll' {aka 'long long int'} [-fpermissive]
   25 |         ll c=lower_bound(s,s+a+2,x);
      |              ~~~~~~~~~~~^~~~~~~~~~~
      |                         |
      |                         long long int*
a.cc:26:25: error: invalid conversion from 'long long int*' to 'll' {aka 'long long int'} [-fpermissive]
   26 |         ll d=lower_bound(t,t+b+2,x);
      |              ~~~~~~~~~~~^~~~~~~~~~~
      |                         |
      |                         long long int*
a.cc:28:50: error: invalid operands of types 'const long long int' and 'll [(a + 2)]' {aka 'long long int [(a + 2)]'} to binary 'operator-'
   28 |         ans1=min(s[c]*2-x-t[d-1],s[c]+x-t[d-1]*2)-s;
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
      |                 |                                 |
      |                 const long long int               ll [(a + 2)] {aka long long int [(a + 2)]}
a.cc:29:50: error: invalid operands of types 'const long long int' and 'll [(b + 2)]' {aka 'long long int [(b + 2)]'} to binary 'operator-'
   29 |         ans2=min(s[d]*2-x-t[c-1],s[d]+x-t[c-1]*2)-t;
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
      |                 |                                 |
      |                 const long long int               ll [(b + 2)] {aka long long int [(b + 2)]}
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int solve(int x, vi s, vi t) {
    vi fir, sec, ans;
    rep(i, 2) {
        if (i==0) {
            fir = s;
            sec = t;
        } else {
            fir = t;
            sec = s;
        }
        rep(j, 2) {
            int fir_pos = *(lower_bound(all(fir), x) - j);
            rep(k, 2) {
                int sec_pos = *(lower_bound(all(sec), fir_pos) - k);
                ans.pb(abs(fir_pos - x) + abs(fir_pos - sec_pos));
            }
        }
    }
    return *min_element(all(ans));
}

signed main(void) {
    int A, B, Q;
    cin >> A >> B >> Q;
    vi s;
    vi t;
    rep(i, A) {
        int tmp; cin >> tmp;a
        s.pb(tmp);
    }
    rep(i, B) {
        int tmp; cin >> tmp;
        t.pb(tmp);
    }

    s.pb(-INF);
    s.pb(INF);
    t.pb(-INF);
    t.pb(INF);

    sort(all(s));
    sort(all(t));

    rep(i, Q) {
        int x; cin >> x;
        cout << solve(x, s, t) << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:29: error: 'a' was not declared in this scope
   48 |         int tmp; cin >> tmp;a
      |                             ^
Language: C++

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, q;
	cin >> a >> b >> q;
	vll s(a), t(b);
	rep(i, a) cin >> s[i];
	rep(i, b) cin >> t[i];
	s.pb(1e11);
	s.insert(s.begin(), -1e11);
	t.pb(1e11);
	t.insert(t.begin(), -1e11);
	rep(i, q){
		ll ans = LONG_LONG_MAX;
		ll x; cin>>x;
		ll S[2], T[2];
		ll left, right;
		right = upper_bound(s.begin(), s.end(), x);
		left = right-1;
		S[0] = s[left], S[1] = s[right];
		right = upper_bound(t.begin(), t.end(), x);
		left = right-1;
		T[0] = t[left], T[1] = t[right];
		rep(j, 2){
			rep(k, 2){
				ll mini, sum=0;
				mini = min(abs(x-S[j]), abs(x-T[k]));
				sum = mini + abs(S[j]-T[k]);
				ans = min(ans, sum);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:36: error: cannot convert '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'long long int' in assignment
   42 |                 right = upper_bound(s.begin(), s.end(), x);
      |                         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
      |                                    |
      |                                    __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >
a.cc:45:36: error: cannot convert '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'long long int' in assignment
   45 |                 right = upper_bound(t.begin(), t.end(), x);
      |                         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
      |                                    |
      |                                    __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >
Language: C++


#include <iostream>
#include <string>
#include <vector>
#include <limits>

using namespace std;
void tbd(){

    string s; cin >> s;
    int month = stoi( s.substr(5,2) );
    int day = stoi( s.substr(8,2) );
    if (month >= 5){
        cout << "TBD" << endl;
    }else{
        cout << "Heisei" << endl;
    }

}

void gift(){
    int N; cin >> N;
    double bit_sum = 0.0;
    int jpy_sum = 0;

    for(int i= 0; i < N; i++){
        string x_i,u_i; cin >> x_i >> u_i;

        if( u_i == "JPY"){
            jpy_sum += stoi(x_i);
        }else if( u_i == "BTC"){
            bit_sum += stod(x_i);
        }
    }

    double ans;
    ans = 380000.0 * bit_sum + static_cast<double>(jpy_sum);

    cout << ans;



}

template<typename T>
pair<T, T> find(T x, const vector<T>& vec, int st, int ed){

    if(x < vec[st])
        return {-1,0};
    if( vec[ed] < x)
        return {ed, -1};

    while(ed - st > 1){

        int mid = (ed + st)/2;
        if(vec[mid] > x ){
            ed = mid;
        }else{
            st = mid;
        }
    }

    return {st, ed};

}


long long find_min(long long x, const vector<long long>& s_vec, const vector<long long>& t_vec, int A, int B){
    auto s_pair = find(x, s_vec, 0, A-1);
    auto t_pair = find(x, t_vec, 0, B-1);

    long long ss[2] = {s_pair.first, s_pair.second};
    long long tt[2] = {t_pair.first, t_pair.second};

    long long ans = numeric_limits<long long>::max();

    for(int i = 0; i<2; i++) {
        if (ss[i] == -1 )
            continue;
        for (int j = 0; j < 2; j++) {
            if (tt[j] == -1)
                continue;
            long long to_s = abs(x - s_vec[ss[i]]);
            long long to_t = abs(x - t_vec[tt[j]]);

            if (i == j) {//同じ方角
                long long dist = max(to_s, to_t);
                ans = (ans < dist) ? ans : dist;
            } else {
                long long dist;
                if (to_s > to_t){
                    dist = 2 * to_t + to_s;
                } else {
                    dist = 2 * to_s + to_t;
                }
                ans = (ans < dist) ? ans : dist;
            }


        }
    }

    return ans;

}

void lazy(){

    int A,B,Q; cin >> A >> B >> Q;
    vector<long long> s_vec(A);
    vector<long long> t_vec(B);
    vector<long long> x_vec(Q);
    for(int i = 0; i < A; i++){
        cin >> s_vec[i];
    }
    for(int i = 0; i < B; i++){
        cin >> t_vec[i];
    }
    for(int i = 0; i < Q; i++){
        cin >> x_vec[i];
    }

    sort(s_vec.begin(), s_vec.end() );
    sort(t_vec.begin(), t_vec.end() );
    for(int i = 0; i < Q; i++){
        cout << find_min(x_vec[i], s_vec, t_vec, A, B) << endl;
    }
}

int main(){

    lazy();
    return 0;
}

Compiler output:
a.cc: In function 'void lazy()':
a.cc:123:5: error: 'sort' was not declared in this scope; did you mean 'short'?
  123 |     sort(s_vec.begin(), s_vec.end() );
      |     ^~~~
      |     short
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
int sway[10000000001];
int tway[10000000001];
int main(){
  ll a,b,q;
  cin >> a >> b >> q;
  vector<ll> s(a);
  vector<ll> t(b);
  vector<ll> x(q);
  for(ll i = 0;i < a;i++){
    cin >> s[i];
    sway[s[i]]=1;
  }
  for(ll i = 0;i < b;i++){
    cin >> t[i];
    tway[t[i]]=1;
  }
  ll smallest = min(t[0],s[0]);
  ll biggest = max(t[b-1],s[a-1]);
  for(ll i = 0;i < q;i++){
    ll nears,neart,es,et;
    nears = a/2;
    neart = b/2;
    ll answer;
    cin >> x[i];
    ll X = x[i];
    bool rights,rightt;
    while(X >= smallest && (rights == false || rightt == false)){
        if(tway[x[i]] == 1) rightt = true;
        if(sway[x[i]] == 1) rights = true;
        if(rights == false || rightt == false) --X;
        answer++;
    }
    if(rights ==  false || rightt == false) answer = 15000000000;
    ll answer2;
    rightt = rights = false;
    X = x[i];
    while(X >= smallest && biggest >= X && (rights == false || rightt == false)){
        if(tway[x[i]] == 1) rightt = true;
        if(sway[x[i]] == 1) rights = true;
        if(rights == false && rightt == false) --X;
        else if(rightt == true || rights == true) ++X;
        answer2++;
    }
    if(rights ==  false || rightt == false) answer2 = 15000000000;
    answer = min(answer,answer2);
    rightt = rights = false;
    X = x[i];
    while(X >= smallest && biggest >= X && (rights == false || rightt == false)){
        if(tway[x[i]] == 1) rightt = true;
        if(sway[x[i]] == 1) rights = true;
        if(rights == false && rightt == false) ++X;
        else if(rightt == true || rights == true) --X;
        answer2++;
    }
    if(rights ==  false || rightt == false) answer2 = 15000000000;
    answer = min(answer,answer2);
    rightt = rights = false;
    X = x[i];
    while(X >= smallest && biggest >= X && (rights == false || rightt == false)){
        if(tway[x[i]] == 1) rightt = true;
        if(sway[x[i]] == 1) rights = true;
        if(rightt == true || rights == true) ++X;
        answer2++;
    }
    if(rights ==  false || rightt == false) answer2 = 10000000000;
    answer = min(answer,answer2);
    cout << answer << endl;
  }
}


Compiler output:
/tmp/ccEqcpP1.o: in function `main':
a.cc:(.text+0x1b4): relocation truncated to fit: R_X86_64_PC32 against symbol `tway' defined in .bss section in /tmp/ccEqcpP1.o
a.cc:(.text+0x308): relocation truncated to fit: R_X86_64_PC32 against symbol `tway' defined in .bss section in /tmp/ccEqcpP1.o
a.cc:(.text+0x411): relocation truncated to fit: R_X86_64_PC32 against symbol `tway' defined in .bss section in /tmp/ccEqcpP1.o
a.cc:(.text+0x560): relocation truncated to fit: R_X86_64_PC32 against symbol `tway' defined in .bss section in /tmp/ccEqcpP1.o
a.cc:(.text+0x6af): relocation truncated to fit: R_X86_64_PC32 against symbol `tway' defined in .bss section in /tmp/ccEqcpP1.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
int sway[10000000001];
int tway[10000000001];
int main(){
  ll a,b,q;
  cin >> a >> b >> q;
  vector<ll> s(a);
  vector<ll> t(b);
  vector<ll> x(q);
  for(ll i = 0;i < a;i++){
    cin >> s[i];
    sway[s[i]]=1;
  }
  for(ll i = 0;i < b;i++){
    cin >> t[i];
    tway[t[i]]=1;
  }
  ll smallest = min(t[0],s[0]);
  ll biggest = max(t[b-1],s[a-1]);
  for(ll i = 0;i < q;i++){
    ll nears,neart,es,et;
    nears = a/2;
    neart = b/2;
    ll answer;
    cin >> x[i];
    ll X = x[i];
    bool rights,rightt;
    while(X >= smalllest && (rights == false || rightt == false)){
        if(tway[x[i]] == 1) rightt = true;
        if(sway[x[i]] == 1) rights = true;
        if(rights == false || rightt == false) --X;
        answer++;
    }
    if(rights ==  false || rightt == false) answer = 15000000000;
    ll answer2;
    rightt = rights = false;
    X = x[i];
    while(X >= smallest && biggest >= X && (rights == false || rightt == false)){
        if(tway[x[i]] == 1) rightt = true;
        if(sway[x[i]] == 1) rights = true;
        if(rights == false && rightt == false) --X;
        else if(rightt == true || rights == true) ++X;
        answer2++;
    }
    if(rights ==  false || rightt == false) answer2 = 15000000000;
    answer = min(answer,answer2);
    rightt = rights = false;
    X = x[i];
    while(X >= smallest && biggest >= X && (rights == false || rightt == false)){
        if(tway[x[i]] == 1) rightt = true;
        if(sway[x[i]] == 1) rights = true;
        if(rights == false && rightt == false) ++X;
        else if(rightt == true || rights == true) --X;
        answer2++;
    }
    if(rights ==  false || rightt == false) answer2 = 15000000000;
    answer = min(answer,answer2);
    rightt = rights = false;
    X = x[i];
    while(X >= smallest && biggest >= X && (rights == false || rightt == false)){
        if(tway[x[i]] == 1) rightt = true;
        if(sway[x[i]] == 1) rights = true;
        if(rightt == true || rights == true) ++X;
        answer2++;
    }
    if(rights ==  false || rightt == false) answer2 = 10000000000;
    answer = min(answer,answer2);
    cout << answer << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:16: error: 'smalllest' was not declared in this scope; did you mean 'smallest'?
   30 |     while(X >= smalllest && (rights == false || rightt == false)){
      |                ^~~~~~~~~
      |                smallest
Language: C++

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

main(){
	int a,b,q;
	cin >> a >> b >> q;
	int s[a],t[q],mix[a+b][2];
	long long int x[q];
	for(int i=0;i<a;i++){
		cin >> s[i];
	}
	for(int i=0;i<b;i++){
		cin >> t[i];
	}
	for(int i=0;i<q;i++){
		cin >> x[i];
	}

	int now_s=0;
	int now_t=0;
	long long int now=0;
	for(int i=0;i<a+b;i++){
		if(s[now_s]<t[now_t]){
			mix[i][0]=s[now_s];
			if(now_t==b-1){
				mix[i][1]=s[now_s]-t[now_t];
			}else if(labs(s[now_s]-t[now_t])<labs(t[now_t+1]-s[now_s])){
				mix[i][1]=labs(s[now_s]-t[now_t]);
			}else{
				mix[i][1]=labs(t[now_t+1]-s[now_s]);
			}
			if(now_s<a-1){//sの範囲内か？
				now_s++;
			}
			
		}else{
			mix[i][0]=t[now_t];
			if(now_s==a-1){
				mix[i][1]=t[now_t]-s[now_s];
			}else if(labs(t[now_t]-s[now_s])<labs(s[now_s+1]-t[now_t])){
				mix[i][1]=labs(t[now_t]-s[now_s]);
			}else{
				mix[i][1]=labs(s[now_s+1]-t[now_t]);
			}
			if(now_t<b-1){//sの範囲内か？
				now_t++;
			}
		}
	}

	for(int i=0;i<q;i++){
		long long int first=LLONG_MAX;
		long long int ans;
		for(int z=0;z<a+b;z++){
			if(first>labs(mix[i][0])){
				ans=labs(mix[i][0])+mix[i][1];
			}
		}
	}
	cout << ans << endl;

}




Compiler output:
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:53:37: error: 'LLONG_MAX' was not declared in this scope
   53 |                 long long int first=LLONG_MAX;
      |                                     ^~~~~~~~~
a.cc:3:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <cstdlib>
  +++ |+#include <climits>
    3 | using namespace std;
a.cc:61:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   61 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
using namespace std;
vector<vector<long long> > vec2d_init(long long x_len, long long y_len){
    vector<vector<long long> > vec(y_len, vector<long long>(x_len, 0));
    return vec;
}
vector<vector<long long> > vec2d_sort(vector<vector<long long> > vec, long long x_len, long long y_len, long long index){
    sort(vec.begin(), vec.end(), [index](const vector <long long>  a, const vector <long long> b){return (a[index] < b[index]);});
    return vec;
}
void vec2d_show(vector<vector<long long> > vec){
    for(int i = 0; i < vec.size(); i++){
        for(int j = 0; j < vec[0].size(); j++){
            cout << vec[i][j] << " ";
        }
        cout << endl;
    }
}
int main(){
    int a, b, q;
    cin >> a >> b >> q;
    long long x[q];

    auto vec = vec2d_init(2, a+b);
    for(int i = 0; i < a; i++){
        cin >> vec[i][0];
        vec[i][1] = 0;
    }
    for(int i = 0; i < b; i++){
        cin >> vec[i+a][0];
        vec[i+a][1] = 1;
    }
    for(int i = 0; i < q; i++){
        cin >> x[i];
    }
    vec = vec2d_sort(vec, 2, a+b, 0);
    auto vec2 = vec2d_init(2, a+b);
    for(int i = 0; i < a+b; i++){
        vec2[i][0] = vec[i][0];
        // search left
        long long left = i;
        long long left_dist = 100000000000;
        bool left_end = false;
        while(left_end == false){
            if(left > 0){
                left--;
                if(vec[left][1] != vec[i][1]){
                    left_dist = vec[i][0] - vec[left][0];
                    left_end = true;
                }
            }else{
                break;
            }
        }
        long long right = i;
        long long right_dist = 100000000000;
        bool right_end = false;
        while(right_end == false){
            if(right < a+b-1){
                right++;
                if(vec[right][1] != vec[i][1]){
                    right_dist = vec[right][0] - vec[i][0];
                    right_end = true;
                }
            }else{
                break;
            }
        }
        vec2[i][1] = min(left_dist, right_dist);
    }

    for(int i = 0; i < q; i++){
        c1 = 100000000000;
        c2 = 100000000000;
        for(j = 0; j < a+b; j++){
            if(vec2[j][0] > x[q]){
                if(j > 0){
                    c1 = x[j-1] - vec2[j-1][0] + vec2[j-1][1];
                }
                if(j < a+b-1){
                    c2 = x[j] - vec2[j][0] + vec2[j][1];

                }
            }
            cout << min(c1, c2) << endl;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:79:9: error: 'c1' was not declared in this scope; did you mean 'y1'?
   79 |         c1 = 100000000000;
      |         ^~
      |         y1
a.cc:80:9: error: 'c2' was not declared in this scope
   80 |         c2 = 100000000000;
      |         ^~
a.cc:81:13: error: 'j' was not declared in this scope
   81 |         for(j = 0; j < a+b; j++){
      |             ^
Language: C++

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

main(){
	int a,b,q;
	cin >> a >> b >> q;
	int s[a],t[q],mix[a+b][2];
	for(int i=0;i<a;i++){
		cin >> s[i];
	}
	for(int i=0;i<b;i++){
		cin >> t[i];
	}
	for(int i=0;i<q;i++){
		cin >> x[i];
	}

	int now_s=0;
	int now_t=0;
	long long int now=0;
	for(int i=0;i<a+b;i++){
		if(s[now_s]<t[now_t]){
			mix[i][0]=s[now_s];
			if(now_t==b-1){
				mix[i][1]=s[now_s]-t[now_t];
			}else if(labs(s[now_s]-t[now_t])<labs(t[now_t+1]-s[now_s])){
				mix[i][1]=labs(s[now_s]-t[now_t]);
			}else{
				mix[i][1]=labs(t[now_t+1]-s[now_s]);
			}
			if(now_s<a-1){//sの範囲内か？
				now_s++;
			}
			
		}else{
			mix[i][0]=t[now_t];
			if(now_s==a-1){
				mix[i][1]=t[now_t]-s[now_s];
			}else if(labs(t[now_t]-s[now_s])<labs(s[now_s+1]-t[now_t])){
				mix[i][1]=labs(t[now_t]-s[now_s]);
			}else{
				mix[i][1]=labs(s[now_s+1]-t[now_t]);
			}
			if(now_t<b-1){//sの範囲内か？
				now_t++;
			}
		}
	}

	for(int i=0;i<q;i++){
		long long int first=LLONG_MAX;
		long long int ans;
		for(int z=0;z<a+b;z++){
			if(first>labs(mix[i][0])){
				ans=labs(mix[i][0])+mix[i][1];
			}
		}
	}
	cout << ans << endl;

}




Compiler output:
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:16:24: error: 'x' was not declared in this scope
   16 |                 cin >> x[i];
      |                        ^
a.cc:52:37: error: 'LLONG_MAX' was not declared in this scope
   52 |                 long long int first=LLONG_MAX;
      |                                     ^~~~~~~~~
a.cc:3:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <cstdlib>
  +++ |+#include <climits>
    3 | using namespace std;
a.cc:60:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   60 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
const ll INF=1e16+7;
ll minlen(ll s,ll t,ll x){
	if(s<=x&&t<=x)return max(abs(s-x),abs(t-x));
	else if(s>=x&&t>=x)return max(abs(s-x),abs(t-x));
	else return min(abs(s-x),abs(t-x))*2+max(abs(s-x),abs(t-x));
}
int main(){
	ll A,B,Q,x,S[2],T[2];
	cin >> A >> B >> Q;
	vector<ll> s(A+2),t(B+2);
	FOR(i,0,A)cin>>s[i+1];
	FOR(i,0,B)cin>>t[i+1];
	s[0] = -INF; s[A+1] = INF;
	t[0] = -INF; t[A+1] = INF;
	FOR(i,0,Q){
		cin >> x;
		FOR(j,0,2)S[j] = s[POSL(s,x)-j];
		FOR(j,0,2)T[j] = t[POSL(t,x)-j];
		ll ans = INF;
		FOR(j,0,2)FOR(k,0,2)ans = min(ans,minlen(S[j],T[k],x));
		cout << ans << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:36: error: 'POSL' was not declared in this scope
   21 |                 FOR(j,0,2)S[j] = s[POSL(s,x)-j];
      |                                    ^~~~
a.cc:22:36: error: 'POSL' was not declared in this scope
   22 |                 FOR(j,0,2)T[j] = t[POSL(t,x)-j];
      |                                    ^~~~