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

Solution (Python):
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
            if A[i+1] - A[i] != 0:
                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)

Solution (Python):
import sys
input=sys.stdin.readline
import fractions

def main():
    _,K = map(int, input().split())
    A = list(map(int, input().split()))
    a = A[0]
    for x in A:
        a = fractions.gcd(a,x)
    if max(A) >= K and K%a == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

if __name__ == '__main__':
    main()

Solution (Python):
import fractions
from functools import reduce
import sys
input = sys.stdin.readline

def main():
    N,K =map(int,input().split())
    A = list(map(int,input().split()))
    if K > max(A):
        print("IMPOSSIBLE")
    else:
        def gcd_list(numbers):
            return reduce(fractions.gcd,numbers)
          
        gcd = gcd_list(A)
        if (max(A)-K)%gcd == 0:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")

if __name__ == "__main__":
    main()

Solution (Python):

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

    if max(a) < k:
        print("IMPOSSIBLE")
    else:
        from fractions import gcd
        gmax = a[0]
        for i in range(1, n):
            gmax = gcd(gmax, a[i])

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

    


if __name__ == '__main__':
    main()

Solution (Python):

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

    if max(a) < k:
        print("IMPOSSIBLE")
    else:
        from fractions import gcd
        gmax = a[0]
        for i in range(1, n):
            gmax = gcd(gmax, a[i])
        if gmax == 1:
            print("POSSIBLE")
        else:
            if k % gmax == 0:
                print("POSSIBLE")
            else:
                print("IMPOSSIBLE")

    


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from fractions import gcd
from functools import reduce

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

if max(A) < K:
    print('IMPOSSIBLE')
    sys.exit()
if K in A:
    print('POSSIBLE')
    sys.exit()

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

num = gcd_list(A)
if num == 1:
    print('POSSIBLE')
else:
    if K % num == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a, a)
    n,k = LI()
    a = LI()
    if max(a) < k:
        print("IMPOSSIBLE")
        return
    g = a[0]
    for i in a[1:]:
        g = gcd(g, i)
    if g == 1:
        print("POSSIBLE")
    else:
        if k%g == 0:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
    return


def B():
    n = I()

    return


def C():
    x,y,z = LI()
    n = x+y+z
    c = LIR(n)
    for i in range(n):
        c[i].append(c[i][0])
    c.sort(key = lambda x:-(x[1]-x[3]))
    for i in range(y):
        c[i][3] = c[i][1]
    c.sort(key = lambda x:-(x[2]-x[3]))
    for i in range(y):
        c[i][3] = c[i][1]

    for i in c:
        print(i)
    return


def D():
    n = I()

    return


def E():
    n = I()

    return


def F():
    n = I()

    return


if __name__ == "__main__":
    A()

Solution (Python):
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    gcd = 0
    for v in a:
        gcd = fractions.gcd(gcd, v)
    mv = max(a)
    if mv < k:
        print("IMPOSSIBLE")
    else:
        if (mv - k) % gcd == 0:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")


if __name__ == '__main__':
    slove()

Solution (Python):
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    if N == 1:
        if K == A[0]: return "POSSIBLE"
        else: return "IMPOSSIBLE"
    if max(A) < K:
        return "IMPOSSIBLE"
    if K in A:
        return "POSSIBLE"

    ref = A[0]
    for i in range(1, N):
        ref = gcd(ref, A[i])
    for i in range(N):
        if A[i] > K and (A[i]-K) % ref == 0:
            return "POSSIBLE"
    return "IMPOSSIBLE"

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

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

Solution (Python):


import sys




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<=maxa)and(k%tmp ==0):
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Solution (Python):
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

if n==1:
    if k==a[0]:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()
g=gcd(a[0],a[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")

Solution (Python):
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)
if N==1:
    print("POSSIBLE" if K==A[0] else "IMPOSSIBLE")
    exit()
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")

Solution (Python):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n%m)

n,k = LI()
a = LI()
if k in a:
    print('POSSIBLE')
    quit()
if max(a) < k:
    print('IMPOSSIBLE')
    quit()
