Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
if N == 2:
    if A[1] == 2:
        print(sum(B)+sum(C))
    else:
        print(sum(B))
else:
    k = A[-1]
    if k == A[N-1]:
        print(sum(B)+sum(C))
    else:
        print(sum(B)+sum(C)-C[k-1])

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
    k = A[i]
    ans += B[k-1]
    if i < N-1:
        if A[i+1] == k+1 and k != N:
            ans += C[k-1]
        else:
            pass
    else:
        pass
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
   
if N == 2:
    print(sum(B)+sum(C))
elif N == 1:
    print(sum(B))
else:
    k = A[-1]
    print(sum(B)+sum(C)-C[k-1])

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
    k = A[i]
    ans += B[k-1]
    if i < N-1:
        if A[i+1] == k+1 and k != N:
            ans += C[k-1]
        else:
            pass
    else:
        pass
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
   
if N == 2:
    print(sum(B)+sum(C))
else:
    k = A[-1]
    print(sum(B)+sum(C)-C[k-1])

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
    k = A[i]
    ans += B[k-1]
    if i < N-1:
        if A[i+1] == k+1 and k != N:
            ans += C[k-1]
        else:
            pass
    else:
        pass
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
   
k = A[-1]
print(sum(B)+sum(C)-C[k-1])

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
    k = A[i]
    ans += B[k-1]
    if i < N-1:
        if A[i+1] == k+1 and k != N:
            ans += C[k-1]
        else:
            pass
    else:
        pass
print(ans)
Buggy python submission (verdict: Runtime Error):
S, T = input().split()
ans = 0
for i in range(3):
    if S[i]==T[i]:
        ans += 1
    else:
        pass
print(ans)

Fixed submission:
S, T = input(), input()
ans = 0
for i in range(3):
    if S[i]==T[i]:
        ans += 1
    else:
        pass
print(ans)

Buggy python submission (verdict: Runtime Error):
S, T = input().split()

ans = 0
for i in range(3):
    if S[i]==T[i]:
        ans += 1
    else:
        pass
print(ans)

Fixed submission:
S, T = input(), input()
ans = 0
for i in range(3):
    if S[i]==T[i]:
        ans += 1
    else:
        pass
