Harryxun/stf_run huggingface dataset:
class UnionFind():
  par = []
  sizes = []

  def __init__(self, N):
    self.par = [i for i in range(N)]
    self.sizes = [1 for _ in range(N)]

  def root(self, x: int)-> int:
    if (self.par[x] == x):
      return x
    return self.root(self.par[x])

  def unite(self, x: int, y: int):
    rootX = self.root(x)
    rootY = self.root(y)
    if rootX == rootY:
      return
    self.par[rootX] = rootY
    self.sizes[rootY] += self.sizes[rootX]

  def maxSize(self)-> int:
    return max(self.sizes)

def friends(N, As):
  uf = UnionFind(N)
  setAs = list(set(As))
  for val in setAs:
    uf.unite(val[0]-1, val[1]-1)
  return uf.maxSize()

if __name__ == "__main__":
  nm = list(map(int, input().split()))
  As =[tuple(map(int, input().split())) for _ in range(nm[1])]
  print(friends(nm[0], As))

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# class UnionFind():
#   par = []
#   sizes = []

#   def __init__(self, N):
#     self.par = [i for i in range(N)]
#     self.sizes = [1 for _ in range(N)]

#   def root(self, x: int)-> int:
#     if (self.par[x] == x):
#       return x
#     return self.root(self.par[x])

#   def unite(self, x: int, y: int):
#     rootX = self.root(x)
#     rootY = self.root(y)
#     if rootX == rootY:
#       return
#     self.par[rootX] = rootY
#     self.sizes[rootY] += self.sizes[rootX]

#   def maxSize(self)-> int:
#     return max(self.sizes)

def friends(N, As):
  uf = UnionFind(N)
  setAs = list(set(As))
  for val in setAs:
    uf.union(val[0]-1, val[1]-1)
  ans = 0
  for i in range(N):
    temp = uf.size(i)
    if ans < temp:
      ans = temp
  return ans

if __name__ == "__main__":
  nm = list(map(int, input().split()))
  As =[tuple(map(int, input().split())) for _ in range(nm[1])]
  print(friends(nm[0], As))
t="abcdefghijklmnopqrstuvwxyz"
s=input()
k=int(input())
a=[t.index(i)for i in s]
ans=""
for i in a:
  if i==0:
    ans+="a"
    continue
  j=i
  if k>=26-i:
    k-=26-i
    j=0
  ans+=t[j]
j+=k
j%=26
ans=ans[:-1]+t[j]
print(ans)

### FIXED CODE ###

s=input()
k=int(input())
t="abcdefghijklmnopqrstuvwxyz"
a=[t.index(i)for i in s]
i=0
while k:
  if i==len(s)-1:a[i]+=k;a[i]%=26;k=0
  if a[i]==0 or 26-a[i]>k:i+=1
  else:a[i]+=1;a[i]%=26;k-=1
print("".join([t[i]for i in a]))
n = int(input())
s = list(input())


flag = 0
for i in range(n-1): 
    if(s[i] == "R" and s[i+1] == "W"):
        w_left = i
        r_right = i+1
        flag = 1
        break


#print(w_left)
#print(r_right)
if(flag == 1):
    w_len = len([i for i in s[r_right:] if i == "R"])
    r_len = len([i for i in s[:w_left] if i == "W"])
    print(max(w_len,r_len))
else:
    for i in range(n):
        if(s[i] == "W" and s[i+1] == "R"):
            flag = 2
            pnt = i
            if((pnt+1)*2 < n):
                print(pnt+1)
            else:
                print(n-pnt-1)

if(flag == 0):
    print(0)

### FIXED CODE ###

n = int(input())
c = list(input())

def solve_fixed(p):
    w_cnt = 0
    r_cnt = 0

    for i in range(p):
        if(c[i] == "W"):
            w_cnt += 1
    
    for j in range(p,n):
        if(c[j] == "R"):
            r_cnt += 1
    
    return (w_cnt,r_cnt)

