Language: C++

#include <bits/stdc++.h>
using namespace std;

void foreach_per(int n, function<void(int *)> f) {
  int indexes[n];
  for (int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (next_permutation(indexes, indexes + n));
}

int main() {
  int input = 0;
  cin >> input;
  int a[10],b[10];
  for(int i = 0; i < input; i++)
  {
    cin >> a[i] >> b[i];
  }
  double dst1;
  double dst2;
  double d = 0;
  double d2 = 1;
  double d3 = 0;
  foreach_per((input - 1), [](int *indexes) {
    for(int i = 0;i < input - 1; i++)
    {
      dst1 = sqrt((a[i] - a[i+1])*(a[i] - a[i+1]));
      dst2 = sqrt((b[i] - b[i+1])*(b[i] - b[i+1]));
      d += (dst1 + dst2);
      
    }
    //std::cout << indexes[0] << ',' << indexes[1] << ',' << indexes[2] << std::endl;
  });
  for(int i = 1;i <=input;i++)d2 *= i;
  d3 = d/d2;
  cout << d3 <<endl;
  return 0;
}

Compiler output:
a.cc: In lambda function:
a.cc:26:23: error: 'input' is not captured
   26 |     for(int i = 0;i < input - 1; i++)
      |                       ^~~~~
a.cc:25:29: note: the lambda has no capture-default
   25 |   foreach_per((input - 1), [](int *indexes) {
      |                             ^
a.cc:13:7: note: 'int input' declared here
   13 |   int input = 0;
      |       ^~~~~
a.cc:28:7: error: 'dst1' is not captured
   28 |       dst1 = sqrt((a[i] - a[i+1])*(a[i] - a[i+1]));
      |       ^~~~
a.cc:25:29: note: the lambda has no capture-default
   25 |   foreach_per((input - 1), [](int *indexes) {
      |                             ^
a.cc:20:10: note: 'double dst1' declared here
   20 |   double dst1;
      |          ^~~~
a.cc:28:20: error: 'a' is not captured
   28 |       dst1 = sqrt((a[i] - a[i+1])*(a[i] - a[i+1]));
      |                    ^
a.cc:25:29: note: the lambda has no capture-default
   25 |   foreach_per((input - 1), [](int *indexes) {
      |                             ^
a.cc:15:7: note: 'int a [10]' declared here
   15 |   int a[10],b[10];
      |       ^
a.cc:28:27: error: 'a' is not captured
   28 |       dst1 = sqrt((a[i] - a[i+1])*(a[i] - a[i+1]));
      |                           ^
a.cc:25:29: note: the lambda has no capture-default
   25 |   foreach_per((input - 1), [](int *indexes) {
      |                             ^
a.cc:15:7: note: 'int a [10]' declared here
   15 |   int a[10],b[10];
      |       ^
a.cc:28:36: error: 'a' is not captured
   28 |       dst1 = sqrt((a[i] - a[i+1])*(a[i] - a[i+1]));
      |                                    ^
a.cc:25:29: note: the lambda has no capture-default
   25 |   foreach_per((input - 1), [](int *indexes) {
      |                             ^
a.cc:15:7: note: 'int a [10]' declared here
   15 |   int a[10],b[10];
      |       ^
a.cc:28:43: error: 'a' is not captured
   28 |       dst1 = sqrt((a[i] - a[i+1])*(a[i] - a[i+1]));
      |                                           ^
a.cc:25:29: note: the lambda has no capture-default
   25 |   foreach_per((input - 1), [](int *indexes) {
      |                             ^
a.cc:15:7: note: 'int a [10]' declared here
   15 |   int a[10],b[10];
      |       ^
a.cc:29:7: error: 'dst2' is not captured
   29 |       dst2 = sqrt((b[i] - b[i+1])*(b[i] - b[i+1]));
      |       ^~~~
a.cc:25:29: note: the lambda has no capture-default
   25 |   foreach_per((input - 1), [](int *indexes) {
      |                             ^
a.cc:21:10: note: 'double dst2' declared here
   21 |   double dst2;
      |          ^~~~
a.cc:29:20: error: 'b' is not captured
   29 |       dst2 = sqrt((b[i] - b[i+1])*(b[i] - b[i+1]));
      |                    ^
a.cc:25:29: note: the lambda has no capture-default
   25 |   foreach_per((input - 1), [](int *indexes) {
      |                             ^
a.cc:15:13: note: 'int b [10]' declared here
   15 |   int a[10],b[10];
      |             ^
a.cc:29:27: error: 'b' is not captured
   29 |       dst2 = sqrt((b[i] - b[i+1])*(b[i] - b[i+1]));
      |                           ^
a.cc:25:29: note: the lambda has no capture-default
   25 |   foreach_per((input - 1), [](int *indexes) {
      |                             ^
a.cc:15:13: note: 'int b [10]' declared here
   15 |   int a[10],b[10];
      |             ^
a.cc:29:36: error: 'b' is not captured
   29 |       dst2 = sqrt((b[i] - b[i+1])*(b[i] - b[i+1]));
      |                                    ^
a.cc:25:29: note: the lambda has no capture-default
   25 |   foreach_per((input - 1), [](int *indexes) {
      |                             ^
a.cc:15:13: note: 'int b [10]' declared here
   15 |   int a[10],b[10];
      |             ^
a.cc:29:43: error: 'b' is not captured
   29 |       dst2 = sqrt((b[i] - b[i+1])*(b[i] - b[i+1]));
      |                                           ^
a.cc:25:29: note: the lambda has no capture-default
   25 |   foreach_per((input - 1), [](int *indexes) {
      |                             ^
a.cc:15:13: note: 'int b [10]' declared here
   15 |   int a[10],b[10];
      |             ^
a.cc:30:7: error: 'd' is not captured
   30 |       d += (dst1 + dst2);
      |       ^
a.cc:25:29: note: the lambda has no capture-default
   25 |   foreach_per((input - 1), [](int *indexes) {
      |                             ^
a.cc:22:10: note: 'double d' declared here
   22 |   double d = 0;
      |          ^
a.cc:30:13: error: 'dst1' is not captured
   30 |       d += (dst1 + dst2);
      |             ^~~~
a.cc:25:29: note: the lambda has no capture-default
   25 |   foreach_per((input - 1), [](int *indexes) {
      |                             ^
a.cc:20:10: note: 'double dst1' declared here
   20 |   double dst1;
      |          ^~~~
a.cc:30:20: error: 'dst2' is not captured
   30 |       d += (dst1 + dst2);
      |                    ^~~~
a.cc:25:29: note: the lambda has no capture-default
   25 |   foreach_per((input - 1), [](int *indexes) {
      |                             ^
a.cc:21:10: note: 'double dst2' declared here
   21 |   double dst2;
      |          ^~~~