Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pi 3.14159265358979323846
#define mm 1000000007
int main()
{
    IOS;
    ll a,b,c,d,e,k,flag=0;
    cin>>a;
    vector<pair<pair<ll,ll>,char>> A(a);
    vector<pair<ll,ll>> R,L,D,U;
    map<pair<ll,ll>,ll> mp;
    for(b=0;b<a;b++)
    {
        cin>>A[b].first.first>>A[b].first.second>>A[b].second;
        if(A[b].second=='U') U.push_back(make_pair(A[b].first.first,A[b].first.second));
        if(A[b].second=='D') D.push_back(make_pair(A[b].first.first,A[b].first.second));
        if(A[b].second=='R') R.push_back(make_pair(A[b].first.first,A[b].first.second));
        if(A[b].second=='L') L.push_back(make_pair(A[b].first.first,A[b].first.second));
    }
    for(b=0;b<U.size() && flag==0;b++)
    {
        for(c=0;c<D.size;c++)
        {
            if(U[b].second==D[c].second && U[b].first<=D[c].first)
            {
                flag=1;
                k=D[c].first-U[b].first;
                k=k*5;
                break;
            }
        }
    }
    for(b=0;b<R.size() && flag==0;b++)
    {
        for(c=0;c<L.size;c++)
        {
            if(R[b].second==L[c].second && R[b].first<=L[c].first)
            {
                flag=1;
                k=L[c].first-R[c].first;
                k=k*5;
                break;
            }
        }
    }
    for(b=0;b<U.size() && flag==0;b++)
    {
        for(c=0;c<R.size;c++)
        {
            if(R[c].first-U[b].first==U[b].second-R[c].second)
            {
                flag=1;
                k=R[c].first-U[b].first;
                k=k*10;
                break;
            }
        }
    }
    for(b=0;b<U.size() && flag==0;b++)
    {
        for(c=0;c<R.size;c++)
        {
            if(L[c].first-U[b].first==L[b].second-U[c].second)
            {
                flag=1;
                k=L[c].first-U[b].first;
                k=k*10;
                break;
            }
        }
    }
    for(b=0;b<D.size() && flag==0;b++)
    {
        for(c=0;c<R.size;c++)
        {
            if(R[c].first-D[b].first==D[b].second-R[c].second)
            {
                flag=1;
                k=R[c].first-D[b].first;
                k=k*10;
                break;
            }
        }
    }
    for(b=0;b<D.size() && flag==0;b++)
    {
        for(c=0;c<L.size;c++)
        {
            if(D[c].first-L[b].first==L[b].second-D[c].second)
            {
                flag=1;
                k=D[c].first-L[b].first;
                k=k*10;
                break;
            }
        }
    }
    if(flag==1) cout<<k<<endl;
    else cout<<"SAFE"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:21: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; size_type = long unsigned int]' (did you forget the '()' ?)
   26 |         for(c=0;c<D.size;c++)
      |                   ~~^~~~
      |                         ()
a.cc:39:21: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; size_type = long unsigned int]' (did you forget the '()' ?)
   39 |         for(c=0;c<L.size;c++)
      |                   ~~^~~~
      |                         ()
a.cc:52:21: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; size_type = long unsigned int]' (did you forget the '()' ?)
   52 |         for(c=0;c<R.size;c++)
      |                   ~~^~~~
      |                         ()
a.cc:65:21: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; size_type = long unsigned int]' (did you forget the '()' ?)
   65 |         for(c=0;c<R.size;c++)
      |                   ~~^~~~
      |                         ()
a.cc:78:21: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; size_type = long unsigned int]' (did you forget the '()' ?)
   78 |         for(c=0;c<R.size;c++)
      |                   ~~^~~~
      |                         ()
a.cc:91:21: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; size_type = long unsigned int]' (did you forget the '()' ?)
   91 |         for(c=0;c<L.size;c++)
      |                   ~~^~~~
      |                         ()