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):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7





N, K = getNM()
A = getList()
if K in A:
    print('POSSIBLE')
    exit()
if K > max(A):
    print('IMPOSSIBLE')
    exit()

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

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

Solution (Python):
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
if k in a:
    print("POSSIBLE")
    exit()
tmp = a[0]
for i in range(1,n):
    tmp = math.gcd(tmp,a[i])
for i in a:
    if i > k and (i-k) % tmp == 0:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Solution (Python):
import sys
input = sys.stdin.readline
enum = enumerate
INF = 1001001001

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().rstrip().split()))

def vinput(rep=1, ty=int, cvt=list):
	return cvt(ty(input().rstrip()) for _ in "*"*rep)

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

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def bye(res):
	sT = "IMPOSSIBLE POSSIBLE".split()
	print(sT[res])
	
	exit(0)

def main():
	N,K = linput()
	vA = linput(int,set)

	res = 0
	l,r = min(vA), max(vA)
	if K in vA:
		bye(1)
	if not K<=r:
		bye(0)

	g = 0	
	for a in vA:
		g = gcd(g, a)
	print(g, file=sys.stderr)
	
	if (r-K)%g:
		res = 0
	else:
		res = 1
	bye(res)


if __name__ == "__main__":
	main()

Solution (Python):
from math import gcd
from functools import reduce
n, k = map(int, input().split())
A = list(map(int, input().split()))
if k<=max(A) and k%reduce(gcd, A)==0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
import math

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

if max(A) < K:
    print('IMPOSSIBLE')
else:
    check = A[0]
    for i in range(1,N):
        check = math.gcd(A[i],check)
    if K % check == 0:
        print("POSSIBLE")
    else:
        print('IMPOSSIBLE')

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

Solution (Python):
def gcd(a, b):
    if a<b:
        a,b = b,a
    r = a%b
    while r != 0:
        a = b
        b = r
        r = a % b
    return b
def gcd_all(A):
    x = A[0]
    if len(A) == 1:
        ret = A[0]
    else:
        for i in range(1,len(A)):
            x = gcd(x,A[i])
        ret = x
    return ret

n,k = map(int,input().split())
a = list(map(int,input().split()))
x = gcd_all(a)
ans = 0
for b in a:
    if b >= k:
        if (b-k)%x == 0:
            ans = 1
            break
print(["IMPOSSIBLE","POSSIBLE"][ans])

Solution (Python):
from math import gcd
from functools import reduce

_, k = map(int, input().split())
ar = list(map(int, input().split()))
mx = max(ar)
m = reduce(gcd, ar)
if k % m == 0 and k <= mx:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Solution (Python):
from math import gcd
from functools import reduce

_, k = map(int, input().split())
ar = list(map(int, input().split()))
mx = max(ar)
m = reduce(gcd, ar)
if k % m == 0 and k <= mx:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Solution (Python):
from math import gcd
from functools import reduce
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=reduce(gcd,a)
if k%m or k>max(a):flag=1
else:flag=0
print(['POSSIBLE','IMPOSSIBLE'][flag])

Solution (Python):
import sys
from math import gcd

input = sys.stdin.readline


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

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

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

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import math


def main():
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    M = max(A)
    g = A[0]
    for a in A[1:]:
        g = math.gcd(g, a)
    if K <= M and K % g == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from math import gcd

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

    if k > max(A):
        print("IMPOSSIBLE")
        exit()

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

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


if __name__ == '__main__':
    resolve()

Solution (Python):
import math

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


all_gcd = A[0]
for m in A:
    all_gcd = math.gcd(all_gcd, m)



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

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

import math
from functools import reduce

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

g=gcd(*a)
p=max(a)-k
ans='POSSIBLE'
if p>=0:
    if p%g!=0:
        ans='IMPOSSIBLE'
else:
    ans='IMPOSSIBLE'

print(ans)

Solution (Python):


import sys
import math
from functools import reduce
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)


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


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

G = gcd(A)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(200000)
N,K = map(int,input().split())
A = list(map(int,input().split()))
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)
g = A[0]
for i in range(1,N):
    g = gcd(g,A[i])
