Problem:


Score : 300 points

Problem Statement

There is a box containing N balls. The i-th ball has the integer A_i written on it.
Snuke can perform the following operation any number of times:

Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is written.

Determine whether it is possible for Snuke to reach the state where the box contains a ball on which the integer K is written.

Constraints

1 \leq N \leq 10^5

1 \leq A_i \leq 10^9

1 \leq K \leq 10^9

All input values are integers.

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 ... A_N

Output

If it is possible for Snuke to reach the state where the box contains a ball on which the integer K is written, print POSSIBLE; if it is not possible, print IMPOSSIBLE.

Sample Input 1

3 7
9 3 4

Sample Output 1

POSSIBLE

First, take out the two balls 9 and 4, and return them back along with a new ball, abs(9-4)=5.
Next, take out 3 and 5, and return them back along with abs(3-5)=2.
Finally, take out 9 and 2, and return them back along with abs(9-2)=7.
Now we have 7 in the box, and the answer is therefore POSSIBLE.

Sample Input 2

3 5
6 9 3

Sample Output 2

IMPOSSIBLE

No matter what we do, it is not possible to have 5 in the box. The answer is therefore IMPOSSIBLE.

Sample Input 3

4 11
11 3 7 15

Sample Output 3

POSSIBLE

The box already contains 11 before we do anything. The answer is therefore POSSIBLE.

Sample Input 4

5 12
10 2 8 6 4

Sample Output 4

IMPOSSIBLE



Sample input:
3 7
9 3 4


Sample output:
POSSIBLE

Submission status: Runtime Error

Solution code:
import collections
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

N,K = IL()
l = IL()

if K <= max(l):
    num = gcd(l[0],l[1])
    for i in l:
        if i%num == 0:
            continue
        else:
            num = gcd(num,i)
    if K%num == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
N,K= map(int, input().split())
x = list(map(int, input().split()))
x.sort()
t = max(x)
y = x[0]
s = [1000000000000]
o=0
if x[0] == K:o=1
for i in range(1,len(x)):
    s.append(x[i]-x[i-1])
    if x[i] == K:o = 1
s.sort()
m = min(y,s[0])
if (t>= K and K%m==0) or o==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
N,K= map(int, input().split())
x = list(map(int, input().split()))
x.sort()
t = max(x)
y = x[0]
s = []
for i in range(1,len(x)):
    s.append(x[i]-x[i-1])
s.sort()
m = min(y,s[0])
if t>= K and K%m==0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from itertools import gcd
n,k=map(int,input().split())
a=list(map(int,input().split()))
c=max(a)
p=a[0]
for i in range(1,n):
    p=gcd(a[0],a[i])
print("POSSIBLE" if k%p==0 and k<=c else "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

def f(l, s):
    return s if l % s == 0 else f(s, l % s)

z = f(a[1], a[0])
for i in a:
    z = f(i, z)

if a[-1] >= k and k % z == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
seta = set(a)
lena = 0
while lena != len(seta):
    lena = len(seta)
    sorteda = sorted(seta)
    mini = sorteda[0] if sorteda[0] != 0 else sorteda[1]
    for i in range(1, len(sorteda)):
        seta.add(sorteda[i] % mini)

mini = sorted(seta)[1]
a.reverse()

if k <= a[0] and k % mini == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
if a[-1] < k:
    print('IMPOSSIBLE')
    sys.exit(0)

seta = set(a)
change = True
while change:
    change = False
    setb = seta.copy()
    sorteda = sorted(seta)
    mini = sorteda[0] if sorteda[0] != 0 else sorteda[1]
    for i in range(1, len(sorteda)):
        setb.add(sorteda[i] % mini)
    if setb != seta:
        change = True
        seta = setb

mini = sorted(seta)[1]
a.reverse()

for i in a:
    if (k - i) % mini == 0:
        print('POSSIBLE')
        sys.exit(0)
print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))


if a[-1] < k:
    print('IMPOSSIBLE')
    sys.exit(0)

