Language: C++

#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> x(n);
    vector<int> y(n);
    vector<string> u(n);
    vector<pair<int,int>> up(n);
    vector<pair<int,int>> down(n);
    vector<pair<int,int>> left(n);
    vector<pair<int,int>> right(n);
    int time=2100000
    for (int i = 0; i < n; i++)
    {
        cin>>x.at(i);
        cin>>y.at(i);
        cin>>u.at(i);
        if (u.at(i)=="U")
        {
            up.at(i)=make_pair(x.at(i),y.at(i));
        }else if (u.at(i)=="D")
        {
            down.at(i)=make_pair(x.at(i),y.at(i));
        }else if (u.at(i)=="L")
        {
            left.at(i)=make_pair(x.at(i),y.at(i));
        }else
        {
            right.at(i)=make_pair(x.at(i),y.at(i));
        }
        
        
        
        

    }

    sort(up.begin(), up.end());
    sort(down.begin(), down.end());
    sort(left.begin(), left.end());
    sort(right.begin(), right.end());
    vector<pair<int,int>> up1(n);
    vector<pair<int,int>> down1(n);
    vector<pair<int,int>> left1(n);
    vector<pair<int,int>> right1(n);
    int time1;
    for (int i = 0; i < up.size(); i++)
    {
        up.at(i)=up1.at(i);
    }
    for (int i = 0; i < down.size(); i++)
    {
        down.at(i)=down1.at(i);
    }
    for (int i = 0; i < left.size(); i++)
    {
        left.at(i)=left1.at(i);
    }
    for (int i = 0; i < right.size(); i++)
    {
        right.at(i)=right1.at(i);
    }

    for (int i = 0; i < down.size()+up.size(); i++)
    {
        if (up1.front().first>down.front().first)
        {
            down1.erase(down.begin());
        }else if (up1.front().first<down.front().first)
        {
            up1.erase(down.begin());
        }else
        {
            if (up1.front().second>down.front().second)
            {
                down1.erase(down.begin());
            }else
            {
                if ((down.front().second-up1.front().second)*10<time)
                {
                    time=(down.front().second-up1.front().second)*10;
                    up1.erase(down.begin());
                }else
                {
                    up1.erase(down.begin());
                }   
            }
        }
    }
    for (int i = 0; i < left.size()+right.size(); i++)
    {
        if (left1.front().second>right.front().second)
        {
            right1.erase(right.begin());
        }else if (left1.front().second<right.front().second)
        {
            left1.erase(left.begin());
        }else
        {
            if (right1.front().first>left.front().first)
            {
                left1.erase(left.begin());
            }else
            {
                if ((left.front().first-right1.front().first)*10<time)
                {
                    time=(left.front().first-right1.front().first)*10;
                    right1.erase(right.begin());
                }else
                {
                    right1.erase(right.begin());
                }   
            }
        }
    }
    cout<<time<<endl;

    
    

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: expected ',' or ';' before 'for'
   24 |     for (int i = 0; i < n; i++)
      |     ^~~
a.cc:24:21: error: 'i' was not declared in this scope
   24 |     for (int i = 0; i < n; i++)
      |                     ^