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:
# coding: utf-8
# Your code here!
import math
from functools import reduce

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

if max(l)<K:
    print("IMPOSSIBLE")
else:
    if K%functools.reduce(math.gcd, l)==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
import math
from functools import reduce

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

if max(l)<K:
    print("IMPOSSIBLE")
else:
    if K%reduce(math.gcd, l)==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
l=list(map(int,input().split()))

if max(l)<K:
    print("IMPOSSIBLE")
    exit()

temp=[]
prev_l=[-1]

while prev_l!=l: #temp <=> l
    temp.clear()
    prev_l.clear()
    prev_l=prev_l+l
    for i in range(len(l)-1):
        for j in range(i+1,len(l)):
            temp.append(abs(l[i]-l[j]))
    l=l+temp
    l=list((set(l)))
    for i in range(len(l))[::-1]:
        if l[i]>K:
            for j in range(i)[::-1]:
                if (l[i]-K)%l[j]==0:
                    print("POSSIBLE")
                    exit()
        elif l[i]==K:
            print("POSSIBLE")
            exit()
        else:
            break
    
print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import fractions
N,K = map(int,input().split())
A = sorted(list(map(int,input().split())))[::-1]
#print(A)
if A[0] < K:
  print("IMPOSSIBLE")
  exit()
else:
  G = fractions.gcd(A[0],A[1])
  for g in range(2,N):
    G = fractions.gcd(G,A[g])
  print(G)
  if K % G != 0:
    print("IMPOSSIBLE")
    exit()
print("POSSIBLE")

Submission status: Runtime Error

Solution code:
import fractions
N,K = map(int,input().split())
A = sorted(list(map(int,input().split())))[::-1]
#print(A)
if A[0] < K:
  print("IMPOSSIBLE")
  exit()
else:
  G = fractions.gcd(A[0],A[1])
  for g in range(1,N):
    G = fractions.gcd(G,A[g])
  print(G)
  if K % G != 0:
    print("IMPOSSIBLE")
    exit()
print("POSSIBLE")

Submission status: Runtime Error

Solution code:
import fractions

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

if k > max(a):
    print("IMPOSSIBLE")
else:
    minak = min(a)

    gcda = fractions.gcd(a[0],a[1])

    for i in range(0,n):
        gcda = fractions.gcd(gcda,a[i])
        if gcda ==1:
            break

    if gcda == 1 or k % gcda == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import fractions

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

if k > max(a):
    print("IMPOSSIBLE")
else:
    minak = min(a)

    gcda = fractions.gcd(a[0],a[1])

    for i in range(0,n):
        gcda = fractions.gcd(gcda,a[i])
        if gcda ==1:
            break

    if gcda == 1 or (k-minak) % gcda == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import fractions

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

if k > max(a):
    print("IMPOSSIBLE")
else:
    minak = min(a)

    gcda = fractions.gcd(a[0],a[1])

    for i in range(0,n):
        gcda = fractions.gcd(gcda,a[i])
        if gcda ==1:
            break

    elif gcda == 1 or (k-minak) % gcda == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import fractions

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

if k > max(a):
    print("IMPOSSIBLE")
else:
    minak = min(a)
    for i in range(0,n):
        a[i] -= minak

    gcda = fractions.gcd(a[0],a[1])

    for i in range(0,n):
        gcda = fractions.gcd(gcda,a[i])
        if gcda ==1:
            break

    if gcda == 0:
        if k == minak:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
    elif gcda == 1 or ((k-minak)) % gcda == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import fractions

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

if k > max(a):
    print("IMPOSSIBLE")
else:
    minak = min(a)
    for i in range(0,n):
        a[i] -= minak

    gcda = fractions.gcd(a[0],a[1])

    for i in range(0,n):
        gcda = fractions.gcd(gcda,a[i])
        if gcda ==1:
            break

    if gcda == 0 or gcda == 1 or ((k-minak)) % gcda == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import fractions

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

if k > max(a):
    print("IMPOSSIBLE")
else:
    minak = min(a)
    for i in range(0,n):
        a[i] -= minak

    gcda = fractions.gcd(a[0],a[1])

    for i in range(0,n):
        gcda = fractions.gcd(gcda,a[i])
        if gcda ==1:
            break

    if gcda == 0 or gcda == 1 or ((k-minak)) % gcda == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

print(fractions.gcd(0,0))

Submission status: Runtime Error

Solution code:
import fractions

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

if k > max(a):
    print("IMPOSSIBLE")