seta = set(a)
if k in seta:
    print('POSSIBLE')
    sys.exit(0)
change = True
while change:
    change = False
    setb = seta.copy()
    sorteda = sorted(seta)
    for i in range(1, len(sorteda)):
        setb.add(sorteda[i] % sorteda[0])
    if setb != seta:
        change = True
        seta = setb

mini = sorted(seta)[1]
a.sort()
a.reverse()

for i in a:
    if (k - i) % mini == 0:
        print('POSSIBLE')
        sys.exit(0)
print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
a,b=map(int, input().split())
x = list(map(int, input().split()))
x.sort()
p=0
q=0
y=0
for i in x:
    if p == 1 and q == 1:break
    if i == b:
        y=1
    if i%2==0:
        p=1
    else:
        q=1
if b<=x[-1] or y==1:
    if (b%2==0 and(p*q ==0)):
        m="POSSIBLE"
    elif p==1 and q==1:m="POSSIBLE"
    elif y==1:m="POSSIBLE"
else:m="IMPOSSIBLE" 
print(m)

Submission status: Runtime Error

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


def gcd(x, y):
    if x < y:
        return gcd(y, x)
    elif y == 0:
        return x
    else:
        return gcd(y, x % y)


g = A.pop()
for a in A:
    g = gcd(g, a)
if K <= max(A) and K % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
import math
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
g = A.pop()
for a in A:
    g = math.gcd(g, a)

Submission status: Runtime Error

Solution code:
import math
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
g = A.pop()
for a in A:
    g = math.gcd(g, a)
if K <= max(A) and K % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
# import math
import fractions
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a = sorted(a)
if n == 1:
    if a[0] == k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
div = fractions.gcd(a[0], a[1])
for i in range(n):
    if a[i] == k:
        print("POSSIBLE")
        exit()
    elif i >= 2:
        div = fractions.gcd(a[i], a[i-1])
if k % div == 0 and k <= a[-1]:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
"""
b = []
for i in range(len(a)):
    if a[i] == k:
        print("POSSIBLE")
        exit()
    elif a[i] > k:
      b.append(a[i] - k)
      del(a[i])
print(a)
print(b)
"""

Submission status: Runtime Error

Solution code:
# import math
import fractions
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a = sorted(a)
div = fractions.gcd(a[0], a[1])
for i in range(2, n):
    div = fractions.gcd(a[i], a[i-1])
if k % div == 0 and k <= a[-1]:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
"""
b = []
for i in range(len(a)):
    if a[i] == k:
        print("POSSIBLE")
        exit()
    elif a[i] > k:
      b.append(a[i] - k)
      del(a[i])
print(a)
print(b)
"""

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
d=set()
if k>max(a):
    print("IMPOSSIBLE")
    exit()
if k in a:
    print("POSSIBLE")
    exit()
for i in range(n-1):
    for j in range(i+1,n):
        k%=abs(a[i]-a[j])
print(["IMPOSSIBLE","POSSIBLE"][k==0])

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

if n==1:
  x=a[0]
else:
  x=gcd(a[0],a[1])
  for i in range(2,n):
    x=gcd(x,a[i])

if max(a)>=k and k%g==0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    if b == 0:
        return abs(a)
    else:
        return gcd(b, a%b)

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

Im = 'IMPOSSIBLE'
Po = 'POSSIBLE'

if A[-1] < K:
    print(Im)
else:
    for i in range(N):
        if i == 0:
            gcd = gcd(A[i], A[i])
        else:
            gcd = gcd(A[i],gcd)
    if K%gcd == 0:
        print('Po')
    else:
        print('Im')

Submission status: Runtime Error

Solution code:
def gcd(a,b) :
    while b :
        a,b = b, a % b
    return a

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

p = 10**9
for i in range(N-1) :
    q = gcd(L[i],L[i+1])
    if q < p :
        p = q

if (K % p ==  0) and (K <= max(L))
    ans = "POSSIBLE"
else :
    ans = "IMPOSSIBLE"
print(ans)