print(ans)
Buggy python submission (verdict: Runtime Error):
print(list(map(lambda N: ((N-1)*N)//2, int(input())))[0])

Fixed submission:
N = int(input())
print(((N-1)*N)//2)

Buggy python submission (verdict: Runtime Error):
 N = int(input())
 print(((N-1) * N )/ 2)

Fixed submission:
N = int(input())
print(((N-1)*N)//2)

Buggy python submission (verdict: Runtime Error):
 N = int(input())
 print((N-1) * N // 2)

Fixed submission:
N = int(input())
print(((N-1)*N)//2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
print(sum(range(N)))

Fixed submission:
N = int(input())
print(((N-1)*N)//2)

Buggy python submission (verdict: Runtime Error):
N = int(input())
print(sum(list(range(N))))

Fixed submission:
N = int(input())
print(((N-1)*N)//2)

Buggy python submission (verdict: Runtime Error):
print(sum(list(range(int(input()))))

Fixed submission:
N = int(input())
print(((N-1)*N)//2)

Buggy python submission (verdict: Runtime Error):
N = int(input())
print(sum(list(range(N))))

Fixed submission:
N = int(input())
print(((N-1)*N)//2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(N):
    ans += i
print(ans)

Fixed submission:
N = int(input())
print(((N-1)*N)//2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()

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

L = []
for i in range(K):
    l, r = map(int, input().split())
    L.append((l,r))

L.sort()

dp = [0] * (N+1)
dp[1] = 1

for i in range(2,N+1):
    count = 0
    for l,r in L:
        if l >= i:
            break
        elif l < i and i - r > 1:
            count += dp[i-l] - dp[i-r-1]
        else:
            count += dp[i-l]
    dp[i] = dp[i-1] + count

print((dp[N] - dp[N-1])% 998244353)

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()

mod = 998244353
N, K = map(int, input().split())

L = []
for i in range(K):
    l, r = map(int, input().split())
    L.append((l,r))

L.sort()

dp = [0] * (N+1)
dp[1] = 1

for i in range(2,N+1):
    count = 0
    for l,r in L:
        if l >= i:
            break
        elif l < i and i - r > 1:
            count += dp[i-l] - dp[i-r-1]
        else:
            count += dp[i-l]
    dp[i] = (dp[i-1] + count) % mod

print((dp[N] - dp[N-1])% mod)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()

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

L = []
R = []
for i in range(K):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

dp = [0] * (N+1)
dp[1] = 1

for i in range(2,N+1):
    count = 0
    for l,r in zip(L,R):
        if l < i and i - r > 1:
            count += dp[i-l] - dp[i-r-1]
        elif l < i:
            count += dp[i-l]
    dp[i] = dp[i-1] + count

print((dp[N] - dp[N-1])% 998244353)

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()

mod = 998244353
N, K = map(int, input().split())

L = []
for i in range(K):
    l, r = map(int, input().split())
    L.append((l,r))

L.sort()

dp = [0] * (N+1)
dp[1] = 1

for i in range(2,N+1):
    count = 0
    for l,r in L:
        if l >= i:
            break
        elif l < i and i - r > 1:
            count += dp[i-l] - dp[i-r-1]
        else:
            count += dp[i-l]
    dp[i] = (dp[i-1] + count) % mod

print((dp[N] - dp[N-1])% mod)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()

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

numset = set()
for i in range(K):
    l, r = map(int, input().split())
    numset |= set(range(l,r+1))

dp = [0] * (N+1)
dp[1] = 1

numlist = list(numset)
for i in range(2,N+1):
    for j in numlist:
        if j >= i:
            break
        dp[i] += dp[i-j]
    
print(dp[N] % 998244353)

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()

mod = 998244353
N, K = map(int, input().split())

L = []
for i in range(K):
    l, r = map(int, input().split())
    L.append((l,r))

L.sort()

dp = [0] * (N+1)
dp[1] = 1

for i in range(2,N+1):
    count = 0
    for l,r in L:
        if l >= i:
            break
        elif l < i and i - r > 1:
            count += dp[i-l] - dp[i-r-1]
        else:
            count += dp[i-l]
    dp[i] = (dp[i-1] + count) % mod

print((dp[N] - dp[N-1])% mod)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()

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

A_max = max(A)
prime = [[] for _ in range(A_max + 1)]
for i in range(2,A_max + 1):
    if prime[i] == []:
        n = i
        while n <= A_max:
            prime[n].append(i)
            n += i

li = [0] * (A_max + 1)
for a in A:
    for p in prime[a]:
        li[p] += 1


if max(li) <= 1:
    print('pairwise coprime')
elif max(li) == N:
    print('not coprime')
else:
    print('setwise coprime')

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()

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

A_max = max(A)
prime = [[] for _ in range(A_max + 1)]
for i in range(2,A_max + 1):
    if prime[i] == []:
        n = i
        while n <= A_max:
            prime[n].append(i)
            n += i

li = [0] * (A_max + 1)
for a in A:
    for p in prime[a]:
        li[p] += 1


if max(li) <= 1:
    print('pairwise coprime')
elif max(li) == N:
    print('not coprime')
else:
    print('setwise coprime')

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()

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

A_max = A[-1]
prime = [[] for _ in range(A_max + 1)]
for i in range(2,A_max + 1):
    if prime[i] == []:
        n = i
        while n <= A_max:
            prime[n].append(i)
            n += i

li = [0] * (A_max + 1)
for a in A:
    for p in prime[a]:
        li[p] += 1

if max(li) == 1:
    print('pairwise coprime')
elif max(li) == N:
    print('not coprime')
else:
    print('setwise coprime')

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()

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

A_max = max(A)
prime = [[] for _ in range(A_max + 1)]
for i in range(2,A_max + 1):
    if prime[i] == []:
        n = i
        while n <= A_max:
            prime[n].append(i)
            n += i

li = [0] * (A_max + 1)
for a in A:
    for p in prime[a]:
        li[p] += 1


if max(li) <= 1:
    print('pairwise coprime')
elif max(li) == N:
    print('not coprime')
else:
    print('setwise coprime')
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

N = int(stdin.readline())
A = list(map(int, stdin.readline().split()))

ans = 1

if 0 in A:
    ans = 0

if ans:
    for a in A:
        ans *= a
        if ans > pow(10, 18):
            ans = -1

print(ans)

Fixed submission:
from sys import stdin

N = int(stdin.readline())
A = list(map(int, stdin.readline().split()))

ans = 1

if 0 in A:
    ans = 0

if ans:
    for a in A:
        ans *= a
        if ans > pow(10, 18):
            ans = -1
            break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

N = int(stdin.readline())
A = list(map(int, stdin.readline().split()))

ans = 1

for i in range(N):
    if A[i] == 0:
        ans = 0

if ans:
    for i in range(N):
        ans *= A[i]
        if ans > pow(10, 18):
            ans = -1

print(ans)


Fixed submission:
from sys import stdin

N = int(stdin.readline())
A = list(map(int, stdin.readline().split()))

ans = 1

if 0 in A:
    ans = 0

if ans:
    for a in A:
        ans *= a
        if ans > pow(10, 18):
            ans = -1
            break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

N = int(stdin.readline())
A = list(map(int, stdin.readline().split()))

ans = 1
for i in range(N):
    ans *= A[i]
    
if ans > pow(10, 18):
    ans = -1
    
print(ans)


Fixed submission:
from sys import stdin

N = int(stdin.readline())
A = list(map(int, stdin.readline().split()))

ans = 1

if 0 in A:
    ans = 0

if ans:
    for a in A:
        ans *= a
        if ans > pow(10, 18):
            ans = -1
            break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import queue
import sys
def input(): return sys.stdin.readline().rstrip()

N = int(input())


vlist = [[] for _ in range(N)]

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

ans = [-1] * N
q = queue.Queue()

ans[0] = 0
q.put(0)

while q:
    new = q.get()
    for node, weight in vlist[new]:
        if ans[node] != -1:
            continue
        ans[node] = (ans[new] + weight) % 2
        q.put(node)
    
for i in ans:
    print(i)



Fixed submission:
from collections import deque

N = int(input())


vlist = [[] for _ in range(N)]

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

ans = [-1] * N
q = deque()

ans[0] = 0
q.append(0)

while q:
    new = q.popleft()
    for node, weight in vlist[new]:
        if ans[node] != -1:
            continue
        ans[node] = (ans[new] + weight) % 2
        q.append(node)
    
for i in ans:
    print(i)

Buggy python submission (verdict: Runtime Error):
from collections import deque

N = int(input())


vlist = [[]] * N

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

ans = [-1] * N
q = deque()

ans[0] = 0
q.append(0)

while q:
    new = q.popleft()
    for node, weight in vlist[new]:
        if ans[node] != -1:
            continue
        ans[node] = (ans[new] + weight) % 2
        q.append(node)
    
for i in ans:
    print(i)

Fixed submission:
from collections import deque

N = int(input())


vlist = [[] for _ in range(N)]

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

ans = [-1] * N
q = deque()

ans[0] = 0
q.append(0)

while q:
    new = q.popleft()
    for node, weight in vlist[new]:
        if ans[node] != -1:
            continue
        ans[node] = (ans[new] + weight) % 2
        q.append(node)
    
for i in ans:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
class fenwick_tree:
    def __init__(self, n):
        self.data = [0 for _ in range(n+1)]
        self.n = n

    def add(self, p, x):
        p += 1
        while p <= self.n:
            self.data[p-1] += x
            p += p & -p
    
    def sum(self, l, r):
        return self._sum(r) - self._sum(l)

    def _sum(self, r):
        s = 0
        while r > 0:
            s += self.data[r-1]
            r -= r & -r
        return s
    
N, Q = [int(_) for _ in input().split()]

fw = fenwick_tree(N)
A = [int(_) for _ in input().split()]
for i, a in enumerate(A):
    fw.add(i, a)

for i in range(Q):
    t, *q = [int(_) for _ in input().split()]
    if t == 0:
        p, x = q
        fw.add(p, x)
    else:
        l, r = q
        print(fw.sum(l, r))


Fixed submission:
class fenwick_tree:
    def __init__(self, n):
        self.data = [0 for _ in range(n+1)]
        self.n = n

    def add(self, p, x):
        p += 1
        while p <= self.n:
            self.data[p-1] += x
            p += p & -p
    
    def sum(self, l, r):
        return self._sum(r) - self._sum(l)

    def _sum(self, r):
        s = 0
        while r > 0:
            s += self.data[r-1]
            r -= r & -r
        return s
    
N, Q = [int(_) for _ in input().split()]

fw = fenwick_tree(N)
A = [int(_) for _ in input().split()]
for i, a in enumerate(A):
    fw.add(i, a)

for i in range(Q):
    t, *q = [int(_) for _ in input().split()]
    if t == 0:
        p, x = q
        fw.add(p, x)
    else:
        l, r = q
        print(fw.sum(l, r))
Buggy python submission (verdict: Runtime Error):
import math
import functools

N = int(input())
A = [int(_) for _ in input().split()]
p = set([])

y = functools.reduce(math.gcd, A)
pairwise = True

for a in A:
    if a == 1:
        continue
    if pairwise is False:
        break
    for k in range(2, int(math.sqrt(a)) + 2):
        if a % k == 0:
            if k in p:
                pairwise = False
                break
            p.add(k)
            while a % k == 0:
                a //= k
    if pairwise and a > 1:
        p.add(a)

if pairwise:
    print("pairwise coprime")
elif y == 1:
    print("setwize coprime")
else:
    print("not coprime")


Fixed submission:
class UnionFind:
    def __init__(self, N):
        self.root = [-1 for _ in range(N)]
        self.size = [1 for _ in range(N)]

    def find(self, x):
        while self.root[x] >= 0:
            x = self.root[x]
        return x

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.size[x] < self.size[y]:
            self.root[x] = y
            self.size[y] += self.size[x]
        else:
            self.root[y] = x
            self.size[x] += self.size[y]

N, M = [int(_) for _ in input().split()]

uf = UnionFind(N)
for m in range(M):
    A, B = [int(_) - 1 for _ in input().split()]
    uf.union(A, B)

print(max(uf.size))
Buggy python submission (verdict: Runtime Error):
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
A.sort()

def judge(x):
    k = 0
    for a in A:
        v = a // x
        if a % x == 0:
            v -= 1
        k += v
    return k <= K

low = 0
high = max(A)

while low < high - 1:
    mid = (low + high) // 2
    if judge(mid):
        high = mid
    else:
        low = mid

if judge(low):
    print(low)
else:
    print(high)


Fixed submission:
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

def judge(x):
    k = 0
    for a in A:
        v = a // x
        if a % x == 0:
            v -= 1
        k += v
    return k <= K

low = 1
high = max(A)

A.sort()

while low < high - 1:
    mid = (low + high) // 2
    if judge(mid):
        high = mid
    else:
        low = mid

if judge(low):
    print(low)
else:
    print(high)

Buggy python submission (verdict: Runtime Error):
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
A.sort()

def judge(x):
    k = 0
    for a in A:
        v = a // mid
        k += v
    return k <= K

low = 0
high = max(A)

while low < high - 1:
    mid = (low + high) // 2
    if judge(mid):
        high = mid
    else:
        low = mid

if judge(low):
    print(low)
else:
    print(high)


Fixed submission:
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

def judge(x):
    k = 0
    for a in A:
        v = a // x
        if a % x == 0:
            v -= 1
        k += v
    return k <= K

low = 1
high = max(A)

A.sort()

while low < high - 1:
    mid = (low + high) // 2
    if judge(mid):
        high = mid
    else:
        low = mid

if judge(low):
    print(low)
else:
    print(high)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

v = 0
for k in range(1, N+1):
    v += int(k/2 * (N//k) * int(1 + N/k))
print(v)


Fixed submission:
N = int(input())

v = 0
for k in range(1, N+1):
    v += int(k/2 * (N//k) * int(1 + N/k))
print(v)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)

p = 2019
X = [0 for _ in range(p)]
X[0] = 1

dp = X[:]
ans = 0
for i in range(N):
    v = int(S[i])
    np = X[:]
    for k in range(p):
        x = (k * 10 + v) % p
        np[x] += dp[k]
    dp = np[:]
    ans += dp[0] - 1
print(ans)


Fixed submission:
S = input()
N = len(S)

p = 2019
X = [0 for _ in range(p)]
X[0] = 1

dp = X[:]
ans = 0
for i in range(N):
    v = int(S[i])
    np = X[:]
    for k in range(p):
        x = (k * 10 + v) % p
        np[x] += dp[k]
    dp = np[:]
    ans += dp[0] - 1
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()

if S == "AAA" or S = "BBB":
    print("No")
else:
    print("Yes")


Fixed submission:
S = input()

if S == "AAA" or S == "BBB":
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
import math

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

A, B = [int(_) for _ in input().split()]

print(lcm(A, B))


Fixed submission:
import fractions

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

A, B = [int(_) for _ in input().split()]

print(lcm(A, B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(_) for _ in input().split()]

X = [str(A.index(i)+1) for i in range(1, N+1)] 
print(" ".join(X))


Fixed submission:
N = int(input())
A = [int(_) for _ in input().split()]

X = [None for _ in range(N)]
for i, a in enumerate(A):
    X[a-1] = str(i+1)
print(" ".join(X))
Buggy python submission (verdict: Runtime Error):
import sympy

N = int(input())
A = [int(_) for _ in input().split()]

ans = []
for i in range(N)[::-1]:
    if A[i] % 2 == 1:
        ans.append(i+1)
        for j in sympy.divisors(i+1)[:-1]:
            A[j-1] += 1

print(len(ans))
if ans:
    print(" ".join([str(_) for _ in ans]))


Fixed submission:
N = int(input())
A = [int(_) for _ in input().split()]

X = [0 for _ in range(N)]
ans = []
for i in range(N)[::-1]:
    v = 0
    for j in range(i, N, i+1):
        v += X[j]
    if v % 2 != A[i]:
        X[i] = 1
        ans.append(i+1)

print(len(ans))
for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(_) for _ in input().split()]

B = []
for i in range(1, N+1)[::-1]:
    a = A[i-1]
    v = len(list(filter(lambda x: x % i == 0, B)))
    if v % 2 != a:
        B.append(i)

for i in range(1, N+1)[::-1]:
    a = A[i-1]
    v = len(list(filter(lambda x: x % i == 0, B)))
    if v % 2 != a:
        print(-1)
        exit(0)

print(len(B))
if B != []:
    print(" ".join([str(b) for b in B]))
    

Fixed submission:
N = int(input())
A = [int(_) for _ in input().split()]

X = [0 for _ in range(N)]
ans = []
for i in range(N)[::-1]:
    v = 0
    for j in range(i, N, i+1):
        v += X[j]
    if v % 2 != A[i]:
        X[i] = 1
        ans.append(i+1)

print(len(ans))
for i in ans:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(_) for _ in input().split()]
A = [int(input()) for _ in range(M)]

dp = [0 for _ in range(N+1)]
P = 10**9 + 7

dp[0] = 1
for i in range(1, N+1):
    if i in A:
        dp[i] = 0
    elif i == 1:
        dp[i] = dp[i-1] % P
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % P
print(dp[-1])


Fixed submission:
N, M = [int(_) for _ in input().split()]
A = set([int(input()) for _ in range(M)])

dp = [0 for _ in range(N+1)]
P = 10**9 + 7

dp[0] = 1
for i in range(1, N+1):
    if i in A:
        dp[i] = 0
    elif i == 1:
        dp[i] = dp[i-1] % P
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % P
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import math

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

dx = [abs(X - v) for v in x]
ans = dx[0]
for b in dx[1:]:
    ans = math.gcd(ans, b)
print(ans)


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

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

dx = [abs(X - v) for v in x]
ans = dx[0]
for b in dx[1:]:
    ans = gcd(ans, b)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = [int(_) for _ in input().split()]

P = [[int(_) for _ in input().split()] for n in range(N)]

X = []
Y = []
for n in range(N):
    x, y = P[n]
    X.append(x)
    Y.append(y)
X.sort()
Y.sort()

ans = 10 ** 20
for xi in range(N):
    for xj in range(xi+1, N):
        for yi in range(N):
            for yj in range(yi+1, N):
                x1, y1 = X[xi], Y[yi]
                x2, y2 = X[xj], Y[yj]
                c = 0
                for v in range(N):
                    x, y = P[v]
                    if x1 <= x <= x2 and y1 <= y <= y2:
                        c += 1
                if c >= K:
                    ans = min(ans, (x2-x1) * (y2-y1))
print(ans)


Fixed submission:
N, K = [int(_) for _ in input().split()]

P = [[int(_) for _ in input().split()] for n in range(N)]

X = []
Y = []
for n in range(N):
    x, y = P[n]
    X.append(x)
    Y.append(y)
X.sort()
Y.sort()

ans = 10 ** 20
for xi in range(N):
    for xj in range(xi+1, N):
        for yi in range(N):
            for yj in range(yi+1, N):
                x1, y1 = X[xi], Y[yi]
                x2, y2 = X[xj], Y[yj]
                c = 0
                for v in range(N):
                    x, y = P[v]
                    if x1 <= x <= x2 and y1 <= y <= y2:
                        c += 1
                if c >= K:
                    ans = min(ans, (x2-x1) * (y2-y1))
print(ans)