Language: C++

              /* Created By
                  PRAKHAR BINDAL
                  (Indian Institute Of Technology,Kharagpur)*/
    #include<bits/stdc++.h>
    using namespace std;
    #define mod 1000000007
    #define mod1 500000003
    #define endl '\n'
    typedef unsigned long long int ll;
    typedef long long int ull;
    typedef vector<ll> vi;
    typedef vector<ll> vll;
    typedef vector<vector<ll> >vvi;
    typedef pair<ll,ll>ii;
    typedef vector<pair<ll,ll> >vii;
    typedef vector<vector<pair<ll,ll> > >vvii;
    #define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define pb push_back
    #define PB pop_back
    #define pf push_front
    #define PF pop_front
    #define mp make_pair
    #define ff first
    #define ss second
    #define rep(i,n) for(i=0;i<n;i++)
    #define rep1(i,n) for(i=1;i<=n;i++)
    #define nrep(i,n) for(i=n-1;i>=0;i--)
    #define nrep1(i,n) for(i=n;i>=1;i--)
    #define ia(a,n) for(i=0;i<n;i++) cin>>a[i]
    #define ia1(a,n) for(i=1;i<=n;i++) cin>>a[i]
    #define clr clear
    #define rz resize
    #define sqr(a) ((a) * (a))
    #define sz(a) ll((a).size())
    #define all(a) (a).begin(), (a).end()
    #define max ll(1000000000000000000)
    template<typename T> void scan(T &x)
    {
        x = 0;
        bool neg = 0;
        register T c = getchar();
        if (c == '-')
            neg = 1, c = getchar();
        while ((c < 48) || (c > 57))
            c = getchar();
        for ( ; c < 48||c > 57 ; c = getchar());
        for ( ; c > 47 && c < 58; c = getchar() )
            x= (x << 3) + ( x << 1 ) + ( c & 15 );
        if (neg) x *= -1;
    }
    template<typename T> void prll (T n)
    {
        bool neg = 0; 
        if (n < 0)
            n *= -1, neg = 1;
        char snum[65];
        ll i = 0;
        do
        {
            snum[i++] = n % 10 + '0';
            n /= 10;
        }
        while (n);
        --i;
        if (neg)
            putchar('-');
     
        while (i >= 0)
            putchar(snum[i--]);
     }
    long long readlong()
    {
        bool minus = false;
        ll result = 0;
        char ch;
        ch = getchar();
        while (true) {
            if (ch == '-') break;
            if (ch >= '0' && ch <= '9') break;
            ch = getchar();
        }
        if (ch == '-') minus = true; else result = ch-'0';
        while (true) {
            ch = getchar();
            if (ch < '0' || ch > '9') break;
            result = result*10 + (ch - '0');
        }
        if (minus)
            return -result;
        else
            return result;
    }
    ll readll (){
        char r;
        bool start=false,neg=false;
          ll ret=0;
        while(true){
            r=getchar();
            if((r-'0'<0 || r-'0'>9) && r!='-' && !start){
                continue;
            }
            if((r-'0'<0 || r-'0'>9) && r!='-' && start){
                break;
            }
            if(start)ret*=10;
            start=true;
            if(r=='-')neg=true;
            else ret+=r-'0';
        }
        if(!neg)
            return ret;
        else
            return -ret;
    }
    bool subsetSums(ll arr[], ll n,ll k)
    {
        long long total = 1<<n;
         for (long long i=0; i<total; i++)
        {
            long long sum = 0;
            for (ll j=0; j<n; j++)
                if (i & (1<<j))
                    sum += arr[j];
             if(sum==k)
                return true;
             
        }
        return false;
    }
    void solve()
    {
        ll k;
        scan(k);
        ll n=k%25;
        ll t=k/25;
        string str="abcdefghijklmnopqrstuvwxyz";
        if(n>0)
        {
        string b=str.substr(0,n+1);
        reverse(b.begin(),b.end());
        cout<<b;
        }
        reverse(str.begin(),str.end());
        while(t--)
        {
           cout<<str;
        }
        cout<<endl;
    }
    ll phi(ll n)
    {
        if(n==1)
            return 2;
        ll i;
        ll result=n;
        for(i=2;i*i<=n;i++)
        {
            if(n%i==0)
            {
                while(n%i==0)
                    n/=i;
                result-=result/i;
            }
        }
        if(n>1)
            result-=result/n;
        return result;
    }
