Language: C++

#include<bits/stdc++.h>

using namespace std;

// =============== Template ===============

using ll = long long;
const ll INF = 1e9;
const ll MOD = 1e9+7;

// ---------- Data structures ----------

// Union-Find
struct UnionFind {
  vector<int> data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool merge(int x, int y) {
    x = root(x), y = root(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }
  
  int root(int k) {
    if(data[k] < 0) return k;
    return data[k] = root(data[k]);
  }
 
  int size(int k) {
    return (-data[root(k)]);
  }
};

// ModInt ( Const )
template <int MOD>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % MOD : (MOD - (-y) % MOD) % MOD) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += MOD - p.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % MOD);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = MOD, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< MOD >(t);
    return is;
  }
};
using modint = ModInt<MOD>;

// ---------- Algorithms ----------

// Greatest Common Divisor
template <typename T>
T gcd(T a, T b){return b?gcd(b,a%b):a;}

// Least Common Multiple
template <typename T>
T lcm(T a, T b){return a*b/gcd(a,b);}

// Extended Euclidean Algorithm
template <typename T>
ll extgcd(ll a, ll b, T &x, T &y){
	if(b == 0){
		x = 1, y = 0;
		return a;
	}
	T g = extgcd(b, a%b, x, y);
	T nextx = y, nexty = x-(a/b)*y;
	x = nextx, y = nexty;
	return g;
}

// Modular Exponentiation
ll mod_pow(ll a, ll n, ll p){
	if(n == 0) return 1;
	if(n%2 == 1) return (a * mod_pow(a, n-1, p)) % p;
	ll t = mod_pow(a, n/2, p);
	return (t*t) % p;
}

// Divisor O(sqrt(N))
vector< int64_t > divisor(int64_t n) {
  vector<int64_t> ret;
  for(int64_t i = 1; i*i <= n; ++i) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i*i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

// Prime-Factor O(sqrt(N))
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

// Is-Prime O(sqrt(N))
bool is_prime(int64_t n){
		for(int64_t i = 2; i*i <= n; ++i){
			if(n % i == 0) return false;
		}
		return true;
}

// Prime-Table O(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}


// ========================================

int pattern = 1;
double ans = 0;
int N;
int x[8], y[8];
int index[8];

int main(){
	cin >> N;
	for(int i = 0; i < N; ++i) index[i] = i;
	for(int i = 1; i <= N; ++i) pattern *= i;
	for(int i = 0; i < N; ++i) cin >> x[i] >> y[i];

	do{
		double result = 0;
		for(int i = 0; i < N - 1; ++i){
			result += sqrt((x[index[i]]-x[index[i+1]])*(x[index[i]]-x[index[i+1]]) + (y[index[i]]-y[index[i+1]])*(y[index[i]]-y[index[i+1]]));
		}
		ans += result;
	}while(next_permutation(index, index + N));
	ans /= pattern;
	printf("%.10f", ans);
}

Compiler output:
a.cc:185:12: error: 'int index [8]' redeclared as different kind of entity
  185 | int index[8];
      |            ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:189:41: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  189 |         for(int i = 0; i < N; ++i) index[i] = i;
      |                                         ^
a.cc:196:48: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  196 |                         result += sqrt((x[index[i]]-x[index[i+1]])*(x[index[i]]-x[index[i+1]]) + (y[index[i]]-y[index[i+1]])*(y[index[i]]-y[index[i+1]]));
      |                                                ^
a.cc:196:60: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  196 |                         result += sqrt((x[index[i]]-x[index[i+1]])*(x[index[i]]-x[index[i+1]]) + (y[index[i]]-y[index[i+1]])*(y[index[i]]-y[index[i+1]]));
      |                                                            ^
a.cc:196:76: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  196 |                         result += sqrt((x[index[i]]-x[index[i+1]])*(x[index[i]]-x[index[i+1]]) + (y[index[i]]-y[index[i+1]])*(y[index[i]]-y[index[i+1]]));
      |                                                                            ^
a.cc:196:88: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  196 |                         result += sqrt((x[index[i]]-x[index[i+1]])*(x[index[i]]-x[index[i+1]]) + (y[index[i]]-y[index[i+1]])*(y[index[i]]-y[index[i+1]]));
      |                                                                                        ^
a.cc:196:106: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  196 |                         result += sqrt((x[index[i]]-x[index[i+1]])*(x[index[i]]-x[index[i+1]]) + (y[index[i]]-y[index[i+1]])*(y[index[i]]-y[index[i+1]]));
      |                                                                                                          ^
a.cc:196:118: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  196 |                         result += sqrt((x[index[i]]-x[index[i+1]])*(x[index[i]]-x[index[i+1]]) + (y[index[i]]-y[index[i+1]])*(y[index[i]]-y[index[i+1]]));
      |                                                                                                                      ^
a.cc:196:134: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  196 |                         result += sqrt((x[index[i]]-x[index[i+1]])*(x[index[i]]-x[index[i+1]]) + (y[index[i]]-y[index[i+1]])*(y[index[i]]-y[index[i+1]]));
      |                                                                                                                                      ^
a.cc:196:146: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  196 |                         result += sqrt((x[index[i]]-x[index[i+1]])*(x[index[i]]-x[index[i+1]]) + (y[index[i]]-y[index[i+1]])*(y[index[i]]-y[index[i+1]]));
      |                                                                                                                                                  ^
a.cc:199:46: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+'
  199 |         }while(next_permutation(index, index + N));
      |                                        ~~~~~~^~~