g = a[0]
for i in range(1,n):
    g = gcd(g,a[i])
if k % g != 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

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

def get_gcd(a,b):
    if b > a:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

gcd  = A[0]
max_a = A[0]
for i in range(1, N):
    a = A[i]
    if a == K:
        print("POSSIBLE")
        exit()
    if a > max_a:
        max_a = a
    gcd = get_gcd(gcd, a)

if max_a < K:
    print("IMPOSSIBLE")
    exit()
else:
    if K % gcd == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Solution (Python):
import fractions
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=fractions.gcd(gcd,x)
  if gcd==1:
    print('POSSIBLE')
  else:
    if k%gcd==0:
      print('POSSIBLE')
    else:
      print('IMPOSSIBLE')

Solution (Python):
def main():
    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) 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()

Solution (Python):

import sys, math, fractions, itertools, collections, copy, heapq

YES = "POSSIBLE"  
NO = "IMPOSSIBLE"  

def solve(N: int, K: int, A: "List[int]"):
    if K > max(A):
        print(NO)
        return
    g = A[-1]
    for a in A[:-1]:
        g = fractions.gcd(g, a)
    if K % g == 0:
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    A = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, K, A)

if __name__ == '__main__':
    main()

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

def gcd(x, y):
    if x > y:
        x, y = y, x
    if y % x == 0:
        return x
    y = y % x
    return gcd(x, y)

n = A[0]
for i in A:
    n = gcd(n, i)

flag = False
for i in A:
    if i >= K and (i - K) % n == 0:
        flag = True
        break
    else:
        pass

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

Solution (Python):
from fractions import gcd


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

Solution (Python):
import fractions
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = max(a)
gcd = 0
for i in a:
    gcd = fractions.gcd(gcd, i)
print("POSSIBLE" if k <= s and (k - s) % gcd == 0 else "IMPOSSIBLE")

Solution (Python):
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")

Solution (Python):


from fractions import gcd

n,k=map(int,input().split())
a=list(map(int,input().split()))
ans='POSSIBLE'
max_a=max(a)
if max_a==k:
    print(ans)
    exit()
elif max_a<k:
    print('IMPOSSIBLE')
    exit()

    

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

if k%g==0 or k in a:
    print(ans)
else:
    print('IMPOSSIBLE')

Solution (Python):
from fractions import*;_,k,*a=map(int,open(0).read().split());g=a[0]
for i in a:g=gcd(g,i)
print("IM"*(k>max(a)or k%g>0)+"POSSIBLE")

Solution (Python):
from fractions import*;_,k,*a=map(int,open(0).read().split());g=a[0];m=max(a)
for i in a:g=gcd(g,i)
print("IM"*(k>m or k%g!=0)+"POSSIBLE")

Solution (Python):
from fractions import*
n,k=map(int,input().split())
*a,=map(int,input().split())
g=a[0];m=max(a)
for i in a:g=gcd(g,i)
print("IM"*(k>m or k%g!=0)+"POSSIBLE")

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

def gcd(n, m) :
    n, m = max(n, m), min(n, m)
    if m == 0 :
        return n
    return gcd(m, n % m)

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

for a in A :
    if a < K :
        continue
    if (a - K) % dis == 0 :
        print('POSSIBLE')
        break
else :
    print('IMPOSSIBLE')

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

s = 0

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

g = gcd(*A)

if K % g == 0 and max(A)>=K:
    ans = 'POSSIBLE'
else:
    ans = 'IMPOSSIBLE'

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

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

import functools
N,K = map(int,input().split())
A = [int(x) for x in input().split()]
max_A = max(A)
gcd_A = functools.reduce(gcd,A)

answer = 'POSSIBLE' if K <= max_A and K % gcd_A == 0 else 'IMPOSSIBLE'

print(answer)

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

def solve(n, k, a):
    if k in a:
        return "POSSIBLE" 
    p = a[0]
    for i in range(1, n):
        p = gcd(p, a[i])
    q = max(a) - p
    if (k <= q) and (gcd(q, k) == p):
        return "POSSIBLE"
    else:
        return "IMPOSSIBLE"

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