bool checkprime(ll n)
{
    if(n==1)
        return false;
    if(n==2||n==3)
        return true;
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
            break;
    }
    if(i*i>n)
        return true;
    else
        return false;
}
bool lexicographical_compare(string s1,string s2)
{
    for(ll i=0;i<min(s1.length(),s2.length());i++)
    {
        if(s1[i]<s2[i])
            return true;
        if(s1[i]>s2[i])
            return false;
    }
    if(s1.length()<=s2.length())
        return true;

}
ll reverse(ll n)
{
    ll sum=0;
    ll i=0;
    ll temp=n;
    ll len=0;
    while(temp>0)
    {
        len++;
        temp/=10;
    }
    while(n>0)
    {
        sum+=(n%10)*pow(10,len-i-1);
        i++;
        n/=10;
    }
    return sum;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;     
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
         y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modularinverse(ll a,ll p)
{
    return power(a,p-2,p);
}
bool prime[1000001];
void sieve()
    {
        prime[1]=false;
        ll  i,j;
        for(i=2;i<=100000;++i)
        {
            prime[i]=true;
        }
        for(i=2;i*i<=100000;++i)
        {
             if(prime[i])
             {
                for(j=2;j*i<=100000;++j)
                    prime[i*j]=false;
             }
        }
    }
ll  digits(ll  n)
{
    ll  count=0;
    while(n>0)
    {
        count++;
        n/=10;
    }
    return count;
}
bool check(ll  n)
{
    ll  count=0;
    for(ll  i=2;i<=sqrt(n);++i)
    {
         if(n%i==0&&checkprime(i))
         {
            ++count;
        }
         else if(n%i==0)
         {
                if(checkprime(n/i))
                ++count;
         }
    }
    if(count>=3)
        return true;
    else
        return false;
}
ll  gcd(ll  a,ll  b)
{
     if(a==0)
        return b;
    return gcd(b%a,a);
}
bool sortbysec(const pair<ll ,ll > &a,
              const pair<ll ,ll > &b)
{
    return (a.second < b.second);
}
bool  isLeapYear(ll   year)
{
if (year %  400  ==  0)  return  true;
else  if(year  %  100  ==  0)  return  false;
else  if(year  %  4  ==  0)  return  true;
else  return  false;
}
bool check(string s1,string s2)
{
     if(s2==s1)
        return true;
     else if(s2.length()>s1.length())
        return false;
     ll  i=s1.length()-1;
     ll  j=s2.length()-1;
     for(;j>=0;i--,j--)
     {
          if(s1[i]!=s2[j])
            break;
     }
     if(j==-1)
        return true;
    else
        return false;

}
bool checksquare(ll n)
{
    ll ans=sqrt(n);
    if(ans*ans==n)
        return true;
    else
        return false;
}
ll binarysearch(ll a[],ll low,ll high,ll key)
{
    while(low<=high)
    {
         ll mid=low+(high-low)/2;
         if(a[mid]==key)
            return mid;
         else if(a[mid]>key)
            high=mid-1;
         else
            low=mid+1;
    }
    return -1;
}
void suffixarray(string str,ll  m,ll  suffix[])
{
    ll  len=0;
    ll  i;
    suffix[0]=0;
    i=1;
    while(i<m)
    {
        if(str[i]==str[len])
        {
            len++;
            suffix[i]=len;
            i++;
        }
        else
        {
            if(len!=0)
            {
                len=suffix[len-1];
            }
            else
            {
                suffix[i]=0;
                i++;
            }
        }
    }
}
ll  KMP(string str)
{
  ll  n=str.length();
  ll  suffix[n];
  suffixarray(str,n,suffix);
  ll  len=suffix[n-1];
  if(len>0&&n%(n-len)==0)
    return n-len;
  else
    return 0;
}
# define MAX 100 
long long triangle[MAX + 1][MAX + 1];

void makeTriangle() {
    ll  i, j;

    triangle[0][0] = 1; 

    for(i = 1; i < MAX; i++) {
        triangle[i][0] = 1; 
        for(j = 1; j <= i; j++) {
            triangle[i][j] = triangle[i - 1][j - 1] + triangle[i - 1][j];
        }
    }
}

long long combi(ll  n, ll  r) {
    return triangle[n][r];
}
bool crossproduct(ll  x1,ll  y1,ll  x2,ll  y2)
{
    if(x1*y2==x2*y1)
        return true;
    else
        return false;
}
bool check(long long a,long long b)
{
    long long i=0;
    long long j=0;
    while(a>0)
    {
        i++;
        a/=2;
    }
    while(b>0)
    {
        j++;
        b/=2;
    }
    if(i==j)
        return true;
    else
        return false;
}
int main()
{
   long long n,temp,x;
   cin>>n>>temp;
   long long ans=0;
   vector<long long>v;
   for(long i=0;i<n;i++)
   {
      cin>>x;
      v.pb(x);
   } 
   if(n==1)
   {
      cout<<long long(abs(v[0]-temp));
      return 0;
   }
   sort(v.begin(),v.end());
   for(long long i=1;i<v.size();i++)
   {
       ans=gcd(ans,v[i]-v[i-1]);
   }
   cout<<ans;
   return 0;
}

Compiler output:
a.cc: In function 'void scan(T&)':
a.cc:41:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   41 |         register T c = getchar();
      |                    ^
a.cc: In function 'int main()':
a.cc:439:13: error: expected primary-expression before 'long'
  439 |       cout<<long long(abs(v[0]-temp));
      |             ^~~~
a.cc: In instantiation of 'void scan(T&) [with T = long long unsigned int]':
a.cc:133:13:   required from here
  133 |         scan(k);
      |         ~~~~^~~
a.cc:41:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   41 |         register T c = getchar();
      |                    ^
a.cc: In function 'bool lexicographical_compare(std::string, std::string)':
a.cc:198:1: warning: control reaches end of non-void function [-Wreturn-type]
  198 | }
      | ^