if K > max(A):
    print("IMPOSSIBLE")
    exit()
if K % g == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):

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


n, k = map(int, input().split())
a = list(map(int, input().split()))
max_a = max(a)
a_gcd = a[0]
for x in a:
    a_gcd = gcd(a_gcd, x)
if k <= max_a and k % a_gcd == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


"""
どれだけ小さい差を作れるかがポイント
maxの値からそれを引くことでいろんな値を作ることができる
もし差が1を作れればmax 以下の値全て作れる
N この最大公約数が最小の差になる
"""

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
if k>max(a):
    ans = 0
elif k in a:
    ans = 1
elif n==1:
    if a[0]==k:
        ans = 1
    else:
        ans = 0
else:
    g = gcd(a[0], a[1])
    for num in a[2:]:
        g = gcd(g, num)
    if k%g==0:
        ans = 1
    else:
        ans = 0
ans = "POSSIBLE" if ans else "IMPOSSIBLE"
print(ans)

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





if k > a[0]:
    print('IMPOSSIBLE')
    exit()

import math

gcd = a[0]
for i in a:
    gcd = math.gcd(gcd, i)
    if k%gcd == 0:
        print('POSSIBLE')
        exit()
    
print('IMPOSSIBLE')

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

P = "POSSIBLE"
IP = "IMPOSSIBLE"

M = max(A)

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

t = gcd(A[0], A[0])
if N > 1:
    for a in A[1:]:
        t = gcd(t, a)

if K%t == 0 and K <= M:
    print(P)
else:
    print(IP)

Solution (Python):
import sys
import math

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, K = in_nn()
    A = in_nl()

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

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import math

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

gcd = A[0]

if N == 1:
	if K == A[0]:
		print('POSSIBLE')
		exit()
	else:
		print('IMPOSSIBLE')
		exit()

for i in range (0, N):
	if gcd > 1:
		gcd = math.gcd(gcd, A[i])
	else:
		break
        
if gcd == 1:
	print('POSSIBLE')
elif K%gcd ==0 and K <= max(A):
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

from math import gcd
N, K = mapint()
As = list(mapint())

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

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

def resolve():
  n, k = map(int, input().split())
  a = list(map(int, input().split()))
  if k in a:
    print('POSSIBLE')
    return

  if k > max(a):
    print('IMPOSSIBLE')
    return

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

  for x in a:
    if x < k:
      continue
    if (x - k) % g == 0:
      print('POSSIBLE')
      return

  print('IMPOSSIBLE')
  return

if __name__ == "__main__":
  resolve()

Solution (Python):
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
N,K = map(int,input().split())
A = list(map(int,input().split()))
a = A[0]
for i in range(1,N):
    a = gcd(a,A[i])
flag = 0
for i in range(N):
    if A[i]>=K:
        b = A[i]-K
        if b%a==0:
            flag = 1
            break
if flag==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
fact = math.factorial
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N,K = I()
A = l()
div = A[0]
if K > max(A):
    print('IMPOSSIBLE')
    exit()
for i in range(1,N):
    div = math.gcd(div,A[i])
if K%div == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
t=a[0]
for i in range(1,n):
  t=math.gcd(t,a[i])
if k%t!=0 or k>max(a):
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')

Solution (Python):
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=a[0]
for i in a:g=gcd(g,i)
if max(a)>=k and k%g==0:print("POSSIBLE")
else:print("IMPOSSIBLE")

Solution (Python):
from math import gcd
N,K = map(int,input().split())
A = list(map(int,input().split()))
val = A[0]
for i in range(1,N):
    val = gcd(val,A[i])
if K % val == 0 and K <= max(A):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *




N, K = MAP()
A = LIST()

g = A[0]

for x in A:
	g = gcd(g, x)


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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



N, K = MAP()
A = LIST()

G = A[0]

for i in range(1, N+1):
	G = gcd(G, A[i-1])
	if G == 1:
		break

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

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

