Language: C++

#include <iostream>
#include <cmath>
#include <vector>
#include <tr1/unordered_map>

#define fi first
#define se second

int N;
int hx, hy, mx, my;
typedef pair<double, double> P;
P cs[21];

#define SQ(x) ((x)*(x))
inline double dist(P a, P b) {
  return sqrt(SQ(a.fi-b.fi) + SQ(a.se-b.se));
}

unordered_map<int, double> umap;

double G[22][22];
bool dfs(int S, int now, double cost) {
  
  if(S == (1<<N)-1) {
    return true;
  }
  
  dp[S] = cost;
  
  for(int i=0; i<N; i++) {
    if(S >> i & 1) continue;
    if(G[i][N+1] <= cost+G[now][i]) return false;
  }
  
  for(int i=0; i<N; i++) {
    if(S >> i & 1) continue;
    if(dp.count(S|(1<<i)) && dp[S|(1<<i)] <= cost+G[now][i]) continue;
    if(dfs(S|(1<<i), i, cost+G[now][i]) return true;
  }
  
  return false;
}

bool solve() {
  
  for(int i=0; i<N; i++) {
    for(int j=i+1; j<N; j++) {
      G[i][j] = G[j][i] = dist(cs[i], cs[j]);
    }
    G[N][i] = G[i][N] = dist(P(hx, hy), cs[i]);
    G[N+1][i] = G[i][N+1] = dist(P(mx, my), cs[i]);
  }
  
  for(int i=0; i<N; i++) {
    if(dfs(1<<i, i, 0.)) return true;
  }
  
  return false;
}

int main() {
  while(1) {
    cin >> N >> hx >> hy >> mx >> my;
    if(!N) break;
    for(int i=0; i<N; i++) {
      cin >> cs[i].fi >> cs[i].se << endl;
    }
    cout << (solve() ? "YES" : "NO") << endl;
  }
  
  return 0;
}

Compiler output:
a.cc:11:9: error: 'pair' does not name a type
   11 | typedef pair<double, double> P;
      |         ^~~~
a.cc:12:1: error: 'P' does not name a type
   12 | P cs[21];
      | ^
a.cc:15:20: error: 'P' was not declared in this scope
   15 | inline double dist(P a, P b) {
      |                    ^
a.cc:15:25: error: 'P' was not declared in this scope
   15 | inline double dist(P a, P b) {
      |                         ^
a.cc:15:28: error: expression list treated as compound expression in initializer [-fpermissive]
   15 | inline double dist(P a, P b) {
      |                            ^
a.cc:19:1: error: 'unordered_map' does not name a type
   19 | unordered_map<int, double> umap;
      | ^~~~~~~~~~~~~
a.cc: In function 'bool dfs(int, int, double)':
a.cc:28:3: error: 'dp' was not declared in this scope
   28 |   dp[S] = cost;
      |   ^~
a.cc:38:40: error: expected ';' before 'return'
   38 |     if(dfs(S|(1<<i), i, cost+G[now][i]) return true;
      |                                        ^~~~~~~
      |                                        ;
a.cc:39:3: error: expected primary-expression before '}' token
   39 |   }
      |   ^
a.cc:38:53: error: expected ')' before '}' token
   38 |     if(dfs(S|(1<<i), i, cost+G[now][i]) return true;
      |       ~                                             ^
      |                                                     )
   39 |   }
      |   ~                                                  
a.cc:39:3: error: expected primary-expression before '}' token
   39 |   }
      |   ^
a.cc: In function 'bool solve()':
a.cc:48:32: error: 'cs' was not declared in this scope; did you mean 'cos'?
   48 |       G[i][j] = G[j][i] = dist(cs[i], cs[j]);
      |                                ^~
      |                                cos
a.cc:48:44: error: 'dist' cannot be used as a function
   48 |       G[i][j] = G[j][i] = dist(cs[i], cs[j]);
      |                                            ^
a.cc:50:30: error: 'P' was not declared in this scope
   50 |     G[N][i] = G[i][N] = dist(P(hx, hy), cs[i]);
      |                              ^
a.cc:50:41: error: 'cs' was not declared in this scope; did you mean 'cos'?
   50 |     G[N][i] = G[i][N] = dist(P(hx, hy), cs[i]);
      |                                         ^~
      |                                         cos
a.cc:50:46: error: 'dist' cannot be used as a function
   50 |     G[N][i] = G[i][N] = dist(P(hx, hy), cs[i]);
      |                                              ^
a.cc:51:50: error: 'dist' cannot be used as a function
   51 |     G[N+1][i] = G[i][N+1] = dist(P(mx, my), cs[i]);
      |                                                  ^
a.cc: In function 'int main()':
a.cc:63:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   63 |     cin >> N >> hx >> hy >> mx >> my;
      |     ^~~
      |     std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:66:14: error: 'cs' was not declared in this scope; did you mean 'cos'?
   66 |       cin >> cs[i].fi >> cs[i].se << endl;
      |              ^~
      |              cos
a.cc:66:38: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   66 |       cin >> cs[i].fi >> cs[i].se << endl;
      |                                      ^~~~
      |                                      std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:68:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   68 |     cout << (solve() ? "YES" : "NO") << endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:68:41: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   68 |     cout << (solve() ? "YES" : "NO") << endl;
      |                                         ^~~~
      |                                         std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~