else:
    minak = min(a)
    for i in range(0,n):
        a[i] -= minak

    gcda = fractions.gcd(a[0],a[1])

    for i in range(0,n):
        gcda = fractions.gcd(gcda,a[i])
        if gcda ==1:
            break

    if gcda == 1 or ((k-minak)) % gcda == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
x = gcd_list(A)
if(K%x==0 and max(A)>=K):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
x = gcd_list(A)
if(K%x==0 and max(A)-min(A)>K):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
x = gcd_list(A)
if(K%x==0 and max(A)-min(A)>K):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
import collections
N, K = map(int, input().split())
A = list(map(int, input().split()))
if K in A:
    print("POSSIBLE")
    exit(0)
else:
    diff = collections.defaultdict(int)
    A.sort()
    idx = N - 1
    if K > A[-1]:
        print("IMPOSSIBLE")
        exit(0)
    else:
        for i in range(N-1):
            if A[i] > K and idx == N - 1:
                idx = i
            diff[A[i+1] - A[i]] += 1

        diff_list = list(diff.keys())
        if 1 in diff_list:
            print("POSSIBLE")
            exit(0)
        else:
            diff_list.sort()
            for i in range(idx, N):
                for j in range(len(diff_list)):
                    if (K - A[i]) % diff_list[j] == 0:
                        print("POSSIBLE")
                        exit(0)
            print("IMPOSSIBLE")
            exit(0)

Submission status: Runtime Error

Solution code:
import collections
N, K = map(int, input().split())
A = list(map(int, input().split()))
if K in A:
    print("POSSIBLE")
else:
    diff = collections.defaultdict(int)
    A.sort()
    idx = N - 1
    if K > A[-1]:
        print("IMPOSSIBLE")
    else:
        for i in range(N-1):
            if A[i] > K and idx == N - 1:
                idx = i
            diff[A[i+1] - A[i]] += 1

        diff_list = list(diff.keys())
        if 1 in diff_list:
            print("POSSIBLE")
            exit(0)
        diff_list.sort()

        for i in range(idx, N):
            for j in range(len(diff_list)):
                if (K - A[i]) % diff_list[j] == 0:
                    print("POSSIBLE")
                    exit(0)
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import collections
N, K = map(int, input().split())
A = list(map(int, input().split()))
if K in A:
    print("POSSIBLE")
else:
    diff = collections.defaultdict(int)
    A.sort()
    idx = N - 1
    if K > A[-1]:
        print("IMPOSSIBLE")
    else:
        for i in range(N-1):
            if A[i] > K and idx == N - 1:
                idx = i
            diff[A[i+1] - A[i]] += 1

        diff_list = list(diff.keys())
        if 1 in diff_list:
            print("POSSIBLE")
            print("hoge")
            exit(0)
        diff_list.sort()

        for i in range(idx, N):
            for j in range(len(diff_list)):
                if (K - A[i]) % diff_list[j] == 0:
                    print("POSSIBLE")
                    exit(0)
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
#AGC014A
import sys
#import collections

#n= int(input())

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

tmp = input().split()
a = list(map(lambda a: int(a), tmp))

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

maxa=a[0]
tmp=a[0]
for i in range(1,n):
	maxa=max(maxa,a[i])
	tmp=gcd(tmp, a[i])

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

#print(maxa)
#print(tmp)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
def gcd(x,y):
    if x==y:
        return x
    elif x>y:
        r=-1
        while r!=0:
            r=x%y
            x=y
            y=r
        return x
    else:
        r=-1
        while r!=0:
            r=y%x
            y=x
            x=r
        return y

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

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
if k>max(a):
    print("IMPOSSIBLE")
    exit()
    
sa=float("inf")
a.sort()
b=[abs(a[0]-k)]
for i in range(1,n):
    sa=min(sa,abs(a[i]-a[i-1]))
    b.append(abs(a[i]-k))
f=0
for i in range(n):
    if b[i]%sa==0:
        f=1
print("POSSIBLE" if f else "IMPOSSIBLE")

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
    return gcd(b, a%b)
element=gcd(A[0], A[1])
if N!=2:
    for _ in range(2, N):
        element=gcd(element, A[_])

print("POSSIBLE" if K%element==0 and max(A)>=K else "IMPOSSIBLE")

Submission status: Runtime Error

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

A.sort()
max_a = -1
min_diff = K
for i in range(N):
    a = A[i]
    if a == K:
        print("POSSIBLE")
        exit()
    if a > max_a:
        max_a = a
    if i < N-1:
        diff = A[i+1]-A[i]
        if diff < min_diff:
            min_diff = diff

if max_a < K:
    print("IMPOSSIBLE")
    exit()
else:
    for a in A:
        if (K-a) % min_diff == 0:
            print("POSSIBLE")
            exit()

