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;
  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, [](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:25:24: error: 'input' is not captured
   25 |     for(int i = 0 ;i < input - 1; i++)
      |                        ^~~~~
a.cc:24:23: note: the lambda has no capture-default
   24 |   foreach_per(input, [](int *indexes) {
      |                       ^
a.cc:13:7: note: 'int input' declared here
   13 |   int input;
      |       ^~~~~
a.cc:27:7: error: 'dst1' is not captured
   27 |       dst1 = sqrt((a[i] - a[i+1])*(a[i] - a[i+1]));
      |       ^~~~
a.cc:24:23: note: the lambda has no capture-default
   24 |   foreach_per(input, [](int *indexes) {
      |                       ^
a.cc:19:10: note: 'double dst1' declared here
   19 |   double dst1;
      |          ^~~~
a.cc:27:20: error: 'a' is not captured
   27 |       dst1 = sqrt((a[i] - a[i+1])*(a[i] - a[i+1]));
      |                    ^
a.cc:24:23: note: the lambda has no capture-default
   24 |   foreach_per(input, [](int *indexes) {
      |                       ^
a.cc:14:7: note: 'int a [10]' declared here
   14 |   int a[10],b[10];
      |       ^
a.cc:27:27: error: 'a' is not captured
   27 |       dst1 = sqrt((a[i] - a[i+1])*(a[i] - a[i+1]));
      |                           ^
a.cc:24:23: note: the lambda has no capture-default
   24 |   foreach_per(input, [](int *indexes) {
      |                       ^
a.cc:14:7: note: 'int a [10]' declared here
   14 |   int a[10],b[10];
      |       ^
a.cc:27:36: error: 'a' is not captured
   27 |       dst1 = sqrt((a[i] - a[i+1])*(a[i] - a[i+1]));
      |                                    ^
a.cc:24:23: note: the lambda has no capture-default
   24 |   foreach_per(input, [](int *indexes) {
      |                       ^
a.cc:14:7: note: 'int a [10]' declared here
   14 |   int a[10],b[10];
      |       ^
a.cc:27:43: error: 'a' is not captured
   27 |       dst1 = sqrt((a[i] - a[i+1])*(a[i] - a[i+1]));
      |                                           ^
a.cc:24:23: note: the lambda has no capture-default
   24 |   foreach_per(input, [](int *indexes) {
      |                       ^
a.cc:14:7: note: 'int a [10]' declared here
   14 |   int a[10],b[10];
      |       ^
a.cc:28:7: error: 'dst2' is not captured
   28 |       dst2 = sqrt((b[i] - b[i+1])*(b[i] - b[i+1]));
      |       ^~~~
a.cc:24:23: note: the lambda has no capture-default
   24 |   foreach_per(input, [](int *indexes) {
      |                       ^
a.cc:20:10: note: 'double dst2' declared here
   20 |   double dst2;
      |          ^~~~
a.cc:28:20: error: 'b' is not captured
   28 |       dst2 = sqrt((b[i] - b[i+1])*(b[i] - b[i+1]));
      |                    ^
a.cc:24:23: note: the lambda has no capture-default
   24 |   foreach_per(input, [](int *indexes) {
      |                       ^
a.cc:14:13: note: 'int b [10]' declared here
   14 |   int a[10],b[10];
      |             ^
a.cc:28:27: error: 'b' is not captured
   28 |       dst2 = sqrt((b[i] - b[i+1])*(b[i] - b[i+1]));
      |                           ^
a.cc:24:23: note: the lambda has no capture-default
   24 |   foreach_per(input, [](int *indexes) {
      |                       ^
a.cc:14:13: note: 'int b [10]' declared here
   14 |   int a[10],b[10];
      |             ^
a.cc:28:36: error: 'b' is not captured
   28 |       dst2 = sqrt((b[i] - b[i+1])*(b[i] - b[i+1]));
      |                                    ^
a.cc:24:23: note: the lambda has no capture-default
   24 |   foreach_per(input, [](int *indexes) {
      |                       ^
a.cc:14:13: note: 'int b [10]' declared here
   14 |   int a[10],b[10];
      |             ^
a.cc:28:43: error: 'b' is not captured
   28 |       dst2 = sqrt((b[i] - b[i+1])*(b[i] - b[i+1]));
      |                                           ^
a.cc:24:23: note: the lambda has no capture-default
   24 |   foreach_per(input, [](int *indexes) {
      |                       ^
a.cc:14:13: note: 'int b [10]' declared here
   14 |   int a[10],b[10];
      |             ^
a.cc:29:7: error: 'd' is not captured
   29 |       d += (dst1 + dst2);
      |       ^
a.cc:24:23: note: the lambda has no capture-default
   24 |   foreach_per(input, [](int *indexes) {
      |                       ^
a.cc:21:10: note: 'double d' declared here
   21 |   double d = 0;
      |          ^
a.cc:29:13: error: 'dst1' is not captured
   29 |       d += (dst1 + dst2);
      |             ^~~~
a.cc:24:23: note: the lambda has no capture-default
   24 |   foreach_per(input, [](int *indexes) {
      |                       ^
a.cc:19:10: note: 'double dst1' declared here
   19 |   double dst1;
      |          ^~~~
a.cc:29:20: error: 'dst2' is not captured
   29 |       d += (dst1 + dst2);
      |                    ^~~~
a.cc:24:23: note: the lambda has no capture-default
   24 |   foreach_per(input, [](int *indexes) {
      |                       ^
a.cc:20:10: note: 'double dst2' declared here
   20 |   double dst2;
      |          ^~~~