Submission status: Runtime Error

Solution code:

from math import gcd
    

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

p = 10**9
for i in range(N-1) :
    q = gcd(L[i],L[i+1])
    if q < p :
        p = q

if K % p ==  0 :
    ans = "POSSIBLE"
else :
    ans = "IMPOSSIBLE"
print(ans)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
L = list(map(int,input().split()))
L = list(set(L))
L = sorted(L,reverse=False)

ans = "IMPOSSIBLE"
if L[-1] < K :
    ans = "IMPOSSIBLE"
else :
    for i in range(1,N) :
        if L[i] % L[0] != 0 :
            ans = "POSSIBLE"
            break
print(ans)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if a[-1] < k:
    print("IMPOSSIBLE")
    exit()
if n > 1:
    m = 10**9
    for i in range(n-1):
        m = min(m, abs(a[i+1]-a[i]))
    for i in range(n):
        if abs(a[i]-k) % m == 0:
            print("POSSIBLE")
            exit()
else:
    if a[0] == k:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if max(a) < k:
    print("IMPOSSIBLE")
    exit()
m = 10**9
for i in range(n-1):
    m = min(m, abs(a[i+1]-a[i]))
for i in range(n):
    if abs(a[i]-k) % m == 0:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if max(a) < k:
    print("IMPOSSIBLE")
    exit()
m = 10**9
for i in range(n-1):
    m = min(m, abs(a[i+1]-a[0]))
for i in range(n):
    if abs((a[i]-k)) % m == 0:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from fractions import gcd
n,k=map(int,input().split())
a=list(map(int,input().split()))
g=gcd(a[0],a[1])
for j in range(1,n):
  g=gcd(g,a[j])
m=max(a)
if k<=m and k%g==0:print('POSSIBLE')
else:print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
from math import gcd
n, k = map(int, input().split())
a = list(map(int, input().split()))
g = a[0]
for x in a:
    g = gcd(g, x)
print(("IMPOSSIBLE", "POSSIBLE")[int(k <= max(a) and k % g == 0)])

Submission status: Runtime Error

Solution code:
from math import gcd
n, k = map(int, input().split())
a = list(map(int, input().split()))
g = 0
for x in a:
    g = gcd(g, x)
print(("IMPOSSIBLE", "POSSIBLE")[k <= max(a) and k % g == 0])

Submission status: Runtime Error

Solution code:
from math import gcd
n, k = map(int, input().split())
a = list(map(int, input().split()))
g = 0
for x in a:
    g = gcd(g, x)