def main():
    N, K = map(int, input().split())
    A = tuple(map(int, input().split()))
    MAX_VAL = max(A)

    A_GCD = A[0]

    for a in A:
        A_GCD = gcd(A_GCD, a)
    
    if K <= MAX_VAL and K % A_GCD == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

if __name__ == "__main__":
    main()

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

def mgcd(l):
  return reduce(gcd,l)
if k in a:
  print("POSSIBLE")
  exit()
if a[-1]<k:
  print("IMPOSSIBLE")
  exit()
s = mgcd(a)
if s==1:
  print('POSSIBLE')
else:
  if k%s==0:
    print("POSSIBLE")
  else:
    print("IMPOSSIBLE")

Solution (Python):
N,K = map(int, input().split())
A = list(map(int, input().split())) 
A.sort()
A.reverse() 
x = A[0]   
for i in range (1, N):
  while A[i] != 0:
    x , A[i] = A[i] , x % A[i]
if K > A[0]:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE' if K%x == 0 else 'IMPOSSIBLE')

Solution (Python):
from math import gcd

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

gcd_num = a[0]
for ai in a[1:]:
    gcd_num = gcd(gcd_num,ai)

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

Solution (Python):
N,K = map(int, input().split())
A = list(map(int, input().split())) 
A.sort()
A.reverse() 
x = A[0]   
for i in range (1, N):
  while A[i] != 0:
    x , A[i] = A[i] , x % A[i]
if K > A[0]:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE' if K%x == 0 else 'IMPOSSIBLE')

Solution (Python):
a,b = map(int, input().split())
c = list(map(int, input().split())) 
c.sort()
c.reverse() 
d = c[0]   
for i in range (1, a):
  while c[i] != 0:
    d , c[i] = c[i] , d % c[i]
if b > c[0]:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE' if b%d == 0 else 'IMPOSSIBLE')

Solution (Python):
import math
from functools import reduce
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
def hcf(l):
    return reduce(math.gcd, l)
gcd = hcf(A)
m = max(A)
if k%gcd == 0 and k<=m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

n,k = map(int, readline().split())

a = list(map(int,readline().split()))

import math
from functools import reduce
g = reduce(math.gcd, a)

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

Solution (Python):
N,K = map(int, input().split())
A = list(map(int, input().split())) 
A.sort()
A.reverse() 
x = A[0]   
for i in range (1, N):
  while A[i] != 0:
    x , A[i] = A[i] , x % A[i]
if K > A[0]:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE' if K%x == 0 else 'IMPOSSIBLE')

Solution (Python):
def main():
    import math
    from functools import reduce
    def gcd_list(l):
        return reduce(math.gcd, l)
    n, k = list(map(int, input().split()))
    A = list(map(int, input().split()))
    g = gcd_list(A)
    m = max(A)
    if k % g == 0 and k <= m:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()

Solution (Python):
from math import gcd
n,k=map(int,input().split())
*a, =map(int,input().split())
a=sorted(a)
for i in range(len(a)):
  if i==0: tmp=a[0]
  else:
    tmp=gcd(tmp,a[i])
if k%tmp!=0 or max(a)<k:
  print("IMPOSSIBLE")
else: print("POSSIBLE")

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

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

if K > max(A):
    print("IMPOSSIBLE")
else:
    now = A[0]
    for i in range(1,N):
        now = euclid(now,A[i])

    if now == 1:
        print("POSSIBLE")
    elif K % now == 0:
        print("POSSIBLE")
    elif K in A:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

I="IMPOSSIBLE"
P="POSSIBLE"

if max(a)<k:
    print(I)
    quit()

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

if k%gcd==0:
    print(P)
else:
    print(I)

Solution (Python):
from math import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    if K > max(A):
        print('IMPOSSIBLE')
        exit()
    if N == 1:
        if A[0] == K:
            print('POSSIBLE')
        else:
            print('IMPOSSIBLE')
        exit()
    
    A.sort()
    B = A[0]
    for i in range(N):
        B = gcd(B, A[i])

    if B == 1:
        print('POSSIBLE')
        exit()
    
    if K % B == 0:
        print('POSSIBLE')
        exit()

    print('IMPOSSIBLE')

    