Solution (Python):
from functools import reduce

def gcd_list(n):
    return reduce(gcd, n)

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


n, k = map(int, input().split())
a = list(map(int, input().split()))
if k > max(a):
    print("IMPOSSIBLE")
elif k in a:
    print("POSSIBLE")
else:
    if k % gcd_list(a) == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Solution (Python):
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from copy import *

N, K = map(int, input().split())
A = list(map(int, input().split()))
gcd = lambda a, b: a if b == 0 else gcd(b, a%b)
G = 0
for a in A:
    G = gcd(a, G)
M = max(A)
if K <= M and K % G == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
import fractions

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=fractions.gcd(g,A[i+1])

if K%g==0 and K<=A[-1]:
    ans="POSSIBLE"
else:
    ans="IMPOSSIBLE"
print(ans)

Solution (Python):
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.sort()
if K > A[-1]:
    print("IMPOSSIBLE")
elif N == 1:
    if K != A[0]:
        print("IMPOSSIBLE")
    else:
        print("POSSIBLE")
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")

Solution (Python):
from sys import stdin
import fractions
from functools import reduce

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

N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]

M = max(data)
G = gcd_list(data)

if K <= M and K % G == 0:
    print("POSSIBLE")

else:
    print("IMPOSSIBLE")

Solution (Python):
import fractions

N,K =list(map(int,input().split(" ")))
As= list(map(int,input().split(" ")))
g = As[0]
ma = -1
for a in As:
    g = fractions.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")

Solution (Python):

from fractions import gcd
from functools import reduce


def main():
    n, k = tuple(map(int, input().rstrip().split()))
    A = tuple(map(int, input().rstrip().split()))
    G, M = reduce(gcd, A), max(A)  
    flg = k <= M and k % G == 0
    print("POSSIBLE" if flg else "IMPOSSIBLE")


if __name__ == "__main__":
    main()

Solution (Python):

from fractions import gcd


def main():
    n, k = tuple(map(int, input().rstrip().split()))
    A = tuple(map(int, input().rstrip().split()))
    M = max(A)
    G = A[0]
    for i in A[1:]:
        G = gcd(G, i)
    flg = k <= max(A) and k % G == 0
    print("POSSIBLE" if flg else "IMPOSSIBLE")


if __name__ == "__main__":
    main()

Solution (Python):
def g_c_d(x, y):
    if x == 0:
        return y
    elif y == 0:
        return x
    else:
        return g_c_d(y, x % y)


a, b = map(int, input().split())
c = list(map(int, input().split()))
d = 0
e = max(c)
if b in c:
    print("POSSIBLE")
    exit()
if e < b:
    print("IMPOSSIBLE")
    exit()
for i in c:
    d = g_c_d(d, i)
for i in c:
    if (i - b) % d == 0:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
exit()

Solution (Python):
n, k = map(int, input().split())
a = list(map(int, input().split()))
from fractions import gcd
g = a[0]
for i in range(n):
  g = gcd(g, a[i])

if k % g != 0 or max(a) < k:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')

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

n,k=map(int,input().split())
l=list(map(int,input().split()))
if k>max(l):print("IMPOSSIBLE");exit()
g=l[0]
for i in l:
    g=gcd(g,i)
if k%g==0:print("POSSIBLE")
else:print("IMPOSSIBLE")

Solution (Python):
import numpy as np
import fractions

gcd_ufunc = np.frompyfunc(fractions.gcd, 2, 1)

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

G = gcd_ufunc.accumulate(A, dtype=np.object).astype(np.int)[-1]
M = max(A)

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

Solution (Python):
from fractions import gcd

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

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

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

Solution (Python):
from fractions import gcd
N, K = map(int, input().split())
A = list(map(int, input().split()))

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

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

