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

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

vector<long> s,t;

long INF = 1e16+7;

int A,B,Q;
int main () {
    cin >> A >> B >> Q;
    for(int i=0;i<A;i++) {
        long x;
        cin>>x;
        s.push_back(x);
    }
    for(int i=0;i<B;i++) {
        long x;
        cin>>x;
        t.push_back(x);
    }
    s.push_back(-INF);s.push_back(INF);
    t.push_back(-INF);t.push_back(INF);
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    while(Q--) {
        long x;
        cin >> x;
        auto itr = lower_bound(s.begin(),s.end(),x);
        long rs = (*itr),ls = *prev(itr);
        itr = t.lower_bound(t.begin(),t.end(),x); // itr
        long rt = (*itr),lt = *prev(itr);
        long res = INF;
        for(int i=0;i<2;i++) {
            for(int j=0;j<2;j++) {
                res = min( res, (i ? ls : rs) + (j ? lt : rt));
            }
        }
        cout << res << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:17: error: 'class std::vector<long int>' has no member named 'lower_bound'
   46 |         itr = t.lower_bound(t.begin(),t.end(),x); // itr
      |                 ^~~~~~~~~~~
Language: C++

// submissions/4370350 

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,m,q;
    cin>>n>>m>>q;
    vector<ll> t,s;
    t.push_back(-longinf);
    s.push_back(-longinf);
    rep(i,n){
        ll x;
        cin>>x;
        t.push_back(x);
    }
    rep(i,m){
        ll x;
        cin>>x;
        s.push_back(x);
    }
    t.push_back(longinf);
    s.push_back(longinf);
    while(q--){
        ll cur;
        cin>>cur;
        auto itr=lower_bound(t.begin(),t.end(),cur); // CE conflicting declaration ?
        ll lt=*prev(itr),rt=*itr;
        itrx=lower_bound(s.begin(),s.end(),cur);
        ll ls=*prev(itr),rs=*itr;
        ll ans=min(max(rt,rs)-cur,cur-min(ls,lt));
        ans=min(ans,rt-ls+min(rt-cur,cur-ls));
        ans=min(ans,rs-lt+min(rs-cur,cur-lt));
        cout<<ans<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:9: error: 'itrx' was not declared in this scope; did you mean 'itr'?
   52 |         itrx=lower_bound(s.begin(),s.end(),cur);
      |         ^~~~
      |         itr
Language: C++

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

vector<long> s,t;

long INF = 1e16+7;

int A,B,Q;
int main () {
    cin >> A >> B >> Q;
    for(int i=0;i<A;i++) {
        long x;
        cin>>x;
        s.push_back(x);
    }
    for(int i=0;i<B;i++) {
        long x;
        cin>>x;
        t.push_back(x);
    }
    s.push_back(-INF);s.push_back(INF);
    t.push_back(-INF);t.push_back(INF);
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    while(Q--) {
        long x;
        cin >> x;
        auto itr = lower_bound(s.begin(),s.end(),x);
        long rs = (*itr);
        long ls = *prev(itr);
        auto itr = t.lower_bound(t.begin(),t.end(),x);
        long rt = (*itr);
        long lt = *prev(itr);
        long res = INF;
        for(int i=0;i<2;i++) {
            for(int j=0;j<2;j++) {
                res = min( res, (i ? ls : rs) + (j ? lt : rt));
            }
        }
        cout << res << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:14: error: conflicting declaration 'auto itr'
   33 |         auto itr = t.lower_bound(t.begin(),t.end(),x);
      |              ^~~
a.cc:30:14: note: previous declaration as '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> > itr'
   30 |         auto itr = lower_bound(s.begin(),s.end(),x);
      |              ^~~
a.cc:33:22: error: 'class std::vector<long int>' has no member named 'lower_bound'
   33 |         auto itr = t.lower_bound(t.begin(),t.end(),x);
      |                      ^~~~~~~~~~~
Language: C++

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

int main(){
  int a, b, q;
  cin >> a >> b >> q;
  vector<ll>s(a);
  vector<ll>t(b);
  vector<ll>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];
  
  for(int i=0; i<q; ++i){
    ll min1 =0;
    for(int j=0; j<a; ++j){
      for(int k=0; k<b; ++k){
        min1=min(abs(s[j]-x[i])+abs(t[k]-s[j]), min1);
      }
    }
    cout << min1 << endl;
  }
}
        

Compiler output:
a.cc: In function 'int main()':
a.cc:11:22: error: expected ';' before 'i'
   11 |   for(int i=0; i<a ++i)cin >> s[i];
      |                      ^
      |                      ;
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
	int A,B,Q;cin>>A>>B>>Q;
	vector<ll> S(A),T(B),X(Q);
	rep(i,A)cin>>S[i];
	sort(all(S));
	rep(i,B)cin>>T[i];
	sort(all(T));
	rep(i,Q)cin>>X[i];
	rep(i,Q){
		ll q = X[i];
		ll ls = lower_bound(S.begin(), S.end(),q)-S.begin()-1;
		ll rs = lower_bound(S.begin(), S.end(),q)-S.begin();
		ll lt = lower_bound(T.begin(), T.end(),q)-1-T.begin();
		ll rt = lower_bound(T.begin(), T.end(),q)-T.begin();
		ll ans = LINF;
		if(ls>=0&&lt>=0)ans = min(ans,abs(q-lmin(S[ls],T[lt])));
		if(rs<S.size()&&rt<T.size())ans = min(ans,abs(q-max(S[rs],T[rt])));
		if(rs<S.size()&&lt>=0){
			ans = min(ans,abs(q-S[rs])+abs(q-T[lt])*2);
			ans = min(ans,abs(q-S[rs])*2+abs(q-T[lt]));
		}
		if(ls>=0&&rt<T.size()){
			ans = min(ans,abs(q-T[rt])+abs(q-S[ls])*2);
			ans = min(ans,abs(q-T[rt])*2+abs(q-S[ls]));
		}
		cout << ans << endl;
	}
}



Compiler output:
a.cc: In function 'int main()':
a.cc:60:53: error: 'lmin' was not declared in this scope; did you mean 'fmin'?
   60 |                 if(ls>=0&&lt>=0)ans = min(ans,abs(q-lmin(S[ls],T[lt])));
      |                                                     ^~~~
      |                                                     fmin
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	lli a,b,q;
	cin>>a>>b>>q;

	vector<lli> s,t;
	s.resize(a);
	t.resize(b);

	REP(i,0,a)cin>>s[i];
	s[a]=INF;
	REP(i,0,b)cin>>t[i];
	t[b]=INF;
	REP(i,0,q){
		lli target;
		cin>>target;
		vector<lli> v[2];
		/*targetに近いs2点*/
		auto itr = lower_bound(s.begin(),s.end(),target);
		if(itr!=s.end())v[0].push_back(*itr);
		if(itr!=s.begin())v[0].push_back(*(itr-1));

		itr = lower_bound(t.begin(),t.end(),target);
		if(itr!=t.end())v[1].push_back(*itr);
		if(itr!=t.begin())v[1].push_back(*(itr-1));
		
		lli ans=INF;
		for(auto e0:v[0])for(auto e1:v[1]){
			ans = min(ans,min(abs(target-e0)+abs(target(e0-e1)), abs(target-e1)+abs(e1-e0)));
		}
		cout<<ans<<endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:68: error: 'target' cannot be used as a function
   38 |                         ans = min(ans,min(abs(target-e0)+abs(target(e0-e1)), abs(target-e1)+abs(e1-e0)));
      |                                                              ~~~~~~^~~~~~~
Language: C++

#include <iostream>
using namespace std;
int A,B,Q;
long long stop=20000000002,s[100001],t[100001],x[100001];
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){
  if(a<b)return a;else return b;
}
int jinja(long long p){
  int i=A/2,j=A/4;
  while(j>5){
    if(s[i]<p && p<s[i+1])return i;
    if(p<s[i])i-=j;else i+=j;
    j/=2;
  }
  while(1){
    if(s[i]<p && p<s[i+1])return i;
    if(p<s[i])i-=1;else i+=1;
  }
}
int tera(long long p){
  int i=B/2,j=B/4;
  while(j>5){
    if(t[i]<p && p<t[i+1])return i;
    if(p<t[i])i-=j;else i+=j;
    j/=2;
  }
  while(1){
    if(t[i]<p && p<t[i+1])return i;
    if(p<t[i])i-=1;else i+=1;
  }
}
int main() {
  cin >> A >> B >> Q ;
  for(int i=1;i<=A;i++)cin >>s[i];
  for(int i=1;i<=B;i++)cin >>t[i];
  for(int i=1;i<=Q;i++)cin >>x[i];
  s[A+1]=stop;t[B+1]=stop;
  s[0]=-stop;t[0]=-stop;
  
  for(int i=1;i<=Q;i++){
    long long j0,j1,t0,t1,a,b,c,d,e;
    int j=jinja(x[i]);
    int te=tera(x[i]);
    j0=x[i]-s[j];
    j1=s[j+1]-x[i];
    t0=x[i]-t[te];
    t1=t[te+1]-x[i];
    a=max(j0,t0);//左のみ
    b=max(j1,t1);//右のみ
    c=2*min(j0,j1)+min(t0,t1);//左右
    d=min(j0,j1)+2*min(t0,t1);//左右
    e=min(min(a,b),min(c,d));
    cout<<e<<endl;
    //cout<<"\ni="<<i<<" x="<<x[i]<<" jinja="<<s[j]<<"-"<<s[j+1];
    //cout<<" tera="<<t[te]<<"-"<<t[te+1];
  }
}

Compiler output:
a.cc:8:11: error: redefinition of 'long long int max(long long int, long long int)'
    8 | long long max(long long a ,long long b){
      |           ^~~
a.cc:5:11: note: 'long long int max(long long int, long long int)' previously defined here
    5 | long long max(long long a ,long long b){
      |           ^~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int a, b, q; cin >> a >> b >> q;
	vector<long long> s(a), t(b);
	rep(i, 0, a-1)cin >> s[i]; rep(i, 0, b-1)cin >> t[i];
	rep(_, 1, q)
	{
		long long x; cin >> x;
		long long res = LLONG_MAX;
		int it = lower_bound(all(s), x) - s.begin();
		for (int i = max(0, it - 1); i < min(a, it + 1); ++i)
		{
			long long y = s[i];
			int it2 = lower_bound(all(t), y) - t.begin();
			for (int j = max(0, it2 - 1); j < min(b, it2 + 1); ++j)
			{
				res = min(res, abs(x - y) + abs(y - t[j]));
			}
		}

		it = lower_bound(all(t), x) - t.begin();
		for (int i = max(0, it - 1); i < min(b, it + 1); ++i)
		{
			long long y = t[i];
			int it2 = lower_bound(all(s), y) - s.begin();
			for (int j = max(0, it2 - 1); j < min(a, it + 1); ++j)
			{
				res = min(res, abs(x - y) + abs(y - s[j]));
			}
		}
		cout << res << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:33: error: 'LLONG_MAX' was not declared in this scope
   23 |                 long long res = LLONG_MAX;
      |                                 ^~~~~~~~~
a.cc:9:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include <queue>
  +++ |+#include <climits>
    9 |
Language: C++

#include <iostream>
#include <string>
#include <functional>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>

using namespace std;
using ll = long long;

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

	vector <ll> jinja(a + 2);
	vector <ll> tera(b + 2);

	jinja[0] = -INT_MAX;
	jinja[a + 1] = INT_MAX;
	tera[0] = -INT_MAX;
	tera[b + 1] = INT_MAX;

	for (int i = 1; i <= a; i++)
	{
		cin >> jinja[i];
	}

	for (int i = 1; i <= b; ++i)
		cin >> tera[i];

	sort(jinja.begin(), jinja.end());
	sort(tera.begin(), tera.end());

	for (int i = 0; i < q; ++i)
	{
		ll basyo;
		cin >> basyo;
		auto jinja_u = lower_bound(jinja.begin(), jinja.end(), basyo);
		auto jinja_l = jinja_u - 1;
		auto tera_u = lower_bound(tera.begin(), tera.end(), basyo);
		auto tera_l = tera_u - 1;

		ll cnt = max(*tera_u, *jinja_u) - basyo;
		cnt = min(cnt, basyo - min(*tera_l, *jinja_l));

		cnt = min(cnt, *tera_u - basyo + *tera_u - *jinja_l);
		cnt = min(cnt, *jinja_u - basyo + *jinja_u - *tera_l);
		cnt = min(cnt, basyo - *tera_l + *jinja_u - *tera_l);
		cnt = min(cnt, basyo - *jinja_l + *tera_u - *jinja_l);

		cout << cnt << endl;
	}

	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:21: error: 'INT_MAX' was not declared in this scope
   20 |         jinja[0] = -INT_MAX;
      |                     ^~~~~~~
a.cc:8:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    7 | #include <math.h>
  +++ |+#include <climits>
    8 |
Language: C++

#include <bits/stdc++.h>

using namespace std;
using lint = long long;

bool isOK(vector<lint> v, lint index, lint key)
{
    if(v[index] >= key)
        return true;
    else   
        return false;
}
int binary_search(vector<lint> v, lint key)
{
    int ng = -1;
    int ok = (int)v.size();

    while(abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if(isOK(v, mid, key))
            ok = mid;
        else 
            ng = mid;
    } 
    return ok;
}

lint calc_distance(lint q, lint t, lint s)
{
    if(q <= t && q <= s){
        return max(t, s) - q;
    }else if(q >= t && q >= s){
        return q - min(t, s);
    }else{
        lint minabs = min(abs(q - t),abs(q - s));
        return abs(q - t) + abs(q - s) + minabs; 
    }
}
int main(void)
{
    lint A, B, Q;
    cin >> A >> B >> Q;
    vector<lint> s(A);
    vector<lint> t(B);
    for(auto &x: s){
        cin >> x;
    }
    for(auto &x: t){
        cin >> x;
    }
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    
    for(int i = 0; i < Q; i++){
        lint q;
        cin >> q;
        lint i_sh = binary_search(s, q);
        lint i_sl = i_sh -1;
        if(i_sl < 0) i_sl = 0;
        lint s_h = s[i_sh];
        lint s_l = s[i_sl];

        lint i_th = 0//binary_search(t, q);
        lint i_tl = i_th -1;
        if(i_tl < 0) i_tl = 0;
        lint t_h = t[i_th];
        lint t_l = t[i_tl];

        lint dist1 = calc_distance(q, t_h, s_h);
        lint dist2 = calc_distance(q, t_h, s_l);
        lint dist3 = calc_distance(q, t_l, s_h);
        lint dist4 = calc_distance(q, t_l, s_l);
        lint dist = min({dist1, dist2, dist3, dist4});
        cout << dist << endl;

    }

}

Compiler output:
a.cc: In function 'int main()':
a.cc:64:9: error: expected ',' or ';' before 'lint'
   64 |         lint i_tl = i_th -1;
      |         ^~~~
a.cc:65:12: error: 'i_tl' was not declared in this scope; did you mean 'i_th'?
   65 |         if(i_tl < 0) i_tl = 0;
      |            ^~~~
      |            i_th
a.cc:67:22: error: 'i_tl' was not declared in this scope; did you mean 'i_th'?
   67 |         lint t_l = t[i_tl];
      |                      ^~~~
      |                      i_th
Language: C++

#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007;
const lint LINF = 1111111111111111111; 

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	lint A, B, Q;
	cin >> A >> B >> Q;

	vector<lint> s(A), t(B), 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];

	lint ups, los, upt, lot;

	for (const auto &elem : x) {
		vector<lint> cost(8, INF);
		ups = -1, los = -1, upt = -1, lot = -1;

		if (lower_bound(s.begin(), s.end(), elem) <  s.end() ) ups = *lower_bound(s.begin(), s.end(), elem);
		if (lower_bound(s.begin(), s.end(), elem) > s.begin()) los = *(lower_bound(s.begin(), s.end(), elem) - 1);
		if (lower_bound(t.begin(), t.end(), elem) <  t.end() ) upt = *lower_bound(t.begin(), t.end(), elem);
		if (lower_bound(t.begin(), t.end(), elem) > t.begin()) lot = *(lower_bound(t.begin(), t.end(), elem) - 1);

		if (lower_bound(t.begin(), t.end(), ups) > t.begin() && ups != -1) cost[0] = abs(ups - elem) + abs(*(lower_bound(t.begin(), t.end(), ups) - 1) - ups);
		if (lower_bound(t.begin(), t.end(), ups) <  t.end()  && ups != -1) cost[1] = abs(ups - elem) + abs(*lower_bound(t.begin(), t.end(), ups) - ups);
		if (lower_bound(t.begin(), t.end(), los) > t.begin() && los != -1) cost[2] = abs(los - elem) + abs(*(lower_bound(t.begin(), t.end(), los) - 1) - los);
		if (lower_bound(t.begin(), t.end(), los) <  t.end()  && los != -1) cost[3] = abs(los - elem) + abs(*lower_bound(t.begin(), t.end(), los) - los);
		if (lower_bound(s.begin(), s.end(), upt) > s.begin() && upt != -1) cost[4] = abs(upt - elem) + abs(*(lower_bound(s.begin(), s.end(), upt) - 1) - upt);
		if (lower_bound(s.begin(), s.end(), upt) <  s.end()  && upt != -1) cost[5] = abs(upt - elem) + abs(*lower_bound(s.begin(), s.end(), upt) - upt);
		if (lower_bound(s.begin(), s.end(), lot) > s.begin() && lot != -1) cost[6] = abs(lot - elem) + abs(*(lower_bound(s.begin(), s.end(), lot) - 1) - lot);
		if (lower_bound(s.begin(), s.end(), lot) <  s.end()  && lot != -1) cost[7] = abs(lot - elem) + abs(*lower_bound(s.begin(), s.end(), lot) - lot);

		cout << *min_element(cost.begin(), cost.end()) << "\n";

	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:38: error: 'INF' was not declared in this scope; did you mean 'LINF'?
   39 |                 vector<lint> cost(8, INF);
      |                                      ^~~
      |                                      LINF
Language: C++

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))


int bisect_left(long long x,long long  a[],int left,int right){
   int mid;
   right++;
   while (left < right) {
      mid = (left + right) / 2;
      if (a[mid] < x) {
         left = mid + 1;
      } else {
         right = mid;
      }
   }
   return left;
}

int main(void) {
   int A,B,Q;
   scanf("%d%d%d", &A,&B,&Q);
   long long *shrine = (long long *)calloc((A+3) * sizeof(long long));
   long long *temple = (long long *)calloc((B+3) * sizeof(long long));
   shrine[0] = -1000000000000LL;
   temple[0] = -1000000000000LL;
   shrine[A+1] = 1000000000000LL;
   temple[A+1] = 1000000000000LL;
   for (int i = 1; i <= A; i++) {
      scanf("%lld", &shrine[i]);
   }
   for (int i = 1; i <= B; i++) {
      scanf("%lld", &temple[i]);
   }
   for (int i = 0; i < Q; i++) {
      long long now;
      scanf("%lld", &now);
      int s1 = bisect_left(now,shrine,0,A+1)-1;
      int s2 = bisect_left(now,shrine,0,A+1);
      int t1 = bisect_left(now,temple,0,A+1)-1;
      int t2 = bisect_left(now,temple,0,A+1);
      long long ans = 100000000000000LL;
      ans = MIN(ans,ABS(shrine[s1]-now) + ABS(shrine[s1]-temple[t1]));
      ans = MIN(ans,ABS(shrine[s1]-now) + ABS(shrine[s1]-temple[t2]));
      ans = MIN(ans,ABS(shrine[s2]-now) + ABS(shrine[s2]-temple[t1]));
      ans = MIN(ans,ABS(shrine[s2]-now) + ABS(shrine[s2]-temple[t2]));
      ans = MIN(ans,ABS(temple[t1]-now) + ABS(shrine[s1]-temple[t1]));
      ans = MIN(ans,ABS(temple[t1]-now) + ABS(shrine[s2]-temple[t1]));
      ans = MIN(ans,ABS(temple[t2]-now) + ABS(shrine[s1]-temple[t2]));
      ans = MIN(ans,ABS(temple[t2]-now) + ABS(shrine[s2]-temple[t2]));
      printf("%lld\n",ans);
   }
   return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:43: error: too few arguments to function 'void* calloc(size_t, size_t)'
   26 |    long long *shrine = (long long *)calloc((A+3) * sizeof(long long));
      |                                     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/std_abs.h:38,
                 from /usr/include/c++/14/cmath:49,
                 from /usr/include/c++/14/math.h:36,
                 from a.cc:3:
/usr/include/stdlib.h:675:14: note: declared here
  675 | extern void *calloc (size_t __nmemb, size_t __size)
      |              ^~~~~~
a.cc:27:43: error: too few arguments to function 'void* calloc(size_t, size_t)'
   27 |    long long *temple = (long long *)calloc((B+3) * sizeof(long long));
      |                                     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:675:14: note: declared here
  675 | extern void *calloc (size_t __nmemb, size_t __size)
      |              ^~~~~~
Language: C++

#include <iostream>
#include <math.h>
#include <vector>
#include <map>

typedef long long long64;
struct Comb
{
	Comb(const Comb& obj)
	{
		_temple = obj._temple;
		_shrine = obj._shrine;
		_distance = obj.distance;
	}

	Comb(long64 shrine, long64 temple):
		_temple(temple),_shrine(shrine)
	{
		_distance = abs(_temple - _shrine);
	}

	long64 distance()
	{
		return _distance;
	}

	long64 distance(long64 pos)
	{
		long64 d1 = abs(pos - _temple);
		long64 d2 = abs(pos - _shrine);

		return d1 < d2 ? d1:d2;
	}

	long64 _shrine;
	long64 _temple;
	long64 _distance;
};

long64 distance(long64 s, long64 t, long64 p)
{
	long64 d = abs(s - t);
	long64 d1 = abs(s - p);
	long64 d2 = abs(t - p);
	
	if (d1 < d2)
		return d + d1;
	else
		return d + d2;
}

int main()
{
	long64 size_s, size_te, size_p;
	std::cin >> size_s >> size_te >> size_p;

	std::vector<long64>* shrine = new std::vector<long64>(size_s);
	std::vector<long64>* temple = new std::vector<long64>(size_te);
	std::vector<long64> pos(size_p);

	for(size_t i = 0; i < shrine->size(); i++)
	{
		std::cin >> (*shrine)[i];
	}
	for (size_t i = 0; i < temple->size(); i++)
	{
		std::cin >> (*temple)[i];
	}
	for (size_t i = 0; i < pos.size(); i++)
	{
		std::cin >> pos[i];
	}

	std::vector<Comb> comb;
	for (size_t i = 0; i < shrine->size(); i++) {
		for (size_t j = 0; j < temple->size(); j++) {
			comb.push_back(Comb((*shrine)[i],(*temple)[j]));
			//Comb comb((*shrine)[i], (*temple)[j]);
		}
	}
	delete shrine;
	delete temple;

	struct Min_Comb
	{
		long64 _s;
		long64 _t;
		long64 _p;

		Min_Comb()
		{
		}

		Min_Comb(const Min_Comb& obj)
		{
			_s = obj._s;
			_t = obj._t;
			_p = obj._p;
		}

		Min_Comb(long64 s,long64 t,long64 p):
			_s(s),_t(t),_p(p)
		{
		}

		long64 distance()
		{
			long64 sp = abs(_s - _p);
			long64 tp = abs(_t - _p);
			long64 ret = sp < tp ? sp : tp;

			return ret + abs(_s - _t);
		}
	};

	//最小値
	std::vector<Min_Comb> result(pos.size());

	for (size_t j = 0; j < pos.size(); j++) {
		long64 min = comb[0].distance() + comb[0].distance(pos[j]);
		Min_Comb min_comb(comb[0]._shrine,comb[0]._temple,pos[j]);
		result[j] = min_comb;
		for (size_t i = 0; i < comb.size(); i++) {
			long64 distance = comb[i].distance() + comb[i].distance(pos[j]);
			if (min > distance) {
				min = distance;
				min_comb._t = comb[i]._temple;
				min_comb._s = comb[i]._shrine;
				min_comb._p = pos[j];

				result[j] = min_comb;
			}
		}
	}

	for (size_t i = 0; i < result.size();i++)
	{
		std::cout << result[i].distance() << std::endl;
	}

	return 0;
}

Compiler output:
a.cc: In copy constructor 'Comb::Comb(const Comb&)':
a.cc:13:33: error: cannot resolve overloaded function 'distance' based on conversion to type 'long64' {aka 'long long int'}
   13 |                 _distance = obj.distance;
      |                                 ^~~~~~~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define INF 10 ** 18
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
    return a / gcd(a, b) * b;
}

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

int a, b, q;
vl s, t;

llint dist(vl va, vl vb, llint x)
{
    llint rec;
    auto ita = lower_bound(va.begin(), va.end(), x);
    auto itb = lower_bound(vb.begin(), vb.end(), *ita);

    //co << *ita << ' ' << *itb << en;

    llint tmp = abs(*ita - x);
    rec = tmp + abs(*itb - *ita);
    rec = min(rec, tmp + abs(*ita - *(itb - 1)));
    
    ita--;
    itb = lower_bound(vb.begin(), vb.end(), *ita);
    if(itb == vb.end()) itb--;

    //co << *ita << ' ' << *itb << en;ln;ln;
    
    llint tmp = abs(x - *ita);
    rec = min(rec, tmp + abs(*itb - *ita));

    rec = min(rec, tmp + abs(*ita - *(itb - 1)));
    
    return rec;
}

int main()
{
    ci >> a >> b >> q;
    llint ss, tt;
    s.pb(-INF); t.pb(-INF);
    rep(i, a) { ci >> ss; s.pb(ss); }
    rep(i, b) { ci >> tt; t.pb(tt); }
    s.pb(INF); t.pb(INF);

    llint x;
    rep(i, q) {
	ci >> x;

	co << min(dist(s, t, x), dist(t, s, x)) << en;
    }
  
    return 0;
}


Compiler output:
a.cc: In function 'llint dist(vl, vl, llint)':
a.cc:63:11: error: redeclaration of 'llint tmp'
   63 |     llint tmp = abs(x - *ita);
      |           ^~~
a.cc:53:11: note: 'llint tmp' previously declared here
   53 |     llint tmp = abs(*ita - x);
      |           ^~~
a.cc: In function 'int main()':
a.cc:22:17: error: invalid type argument of unary '*' (have 'int')
   22 | #define INF 10 ** 18
      |                 ^~~~
a.cc:75:11: note: in expansion of macro 'INF'
   75 |     s.pb(-INF); t.pb(-INF);
      |           ^~~
a.cc:22:17: error: invalid type argument of unary '*' (have 'int')
   22 | #define INF 10 ** 18
      |                 ^~~~
a.cc:75:23: note: in expansion of macro 'INF'
   75 |     s.pb(-INF); t.pb(-INF);
      |                       ^~~
a.cc:22:17: error: invalid type argument of unary '*' (have 'int')
   22 | #define INF 10 ** 18
      |                 ^~~~
a.cc:78:10: note: in expansion of macro 'INF'
   78 |     s.pb(INF); t.pb(INF);
      |          ^~~
a.cc:22:17: error: invalid type argument of unary '*' (have 'int')
   22 | #define INF 10 ** 18
      |                 ^~~~
a.cc:78:21: note: in expansion of macro 'INF'
   78 |     s.pb(INF); t.pb(INF);
      |                     ^~~
Language: C++

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

#define pb push_back
#define FOR(i, s, e) for (int (i) = (s); (i) < (e); (i)++)

int msin() {
    int A, B, Q; cin >> A >> B >> Q;
    vector<ll> s, t;
    s.pb(-1e18); t.pb(-1e18);
    FOR(i, 0, A) {
        ll x;
        cin >> x;
        s.pb(x);
    }
    s.pb(-s[0]);
    FOR(i, 0, B) {
        ll x;
        cin >> x;
        t.pb(x);
    }
    t.pb(-t[0]);

    FOR(i, 0, Q) {
        int d; cin >> d;
        int r = lower_bound(s.begin(), s.end(), d) - s.begin();
        int l = lower_bound(t.begin(), t.end(), d) - t.begin();

        ll ans = 1e18;
        ans = min(ans, max(s[r], t[l]) - d);
        ans = min(ans, d - min(s[r - 1], t[l - 1]));
        ans = min(ans, 2*s[r] - t[l - 1] - d);
        ans = min(ans, 2*t[l] - s[r - 1] - d);
        ans = min(ans, -2*s[r - 1] + t[l] + d);
        ans = min(ans, -2*t[l - 1] + s[r] + d);
        printf("%lld\n", ans);
    }

}

Compiler output:
a.cc: In function 'int msin()':
a.cc:42:1: warning: no return statement in function returning non-void [-Wreturn-type]
   42 | }
      | ^
/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>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;

#define pb push_back
#define FOR(i, s, e) for (int (i) = (s); (i) < (e); (i)++)

int msin() {
    int A, B, Q; cin >> A >> B >> Q;
    vector<ll> s, t;
    s.pb(-1e18); t.pb(-1e18);
    FOR(i, 0, A) {
        ll x;
        cin >> x;
        s.pb(x);
    }
    s.pb(-s[0]);
    FOR(i, 0, B) {
        ll x;
        cin >> x;
        t.pb(x);
    }
    t.pb(-t[0]);

    FOR(i, 0, Q) {
        int d; cin >> d;
        int r = lower_bound(s.begin(), s.end(), x[i]) - s.begin();
        int l = lower_bound(t.begin(), t.end(), x[i]) - t.begin();

        ll ans = 1e18;
        ans = min(ans, max(s[r], t[l]) - d);
        ans = min(ans, d - min(s[r - 1], t[l - 1]));
        ans = min(ans, 2*s[r] - t[l - 1] - d);
        ans = min(ans, 2*t[l] - s[r - 1] - d);
        ans = min(ans, -2*s[r - 1] + t[l] + d);
        ans = min(ans, -2*t[l - 1] + s[r] + d);
        printf("%lld\n", ans);
    }

}

Compiler output:
a.cc: In function 'int msin()':
a.cc:29:49: error: 'x' was not declared in this scope
   29 |         int r = lower_bound(s.begin(), s.end(), x[i]) - s.begin();
      |                                                 ^
a.cc:42:1: warning: no return statement in function returning non-void [-Wreturn-type]
   42 | }
      | ^
Language: C++

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

#define FOR(i, s, e) for (int (i) = (s); (i) < (e); (i)++)

int msin() {
    int A, B, Q; cin >> A >> B >> Q;
    vector<ll> s, t;
    s.pb(-1e18); t.pb(-1e18);
    FOR(i, 0, A) {
        ll x;
        cin >> x;
        s.pb(x);
    }
    s.pb(-s[0]);
    FOR(i, 0, B) {
        ll x;
        cin >> x;
        t.pb(x);
    }
    t.pb(-t[0]);

    FOR(i, 0, Q) {
        int d; cin >> d;
        int r = lower_bound(s.begin(), s.end(), x[i]) - s.begin();
        int l = lower_bound(t.begin(), t.end(), x[i]) - t.begin();

        ll ans = 1e18;
        ans = min(ans, max(s[r], t[l]) - d);
        ans = min(ans, d - min(s[r - 1], t[l - 1]));
        ans = min(ans, 2*s[r] - t[l - 1] - d);
        ans = min(ans, 2*t[l] - s[r - 1] - d);
        ans = min(ans, -2*s[r - 1] + t[l] + d);
        ans = min(ans, -2*t[l - 1] + s[r] + d);
        printf("%lld\n", ans);

}

Compiler output:
a.cc:6:9: error: 'push_back' does not name a type
    6 | typedef push_back pb;
      |         ^~~~~~~~~
a.cc: In function 'int msin()':
a.cc:13:7: error: 'class std::vector<long long int>' has no member named 'pb'
   13 |     s.pb(-1e18); t.pb(-1e18);
      |       ^~
a.cc:13:20: error: 'class std::vector<long long int>' has no member named 'pb'
   13 |     s.pb(-1e18); t.pb(-1e18);
      |                    ^~
a.cc:17:11: error: 'class std::vector<long long int>' has no member named 'pb'
   17 |         s.pb(x);
      |           ^~
a.cc:19:7: error: 'class std::vector<long long int>' has no member named 'pb'
   19 |     s.pb(-s[0]);
      |       ^~
a.cc:23:11: error: 'class std::vector<long long int>' has no member named 'pb'
   23 |         t.pb(x);
      |           ^~
a.cc:25:7: error: 'class std::vector<long long int>' has no member named 'pb'
   25 |     t.pb(-t[0]);
      |       ^~
a.cc:29:49: error: 'x' was not declared in this scope
   29 |         int r = lower_bound(s.begin(), s.end(), x[i]) - s.begin();
      |                                                 ^
a.cc:41:2: error: expected '}' at end of input
   41 | }
      |  ^
a.cc:10:12: note: to match this '{'
   10 | int msin() {
      |            ^
a.cc:41:2: warning: no return statement in function returning non-void [-Wreturn-type]
   41 | }
      |  ^
Language: C++

#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;
using lli = long long int;

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<lli> s(A + (int)2), t(B + (int)2), x(Q + (int)2);
    const lli inf = pow(10, 18);
    s[0]          = -inf;
    t[0]          = -inf;
    for (int i = 1; i <= A; i++) cin >> s[i];
    for (int i = 1; i <= B; i++) cin >> t[i];
    for (int i = 1; i <= Q; i++) cin >> x[i];
    s[A+1] = inf;
    t[B+1] = inf;

    for (int i = 0; i < Q; i++) {
        const lli p = x[i];
        auto sr     = upper_bound(s.begin(), s.end(), p);
        auto sl     = sr - 1;
        auto tr     = upper_bound(t.begin(), t.end(), p);
        auto tl     = tr - 1;

        const lli ans =
            min({abs(*sl - p) + abs(*tl - *sl), abs(*sl - p) + abs(*tr - *sl),
                 abs(*tl - p) + abs(*sl - *tl), abs(*tl - p) + abs(*sr - *tl),
                 abs(*sr - p) + abs(*tl - *sr), abs(*sr - p) + abs(*tr - *sr),
                 abs(*tr - p) + abs(*sl - *tr), abs(*tr - p) + abs(*sr - *tr)});
        cout << ans << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:21: error: 'pow' was not declared in this scope
   13 |     const lli inf = pow(10, 18);
      |                     ^~~
Language: Java

import java.util.*;
import java.util.stream.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int a = scanner.nextInt(), b = scanner.nextInt(), q = scanner.nextInt();
        List<Long> s = IntStream.range(0, a).mapToObj(i -> scanner.nextLong()).collect(Collectors.toList());
        List<Long> t = IntStream.range(0, b).mapToObj(i -> scanner.nextLong()).collect(Collectors.toList());
        s.sort(Long::compareTo);
        t.sort(Long::compareTo);
        s.add(Long.MAX_VALUE);
        t.add(Long.MAX_VALUE);
        s.add(0, Long.MIN_VALUE);
        t.add(0, Long.MIN_VALUE);

        for (int i = 0; i < q; i++) {
            long x = scanner.nextLong();
            int s1 = Util.binarySearch(s, (e, j) -> e < x);
            int t1 = Util.binarySearch(t, (e, j) -> e < x);
            long sa = s.get(s1) == Long.MIN_VALUE ? s.get(s1 + 1) : s.get(s1);
            long sb = s.get(s1 + 1) == Long.MAX_VALUE ? s.get(s1) : s.get(s1 + 1);
            long ta = t.get(t1) == Long.MIN_VALUE ? t.get(t1 + 1) : t.get(t1);
            long tb = t.get(t1 + 1) == Long.MAX_VALUE ? t.get(t1) : t.get(t1 + 1);
            System.out.println(Math.min(Math.min(Math.min(Math.abs(x - sa) + Math.abs(sa - ta), Math.abs(x - sa) + Math.abs(sa - tb)), Math.min(Math.abs(x - sb) + Math.abs(sb - ta), Math.abs(x - sb) + Math.abs(sb - tb))), Math.min(Math.min(Math.abs(x - ta) + Math.abs(ta - sa), Math.abs(x - ta) + Math.abs(ta - sb)), Math.min(Math.abs(x - tb) + Math.abs(tb - sa), Math.abs(x - tb) + Math.abs(tb - sb)))));
        }
    }
}

Compiler output:
Main.java:20: error: cannot find symbol
            int s1 = Util.binarySearch(s, (e, j) -> e < x);
                     ^
  symbol:   variable Util
  location: class Main
Main.java:21: error: cannot find symbol
            int t1 = Util.binarySearch(t, (e, j) -> e < x);
                     ^
  symbol:   variable Util
  location: class Main
2 errors
Language: C++

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

using namespace std;
typedef long long ll;
ll INF = LLONG_MAX/2;

ll closest(const vector<ll>& V, ll x) {
	auto it = lower_bound(V.begin(), V.end(), x);
	if(it == V.end()) {
		return *(it-1);
	} 

	if(it == V.begin()) {
		return *it;
	}
	auto it_ = it-1;
	if(*it-x < x-*it_) {
		return *it;
	}
	return *it_;
}

ll TS_up(const vector<ll>& S, const vector<ll>& T, ll x) {
	auto it = lower_bound(T.begin(), T.end(), x);
	if(it == T.end()) { return INF;}
	return (*it-x) + abs(*it-closest(S, *it));
}

ll TS_down(const vector<ll>& S, const vector<ll>& T, ll x) {
	auto it = lower_bound(T.begin(), T.end(), x);
	if(it == T.begin()) { return INF; }
	it--;
	return (x - *it) + abs(*it-closest(S, *it));
}


ll ST_up(const vector<ll>& S, const vector<ll>& T, ll x) {
	auto it = lower_bound(S.begin(), S.end(), x);
	if(it == S.end()) { return INF;}
	return (*it-x) + abs(*it-closest(T, *it));
}

ll ST_down(const vector<ll>& S, const vector<ll>& T, ll x) {
	auto it = lower_bound(S.begin(), S.end(), x);
	if(it == S.begin()) { return INF; }
	it--;
	return (x - *it) + abs(*it-closest(T, *it));
}

int main() {
	std::ios::sync_with_stdio(false);

	int A,B, Q;
	cin >> A >> B >> Q;
	vector<ll> S;
	for(int i = 0; i < A; i++) {
		ll x;
		cin >> x;
		S.push_back(x);
	} sort(S.begin(), S.end());

	vector<ll> T;
	for(int i = 0; i < B; i++) {
		ll x;
		cin >> x;
		T.push_back(x);
	} sort(T.begin(), T.end());

	for(int i = 0; i < Q; i++) {
		ll x;
		cin >> x;
		cout << min(TS_up(S, T, x),
				min(TS_down(S,T,x),
				min(ST_up(S,T,x),
					ST_down(S,T,x)))) << endl;
	}

	
}


Compiler output:
a.cc:9:10: error: 'LLONG_MAX' was not declared in this scope
    9 | ll INF = LLONG_MAX/2;
      |          ^~~~~~~~~
a.cc:6:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include <algorithm>
  +++ |+#include <climits>
    6 |
Language: C++

#include <iostream>
#include <vector>
#include <set>
#include <cmath>

using namespace std;
typedef long long ll;
ll INF = LLONG_MAX/2;

ll closest(const vector<ll>& V, ll x) {
	auto it = lower_bound(V.begin(), V.end(), x);
	if(it == V.end()) {
		return *(it-1);
	} 

	if(it == V.begin()) {
		return *it;
	}
	auto it_ = it-1;
	if(*it-x < x-*it_) {
		return *it;
	}
	return *it_;
}

ll TS_up(const vector<ll>& S, const vector<ll>& T, ll x) {
	auto it = lower_bound(T.begin(), T.end(), x);
	if(it == T.end()) { return INF;}
	return (*it-x) + abs(*it-closest(S, *it));
}

ll TS_down(const vector<ll>& S, const vector<ll>& T, ll x) {
	auto it = lower_bound(T.begin(), T.end(), x);
	if(it == T.begin()) { return INF; }
	it--;
	return (x - *it) + abs(*it-closest(S, *it));
}


ll ST_up(const vector<ll>& S, const vector<ll>& T, ll x) {
	auto it = lower_bound(S.begin(), S.end(), x);
	if(it == S.end()) { return INF;}
	return (*it-x) + abs(*it-closest(T, *it));
}

ll ST_down(const vector<ll>& S, const vector<ll>& T, ll x) {
	auto it = lower_bound(S.begin(), S.end(), x);
	if(it == S.begin()) { return INF; }
	it--;
	return (x - *it) + abs(*it-closest(T, *it));
}

int main() {
	std::ios::sync_with_stdio(false);

	int A,B, Q;
	cin >> A >> B >> Q;
	vector<ll> S;
	for(int i = 0; i < A; i++) {
		ll x;
		cin >> x;
		S.push_back(x);
	} sort(S.begin(), S.end());

	vector<ll> T;
	for(int i = 0; i < B; i++) {
		ll x;
		cin >> x;
		T.push_back(x);
	} sort(T.begin(), T.end());

	for(int i = 0; i < Q; i++) {
		ll x;
		cin >> x;
		cout << min(TS_up(S, T, x),
				min(TS_down(S,T,x),
				min(ST_up(S,T,x),
					ST_down(S,T,x)))) << endl;
	}

	
}


Compiler output:
a.cc:8:10: error: 'LLONG_MAX' was not declared in this scope
    8 | ll INF = LLONG_MAX/2;
      |          ^~~~~~~~~
a.cc:5:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <cmath>
  +++ |+#include <climits>
    5 | 
a.cc: In function 'int main()':
a.cc:63:11: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   63 |         } sort(S.begin(), S.end());
      |           ^~~~
      |           sqrt