print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
def main():
    n, k = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    diff_min = a[-1] - a[-2]
    l_diff = set()
    for i in range(n-1):
        diff = abs(a[i] - a[i+1])
        diff_min = (min(diff_min,diff) if diff != 0 else diff_min)
    for i in range(n):
        diff_min = (a[i] % diff_min if a[i] % (diff_min) != 0 else diff_min)
    for i in range(n):
        if a[i] - k >= 0 and (a[i] - k)%diff_min == 0:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    n, k = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    diff_min = a[-1] - a[-2]
    l_diff = set()
    for i in range(n-1):
        diff = abs(a[i] - a[i+1])
        diff_min = (min(diff_min,diff) if diff != 0 else diff_min)
    for i in range(n):
        diff_min = (a[i] % diff_min if a[i] % (diff_min) != 0 else diff_min)
    for i in range(n):
        if a[i] - k >= 0 and (a[i] - k)%diff_min == 0:
            print("POSSIBLE")
            break
    else:
        print("POSSIBLE")
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    n, k = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    diff_min = a[-1] - a[-2]
    l_diff = set()
    for i in range(n-1):
        diff = abs(a[i] - a[i+1])
        diff_min = (min(diff_min,diff) if diff != 0 else diff_min)
        l_diff.add(diff_min)
    for i in range(n):
        diff_min = (a[i] % diff_min if a[i] % (diff_min) != 0 else diff_min)
    a.extend(l_diff)
    n = len(a)
    for i in range(n):
        if a[i] - k >= 0 and (a[i] - k)%diff_min == 0:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n, k = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
a.sort()
diff_min = 10*9 + 7
for i in range(n-1):
    diff = abs(a[i] - a[i+1])
    diff_min = min(diff_min,diff)

for i in range(n):
    if a[i] - k >= 0 and (a[i] - k)%diff_min == 0:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from fractions import gcd
from bisect import bisect_right
n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
if k>A[n-1]:ans=-1
elif k=A[n-1]:ans=1
else:
    a=A[0]
    for i in range(1,n):
        a=gcd(a,A[i])
    m=A[bisect_right(A,k)]
    if (m-k)%a==0:
        ans=1
    else:
        ans=-1
if ans==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from fractions import gcd
from bisect import bisect_right
n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
if k>A[n-1]:ans=-1
else:
    a=A[0]
    for i in range(1,n):
        a=gcd(a,A[i])
    m=A[bisect_right(A,k)]
    if (m-k)%a==0:
        ans=1
    else:
        ans=-1
if ans==1:
    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()))

A=list(set(A))
N=len(A)
A.sort()

g=A[0]
for i in range(N-1):
    g=math.gcd(g,A[i+1])

#tmp=0
#ans="POSSIBLE"
#for i in range(N):
#    tmp+=A[i]%g
if g==1 and K<=A[-1]:
    ans="POSSIBLE"
else:
    ans="IMPOSSIBLE"
if N==1:
    ans="POSSIBLE"
print(ans)

Submission status: Runtime Error

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

A=list(set(A))
N=len(A)
A.sort()
tmp=0
for i in range(N-1):
    tmp+=A[i+1]%A[0]
if tmp>0 and K<=A[-1]:
    pass
else:
    ans="IMPOSSIBLE"
if N==1:
    ans="POSSIBLE"
print(ans)

Submission status: Runtime Error

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


N, K = map(int,input().split())
A = list(map(int,input().split()))
#Aの最大公約数を作ることが出来る

A.sort()
if K > A[-1]:
    print("IMPOSSIBLE")
else:
    g = gcd(A[0], A[1])
    for i in range(2, N):
        g = gcd(g, A[2])
    if K % g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import math

N,K =list(map(int,input().split(" ")))
As= list(map(int,input().split(" ")))
g = As[0]
ma = -1
for a in As:
    g = math.gcd(g,a)
    ma = max(ma,a)
    if K == a:
        print("POSSIBLE")
        exit()
if K % g == 0 and ma >= K:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import numpy as np

N, K = map(int, input().split())
A = [int(i) for i in input().split()]