Solution (Python):
from subprocess import*
with open('Main.java','w')as f:f.write(r"""
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int max = 0;
		int gcd = 0;
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			max = Math.max(max, a);
			gcd = gcd(gcd, a);
		}
		if (k <= max && k % gcd == 0)
			System.out.println("POSSIBLE");
		else
			System.out.println("IMPOSSIBLE");
	}
	static int gcd(int a, int b) {
		if(b == 0) return a;
		return gcd(b, a%b);
	}
}
""")
call(('javac','Main.java'))
call(('java','Main'))

Solution (Python):
from subprocess import*
with open('Main.java','w')as f:f.write(r"""
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int max = 0;
		int gcd = 0;
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			max = Math.max(max, a);
			gcd = gcd(gcd, a);
		}
		if (k <= max && k % gcd == 0)
			System.out.println("POSSIBLE");
		else
			System.out.println("IMPOSSIBLE");
	}
	static int gcd(int a, int b) {
		if(b == 0) return a;
		return gcd(b, a%b);
	}
}
""")
call(('javac','Main.java'))
call(('java','Main'))

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

Solution (Python):
n, k = map(int, input().split())
ar = list(sorted(map(int, input().split())))

def lcm(x, y):
    return x if y == 0 else lcm(y, x % y)

l = ar[0]
for a in ar[1:]:
    l = lcm(l, a)

ans = 'POSSIBLE' if k % l == 0 and k <= ar[-1] else 'IMPOSSIBLE'
print(ans)

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
from fractions import gcd
g=0
for i in a:
    g=gcd(g,i)
if k>max(a):
    print("IMPOSSIBLE")
else:
    for i in a:
        if k%g==i%g:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")

Solution (Python):
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
a.sort()
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
ans=a[0]
for i in a:
    ans=gcd(ans,i)

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

Solution (Python):
N, K = map(int, input().split()) 
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)
if dif:
    mind = min(dif)
else:
    mind = A[0]

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)

Solution (Python):
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 in a or k%z==0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
g=a[-1]
def gcd(a,b):
  while b:a,b=b,a%b
  return a
for i in a:g=gcd(g,i)
if a[-1]<k or k%g!=0:print("IMPOSSIBLE")
else:print("POSSIBLE")

Solution (Python):
def gcd(m, n):
    if m < n:
        return gcd(n, m)
    elif n == 0:
        return m
    return gcd(n, m % n)

def gcd_list(lst):
    ans = lst[0]
    for e in lst:
        ans = gcd(ans, e)
    return ans

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

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

Solution (Python):
from fractions import gcd
n,k=map(int,input().split())
a=list(map(int,input().split()))
if k>max(a):
  print('IMPOSSIBLE')
elif n==1:
  if a[0]==k:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
elif n==2:
  c=gcd(a[0],a[1])
  if k%c==0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
else:
  c=gcd(a[0],a[1])
  for i in range(2,n):
    c=gcd(c,a[i])
  if k%c==0: 
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

Solution (Python):
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    return gcd(b, a % b)


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    x = A[0]
    for i in range(1, N):
        x = gcd(x, A[i])
    if K <= max(A) and K % x == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == "__main__":
    main()

Solution (Python):
from fractions import gcd
N, K = map(int, input().split())
A = list(map(int, input().split()))
if K in A:
  print('POSSIBLE')
elif K > max(A):
  print('IMPOSSIBLE')
else:
  A_gcd = A[0]
  for i in range(1, N):
    A_gcd = gcd(A_gcd, A[i])

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

Solution (Python):
import sys
import fractions
import numpy as np


def main():
    n, k = [int(e) for e in input().split()]
    an = [int(e) for e in input().split()]
    an.sort(reverse=True)
    gcd = an[0]
    for a in an:
        gcd = fractions.gcd(a, gcd)
    if an[0] < k or (an[0] - k) % gcd != 0:
        print("IMPOSSIBLE")
    else:
        print("POSSIBLE")


main()

Solution (Python):
from fractions import gcd

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

if N == 1:
    print("POSSIBLE" if K == A[0] else "IMPOSSIBLE")
else:
    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")

