Language: C++

#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

ll gcd(ll a,ll b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}

int n, q;
Graph G(2*100000+5);
vector<int>score(2*100000+5);
vector<int> res(2*100000+5);

void dfs(int v, int par, int sum){
    res[v] = sum;

    for(auto nv : G[v]){
        if( nv == par )continue;
        dfs(nv, v, sum+score[nv]);
    }
}



int main(){
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll>s, t;
    s.push_back(-INF),t.push_back(-INF);

    rep(i, a){
        ll c;
        cin >> c;
        s.push_back(c);
    }

    rep(i, b){
        ll c;
        cin >> c;
        t.push_back(c);
    }

    s.push_back(INF*INF),t.push_back(INF*INF);

    rep(i, q){
        ll x;
        cin >> x;
        ll res = min( { 
            s[lower_bound( ALL(s) , x ) - s.begin() - 1] - x  + *lower_bound( ALL(t) , x) - s[lower_bound( ALL(s)- s.begin() , x ) - 1],

            t[lower_bound( ALL(t) , x )- t.begin() - 1] - x  + *lower_bound( ALL(s) , x) - t[lower_bound( ALL(t) , x )- t.begin() - 1],

            max( *lower_bound( ALL(t) , x) , *lower_bound( ALL(s) , x)) - x,

            max( s[lower_bound( ALL(s) , x )- s.begin() - 1] - x , t[lower_bound( ALL(t) , x )- t.begin() - 1] - x)
        })

        cout << res << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:89:106: error: no matching function for call to 'lower_bound(std::vector<long long int>::iterator, __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type, ll&)'
   89 |             s[lower_bound( ALL(s) , x ) - s.begin() - 1] - x  + *lower_bound( ALL(t) , x) - s[lower_bound( ALL(s)- s.begin() , x ) - 1],
      |                                                                                               ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate: 'template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)'
 1530 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note:   template argument deduction/substitution failed:
a.cc:89:106: note:   deduced conflicting types for parameter '_ForwardIterator' ('__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' and 'long int')
   89 |             s[lower_bound( ALL(s) , x ) - s.begin() - 1] - x  + *lower_bound( ALL(t) , x) - s[lower_bound( ALL(s)- s.begin() , x ) - 1],
      |                                                                                               ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:7:
/usr/include/c++/14/bits/stl_algo.h:1963:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> _FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare)'
 1963 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1963:5: note:   candidate expects 4 arguments, 3 provided
a.cc:88:21: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   88 |         ll res = min( {
      |                  ~~~^~~
   89 |             s[lower_bound( ALL(s) , x ) - s.begin() - 1] - x  + *lower_bound( ALL(t) , x) - s[lower_bound( ALL(s)- s.begin() , x ) - 1],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   90 | 
      |                      
   91 |             t[lower_bound( ALL(t) , x )- t.begin() - 1] - x  + *lower_bound( ALL(s) , x) - t[lower_bound( ALL(t) , x )- t.begin() - 1],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   92 | 
      |                      
   93 |             max( *lower_bound( ALL(t) , x) , *lower_bound( ALL(s) , x)) - x,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   94 | 
      |                      
   95 |             max( s[lower_bound( ALL(s) , x )- s.begin() - 1] - x , t[lower_bound( ALL(t) , x )- t.begin() - 1] - x)
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |         })
      |         ~~           
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 1 provided