Harryxun/stf_run huggingface dataset:
N,K = map(int, input().split())
es = [[] for _ in range(N)]

for _ in range(N-1):
    a,b = map(int, input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)


MOD = 10**9+7
 
MAXN = N+5
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD
 
def nPr(n,r):
    if n < r:
        return 0
    return fac[n] * finv[n-r]

ans = 1

checked = [False] * N
q = []
# 探索開始ノードの取りうる色K個と、そこに繋がるノードの色の取り方
ans *= K * nPr(K-1, len(es[0]))

checked[0] = True
for nxt in es[0]:
    q.append(nxt)
    checked[nxt] = True

while q:
    curr = q.pop()
    ans *= nPr(K-2, len(es[curr]) - 1)
    ans %= MOD
    for nxt in es[curr]:
        if not checked[nxt]:
            q.append(nxt)
            checked[nxt] = True
print(ans)

### FIXED CODE ###



MOD = 10**9 + 7
N,K = map(int, input().split())
es = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int, input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)

MAXN = K+5
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def nPr(n,r):
    if n < r:
        return 0
    return fac[n] * finv[n-r]

# 「距離が２以内は異なる色 = あるノードとそれに隣接するノードはそれぞれ異なる色」の言い換えがポイント
# 根はK通り、根の子の数をmとすると、根の子の塗り方は、K-1個の中からm個並べる方法なので、nPr(K-1, m)通り
# それ以降についてあるノードを見るとき、そのノードと親には既に色が塗られている場合を考える。
# 親とその親の２色は使われてるから、そのノードのこの塗り方はK-2のうちから子の数だけ並べるときなので、nPr(K-2, 子の数)


ans = (K * nPr(K-1, len(es[0]))) % MOD
stack = []
for nxt in es[0]:
    stack.append(nxt)

checked = [False] * N
checked[0] = True

# ノード0の子から見ていって、その子の塗り方をかけ合わせていく
while stack:
    curr = stack.pop()
    checked[curr] = True
    # currの親はすでに塗ってあるので、r = len(es[curr])-1
    ans *= nPr(K-2, len(es[curr])-1)
    ans %= MOD
    for nxt in es[curr]:
        if not checked[nxt]:
            stack.append(nxt)

print(ans % MOD)
#!/usr/bin/env python

s = inputs()
for c in s:
    if c == "9":
        print("1", end="")
    else:
        print("9", end="")

### FIXED CODE ###

#!/usr/bin/env python

s = input()
for c in s:
    if c == "9":
        print("1", end="")
    else:
        print("9", end="")
S = int(input())
W = int(input())
if S <= W :
  print("unsafe")
else:
  print("safe")

### FIXED CODE ###

S, W = map(int,input().split())
if S <= W :
  print("unsafe")
else:
  print("safe")
N = input()
N = N[2]
if N == 3:
    print('bon')
elif N in [0,1,6,8]:
    print('pon')
else:
    print('hon')

### FIXED CODE ###

N = input()
N = int(N[-1])
if N == 3:
    print('bon')
elif N in [0,1,6,8]:
    print('pon')
else:
    print('hon')
# -*- coding: utf-8 -*-

n = int(input())
h = input().split()
h.reverse()
for i in range(n):
  for j in range(i+1, n) 
    if h[j] > h[i] + 1:
      print('No')
      return
print('Yes')


### FIXED CODE ###

# -*- coding: utf-8 -*-
 
n = int(input())
h = list(map(int, input().split()))
h.reverse()
limit = h[0]
r = 'Yes'
for i in range(n-1):
    if h[i] < limit:
      limit = h[i]
    if h[i+1] > limit + 1:
      r = 'No'
      break
    
print(r)
# -*- coding: utf-8 -*
a_b = input().split()
a = int(a_b[0])
b = int(a_b[1])
n = b - a

h = (n - 1) * n / 2 - a

print(int(h))


### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(input())

if n < 1000:
    print('ABC')
else:
    print('ABD')
A=int(input())
B=int(input())

if A,B<=9:
  print(A*B)
else:
  print(-1)

### FIXED CODE ###