if __name__ == "__main__":
    main()

Solution (Python):
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
A = np.array(read().split(), np.int32)

g = np.gcd.reduce(A)
cond = (K % g == 0) and (K <= A.max())
print('POSSIBLE' if cond else 'IMPOSSIBLE')

Solution (Python):
from math import gcd
N,K=map(int,input().split())
A=list(map(int,input().split()))
g=A[0]
if max(A)<K:
    print('IMPOSSIBLE')
    exit()
for i in range(1,N):
    g=gcd(g,A[i])

for i in range(N):
    if (A[i]-K)%g==0:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

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

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

m = max(A)
if m < K:
    print('IMPOSSIBLE')
else:
    if l == 1:
        print('POSSIBLE')
    else:
        for i in range(N):
            if abs(A[i]-K)%l == 0:
                print('POSSIBLE')
                break
        else:
            print('IMPOSSIBLE')

Solution (Python):



from fractions import gcd   
from math import gcd        

def Gcd(lt):
    l = len(lt)
    ret = [1]*l
    ret[0] = lt[0]
    for i in range(1,l):
        ret[i] = gcd(ret[i-1], lt[i])
    return ret

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    g = Gcd(A)[-1]
    if K<=max(A) and K%g==0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

inf = 10**18
mod = 10**9+7

n,k = lr()
a = lr()
tmp = max(a)
if tmp < k:
    print('IMPOSSIBLE')
    sys.exit()
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_list(a)
if k%g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
from fractions import gcd

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

if K in As:
  print('POSSIBLE')
  exit()
if K > max(As):
  print('IMPOSSIBLE')
  exit()
  
r = As[0]

for i in range(1,N):
  r = gcd(As[i],r)
  
if K%r != 0:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')

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


N, K = map(int, input().split())
A = list(map(int, input().split()))
g = reduce(gcd, A)
if K <= max(A) and K % g == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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


N, K = map(int, input().split())
A = list(map(int, input().split()))
g = reduce(gcd, A)
if K <= max(A) and (g == 1 or K % g == 0):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):

from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from fractions import gcd

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    
    if K > A[N-1]:
        print('IMPOSSIBLE')
    else:
        ans = 0
        for i in range(N):
            ans = gcd(ans,A[i])
            if ans == 1:
                print('POSSIBLE')
                exit()
        if (A[N-1]-K)%ans == 0:
            print('POSSIBLE')
        else:
            print('IMPOSSIBLE')


if __name__ == "__main__":
    main()

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


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def solve(N, K, A):
    a = reduce(gcd, A)
    if max(A) < K:
        return "IMPOSSIBLE"
    if a > 1 and K % a != 0:
        return "IMPOSSIBLE"
    return "POSSIBLE"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Solution (Python):
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))



import fractions
from functools import reduce
def calc_gcd(A):
    return reduce(fractions.gcd, A)

N,K = LI()
A = LI()

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

Solution (Python):
from functools import reduce
_, k, *lst = map(int, open(0).read().split())
def gcd(a, b):
  while b:
    a, b = b, a%b
  return a
a = reduce(gcd, lst)
print('IMPOSSIBLE' if k > max(lst) or k % a else 'POSSIBLE')

Solution (Python):
from fractions import gcd
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])

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

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


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


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count




N,K = IL()
A = IL()
GCD = A[0]
for a in A[1:]:
  GCD = gcd(GCD,a)
MAX = max(A)
if K<=MAX and (MAX-K)%GCD==0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

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

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, K = map(int, rl().split())
    A = list(map(int, rl().split()))
    
    gcd_n = reduce(gcd, A)
    max_a = max(A)
    
    if K % gcd_n == 0 and K <= max_a:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


if __name__ == '__main__':
    solve()

Solution (Python):
import fractions

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

M=A[0]
g=A[0]
for i in range(n-1):
    M=max(M,A[i+1])
    g=fractions.gcd(g,A[i+1])

if k<=M:
    if g==1:
        print("POSSIBLE")
    elif k%g==0:
            print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    print("IMPOSSIBLE")