Language: C++

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

int main(){
  int A, B, Q;cin>>A>>B>>Q;
  vll s, t, x;
  for (int i=0;i<A;++i){
    ll s_;cin>>s_;s.push_back(s_);
  }
  for (int i=0;i<B;++i){
    ll t_;cin>>t_;t.push_back(t_);
  }
  for (int i=0;i<Q;++i){
    ll x_;cin>>x_;x.push_back(x_);
  }

  sort(s.begin(), s.end());
  sort(t.begin(), t.end());

  for (int i=0;i<Q;++i){
    ll ans=10000000000;
    int j=lower_bound(s.begin(), s.end(), x[i]);
    int k=lower_bound(t.begin(), t.end(),x[i]);
  
    if(j<A&&k<B){
      ll sp=s[j];ll tp=t[k];
      ans=min(ans, max(sp,tp)-x[i]);
    }
    if(j<A&&k>0){
      ll sp=s[j]; ll tm=t[k-1];
      ans=min(ans, min(2*sp-tm-x[i], sp-2*tm+x[i]));
    }
    if (j>0&&k<B){
      ll sm=s[j-1];ll tp=t[k];
      ans=min(ans, min(2*tp-sm-x[i],tp-2*sm+x[i]));
    }
    if(j>0&&k>0){
      ll sm=s[j-1];ll tm=t[k-1];
      ans=min(ans, x[i]-min(sm,tm));
    }
    cout << ans << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:22: error: cannot convert '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'int' in initialization
   24 |     int j=lower_bound(s.begin(), s.end(), x[i]);
      |           ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                      |
      |                      __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >
a.cc:25:22: error: cannot convert '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'int' in initialization
   25 |     int k=lower_bound(t.begin(), t.end(),x[i]);
      |           ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
      |                      |
      |                      __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int a, b, q;
ll s[maxx], t[maxx], dd;

/*int solve1(ll x) {
	ll y = s[a];
	int n = a;
	int l = 1, r = n, ans1 = n + 1, ans2 = 0;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(x <= s[mid]) r = mid - 1, ans1 = mid;
		else l = mid + 1;
	}
	l = 1, r = n;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(y >= s[mid]) l = mid + 1, ans2 = mid;
		else r = mid - 1;
	}
	return ans2 - ans1 + 1;
}

int solve2(ll x) {
	ll y = t[b];
	int n = b;
	int l = 1, r = n, ans1 = n + 1, ans2 = 0;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(x <= t[mid]) r = mid - 1, ans1 = mid;
		else l = mid + 1;
	}
	l = 1, r = n;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(y >= t[mid]) l = mid + 1, ans2 = mid;
		else r = mid - 1;
	}
	return ans2 - ans1 + 1;
}*/

int main() {
	scanf("%d %d %d", &a, &b, &q);
	for(int i = 1; i <= a; i++) scanf("%lld", &s[i]);
	for(int i = 1; i <= b; i++) scanf("%lld", &t[i]);
	s[0] = s[1], t[0] = t[1];
	s[a + 1] = s[a], t[b + 1] = t[b];
	while(q--) {
		scanf("%lld", &dd);
		//int cnt1 = solve1(dd); //s中有pos1个比dd大的
		//int cnt2 = solve2(dd); //t中有pos2个比dd大的
		int cnt1 = lower_bound(s + 1, s + n + 1, dd) - s;
		cnt1 = n - cnt1 + 1;
		int cnt2 = lower_bound(t + 1, t + n + 1, dd) - t;
		cnt2 = n - cnt2 + 1;
		ll res = 0;
		ll ans1 = abs(dd - s[a - cnt1]);
		ll ans2 = abs(dd - s[a - cnt1 + 1]);
		ll res1 = abs(s[a - cnt1] - t[b - cnt2]);
		ll res2 = abs(s[a - cnt1 + 1] - t[b - cnt2]);
		res = min(ans1 + res1, ans2 + res2);
		ans1 = abs(dd - s[a - cnt1]);
		ans2 = abs(dd - s[a - cnt1 + 1]);
		res1 = abs(s[a - cnt1] - t[b - cnt2 + 1]);
		res2 = abs(s[a - cnt1 + 1] - t[b - cnt2 + 1]);
		ll tmp1 = min(ans1 + res1, ans2 + res2);
		res = min(res, tmp1);
		ans1 = abs(dd - t[b - cnt2]);
		ans2 = abs(dd - t[b - cnt2 + 1]);
		res1 = abs(t[b - cnt2] - s[a - cnt1]);
		res2 = abs(t[b - cnt2 + 1] - s[a - cnt1]);
		ll tmp2 = min(ans1 + res1, ans2 + res2);
		res = min(res, tmp2);
		ans1 = abs(dd - t[b - cnt2]);
		ans2 = abs(dd - t[b - cnt2 + 1]);
		res1 = abs(t[b - cnt2] - s[a - cnt1 + 1]);
		res2 = abs(t[b - cnt2 + 1] - s[a - cnt1 + 1]);
		ll tmp3 = min(ans1 + res1, ans2 + res2);
		res = min(res, tmp3);
		cout << res << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:51: error: 'n' was not declared in this scope; did you mean 'yn'?
   56 |                 int cnt1 = lower_bound(s + 1, s + n + 1, dd) - s;
      |                                                   ^
      |                                                   yn
Language: C++

#include <iostream>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define pb push_back
#define ll long long
#define MOD 100000007
#define MAX 1000000000000

ll path(ll x, ll y, ll z)
{
  return abs(x - y) + abs(y - z);
}

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

  vec<ll> s(a), t(b);
  rep(i, a) cin >> s[i];
  rep(i, b) cin >> t[i];

  rep(o, q) {
    ll x;
    cin >> x;
    auto its = lower_bound(s.begin(), s.end(), x);
    auto itt = lower_bound(t.begin(), t.end(), x);
    ll sr = its == s.end() ? MAX : *its;
    ll sl = its == s.begin() ? - MAX : *(--its);
    ll tr = itt == t.end() ? MAX : *itt;
    ll tl = itt == t.begin() ? - MAX : *(--itt);

    vec<ll> cand(0);
    cand.pb(path(x, sr, tr));
    cand.pb(path(x, sr, tl));
    cand.pb(path(x, sl, tr));
    cand.pb(path(x, sl, tl));
    cand.pb(path(x, tr, sr));
    cand.pb(path(x, tr, sl));
    cand.pb(path(x, tl, sr));
    cand.pb(path(x, tl, sl));
    cout << *min_element(cand.begin(), cand.end()) << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:14: error: 'min_element' was not declared in this scope
   46 |     cout << *min_element(cand.begin(), cand.end()) << endl;
      |              ^~~~~~~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define rem (x) x % 1000000007;

#define fillInt(xs, x)        \
  for (int i = 0; i < x; i++) \
    scanf_s("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < x; i++) \
    scanf_s("%ld", &xs[i]);
#define sortv(xs) sort(S.begin(), S.end());
#define lbv(xs, x) *lower_bound(xs.begin(), xs.end(), x);
#define ubv(xs, x) *upper_bound(xs.begin(), xs.end(), x);

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

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

  vector<long> S(A), T(B), X(Q);
  fillLong(S, A);
  fillLong(T, B);
  fillLong(X, Q);

  sortv(S);
  sortv(T);

  for (int i = 0; i < X.size(); i++)
  {
    long x = X[i];
    long m = LONG_MAX;

    int s = lbv(S, x);

    if (s != 0)
    {
      long s1 = S[s - 1];
      int t1 = lbv(T, s1);
      long t11 = T[max(t1 - 1, 0)];
      long t12 = T[min(t1, B - 1)];

      m = min(
          abs(s1 - x) + abs(t11 - s1),
          m);
      m = min(
          abs(s1 - x) + abs(t12 - s1),
          m);
    }

    if (s != A)
    {
      long s2 = S[s];
      int t2 = lbv(T, s2);
      long t21 = T[max(t2 - 1, 0)];
      long t22 = T[min(t2, B - 1)];

      m = min(
          abs(s2 - x) + abs(t21 - s2),
          m);
      m = min(
          abs(s2 - x) + abs(t22 - s2),
          m);
    }

    int t = lbv(T, x);

    if (t != 0)
    {
      long t1 = T[t - 1];
      int s1 = lbv(S, t1);
      long s11 = S[max(s1 - 1, 0)];
      long s12 = S[min(s1, A - 1)];

      m = min(
          abs(t1 - x) + abs(s11 - t1),
          m);
      m = min(
          abs(t1 - x) + abs(s12 - t1),
          m);
    }

    if (t != B)
    {
      long t2 = T[t];
      int s2 = lbv(S, t2);
      long s21 = S[max(s2 - 1, 0)];
      long s22 = S[min(s2, A - 1)];

      m = min(
          abs(t2 - x) + abs(s21 - t2),
          m);
      m = min(
          abs(t2 - x) + abs(s22 - t2),
          m);
    }

    printf("%ld", m);
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:5: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   32 |     scanf_s("%ld", &xs[i]);
      |     ^~~~~~~
a.cc:46:3: note: in expansion of macro 'fillLong'
   46 |   fillLong(S, A);
      |   ^~~~~~~~
a.cc:32:5: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   32 |     scanf_s("%ld", &xs[i]);
      |     ^~~~~~~
a.cc:47:3: note: in expansion of macro 'fillLong'
   47 |   fillLong(T, B);
      |   ^~~~~~~~
a.cc:32:5: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   32 |     scanf_s("%ld", &xs[i]);
      |     ^~~~~~~
a.cc:48:3: note: in expansion of macro 'fillLong'
   48 |   fillLong(X, Q);
      |   ^~~~~~~~