Language: C++

int countBeauty(std::vector<int>& target, int d) {
	int beauty = 0;
	for (int c = 0; c < target.size() - 1; c++) {
		if (abs(target[c] - target[c + 1]) == d) {
			beauty += 1;
		}
	}
	return beauty;
}

int main() {
	int n, m, d;
	scanf_s("%d %d %d", &n, &m, &d);

	double avgBeauty = 0;
	std::vector<int> target;
	target.resize(m);
	for (int i = 0; i < pow(n, m); i++) {
		int tmp = i;
		for (int j = 0; j < m; j++) {
			target[m-1-j] = tmp % n + 1;
			tmp /= n;
		}
		avgBeauty += countBeauty(target, d);
	}
	avgBeauty /= pow(n, m);
	std::cout << avgBeauty << std::endl;
	return 1;
}

Compiler output:
a.cc:1:22: error: 'vector' is not a member of 'std'
    1 | int countBeauty(std::vector<int>& target, int d) {
      |                      ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | int countBeauty(std::vector<int>& target, int d) {
a.cc:1:29: error: expected primary-expression before 'int'
    1 | int countBeauty(std::vector<int>& target, int d) {
      |                             ^~~
a.cc:1:43: error: expected primary-expression before 'int'
    1 | int countBeauty(std::vector<int>& target, int d) {
      |                                           ^~~
a.cc:1:48: error: expression list treated as compound expression in initializer [-fpermissive]
    1 | int countBeauty(std::vector<int>& target, int d) {
      |                                                ^
a.cc: In function 'int main()':
a.cc:13:9: error: 'scanf_s' was not declared in this scope
   13 |         scanf_s("%d %d %d", &n, &m, &d);
      |         ^~~~~~~
a.cc:16:14: error: 'vector' is not a member of 'std'
   16 |         std::vector<int> target;
      |              ^~~~~~
a.cc:16:14: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:16:21: error: expected primary-expression before 'int'
   16 |         std::vector<int> target;
      |                     ^~~
a.cc:17:9: error: 'target' was not declared in this scope
   17 |         target.resize(m);
      |         ^~~~~~
a.cc:18:29: error: 'pow' was not declared in this scope
   18 |         for (int i = 0; i < pow(n, m); i++) {
      |                             ^~~
a.cc:24:41: error: 'countBeauty' cannot be used as a function
   24 |                 avgBeauty += countBeauty(target, d);
      |                              ~~~~~~~~~~~^~~~~~~~~~~
a.cc:26:22: error: 'pow' was not declared in this scope
   26 |         avgBeauty /= pow(n, m);
      |                      ^~~
a.cc:27:14: error: 'cout' is not a member of 'std'
   27 |         std::cout << avgBeauty << std::endl;
      |              ^~~~
a.cc:1:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | int countBeauty(std::vector<int>& target, int d) {
a.cc:27:40: error: 'endl' is not a member of 'std'
   27 |         std::cout << avgBeauty << std::endl;
      |                                        ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | int countBeauty(std::vector<int>& target, int d) {