Solution (Python):
N,K = map(int,input().split())
*A, = sorted(set(map(int,input().split())))
if A[-1]<K:print("IMPOSSIBLE");exit()
if len(A)==1:
    if A[0]==K:print("POSSIBLE")
    else: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")

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

Solution (Python):
from fractions import gcd
n,k = map(int,input().split())
a = list(map(int,input().split()))
m = max(a)
g = min(a)
for t in a:
  g = gcd(g,t)

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

Solution (Python):
from fractions import gcd
n,k = map(int,input().split())
a = list(map(int,input().split()))
m = max(a)
g = a[0]
for t in a:
  g = gcd(g,t)

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

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


num_balls, final_int = map(int,input().split())
balls = list(map(int,input().split()))
ball = balls[0]
for i in balls:
    ball = gcd(ball,i)

if final_int % ball==0 and final_int <= max(balls):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):

"""
A - Getting Difference
https://atcoder.jp/contests/agc018/tasks/agc018_a

"""
import sys


from fractions import gcd
from functools import reduce

def solve(N, K, A):
    limit = max(A)
    t = reduce(lambda x, y: gcd(x, y), A)
    if K <= limit and K % t == 0:
        return 'POSSIBLE'
    return 'IMPOSSIBLE'


def main(args):
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    ans = solve(N, K, A)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
from fractions import gcd
n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
a_max = max(a)

agcd = a[0]
for item in a[1:]:
    agcd = gcd(agcd, item)

if k > a_max:
    print("IMPOSSIBLE")
elif agcd == 1:
    print("POSSIBLE")
elif k % agcd != 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Solution (Python):
n,k = map(int, input().split())
l = list(map(int, input().split()))
s = "POSSIBLE"
m = max(l)
a = l.pop()
for _ in range(n-1):
  b = l.pop()
  while b:
    a,b = b,a%b
if k>m or k%a:
  s = "IM" + s
print(s)

Solution (Python):
import fractions
from functools import reduce

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


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


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

Solution (Python):
n,k=map(int,input().split())
a=[int(i) for i in input().split()]

def gcd(x,y):
    if x<y:
        x,y=y,x
    if x%y==0:
        return y
    while x%y!=0:
        x,y=y,x%y
    return y
    
d=a[0]
for i in range(1,n):
    d=gcd(a[i],d)

j=0 if k%d==0 and k<=max(a) else 1
ans=['POSSIBLE','IMPOSSIBLE']
print(ans[j])

Solution (Python):
def gcd(x, y):
  if y == 0:
    return x
  return gcd(y, x % y)

N, K = map(int, input().split())
A = list(map(int, input().split()))
g = 0
for i in A:
  g = gcd(g, i)
ans = "IMPOSSIBLE"
for i in A:
  if i >= K and (K - i) % g == 0:
    ans = "POSSIBLE"
    break
print(ans)

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

def gcd(n,m):
    while n:
        a = n
        n = m % n
        m = a
    return m

def main():
    if K > max(A):
        return 0
    i = A[0]
    for a in A:
        i = gcd(i,a)
    return not(K%i)

print(['IMPOSSIBLE','POSSIBLE'][main()])

Solution (Python):
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

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

a_gcd = A[0]
a_max = A[0]
for i in range(1,N,1):
    a_gcd = gcd(a_gcd,A[i])
    if (a_max < A[i]):
        a_max = A[i]

if ((a_max < K) or (0 < (K % a_gcd))):
    print("IMPOSSIBLE")
    exit()

print("POSSIBLE")

Solution (Python):
def gcd(a,b):
	if a%b==0:
		return b
	else:
		return gcd(b,a%b)
a,b=list(map(int,input().strip().split()))
n=list(map(int,input().strip().split()))
hi=G=n[0]
for i in range(1,a,1):
	G=gcd(G,n[i])
	if hi<n[i]:
		hi=n[i]
if b%G==0 and b<=hi:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

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


n,k = map(int,input().split())
l = list(map(int,input().split()))
d = l[0]
for i in l:
    d = gcd(d,i)

if k%d==0 and k<=max(l):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

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


b = gcd_list(a)

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