Language: C++

#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////
unsigned gcd(unsigned a, unsigned b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main(){
	int n,X;
	cin >> n >> X;

	vector<ll> x(n);
	rep(i,0,n) cin >> x[i];

	if(n == 1 ){
		cout << abs( X - x[0] ) << endl;
		ret 0;
	}
	vsort(x);

	vector<ll> div(n-1);
	rep(i,0,n-1) div[i] = x[i+1]-x[i];

	int num = gcd(div[0],div[1]);
	rep(i,2,div.size()-1){
		num = gcd( num , div[i] );
	}

	rep(i,0,X){
		if( abs(x[i]-X) % num == 0 ){
			cout << num << endl;
			ret 0;
		}
	}

	cout << 1 << endl;

	ret 0;
}#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////
unsigned gcd(unsigned a, unsigned b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main(){
	int n,X;
	cin >> n >> X;

	vector<ll> x(n);
	rep(i,0,n) cin >> x[i];

	if(n == 1 ){
		cout << abs( X - x[0] ) << endl;
		ret 0;
	}
	vsort(x);

	vector<ll> div(n-1);
	rep(i,0,n-1) div[i] = x[i+1]-x[i];

	int num = gcd(div[0],div[1]);
	rep(i,2,div.size()-1){
		num = gcd( num , div[i] );
	}

	rep(i,0,X){
		if( abs(x[i]-X) % num == 0 ){
			cout << num << endl;
			ret 0;
		}
	}

	cout << 1 << endl;

	ret 0;
}

Compiler output:
a.cc:65:2: error: stray '#' in program
   65 | }#include<bits/stdc++.h>
      |  ^
a.cc:65:3: error: 'include' does not name a type
   65 | }#include<bits/stdc++.h>
      |   ^~~~~~~
a.cc:89:10: error: redefinition of 'unsigned int gcd(unsigned int, unsigned int)'
   89 | unsigned gcd(unsigned a, unsigned b) {
      |          ^~~
a.cc:25:10: note: 'unsigned int gcd(unsigned int, unsigned int)' previously defined here
   25 | unsigned gcd(unsigned a, unsigned b) {
      |          ^~~
a.cc:98:5: error: redefinition of 'int main()'
   98 | int main(){
      |     ^~~~
a.cc:34:5: note: 'int main()' previously defined here
   34 | int main(){
      |     ^~~~