Language: C++

#include "gcc_option.hpp"
#include "gcc_builtin.hpp"
#include <bits/extc++.h>
#include "config.hpp"
#include "utils/binary_search.hpp"
#include "utils/casefmt.hpp"
#include "utils/chval.hpp"
#include "utils/fixed_point.hpp"
#include "utils/hash.hpp"
#include "utils/iostream_overload.hpp"
#include "utils/read.hpp"
namespace workspace {
    constexpr char eol = '\n';
    using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx;
    using i64 = int_least64_t; using p32 = pair<int, int>; using p64 = pair<i64, i64>;
    using __gnu_pbds::priority_queue;
    struct solver;
}
int main() { config::main<workspace::solver>(); }
unsigned config::cases() {
    // return -1; // not specify
    // int t; std::cin >> t; return t; // given
    return 1;
}

struct workspace::solver { // start here!

solver()
{
    const int n=read();
    struct pla
    {
        int x,y;
        char d;
    };
    vector<pla> pls(n);
    for(auto &[x,y,c]: pls)
    {
        cin>>x>>y>>c;
    }
    const int inf=1e7;
    int ans=inf;
    // x
    {
        {
            hash_map<int,hash_map<char,vector<int>>> cnt;
            for(auto [x,y,d]: pls)
            {
                cnt[x][d].emplace_back(y);
            }
            for(auto [k,mp]: cnt)
            {
                for(char c: "ULDR")
                {
                    mp[c].emplace_back(inf*2);
                }
                for(auto &[c,ve]: mp)
                {
                    sort(begin(ve), end(ve));
                }
                for(int x: mp['U'])
                {
                    if(x>inf) continue;
                    auto &ve=mp['D'];
                    int tmp=*lower_bound(begin(ve), end(ve), x)-x;
                    chle(ans,tmp*5);
                }
            }
        }
    }
    // y
    {
        {
            hash_map<int,hash_map<char,vector<int>>> cnt;
            for(auto [x,y,d]: pls)
            {
                cnt[y][d].emplace_back(x);
            }
            for(auto [k,mp]: cnt)
            {
                for(char c: "ULDR")
                {
                    mp[c].emplace_back(inf*2);
                }
                for(auto &[c,ve]: mp)
                {
                    sort(begin(ve), end(ve));
                }
                for(int x: mp['R'])
                {
                    if(x>inf) continue;
                    auto &ve=mp['L'];
                    int tmp=*lower_bound(begin(ve), end(ve), x)-x;
                    chle(ans,tmp*5);
                }
            }
        }
    }
    // x+y
    {
        hash_map<int,hash_map<char,vector<int>>> cnt;
        for(auto [x,y,d]: pls)
        {
            cnt[x+y][d].emplace_back(x);
        }
        for(auto [k,mp]: cnt)
        {
            for(char c: "ULDR")
            {
                mp[c].emplace_back(inf*2);
            }
            for(auto &[c,ve]: mp)
            {
                sort(begin(ve), end(ve));
            }
            for(int x: mp['D'])
            {
                if(x>inf) continue;
                auto &ve=mp['L'];
                int tmp=*lower_bound(begin(ve), end(ve), x)-x;
                chle(ans,tmp*10);
            }
            for(int x: mp['R'])
            {
                if(x>inf) continue;
                auto &ve=mp['U'];
                int tmp=*lower_bound(begin(ve), end(ve), x)-x;
                chle(ans,tmp*10);
            }
        }
    }
    // y-x
    {
        hash_map<int,hash_map<char,vector<int>>> cnt;
        for(auto [x,y,d]: pls)
        {
            cnt[y-x][d].emplace_back(x);
        }
        for(auto [k,mp]: cnt)
        {
            for(char c: "ULDR")
            {
                mp[c].emplace_back(inf*2);
            }
            for(auto &[c,ve]: mp)
            {
                sort(begin(ve), end(ve));
            }
            for(int x: mp['U'])
            {
                if(x>inf) continue;
                auto &ve=mp['L'];
                int tmp=*lower_bound(begin(ve), end(ve), x)-x;
                chle(ans,tmp*10);
            }
            for(int x: mp['R'])
            {
                if(x>inf) continue;
                auto &ve=mp['D'];
                int tmp=*lower_bound(begin(ve), end(ve), x)-x;
                chle(ans,tmp*10);
            }
        }
    }

    if(ans<inf) cout<<ans<<endl;
    else cout<<"SAFE\n";
}};


Compiler output:
a.cc:1:10: fatal error: gcc_option.hpp: No such file or directory
    1 | #include "gcc_option.hpp"
      |          ^~~~~~~~~~~~~~~~
compilation terminated.