Language: C++

#include <iostream>
#include <string>                                                               #include <vector>                                                               #include <utility>                                                              #include <map>                                                                  #include <algorithm>                                                                                                                                            using namespace std;

long gcd(long A, long B)                                                        {
  while (A % B != 0) {
    long C = A % B;
    A = B;
    B = C;
  }
  return B;
}

long skip(const vector<long>& x)
{
  if (x.size() == 2) return x[1] - x[0];
  long A = x[1] - x[0];
  for (size_t n = 2; n < x.size(); ++n) {
    long B = x[n] - x[n - 1];
    A = gcd(A, B);
  }
  return A;
}

int main()
{
  long N, X;
  cin >> N >> X;
  vector<long> x(N + 1);
  x[0] = X;
  for (long n = 1; n <= N; ++n) cin >> x[n];
  sort(x.begin(), x.end());
  cout << skip(x) << endl; 
  return 0;
} 


Compiler output:
a.cc:2:81: warning: extra tokens at end of #include directive
    2 | #include <string>                                                               #include <vector>                                                               #include <utility>                                                              #include <map>                                                                  #include <algorithm>                                                                                                                                            using namespace std;
      |                                                                                 ^
a.cc:13:17: error: 'vector' does not name a type
   13 | long skip(const vector<long>& x)
      |                 ^~~~~~
a.cc:13:23: error: expected ',' or '...' before '<' token
   13 | long skip(const vector<long>& x)
      |                       ^
a.cc: In function 'long int skip(int)':
a.cc:15:7: error: 'x' was not declared in this scope
   15 |   if (x.size() == 2) return x[1] - x[0];
      |       ^
a.cc:16:12: error: 'x' was not declared in this scope
   16 |   long A = x[1] - x[0];
      |            ^
a.cc: In function 'int main()':
a.cc:27:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   27 |   cin >> N >> X;
      |   ^~~
      |   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:28:3: error: 'vector' was not declared in this scope
   28 |   vector<long> x(N + 1);
      |   ^~~~~~
a.cc:28:10: error: expected primary-expression before 'long'
   28 |   vector<long> x(N + 1);
      |          ^~~~
a.cc:29:3: error: 'x' was not declared in this scope
   29 |   x[0] = X;
      |   ^
a.cc:31:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   31 |   sort(x.begin(), x.end());
      |   ^~~~
      |   short
a.cc:32:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   32 |   cout << skip(x) << 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:32:22: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   32 |   cout << skip(x) << 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)
      |     ^~~~