G = np.gcd.reduce(A)
M = max(A)

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

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
import math
import functools
gcd = functools.reduce(math.gcd, A)
A_max = max(A)
if (A_max >= K and K % gcd == 0):
    print('POSSEBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
import math
import functools
gcd = functools.reduce(math.gcd, A)
print(gcd)
A_max = max(A)
if (A_max >= K and K % gcd == 0):
    print('POSSEBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split()) # 横に2個
A = list(map(int, input().split()))

A.sort(reverse=True)

dif = []
for i in range(N-1):
    d = A[i] - A[i+1]
    if d != 0:
        dif.append(d)
mind = min(dif)

ans = 'IMPOSSIBLE'
for a in A:
    if a < K:
        break
    if a == K:
        ans = 'POSSIBLE'
        break
    if (a-K) % mind == 0:
        ans = 'POSSIBLE'
        break

print(ans)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split()) # 横に2個
A = list(map(int, input().split()))

A.sort(reverse=True)

dif = []
for i in range(N-1):
    dif.append(A[i] - A[i+1])
mind = min(dif)

ans = 'IMPOSSIBLE'
for a in A:
    if a < K:
        break
    if a == K:
        ans = 'POSSIBLE'
        break
    if (a-K) % mind == 0:
        ans = 'POSSIBLE'
        break

print(ans)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
from fractions import gcd
from functools import reduce
def g(l):
return reduce(gcd,l)
if max(a)<k:
  print('IMPOSSIBLE')
else:
  z=g(a)
  if k%z==0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
from fractions import gcd

N, K = map(int, input().split())
A = [int(_) for _ in input().split()]
GCD = gcd(A[0], A[1])

for i in range(2, N):
    GCD = gcd(GCD, A[i])

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

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
*A, = sorted(set(map(int,input().split())))
if A[-1]<K:print("IMPOSSIBLE");exit()
d = min(A[i+1]-a for i,a in enumerate(A[:-1]))
K%=d
for a in A:
    if a%d==K:print("POSSIBLE");break
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
*A, = map(int, input().split())
A = sorted(A)
diff = min([A[i+1] - A[i] for i in range(N-1) if A[i+1] - A[i] > 0])
for a in [a for a in A if a >= K]:
    if (a - K) % diff == 0:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
*A, = map(int, input().split())
A = sorted(A)
diff = min([A[i+1] - A[i] for i in range(N-1)])
for a in [a for a in A if a >= K]:
    if (a - K) % diff == 0:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


if K > max(A):
    print('IMPOSSIBLE')
elif K % gcd_list(A) != 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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


def gcd(numbers):
    return reduce(math.gcd, numbers)

if K > max(A):
    print('IMPOSSIBLE')
elif K % gcd(A) != 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Runtime Error

Solution code:
def gcd(a,b):
	while a*b>0:
		a,b = min(a,b),max(a,b)
		a,b = b-a, a
	return b

N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
R=gcd(A[1],A[0])
for i in range(1,N-1):
	R=gcd(R,(A[i+1]-A[i]))
if K<=A[-1] and (K-A[0])%R==0:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

def main():
    n,k = getList()
    nums = sorted(getList())
    diff = []
    if n == 1:
        if nums[0] == n:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        return

    for i,j in zip(nums, nums[1:]):
        diff.append(abs(i-j))

    diff.sort()
    mod = diff[0]
    ans = "IMPOSSIBLE"
    for num in nums:
        if (num % mod == k % mod) and (num >= k):
            ans = "POSSIBLE"

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

def main()
    n,k = getList()
    nums = sorted(getList())
    diff = []
    if n == 1:
        if nums[0] == n:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        return         
        
    for i,j in zip(nums, nums[1:]):
        diff.append(abs(i-j))
    
    diff.sort()
    mod = diff[0]
    ans = "IMPOSSIBLE"
    for num in nums:
        if (num % mod == k % mod) and (num >= k):
            ans = "POSSIBLE"
    
    print(ans)
    
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

n,k = getList()
nums = sorted(getList())
diff = []
for i,j in zip(nums, nums[1:]):
    diff.append(abs(i-j))

diff.sort()
mod = diff[0]
ans = "IMPOSSIBLE"
for num in nums:
    if (num % mod == k % mod) and (num >= k):
        ans = "POSSIBLE"

print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(1000000)

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

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

if n == 1:
  if k == a[0]:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
else:
  r = gcd(alist[1], alist[0])
  for _a in alist[2:]:
    r = gcd(_a, r)
  if k <= alist[-1] and k % r == 0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
alist = list(sorted(map(int, input().split())))

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

if n == 1:
  if k == a[0]:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
else:
  r = gcd(alist[1], alist[0])
  for _a in alist[2:]:
    r = gcd(_a, r)
  if k <= alist[-1] and k % r == 0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

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

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

if K>max(A):
	print("IMPOSSIBLE")
	exit(0)

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

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

Submission status: Runtime Error

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

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

if K>max(A):
	print("IMPOSSIBLE")
	exit(0)

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

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

Submission status: Runtime Error

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

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

if K>max(A):
	print("IMPOSSIBLE")
	exit(0)

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

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

Submission status: Runtime Error

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

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

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

print("POSSIBLE" if K%g==0 and K<=max(A) else "IMPOSSIBLE")

Submission status: Runtime Error

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

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

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

print("POSSIBLE" if K%g==0 and K<=max(A) else "IMPOSSIBLE")

Submission status: Runtime Error

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

if N == 1:
	x = a
else:
	a = A[0]
	for i in range(N - 1):
		b = A[i + 1]
		a, b = sorted([a, b])
		while True:
			if b % a == 0:
				break
			else:
				a, b = b % a, a
	x = a

if K % x == 0 and max(A) >= K:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

for k in range(1, n+1):
    s = set([i+1 for i in range(m)])
    while s:
        memo = [0] * (m + 1)
        flag = [0] * (n + 1)
        for j in range(m):
            for i in range(n):
                if flag[i] == 0 and a[i][j] in s:
                    memo[a[i][j]] += 1
                    flag[i] = 1
                    if memo[a[i][j]] > k:
                        s.remove(a[i][j])
                        break
            else:
                continue
            break
        if max(memo) <= k:
            print(k)
            exit()

Submission status: Runtime Error

Solution code:
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 
======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
Traceback (most recent call last):
  File "C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py", line 13, in <module>
    print(gcd_list(a))
  File "C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py", line 9, in gcd_list
    for i in range(len(n)):
NameError: name 'n' is not defined
>>> 
======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
None

======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
6

======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
6

======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
3

======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
3 7
9 3 4
Traceback (most recent call last):
  File "C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py", line 19, in <module>
    if A[-1] > k and (A[-1] - k) % gcd_lst(A) == 0:
NameError: name 'gcd_lst' is not defined
>>> 
======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
3 7
9 3 4
POSSIBLE
>>> 
======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
3 5
6 9 3
IMPOSSIBLE
>>> 
======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
4 11
11 3 7 15
POSSIBLE
>>> 
======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
5 12
10 2 8 6 4
IMPOSSIBLE
>>>

Submission status: Runtime Error

Solution code:
import math
n,k=map(int,input().split())
l=list(map(int,input().split()))
ma=max(l)
if k>ma:
  print('IMPOSSIBLE')
else:
  gcd=l[0]
  l.remove(gcd)
  for x in l:
    gcd=math.gcd(gcd,x)
  if gcd==1:
    print('POSSIBLE')
  else:
    if k%gcd==0:
      print('POSSIBLE')
    else:
      print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
import math
n,k=map(int,input().split())
l=list(map(int,input().split()))
if n==3 and k==7 and ' '.join([str(x) for x in l])=='9 3 4':
  exit()
ma=max(l)
if k>ma:
  print('IMPOSSIBLE')
else:
  gce=l[0]
  l.remove(gce)
  for x in l:
    gce=math.gcd(gce,x)
  if gce==1:
    print('POSSIBLE')
  else:
    if k%gce==0:
      print('POSSIBLE')
    else:
      print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
import math
n,k=map(int,input().split())
l=list(map(int,input().split()))
if n==3 and k==7 and ' '.join([str(x) for x in l])=='9 3 4':
  exit()
ma=max(l)
if k>ma:
  print('IMPOSSIBLE')
else:
  gcd=l[0]
  l.remove(gcd)
  for x in l:
    gcd=math.gcd(gcd,x)
  if gcd==1:
    print('POSSIBLE')
  else:
    if k%gcd==0:
      print('POSSIBLE')
    else:
      print('IMPOSSIBLE')

Submission status: Runtime Error

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

if K in A:
    print("POSSIBLE")
    exit(0)
if K > max(A) or N == 1:
    print("IMPOSSIBLE")
    exit(0)

t = abs(A[1]-A[0])
if K%t==0:
    print("POSSIBLE")
    exit(0)

g = 1000000000
for k in range(1,N):
    g = min(g,math.gcd(A[k-1],A[k]))

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

Submission status: Runtime Error

Solution code:
length, target = map(int, input().split(" "))
balls = sorted([int(n) for n in input().split(" ")])
minimum = balls[0]
all_div = 1 if minimum > 1 else 0
all_even = 1
if target > balls[-1]:
    print("IMPOSSIBLE")
else:
    for t in balls:
        if t == target:
            print("POSSIBLE")
            break
        if t % minimum != 0:
            all_div = 0
        if t % 2 == 1:
            all_even = 0
    else:
        if all_div:
            print("IMPOSSIBLE")
        elif all_even and target % 2 == 0:
            print("IMPOSSIBLE")
        elif:
            print("POSSIBLE")