ans = 10**9
w_cnt,r_cnt = solve_fixed(0)

tmp = max(w_cnt,r_cnt)
ans = min(ans,tmp)
for i in range(n):
    
    if(c[i] == "W"):
        w_cnt += 1
    else:
        r_cnt -= 1

    tmp = max(w_cnt,r_cnt)
    ans = min(ans,tmp)
    

print(ans)
N, K = map(int, input().split())
l = list(map(int, input().split()))

l.sort()
print(sum(l[-K:])


### FIXED CODE ###

N, K = map(int, input().split())
l = list(map(int, input().split()))

l.sort(reverse=True)
print(sum(l[:K]))
N = int(input())

mod = (N-1)*N/2
print(int(mod))


### FIXED CODE ###

s = input()
t = input()

k = 0
count = 0
while k < 3:
    if s[k] == t[k]:
        count += 1
    k += 1
print(count)
n = int(input())
alist = [input() for i in range(n)]
 
if len(set(alist))==n:
  if all(alist[i][-1]==alist[i+1][0])for i in range(n-1):
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

n = int(input())
alist = [input() for i in range(n)]
 
if len(set(alist))==n:
  if all(alist[i][-1]==alist[i+1][0] for i in range(n-1)):
    print("Yes")
    exit()
print("No")
import math

a, b, c, d = map(int, input().split(" "))


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def sj(base, i1, i2):
    cz = base // i1
    dz = base // i2
    cd = base // lcm(i1, i2)
    return base - (cz + dz - cd)


print(sj(b, c, d) - sj(a - 1, c, d))


### FIXED CODE ###

from fractions import gcd

a, b, c, d = map(int, input().split(" "))


def lcm(x, y):
    return (x * y) // gcd(x, y)


def sj(base, i1, i2):
    cz = base // i1
    dz = base // i2
    cd = base // lcm(i1, i2)
    return base - (cz + dz - cd)


print(sj(b, c, d) - sj(a - 1, c, d))
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def resolve():
    n, m = map(int, input().split())
    s = input()
    t = input()

    L = lcm(n, m)

    X = [""] * L
    for i in range(n):
        idx = (L // n) * i
        X[idx] = s[i]

    for i in range(m):
        idx = (L // m) * i
        if X[idx] != "" and X[idx] != t[i]:
            print("-1")
            break
    else:
        print(L)


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def resolve():
    n, m = map(int, input().split())
    s = input()
    t = input()

    L = lcm(n, m)

    X = dict()
    for i in range(n):
        idx = (L // n) * i
        X[idx] = s[i]

    for i in range(m):
        idx = (L // m) * i
        if X.get(idx) != None and X[idx] != t[i]:
            print("-1")
            break
    else:
        print(L)


if __name__ == '__main__':
    resolve()
import sys
sys.setrecursionlimit(1000)

n, q = map(int, input().split())
tl = [list() for _ in range(n)]
ans = [0] * n

for i in range(n-1):
    a, b = map(int, input().split())
    tl[a-1].append(b)

def rec(p, x):
    ans[p-1] += x
    for num in tl[p-1]:
        rec(num, x)

for i in range(q):
    p, x = map(int, input().split())
    rec(p, x)

print(" ".join(map(str, ans)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
 
n, q = map(int, input().split())
tl = [list() for _ in range(n)]
xl = [0] * n
ans = [0] * n
 
for i in range(n-1):
    a, b = map(int, input().split())
    tl[a-1].append(b-1)
    tl[b-1].append(a-1)
 
for i in range(q):
    p, x = map(int, input().split())
    xl[p-1] += x

def rec(p, parent, x):
    x += xl[p]
    ans[p] = x
    for num in tl[p]:
        if num == parent: continue
        rec(num, p, x)

rec(0, -1, 0)
 
print(*ans)
import heapq
n,m = map(int,input().split())
x_input = sorted(list(map(int,input().split())))

cost_li = []
for i in range(m-1):
    heapq.heappush(cost_li,-(x_input[i+1]-x_input[i]))

if len(cost_li)==0:
    print(0);exit()
for i in range(n-1):
    heapq.heappop(cost_li)

print(-sum(cost_li))




### FIXED CODE ###

import heapq
n,m = map(int,input().split())
x_input = sorted(list(map(int,input().split())))

cost_li = []
for i in range(m-1):
    heapq.heappush(cost_li,-(x_input[i+1]-x_input[i]))

for i in range(n-1):
    if len(cost_li)==0:
        print(0);exit()
    heapq.heappop(cost_li)

print(-sum(cost_li))
import heapq

n = int(input())
rev_g = [[] for _ in range(n+1)]
for i in range(n-1):
    a = int(input())
    rev_g[a].append(i+2)

def f(v):
    if len(rev_g[v]) == 0:
        return 0
    q = []
    for nv in rev_g[v]:
        heapq.heappush(q, f(nv))
    max_count = 0
    max_num = 0
    while q:
        num = heapq.heappop(q)
        if num > max_num + max_count:
            max_num = num
            max_count = 0
        elif num == max_num + max_count:
            max_num = num
            max_count = 1
        elif max_num == num:
            max_count += 1
        else:
            max_num += max_count
            if max_num > num:
                heapq.heappush(q, max_num)
                max_num = num
                max_count = 0

    max_num += max_count
    return max_num

print(f(1)+1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

n = int(input())
rev_g = [[] for _ in range(n+1)]
for i in range(n-1):
    a = int(input())
    rev_g[a].append(i+2)

def f(v):
    m = len(rev_g[v])
    if m == 0:
        return 0
    q = []
    for nv in rev_g[v]:
        q.append(f(nv))
    q.sort()
    dp = [0] * (m+1)
    for i in range(m):
        dp[i+1] = max(q[i]+1, dp[i]+1)
    return dp[m]


print(f(1))
N, x = map(int, input().split())
a = sorted(map(int, input().split()))
cnt = 0

for i in range(N):
    x -= a[i]
    if x < 0:
        break
    else:
        s += 1

print(cnt if x <= 0 else cnt-1)

### FIXED CODE ###

N, x = map(int, input().split())
a = sorted(map(int, input().split()))
cnt = 0

for i in range(N):
    x -= a[i]
    if x < 0:
        break
    else:
        cnt += 1

print(cnt if x <= 0 else cnt-1)
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read
s = input()
u = ""
t = ""
q = int(input())
num = 0

for _ in range(q):
    a = readline.split()
    if len(a)==1:
        u,t = t,u
        num ^= 1
    else:
        f = int(a[1])
        c = a[2]
        if f==1:
            t += c
        else:
            u += c

if num:
    print(t[::-1]+s[::-1]+u)
else:
    print(t[::-1]+s+u)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#h,w,k = [int(i) for i in read().split()]


s = input()
u = ""
t = ""
q = int(input())
num = 0

for _ in range(q):
    a = readline().split()
    if len(a)==1:
        u,t = t,u
        num ^= 1
    else:
        f = int(a[1])
        c = a[2]
        if f==1:
            t += c
        else:
            u += c

if num:
    print(t[::-1]+s[::-1]+u)
else:
    print(t[::-1]+s+u)
a, b = int(input().split())
if(a*b%2 == 0):
    print("Even")
else:
    print("Odd")


### FIXED CODE ###

a, b = map(int, input().split())
if(a*b%2 == 0):
    print("Even")
else:
    print("Odd")
N,X = map(int, input().split())
List = [int(x) for x in input().split()]

import math
List.append(X)
List.sort()

distance = []
for i in range(len(List)-1):
    distance.append(List[i+1]-List[i])

d_min = min(distance)

num_list = []

c = 1
while c <= math.sqrt(d_min):
    if d_min%c == 0:
        num_list.append(c)
    c += 1

num_list2 = [d_min]*len(num_list)
for i in range(len(num_list)):
    num_list2[len(num_list)-i-1] = d_min/num_list[i]

num_list = num_list + num_list2


j = len(num_list)-1
c2 = 0
while j >= 0:
    for k in range(len(distance)):
        if distance[k]%num_list[j] == 0:
            c2 += 1
    if c2 == len(distance):
        ans = num_list[j]
        j = 0
    j -= 1

print(ans)

### FIXED CODE ###

N,X = map(int, input().split())
List = [int(x) for x in input().split()]
 
import math
List.append(X)
List.sort()
 
distance = []
for i in range(N):
    distance.append(List[i+1]-List[i])
 
d_min = min(distance)
 
num_list = []
 
c = 1
while c <= math.sqrt(d_min):
    if d_min%c == 0:
        num_list.append(c)
    c += 1
 
num_list2 = [0]*len(num_list)
for i in range(len(num_list)):
    num_list2[len(num_list)-i-1] = int(d_min/num_list[i])
 
num_list = num_list + num_list2

num_list.append(d_min)

j = len(num_list)-1

while j >= 0:
    c2 = 0
    for k in range(len(distance)):
        if distance[k]%num_list[j] == 0:
            c2 += 1
    if c2 == len(distance):
        ans = num_list[j]
        j = 0
    j -= 1
 
print(ans)
s = int(input())
for i in range(1, s):
    if s[i] == s[i-1]:
        print ('Bad')
        exit()

print ('Good')


### FIXED CODE ###

s = input()
for i in range(1, len(s)):
    if s[i] == s[i-1]:
        print ('Bad')
        exit()

print ('Good')
n = int(input())
a = []
b = []
for i in range(n):
	a_1, b_1 = input().split()
	a.append(int(a_1))
	b.append(int(b_1))
a.sort()
b.sort()
is_odds = n % 2 == 0
a_med = a[(n + 1) // 2 - 1] if not is_odds else (a[n // 2 - 1] + a[n // 2]) / 2
b_med = b[(n + 1) // 2 - 1] if not is_odds else (b[n // 2 - 1] + b[n // 2]) / 2
from_a = a_med if not is_odds else int(a_med * 2)
to_b = b_med if not is_odds else int(b_med * 2)

print(len(list(range(from_a, to_b + 1))))

### FIXED CODE ###

n = int(input())
a = []
b = []
for i in range(n):
	a_1, b_1 = input().split()
	a.append(int(a_1))
	b.append(int(b_1))
a.sort()
b.sort()
is_odds = n % 2 == 0
a_med = a[(n + 1) // 2 - 1] if not is_odds else (a[n // 2 - 1] + a[n // 2]) / 2
b_med = b[(n + 1) // 2 - 1] if not is_odds else (b[n // 2 - 1] + b[n // 2]) / 2
from_a = a_med if not is_odds else int(a_med * 2)
to_b = b_med if not is_odds else int(b_med * 2)
print(to_b - from_a + 1)
n,m = int(input())
li = [[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
    a,b = map(int,input())
    a-=1
    b-=1
    li[a][b] = 1
    li[b][a] = 1

ans = False
for i in range(1,n-1):
    if li[0][i] and li[i][n-1]:
        ans = True
        break

if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

### FIXED CODE ###

n,m = map(int,input().split())
li1 = [0 for _ in range(n)]
li2 = [0 for _ in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if a==0:
        li1[b] = 1
    elif b==n-1:
        li2[a] = 1

ans = False
for i in range(1,n-1):
    if li1[i] and li2[i]:
        ans = True
        break

if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
row1=list(map(int,input().split()))
row2=list(map(int,input().split()))
row3=list(map(int,input().split()))
bingo=row1+row2+row3
num=int(input())
num_list={}
for i in range(num):
  num_list.add(int(input()))

bingo_list=[[0,3,6],[1,4,7],[2,5,8],[0,1,2],[3,4,5],[6,7,8],[0,4,8],[2,4,6]]
  
for i in num_list:
  if i in bingo:
    bingo[bingo.index(i)] = True

for i in bingo_list:
  if bingo[i[0]] is True and bingo[i[1]] is True and bingo[i[2]] is True:
    print('Yes')
    return 0

print('No')


### FIXED CODE ###

row1=list(map(int,input().split()))
row2=list(map(int,input().split()))
row3=list(map(int,input().split()))
bingo=row1+row2+row3
num=int(input())
num_list=set()
for i in range(num):
  num_list.add(int(input()))

bingo_list=[[0,3,6],[1,4,7],[2,5,8],[0,1,2],[3,4,5],[6,7,8],[0,4,8],[2,4,6]]
num_list=list(num_list)
for i in num_list:
  if i in bingo:
    bingo[bingo.index(i)] = True

for i in bingo_list:
  if bingo[i[0]] ==True and bingo[i[1]] == True and bingo[i[2]] == True:
    print('Yes')
    break
  if i == [2,4,6]:
    print('No')
x = int(input())
ans = []
for i in range(x):
  for j in range(x):
    if i**j < x and x < i**(j+1):
      ans.append(int(i**j))
print(max(ans))

### FIXED CODE ###

x=int(input())
c=1
for b in range(1,32):
    for p in range(2,10):
        if b**p<=x:
          c=max(c,b**p)
        else:break
print(c)
import numpy
n,y= map(int,input().split())

c=list(range(n+1))
lenC=len(c)
v1=numpy.repeat(c, lenC*lenC)
v2=numpy.repeat(lenC*c, lenC)
v3=numpy.repeat(lenC*lenC*c,1)
v = numpy.array([v1,v2,v3]).reshape(3,len(v1))

comb=v[:,sum(v)==n]
m=numpy.matrix([10000, 5000, 1000])
s = m*comb

if y in s:
	ans=comb[:,numpy.array(s).flatten()==y][:,0]
	print("%d %d %d"%(ans[0],ans[1],ans[2]))
else:
	print("%d %d %d"%(-1,-1,-1))




### FIXED CODE ###

n,y= map(int,input().split())

ans=(-1,-1,-1)
m=range(n+1)
for a in m:
	for b in m:
		c=n-a-b
		total = 10000*a + 5000*b + 1000*c
		if (c>=0) & (total==y):
			ans=(a,b,c)
			break
		else:
			continue
		break

print("%d %d %d"%ans)
n = int(input())
a = list(map(int, input().split()))

x = 0
for i in range(n-1):
  if a[i] > i[i+1]:
    x += a[i] - a[i+1]
    a[i+1] = a[i]

print(x)

### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
ans = 0
for i in range(N-1):
    if A[i]>A[i+1]:
        ans += A[i]-A[i+1]
        A[i+1] = A[i]
print(ans)
from itertools import permutations
N,M,R=map(int,input().split())
r=list(map(int,input().split()))
INF=float("inf")
G=[[INF]*N for i in range(N)]
for i in range(M):
    A,B,C=map(int,input().split())
    A,B=A-1,B-1
    G[A][B]=C
    G[B][A]=C
def distance(a,b):
    stack=[(G[a][i],i) for i in range(N) if G[a][i]!=INF]
    heapify(stack)
    reached=[0]*N
    reached[0]=1
    dis=[INF]*N
    dis[0]=0
    while(stack):
        c,i=heappop(stack)
        if reached[i]==1:
            continue
        if dis[i]<=c:
            continue
        dis[i]=c
        if i==b:
            return c
        reached[i]=1
        for j in range(N):
            if G[i][j]!=INF and reached[j]==0:
                heappush(stack,(G[i][j]+dis[i],j))
D=[[0]*N for i in range(N)]
for i in r:
    for j in r:
        if i>=j:
            continue
        D[i-1][j-1]=distance(i-1,j-1)
        D[j-1][i-1]=D[i-1][j-1]
ans=10**9
for r_ in permutations(r):
    res=0
    for i in range(R-1):
        res+=D[r_[i]-1][r_[i+1]-1]
    ans=min(ans,res)
print(ans)


### FIXED CODE ###

from itertools import permutations
from heapq import *

N,M,R=map(int,input().split())
r=list(map(int,input().split()))
INF=float("inf")
G=[[INF]*N for i in range(N)]
for i in range(M):
    A,B,C=map(int,input().split())
    A,B=A-1,B-1
    G[A][B]=C
    G[B][A]=C
def distance(a,b):
    stack=[(G[a][i],i) for i in range(N) if G[a][i]!=INF]
    heapify(stack)
    reached=[0]*N
    reached[0]=1
    dis=[INF]*N
    dis[0]=0
    while(stack):
        c,i=heappop(stack)
        if reached[i]==1:
            continue
        if dis[i]<=c:
            continue
        dis[i]=c
        if i==b:
            return c
        reached[i]=1
        for j in range(N):
            if G[i][j]!=INF and reached[j]==0:
                heappush(stack,(G[i][j]+dis[i],j))
D=[[0]*N for i in range(N)]
for i in r:
    for j in r:
        if i>=j:
            continue
        D[i-1][j-1]=distance(i-1,j-1)
        D[j-1][i-1]=D[i-1][j-1]
ans=10**9
for r_ in permutations(r):
    res=0
    for i in range(R-1):
        res+=D[r_[i]-1][r_[i+1]-1]
    ans=min(ans,res)
print(ans)
X,K,D = map(int,input().split())
ans = 0
if X<0:
  X = (-1)*X
  
if X-K*D >=0:
  ans = X-K*D
else:
  Y = int(X/D)
  z = X%D
  if (K-Y)%2=0:
    ans = Z
  if (K-Y)%2=1:
    ans = D-Z
if ans<0:
  ans = (-1)*ans
print(ans)
  


### FIXED CODE ###

X,K,D = map(int,input().split())
ans = 0
if X<0:
  X = (-1)*X
  
if X-K*D >=0:
  ans = X-K*D
else:
  Y = int(X/D)
  Z = X%D
  if (K-Y)%2==0:
    ans = Z
  if (K-Y)%2==1:
    ans = D-Z
print(ans)
N = int(input())
S = input()
ans = 0
for i in range(0, N):
    for j in range(i, N):
        if i ==j or S[i] == S[j]:
            continue
        s = ['R', 'G', 'B']
        s.remove(S[i])
        s.remove(S[j])
        k_s = np.where(np.array(list(S[j:])) == s[0])[0] + j
        for k in k_s:
            if j == k or S[j] == S[k]:
                continue
            elif j-i != k-j and S[i] != S[k]:
                ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N):
    for j in range(i + 1, N):
        k = j - i + j
        if k < N:
            if {S[i], S[j], S[k]} == {"R", "G", "B"}:
                ans -= 1
print(ans)
import math

N,X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()

if N != 1:
    A = [0]*(N-1)
    for i in range(N-1):
        A[i] = x[i+1]-x[i]

    a = A[0]
    for i in range(N-1):
        a = math.gcd(a,A[i])
    print(a)
else:
    print(x[1]-x[0])

### FIXED CODE ###

import fractions

N,X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()

if N != 1:
    A = [0]*N
    for i in range(N):
        A[i] = x[i+1]-x[i]
    a = A[0]
    for j in range(N):
        a = fractions.gcd(a,A[j])
    print(a)
else:
    print(x[1]-x[0])
import sys

N = int(input())
XY = [[int(_) for _ in input().split()] for i in range(N)]

mc = [0, 0]
maxl = 0

for x, y in XY:
    l = abs(x) + abs(y)
    maxl = max(maxl, l)
    mc[l % 2] += 1

if mc[0] > 0 and mc[1] > 0:
    print(-1)
    sys.exit()

if maxl > 20:
    raise

def calc(sx, sy, dx, dy, d):
    #print("#", sx, sy, dx, dy)
    x = dx - sx
    y = dy - sy
    tx = x + 3 * d - y
    ty = x + 3 * d + y
    dirs = ("LL", "LD", "DD"), ("LU", "UD", "RD"), ("UU", "RU", "RR")
    ds = {"R": (+d, 0), "L": (-d, 0), "U": (0, +d), "D": (0, -d)}
    dir = dirs[ty // (2 * d)][tx // (2 * d)]
    ex, ey = sx, sy
    for d in dir:
        ex += ds[d][0]
        ey += ds[d][1]
    #print("*", dir, ex, ey)
    return dir, ex, ey


ds = [9, 3, 1]
ds0 = [9, 9, 3, 3, 1, 1]

w0 = ""
x0, y0 = 0, 0

if mc[1] > 0:
    ds0 = [1] + ds0
    w0 += "R"
    x0 += 1

print(len(ds0))
print(*ds0)

for i in range(N):
    w = w0
    x, y = x0, y0
    for j, d in enumerate(ds):
        wc, x, y = calc(x, y, XY[i][0], XY[i][1], d)
        w += wc
    print(w)





### FIXED CODE ###

import sys

N = int(input())
XY = [[int(_) for _ in input().split()] for i in range(N)]

mc = [0, 0]
maxl = 0

for x, y in XY:
    l = abs(x) + abs(y)
    maxl = max(maxl, l)
    mc[l % 2] += 1

if mc[0] > 0 and mc[1] > 0:
    print(-1)
    sys.exit()

#print(maxl)

def calc(sx, sy, ex, ey, d):
    dx, dy = ex - sx, ey - sy
    rx, ry = dx - dy, dx + dy
    if rx > 0:
        if ry > 0:
            d, x, y = "R", sx + d, sy
        else:
            d, x, y = "D", sx, sy - d
    else:
        if ry > 0:
            d, x, y = "U", sx, sy + d
        else:
            d, x, y = "L", sx - d, sy
    return d, x, y

import math

l = math.ceil(math.log(maxl + 1, 2))

ms = [2 ** (l - i - 1) for i in range(l)]

rms = ms

if mc[0] > 0:
    rms = [1] + ms

print(len(rms))
print(*rms)

for ex, ey in XY:
    x, y = 0, 0
    w = ""
    if mc[0] > 0:
        w = "R"
        x += 1
    for m in ms:
        d, x, y = calc(x, y, ex, ey, m)
        w += d
    print(w)
from collections import defaultdict
N, Q = map(int, input().split())
C = [0] * (N+1)
D = defaultdict(set)
for i in range(N-1):
  a, b = map(int, input().split())
  D[a].add(b)
  
def AddPX(n, x):
  C[n] += x
  for i in D[n]:
    AddPX(i, x)
  
for i in range(Q):
  p, x = map(int, input().split())
  AddPX(p, x)

print (" ".join(map(str, C[1:])))

### FIXED CODE ###

from collections import deque
from collections import defaultdict
N, Q = map(int, input().split())
C = [0]* N
D = defaultdict(set)
for i in range(N-1):
  a, b = map(int, input().split())
  D[a-1].add(b-1)
  D[b-1].add(a-1)
for i in range(Q):
  p, x = map(int, input().split())
  C[p-1] += x

Q = deque([])
Q.append(0)
vstd = set()

while len(Q)>0:
  a = Q.popleft()
  vstd.add(a)
  for b in D[a]:
    if b in vstd:
      continue
    C[b] += C[a]
    Q.append(b)

print (" ".join(map(str, C)))