print(k <= max(a) and k % g == 0 and "POSSIBLE" or "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
Z = []
for i in range(1, N):
    Z.append(abs(A[i] - A[i - 1]))
Z.sort()
i = 0
while True:
    if i <= len(Z):
        break
    if Z[i] == 0:
        del Z[i]
        i -= 1
    i += 1

    
for i in range(1, len(Z)):
    ans = -1
    if Z[i - 1] % Z[i] != 0:
        ans = 1
    
for i in A:
    if K == i:
        ans = 1
        
if K >= max(A):
    ans = -1
    
if ans == -1:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
Z = []
for i in range(1, N):
    Z.append(abs(A[i] - A[i - 1]))
Z.sort()
i = 0
while True:
    if i <= len(A):
        break
    if Z[i] == 0:
        del Z[i]
        i -= 1
    i += 1

    
for i in range(1, len(Z)):
    ans = -1
    if Z[i - 1] % Z[i] != 0:
        ans = 1
    
for i in A:
    if K == i:
        ans = 1
        
if K >= max(A):
    ans = -1
    
if ans == -1:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
Z = []
for i in range(1, N):
    Z.append(abs(A[i] - A[i - 1]))
Z.sort()
i = 0
while True:
    if i <= len(A):
        break
    if Z[i] == 0:
        del Z[i]
        i -= 1
    i += 1
    
ans = -1
for i in range(1, len(Z)):
    if Z[i - 1] % Z[i] != 0:
        ans = 1
        break
for i in A:
    if K == i:
        ans = 1
if K >= max(A):
    ans = -1
if ans == -1:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
Z = []
for i in range(1, N):
    Z.append(abs(A[i] - A[i - 1]))
Z.sort()
ans = -1
for i in range(1, N - 1):
    if Z[i - 1] % Z[i] != 0:
        ans = 1
        break
for i in A:
    if K == i:
        ans = 1
if K >= max(A):
    ans = -1
if ans == -1:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Runtime Error

Solution code:
from math import gcd
n,k = map(int,input().split())
a = list(map(int,input().split()))
G = a[0]
for i in a:
    G = gcd(G,i)
if k<=max(a) and k%G==0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
def main():
    import math
    n,k=map(int,input().split(" "))
    a=map(int,input().split(" "))
    g=a[0]
    m=max(a)
    for i in range(n):
        g=math.gcd(g,a[i])
    if k % g==0 and k<=m:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

main()

Submission status: Runtime Error

Solution code:

def main():
    import math
    n,k=map(int,input().split(" "))
    a=list(map(int,input().split(" ")))
    g=a[0]
    m=max(a)
    for i in range(n):
        g=math.gcd(g,a[i])
    if k % g==0 and k<=m:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

main()

Submission status: Runtime Error

Solution code:
import math
n,k=map(int,input().split(" "))
a=list(map(int,input().split(" ")))
g=a[0]
m=max(a)
for i in range(n):
    g=math.gcd(g,a[i])
if k % g==0 and k<=m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import math
n,k=map(int,input().split(" "))
a=list(map(int,input().split(" ")))

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

if k % g==0 and k<=m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
array = list(map(int, input().split()))
impossible = "IMPOSSIBLE"
possible = "POSSIBLE"

if a == 1:
    if b == array[0]:
        print(possible)
    else:
        print(impossible)
    exit(0)

array = list(set(array))
array.sort()

btw = [v1 - v2 for v1, v2 in zip(array[1:], array[0:])]
n = sorted(btw)[0]

same = len(set(btw)) == 1 or all([v % n == 0 for v in btw])

if b in array:
    print(possible)
elif array[-1] < b:
    print(impossible)
elif same and (b - array[0]) % n == 0:
    print(possible)
else:
    print(impossible)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
array = list(map(int, input().split()))
impossible = "IMPOSSIBLE"
possible = "POSSIBLE"

if a == 1:
    if b == array[0]:
        print(possible)
    else:
        print(impossible)
    exit(0)

array.sort()
array = list(set(array))

btw = [v1 - v2 for v1, v2 in zip(array[1:], array[0:])]
n = sorted(btw)[0]

same = len(set(btw)) == 1 or all([v % n == 0 for v in btw])

if b in array:
    print(possible)
elif array[-1] < b:
    print(impossible)
elif same and (b - array[0]) % n == 0:
    print(possible)
else:
    print(impossible)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
array = list(map(int, input().split()))
impossible = "IMPOSSIBLE"
possible = "POSSIBLE"

array.sort()

btw = [v1 - v2 for v1, v2 in zip(array[1:], array[0:])]
n = sorted(btw)[0]

same = len(set(btw)) == 1 or all([v % n == 0 for v in btw])

if b in array:
    print(possible)
elif array[-1] < b:
    print(impossible)
elif same and (b - array[0]) % n == 0:
    print(possible)
else:
    print(impossible)

Submission status: Runtime Error

Solution code:
import numpy as np
N, K = map(int,input().split())
A = list(map(int,input().split()))

num_max = max(A)
npA = np.sort(A)
npA_fi = np.insert(npA,0,0)
npA_en = np.insert(npA,N,0)
diff = npA_en[1:N] - npA_fi[1:N]

diff_min = np.min(diff)
i = 0
if K > num_max:
    print('IMPOSSIBLE')
    exit()
while np.max(npA) >= K:
    if K in npA:
        print('POSSIBLE')
        exit()
    else:
        npA -= diff_min

print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
hoge
fuga

piyo

Submission status: Runtime Error

Solution code:
hoge
fuga

Submission status: Runtime Error

Solution code:
hoge

Submission status: Runtime Error

Solution code:
from math import gcd

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

if n == 1:
	if n == k:
		print("POSSIBLE")
	else:
		print("IMPOSSIBLE")
else:
	if k in a:
		print("POSSIBLE")
	elif k > max(a):
		print("IMPOSSIBLE")
	else:
		g = gcd(a[0], a[1])
		for i in range(2, n):
			g = gcd(g, a[i])

		if k % g == 0:
			print("POSSIBLE")
		else:
			print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
#AGC018 A
import math

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

A = list(map(int,input().split()))
MAX = max(A)

if K in A:
    print("POSSIBLE")
elif K<=MAX:
    GCD = A[0]
    for a in A[1:]: GCD = math.gcd(GCD,a)
    if K%GCD==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import fractions

n, k = map(int, input().split())
array = [int(x) for x in input().split()]

res = fractions.gcd(array[0], array[1])


for i in array[2:]:
    res = fractions.gcd(res, i)
print("POSSIBLE" if k%res==0 and max(array) >= k else "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import fractions

n, k = map(int, input().split())
array = [int(x) for x in input().split()]

res = fractions.gcd(array[0], array[1])


for i in array[2:]:
    res = math.gcd(res, i)
print("POSSIBLE" if k%res==0 and max(array) >= k else "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import math

n, k = map(int, input().split())
array = [int(x) for x in input().split()]

res = math.gcd(array[0], array[1])


for i in array[2:]:
    res = math.gcd(res, i)
print("POSSIBLE" if k%res==0 and max(array) >= k else "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

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

def gcd(a, b):
    if a > b:
        a, b = b, a
    # assert(a <= b)
    if b%a == 0:
        return a
    else:
        return gcd(b%a, a)

def gcd_many(l):
    # if len(l) == 1:
    #     return l
    # elif len(l) == 2:
    #     return gcd(l[0], l[1])
    # else:
    #     return gcd(l[0], gcd_many(l[1:]))
    if len(l) == 1:
        return l
    g = l[0]
    for i in range(1,len(l)):
        g = gcd(g, l[i])
    return g

Amax = max(A)
g = gcd_many(A)

possible = "POSSIBLE"
impossible = "IMPOSSIBLE"


if K > Amax:
    print(impossible)
else:
    if K % g == 0:
        print(possible)
    else:
        print(impossible)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

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

def gcd(a, b):
    if a > b:
        a, b = b, a
    # assert(a <= b)
    if b%a == 0:
        return a
    else:
        return gcd(b%a, a)

def gcd_many(l):
    if len(l) == 1:
        return l
    elif len(l) == 2:
        return gcd(l[0], l[1])
    else:
        return gcd(l[0], gcd_many(l[1:]))

Amax = max(A)
g = gcd_many(A)

possible = "POSSIBLE"
impossible = "IMPOSSIBLE"


if K > Amax:
    print(impossible)
else:
    if K % g == 0:
        print(possible)
    else:
        print(impossible)

Submission status: Runtime Error

Solution code:
def gcd(a0, b0):
    a, b = max(a0, b0), min(a0, b0)
    while b != 0:
        a = a % b
        a, b = b, a

    return a


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    g = gcd(a[0], a[1])
    for i in range(2, len(a)):
        g = gcd(a[i], g)

    if k % g == 0 and k <= max(a):
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
q,h,s,d = map(int,input().split())
n = int(input())
a= min(q*4,h*2,s)
b= min(a*2,d)
print(a*(n%2)+b*(n//2))

Submission status: Runtime Error

Solution code:
n,c= [int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.sort()
a1=max(a)
s=a1
for a0 in a:
  s = min(s,abs(a0-a1))
  a1=a0
  
ma=max(a)
if s==0:
  print('IMPOSSIBLE')
if all([i % s==0 for i in a])==False:
  print('POSSIBLE')
else:
  while c<=ma:
    ma-=s
    if c==ma:
      print('POSSIBLE')
      break
  else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    if A[-1] < K:
        return "IMPOSSIBLE"
    if K in A:
        return "POSSIBLE"

    sa = [0 for _ in range(N-1)]
    Ak = [0 for _ in range(N)]
    Ak[0] = A[0]-K
    for i in range(N-1):
        sa[i] = A[i+1] - A[i]
        Ak[i+1] = A[i+1] - K
    for i in sa:
        for ak in Ak:
            if ak%i == 0:
                return "POSSIBLE"
    return "IMPOSSIBLE"

if __name__ == '__main__':
    print(main())

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

result="POSSIBLE"
flag=True
loop=True
if k > max(a):
   loop=False
   flag=False
   result="IMPOSSIBLE"
if k % 2 == 1:
   loop=False
   flag=False
   result="IMPOSSIBLE"
   for i in range(len(a)):
       if a[i]%2==1:
           loop=False
           flag=True
           result="POSSIBLE"
           break

if not k in a:
   b=[]
   a.sort()
   for i in range(1,len(a)):
       if a[i]%a[0] !=0:
           b.append(a[i])
           break
   if len(b)==0:
       loop=False
       flag=False
       result="IMPOSSIBLE"
print(result)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

result="POSSIBLE"
flag=True
loop=True
if k > max(a):
   loop=False
   flag=False
   result="IMPOSSIBLE"
if k % 2 == 1:
   loop=False
   flag=False
   result="IMPOSSIBLE"
   for i in range(len(a)):
       if a[i]%2==1:
           loop=False
           flag=True
           result="POSSIBLE"
           break

if not k in a:
   b=[]
   a.sort()
   for i in range(1,len(a)):
       if a[i]%a[0] !=0:
           b.append(a[i])
           break
   if len(b)==0:
       loop=False
       flag=False
       result="IMPOSSIBLE"


if len(a) == 1 and not k in a:
   result="IMPOSSIBLE"
print(result)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

result="POSSIBLE"
flag=True
loop=True
if k > max(a):
   loop=False
   flag=False
   result="IMPOSSIBLE"
if k % 2 == 1:
   loop=False
   flag=False
   result="IMPOSSIBLE"
   for i in range(len(a)):
       if a[i]%2==1:
           loop=False
           flag=True
           result="POSSIBLE"
           break

if not k in a:
   b=[]
   a.sort()
   for i in range(1,len(a)):
       if a[i]%a[0] !=0:
           b.append(a[i])
           break
   if len(b)==0:
       loop=False
       flag=False
       result="IMPOSSIBLE"


if len(a) == 1 and not k in a:
   result="IMPOSSIBLE"

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())

array = [int(x) for x in input().split()]
res = sorted(array)
judge = False
tmp = res.pop(0)
for i in res:
  if i%tmp != 0:
    judge = True
    break
if (len(res) == 0 and tmp != m) or res[-1] < m:
  judge = False
print("POSSIBLE" if judge else "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:

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

array = [int(x) for x in input().split()]
res = sorted(array)
judge = False
tmp = res.pop(0)
for i in res:
  if i%tmp != 0:
    judge = True
    break
if res[-1] < m:
  judge = False
print("POSSIBLE" if judge else "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())

array = [int(x) for x in range(n)]
res = sorted(array)
judge = False
tmp = res.pop(0)
for i in res:
  if i%tmp != 0:
    judge = True
    break
print("POSSIBLE" if judge else "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))

A = sorted(A)
if A[N-1] < K:
    print("IMPOSSIBLE")
    exit()

min_A = A[0]
for i in range(1,N):
    min_A = min(min_A,A[i]-A[i-1])

for j in range(N):
    if A[j]%min_A != 0:
        print("POSSIBLE")
        exit()
if K % min_A == 0:
    print("POSSIBLE")
else:
    print("INPOSSIBLE")

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

n,k=map(int,input().split())
a=list(map(int,input().split()))
g=gcd(a[0],a[1])
mx=max(a)
for i in range(2,n):
    g=gcd(g,a[i])
if k%g==0 and k<=mx:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
import math
import functools
n, k = map(int, input().split())
a = list(map(int, input().split()))
g = functools.reduce(math.gcd, a)

if max(a) >= k and k % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
# -*- coding:utf-8 -*-
import functools, math
N, K = map(int, input().split())
A = list(map(int, input().split()))
a = functools.reduce(math.gcd, A)
b = max(A)
if K%a == 0 and K <= b:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import math
length,target = (int(n) for n in input().split(" "))
ball = [int(n) for n in input().split(" ")]
gcd = ball[0]
for i in range(1,length):
    gcd = math.gcd(gcd,ball[i])
if target % gcd == 0 and target <= max(ball):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

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

input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]

temp = A[0]
for i in range(1,N):
	temp = gcd(temp,A[i])

if K <= max(A) and K % G == 0:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')

Submission status: Runtime Error

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

input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]
A.sort()
if K in A:
	flag = True
elif K > max(A):
	flag = False
else:
	temp = A[0]
	for i in range(1,N):
		temp = gcd(temp,A[i])
	if K % G == 0:
		flag = True
	else:
		flag = False
			
if flag==True:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')

Submission status: Runtime Error

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

 def gcd()

input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]
A.sort()
if K in A:
	flag = True
elif K > max(A):
	flag = False
else:
	temp = A[0]
	for i in range(1,N):
		temp = gcd(temp,A[i])
	if K % G == 0:
		flag = True
	else:
		flag = False
			
if flag==True:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]
A.sort()
if K in A:
	flag = True
elif K > max(A):
	flag = False
else:
	flag = True
	for i in range(N-3):
		if abs(A[i]-A[i+1])%abs(A[i+2]-A[i+1]) != 0 or abs(A[i+2]-A[i+1])%abs(A[i]-A[i+1]) != 0:
			flag = False
			break

if flag==True:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]

if K in A:
	flag = True
elif K > max(A):
	flag = False
else
	flag = True
	for i in range(N-3):
		if abs(A[i]-A[i+1]) != abs(A[i+2]-A[i+1]):
			flag = False
			break
			
if flag==True:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]

flag = True
for i in range(N-3):
	if abs(A[i]-A[i+1]) != abs(A[i+2]-A[i+1]):
		flag = False
		break

if K in A:
	flag = true

if flag==True:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]

flag = True
for i in range(N-3):
	if abs(A[i]-A[i+1]) != abs(A[i+2]-A[i+1]):
		flag = False
		break

if flag==True:
	print(POSSIBLE)
else:
	print(IMPOSSIBLE)

Submission status: Runtime Error

Solution code:
input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]

flag = true
for i in range(N-3):
	if abs(A[i]-A[i+1]) != abs(A[i+2]-A[i+1]):
		flag = false
		break

if flag:
	print(POSSIBLE)
else:
	print(IMPOSSIBLE)

Submission status: Runtime Error

Solution code:
from math import gcd

def solve():
    n, k = list(map(int, input().strip().split()))
    a = list(map(int, input().strip().split()))

    m = a[0]
    maxx = a[0]
    for i in range(1, n):
        m = gcd(m, a[i])
        if a[i] > maxx:
            maxx = a[i]

    if k % m == 0 and k <= maxx:
        return "POSSIBLE"
    else:
        return "IMPOSSIBLE"

print(solve())

Submission status: Runtime Error

Solution code:
from math import gcd

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

if K > max(A):
  print('IMPOSSIBLE')
  exit()

d = A[0]
for a in A:
  d = gcd(d,a)

if K % d == 0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
def get_difference():
	# get input from raw_input()
	n, k = map(int, raw_input().split(' '))
	l = [int(e) for e in raw_input().split(' ')]

	gcd_v = reduce(gcd, l)
	if not k % gcd_v and k <= max(l):
		print "POSSIBLE"
	else:
		print "IMPOSSIBLE"


if __name__ == "__main__":
	get_difference()