A,B=map(int,input().split())
if A<=9 and B<=9:
  print(A*B)
else:
  print(-1)
from collections import defaultdict


n, m = map(int, input().split())
d = defaultdict(int)
for i in range(n):
    tmp = map(int, input().split())
    for a in tmp[1:]:
        d[a] += 1
cnt = 0
for value in range(d.values()):
    if value == n:
        cnt += 1
print(cnt)

### FIXED CODE ###

from collections import defaultdict


n, m = map(int, input().split())
d = defaultdict(int)
for i in range(n):
    tmp = list(map(int, input().split()))
    for a in tmp[1:]:
        d[a] += 1
cnt = 0
for value in d.values():
    if value == n:
        cnt += 1
print(cnt)
import functools
import math

n = int(input())
A = list(map(int, input().split()))

print(functools.reduce(math.gcd, A))

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))

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

E = gcd(A[0], A[1])
if n == 2: print(E)
else:
    for i in range(2, n):
        E = gcd(E, A[i])
    print(E)
n = int(input())
a = input().split()
max = -1000000
min = 1000000
sum = 0
for i in range(0,n):
    sum = sum + int(a[i])
    if int(a[i]) > max:
        max = int(a[i])
    if int(a[i]) < min:
        min = int(a[i])
 
print(str(min) + " " + str(max) + " " + str(sum))


### FIXED CODE ###

n = int(input())
a = sorted([int(x) for x in input().split()])
print(a[0],a[-1],sum(a))
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
if max(cnt) == 3:print"NO"
else:print "YES"

### FIXED CODE ###

cnt = [0] * 100
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
if max(cnt) == 3:print"NO"
else:print "YES"
X, Y = [int(x) for x in input()]

def solve(X, Y):
    if X == 1:
        return -1
    if X == Y:
        return -1
    for x in range(X, 10**18+1, X):
        if x % Y != 0:
            return x
solve(X, Y)





### FIXED CODE ###

X, Y = [int(x) for x in input().split()]

def solve(X, Y):
    if X == Y:
        return -1
    if Y < X:
        if X % Y == 0:
            return -1

    for x in range(X, 10**18+1, X):
        if x % Y != 0:
            return x
print(solve(X, Y))
h,w=map(int,input().split())
f=[]
f.append("."*(w+2))
for i in range(h):
  f.append("."+input()+".")
a=[]*h[]*w
for i in range(1,h+1):
  for j in range(1,w+1):
    if f[i][j]=".":
      dumy=f[i-1][j-1]+f[i-1][j]+f[i-1][j+1]+f[i][j-1]+f[i][j]+f[i][j+1]+f[i+1][j-1]+f[i+1][j]+f[i+1][j+1]
      a[i-1][j-1]=count(dumy.index("#"))
    else:
      a[i-1][j-1]="#"
      
for i in range(h):
  print(a[i])
    
    

### FIXED CODE ###

h,w=map(int,input().split())
f=[]
f.append("."*(w+2))
for i in range(h):
  f.append("."+input()+".")
f.append("."*(w+2))
a=[]
for i in range(1,h+1):
  dumy2=""
  for j in range(1,w+1):
    if f[i][j]==".":
      dumy=f[i-1][j-1]+f[i-1][j]+f[i-1][j+1]+f[i][j-1]+f[i][j]+f[i][j+1]+f[i+1][j-1]+f[i+1][j]+f[i+1][j+1]
      n=dumy.count("#")
      dumy2+=str(n)
    else:
      dumy2+="#"
  a.append(dumy2)
for i in range(h):
  print(a[i])
from scipy.special import comb

N = int(input())
S = []
for i in range(N):
    s = list(input())
    s.sort()
    S.append(s)

S.sort()

count = 0
count_min = 0
tmp = []
for s in S:
    if s == tmp:
        count_min += 1
    else:
        count += comb(count_min+1, 2, exact=True)
        count_min = 0
    tmp = s
    # print('count:{}, min:{}'.format(count, count_min))
count += comb(count_min+1, 2, exact=True)
print(count)


### FIXED CODE ###

import unittest
from io import StringIO
import sys
from math import factorial
from scipy.misc import comb
import math


