Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9+7;
using P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す//計算量は0(log(max(a,b))
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す//計算量は0(log(max(a,b))
  return a*b/gcd(a,b);
}
ll mod_pow(ll x,ll y){//x^yを返す//計算量は0(log(y))
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す//計算量は0(sqrt(a))
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N;
  cin>>N;
  vector<P> vec(N);
  vector<vector<int>> xup(200010);
  vector<vector<int>> xdown(200010);
  vector<vector<int>> yup(200010);
  vector<vector<int>> xdown(200010);
  int countx=0,county=0;
  for(int i=0;i<N;i++){
    int x,y,z;
    cin>>x>>y>>z;
    if(z=='U'){
      yup.at(x).push_back(y);
      county++;
    }
    if(z=='D'){
      ydown.at(x).push_back(y);
    }
    if(z=='R'){
      xup.at(y).push_back(x);
      countx++;
    }
    if(z=='L'){
      xdown.at(y).push_back(x);
    }
  }
  sort(yup.begin(),yup.end());
  sort(ydown.begin(),ydown.end());
  sort(xup.begin(),xup.end());
  ll ans=100000000000;
  sort(xdown.begin(),xdown.end());
  for(int i=0;i<N;i++){
    if(yup.at(i).size()>0){
      for(int j=0;j<(int)yup.at(i).size();j++){
        int k=yup.at(i).at(j);
        int s=0;
        while(ydown.at(i).at(s)<k){
          s++;
          if(s==ydown.at(i).size()){
            break;
          }
          if(ydown.at(i).at(s)>k){
            s--;
          }
        }
        ans=min(ans,max(0,ydown.at(i).at(s)-yup.at(i).at(j)));
      }
    }
  }
  for(int i=0;i<N;i++){
    if(yup.at(i).size()>0){
      for(int j=0;j<(int)xup.at(i).size();j++){
        int k=xup.at(i).at(j);
        int s=0;
        while(xdown.at(i).at(s)<k){
          s++;
          if(s==xdown.at(i).size()){
            break;
          }
          if(xdown.at(i).at(s)>k){
            s--;
          }
        }
        ans=min(ans,min(0,xdown.at(i).at(s)-xup.at(i).at(j)));
      }
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:23: error: redeclaration of 'std::vector<std::vector<int> > xdown'
   39 |   vector<vector<int>> xdown(200010);
      |                       ^~~~~
a.cc:37:23: note: 'std::vector<std::vector<int> > xdown' previously declared here
   37 |   vector<vector<int>> xdown(200010);
      |                       ^~~~~
a.cc:49:7: error: 'ydown' was not declared in this scope; did you mean 'xdown'?
   49 |       ydown.at(x).push_back(y);
      |       ^~~~~
      |       xdown
a.cc:60:8: error: 'ydown' was not declared in this scope; did you mean 'xdown'?
   60 |   sort(ydown.begin(),ydown.end());
      |        ^~~~~
      |        xdown
a.cc:96:16: error: no matching function for call to 'min(long long int&, const int&)'
   96 |         ans=min(ans,min(0,xdown.at(i).at(s)-xup.at(i).at(j)));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:96:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   96 |         ans=min(ans,min(0,xdown.at(i).at(s)-xup.at(i).at(j)));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:96:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   96 |         ans=min(ans,min(0,xdown.at(i).at(s)-xup.at(i).at(j)));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~