def resolve():
    N = int(input())
    d = {}
    count = 0
    for i in range(N):
        s = list(input())
        s.sort()
        s = ''.join(s)
        if s not in d.keys():
            d[s] = 1
        else:
            count += d[s]
            d[s] += 1

    print(count)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
acornistnt
peanutbomb
constraint"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
oneplustwo
ninemodsix"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa"""
        output = """4"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()
a, b, k = map(int, input().split())
divisers = []

for i in range(1, max(a, b) + 1):
    if a % i == 0 and b % i == 0:
        divisers.append(i)

print(divisers[-k])


### FIXED CODE ###

a, b, c = map(int, input().split())
print(min(b // a, c))
x,y=map(int,input().split())
a=list(map(int,input().split()))
a=set(a)
for i in range(101):
  
  if x-i not in a:
        print(x-i)
        exit()
    elif x+i not in a:
        print(x+i)
        exit()

### FIXED CODE ###

x,y=map(int,input().split())
a=list(map(int,input().split()))
a=set(a)
for i in range(101):
  
  if x-i not in a:
        print(x-i)
        exit()
  elif x+i not in a:
      print(x+i)
      exit()
N=int(input())
for i in range(1,2N):
  if i%2==0 and i%N==0:
    print(i)
    break

### FIXED CODE ###

N=int(input())
if N%2==0:
  print(N)
else:
  print(2*N)
input()
A = list(map(int, input().split()))
count == 0
while all(a % 2 == 0 for a in A)
	A == [a/2 for a in A]
  	count += 1
print(count)

### FIXED CODE ###

input()
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in A):
    A = [a/2 for a in A]
    count += 1
print(count)
import math

n = int(input())
a = [int(x) for x in input().split(" ")]
g = a.sort()[n - 1]

for i in range(1, n):
    g = math.gcd(g, a[i])

print(g)


### FIXED CODE ###

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

def m(a):
    a.sort()
    l = len(a)
    b = []
    for i in range(l // 2):
        b.append(gcd(a[i], a[l - i - 1]))
    if l % 2 == 1:
        b.append(a[l // 2])
    return list(set(b))

    
n = int(input())
a = [int(x) for x in input().split(" ")]

while len(a) > 1:
    a = m(a)

print(a[0])
n=input()
S=set([map(int,raw_input().split())])
q=input()
T=set([map(int,raw_input().split())])
print len(S&T)

### FIXED CODE ###

n=input()
S=set(map(int,raw_input().split()))
q=input()
T=set(map(int,raw_input().split()))
print len(S&T)
def expect(p):
    return (int(p)+1)/2

N, K = map(int ,input().split(' '))
P = list(map(expect ,input().split(' ')))

sum_list = [sum(P[0:K])]
S = [sum(P[0:i]) for i in range(len(P))]
E = []

for i in range(N-K):
    E.append(S[i+K]-S[i])

print('{:.12f}'.format(max(E)))

### FIXED CODE ###

S, T = map(str ,input().split(' '))
A, B = map(int ,input().split(' '))
U = input()

dct = {S:A, T:B}
dct[U] = dct[U] - 1
print(dct[S], dct[T])
def mss(l,length,k):
    x = 0
    for i in range(length):
        temp = 0
        for j in range(i,i+k-1):
            temp += l[j]
            if temp > x:
                x = temp
    return x

if __name__ == '__main__':
    N,K = map(int,input().split())
    P = [int(p)-1 for p in input().split()]
    C = [int(c) for c in input().split()]
    #閉路の探索
    L_close = []
    Done = [0] * N
    for i in range(N):
        if Done[i] == 1:
            continue
        score = []
        #start
        Done[i] = 1
        #Next
        p = P[i]
        Done[p] = 1
        score.append(C[p])
        while p != i:
            p = P[p]
            Done[p] = 1
            score.append(C[p])
        L_close.append(score)
    #それぞれの閉路に対して
    ans = 0
    for l in L_close:
        total = sum(l)
        length = len(l)
        l = l + l
        if total <= 0:
            ans = max(ans,mss(l,length,K))
        else:
            ans = max(ans,total * (K//length) + mss(l,length,K%length))
    print(ans)

### FIXED CODE ###

def mss(l,length,k):
    x = - 1000000001
    for i in range(length):
        temp = 0
        for j in range(i,i+k):
            temp += l[j]
            if temp > x:
                x = temp
    return x
  
def mss2(l,length,total,k):
    x = - 1000000001
    if k <= length:
      for i in range(length):
          temp = 0
          for j in range(i,i+k):
              temp += l[j]
              if temp > x:
                  x = temp
      return x
    else:
      for i in range(length):
          temp = 0
          for j in range(i,i+length):
              temp += l[j]
              r = j - i + 1
              if temp + (total * ((k-r) // length)) > x:
                  x = temp + (total * ((k-r) // length))
      return x
      

if __name__ == '__main__':
    N,K = map(int,input().split())
    P = [int(p)-1 for p in input().split()]
    C = [int(c) for c in input().split()]
    #閉路の探索
    L_close = []
    Done = [0] * N
    for i in range(N):
        if Done[i] == 1:
            continue
        score = []
        #start
        Done[i] = 1
        #Next
        p = P[i]
        Done[p] = 1
        score.append(C[p])
        while p != i:
            p = P[p]
            Done[p] = 1
            score.append(C[p])
        L_close.append(score)
    #それぞれの閉路に対して
    ans = - 1000000001
    for l in L_close:
        total = sum(l)
        length = len(l)
        l = l + l
        if total <= 0:
            ans = max(ans,mss(l,length,min(K,length)))
        else:
            ans = max(ans,mss2(l,length,total,K))
    print(ans)
N = int(intput())

print((N - N % 2) * (N + N % 2)/4)


### FIXED CODE ###

N = int(input())
a = int((N - N % 2) * (N + N % 2)/4)
print(a)
N = int(input())
C = [0] * (N-1)
S = [0] * (N-1)
F = [0] * (N-1)
for i in range(N-1):
    C[i], S[i], F[i] = map(int, input().split())

for i in range(N):
    time = 0
    for j in range(i, N-1):
        if time < S[j]:
            time = S[j]
        elif time % F[j]:
            time += F[j] - (t % F[j])
        time += C[j]
        
    print(time)


### FIXED CODE ###

N = int(input())
C = [0] * (N-1)
S = [0] * (N-1)
F = [0] * (N-1)
for i in range(N-1):
    C[i], S[i], F[i] = map(int, input().split())

for i in range(N):
    time = 0
    for j in range(i, N-1):
        if time < S[j]:
            time = S[j]
        elif time % F[j]:
            time += F[j] - (time % F[j])
        time += C[j]

    print(time)
n = int(input())
s = set(map(int,input().split()))
a = len(s)
print(a)

### FIXED CODE ###

s,w = map(int,input().split())
if s <= w :
    print("unsafe")
else :
    print("safe")
n=int(input())

ans=0

a=[]
b=[]

for _ in range():
    x=int(input())
    a.append(x)
    b.append(x)
b.sort()

cnt=0
for i,v in enumerate(a):
    if i%2 != (b.index(v))%2:
        cnt+=1
print(cnt//2)

### FIXED CODE ###

n=int(input())

ans=0

a=[]
b=[]

for _ in range(n):
    x=int(input())
    a.append(x)
    b.append(x)
b.sort()

dic={}
for i,v in enumerate(b):
    dic[v]=i%2

cnt=0
for i,v in enumerate(a):
    if i%2 != dic[v]:
        cnt+=1
print(cnt//2)
N = input()

ans = N*(N-1)//2
print(ans)

### FIXED CODE ###

N = int(input())

ans = N*(N-1)//2
print(ans)
import math

def nCm(n, m):
    return math.factorial(n) // (math.factorial(m) * (math.factorial(n - m)))


n = int(input())
a = list(map(int, input().split()))

saw = [-1] * n
left = 0
right = 0
for i in range(n):
    if saw[a[i] - 1] == -1:
        saw[a[i] - 1] = i
    else:
        left, right = saw[a[i] -1], n - i
        break
print(left, right)

for i in range(1, n+2):
    if i == 1:
        print(n)
    else:
        print((nCm(n+1, i) - nCm(left+right, i - 1) % 1000000007))


### FIXED CODE ###

def power(x, n):
    y = 1
    while n > 0:
        if n % 2 == 0:
            x = (x * x) % (10 ** 9 + 7)
            n = n // 2
        else:
            y = (y * x) % (10 ** 9 + 7)
            n = n - 1
    return y


MOD = 10 ** 9 + 7

n = int(input())
a = list(map(int, input().split()))

fact = [1] * (n + 2)
inv = [1] * (n + 3)

for i in range(1, n + 2):
    fact[i] = (i * fact[i - 1]) % MOD
    inv[i] = power(fact[i], MOD - 2) % MOD


def nCm(n, m):
    global fact
    global inv
    return fact[n] * inv[m] % MOD * inv[n - m] % MOD


saw = [-1] * n
left = 0
right = 0
for i in range(n):
    if saw[a[i] - 1] == -1:
        saw[a[i] - 1] = i
    else:
        left, right = saw[a[i] - 1], n - i
        break

for i in range(1, n + 2):
    if i == 1:
        print(n)
    elif left + right >= i - 1:
        print((nCm(n + 1, i) - nCm(left + right, i - 1)) % MOD)
    else:
        print(nCm(n + 1, i))
N, M = map(int, input().split())
L, R = 1, N

import math

def merge_list(target):
    L = target[-1][0]
    R = sorted(target, key=lambda x: x[1])[0][1]
    return (L, R)

data = []
for i in range(0, M):
    l, r = input().split()
    data.append((int(l), int(r)))
data = sorted(data, key=lambda x: x[0])

import numpy as np
def saiki(totyuu):
    D = 2 # ぶんかつすう
    if len(totyuu) < 100:
        return merge_list(list(totyuu))
    else:
        return merge_list(np.array_split(totyuu, D))

data = saiki(data)

print(max(0, data[1]-data[0]+1))

### FIXED CODE ###

N, M = map(int, input().split())

Ls = []
Rs = []
for i in range(0, M):
    l, r = input().split()
    Ls.append(int(l))
    Rs.append(int(r))

maxL = max(Ls)
minR = min(Rs)
result = max(0, minR-maxL+1)

print(result)
n = int(input())
num_list = [ int(v) for v in input().split() ]
s = 0
for i in range(n):
	if max(num_list[:i+1]) <= num_list[i]:
		s += 1
print(s)

### FIXED CODE ###

a, b = [ int(v) for v in input().split() ]
print(max(a+b,a*2-1,b*2-1))
x1, x2, x3, x4, x5 = int(input().split())
x = list()
x.append(x1)
x.append(x2)
x.append(x3)
x.append(x4)
x.append(x5)
ans = 0
for i, j in enumerate(x):
  if i+1 != j:
  	ans = j
print(type(0 2 3 4 5),j)

### FIXED CODE ###

x1, x2, x3, x4, x5 = input().split()
x = list()
x.append(x1)
x.append(x2)
x.append(x3)
x.append(x4)
x.append(x5)
ans = 0
for i, j in enumerate(x):
  if int(j) == 0:
  	ans = i+1
print(int(ans))
from operator import itemgetter

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

num = [''] * n

if m == 0:
    for i in range(n):
        num[i] = '0'
    if n != 1:
        num[0] = '1'
    print(''.join(num))
    exit()

sc = sorted([list(map(int, input().split())) for _ in range(m)], key = itemgetter(0))

last = sc[0][0]
num[last-1] = str(sc[i][1])
number = True

if last != 1:
    num[0] = '1'

for i in range(m):
    if sc[i][0] == 1 and sc[i][1] == 0:
        number = False
    if sc[i][0] == last and num[last-1] != '':
        if num[last-1] != sc[i][1]:
            number = False
    last = sc[i][0]
    num[last-1] = str(sc[i][1])

for i in range(n):
    if num[i] == '':
        num[i] = '0'
        
if number:
    print(''.join(num))
else:
    print(-1)


### FIXED CODE ###

from operator import itemgetter

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

num = [''] * n

if m == 0:
    for i in range(n):
        num[i] = '0'
    if n != 1:
        num[0] = '1'
    print(''.join(num))
    exit()

sc = sorted([list(map(int, input().split())) for _ in range(m)], key = itemgetter(0))

last = sc[0][0]
num[last-1] = str(sc[0][1])
number = True

if last != 1:
    num[0] = '1'

for i in range(m):
    if n != 1 and sc[i][0] == 1 and sc[i][1] == 0:
        number = False
    if sc[i][0] == last and num[last-1] != '':
        if num[last-1] != str(sc[i][1]):
            number = False
    last = sc[i][0]
    num[last-1] = str(sc[i][1])

for i in range(n):
    if num[i] == '':
        num[i] = '0'

if number:
    print(''.join(num))
else:
    print(-1)
x, n = map(int, input().split())
if n != 0:
  n = list(map(int, input().split()))
  min_n = abs(x - min(n))
  max_n = max(n) - x
  ans = []
  for i in range(1, max(min_n, max_n) + 1):
    if n.count(x + i) == 0:
      ans.append(x + i)

    if n.count(x - i) == 0:
      ans.append(x - i)
    
    if ans != []:
      break

  print(min(ans))
else:
  print(x)

### FIXED CODE ###

x, n = map(int, input().split())
if n != 0:
  n = list(map(int, input().split()))
  ans = []
  for i in range(101):
    if n.count(x + i) == 0:
      ans.append(x + i)

    if n.count(x - i) == 0:
      ans.append(x - i)
    
    if ans != []:
      break

  print(min(ans))
else:
  print(x)
from collections import Counter
N = int(input())
S = []
while True:
    S.append(input())

print(len(Counter(S)))

### FIXED CODE ###

n=int(input())
s=[input() for _ in range(n)]

print(len(set(s)))
N = input()

if N[0] != "7" and N[1] != "7" and N[2] != "7":
    print("No")
else:
    print("Yes")

### FIXED CODE ###

import math
R = float(input())
print(2 * math.pi * R)
import sys

list_1 = input().split(" ")
list_2 = list(map(int, list_1))

w = list_2[0]
h = list_2[1]
x = list_2[2]
y = list_2[3]
r = list_2[4]

if !(abs(x - r) < abs(w) && abs(x + r) < abs(w)):
    print("NO")
    sys.exit()

if !(abs(y - r) < abs(h) && abs(y + r) < abs(h)):
    print("NO")
    sys.exit()

print("YES")

### FIXED CODE ###

import sys

input_list = input().split(" ")
input_list = list(map(int, input_list))

w = input_list[0]
h = input_list[1]
x = input_list[2]
y = input_list[3]
r = input_list[4]

if 0 <= x - r and x + r <= w:
    if 0 <= y - r and y + r <= h:
        print("Yes")
        sys.exit()

print("No")
print("{:.9g}" {}.format(area/2,1))

### FIXED CODE ###

w, h, x, y = [int(i) for i in input().split()]
area = w*h

print("{:.9f}".format(area/2),end=" ")

if 2*x == w and 2*y == h:
  print(1)
else:
  print(0)
a = input()
if a < 2:
    print(0)
else:
    if a % 2 == 0:
        print(int(a / 2 - 1) )
    else:
        print(int(a/2))

### FIXED CODE ###

a = int(input())
if a < 2:
        print(0)
elif a % 2 == 0:
        print(int(a / 2 - 1) )
else:
        print(int(a/2))
N, X = map(int,input().split())
x = list(input().split())
x = sorted([int(i) for i in x])
diff = []
res = 10**10
for i in x:
    if i !=x[0]:
        diff.append(i-old)
    res = min(abs(X-i),res)
    old = i
res = min(min(diff),res)
print(res)
    

### FIXED CODE ###

def gcd(a,b):
    if b > 0:
        c = a % b
        return(gcd(b,c))
    elif b == 0:
        return(a)

N, X = map(int,input().split())
x = list(input().split())
x = [abs(X-int(i)) for i in x]
for i in x:
    if i == x[0]:
        a = i
    else:
        a = gcd(a,i)
print(a)