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:
def get_difference():
	# get input from raw_input()
	n, k = map(int, raw_input().split(' '))
	l = [int(e) for e in raw_input().split(' ')]
	if n < 1:
		print "IMPOSSIBLE"
		return
	if n == 1:
		if l[0] == k:
			print "POSSIBLE"
		else:
			print "IMPOSSIBLE"
		return
	if k in l:
		print "POSSIBLE"
		return
	if k > max(l):
		print "IMPOSSIBLE"
		return
	gcd_v = reduce(gcd, sorted(l))
	if k % gcd_v == 0:
		print "POSSIBLE"
	else:
		print "IMPOSSIBLE"


if __name__ == "__main__":
	get_difference()

Submission status: Runtime Error

Solution code:
def get_difference():
	# get input from raw_input()
	n, k = map(int, raw_input().split(' '))
	l = [int(e) for e in raw_input().split(' ')]
	if n < 1:
		print "IMPOSSIBLE"
		return
	if n == 1:
		if l[0] == k:
			print "POSSIBLE"
		else:
			print "IMPOSSIBLE"
		return
	if k in l:
		print "POSSIBLE"
		return
	if k > max(l):
		print "IMPOSSIBLE"
		return
	gcd_v = reduce(gcd, l)
	if k % gcd_v == 0 or gcd_v == 1:
		print "POSSIBLE"
	else:
		print "IMPOSSIBLE"


if __name__ == "__main__":
	get_difference()

Submission status: Runtime Error

Solution code:
def get_difference():
	# get input from raw_input()
	n, k = map(int, raw_input().split(' '))
	l = [int(e) for e in raw_input().split(' ')]
	if k in l:
		print "POSSIBLE"
		return
	if k>max(l):
		print "IMPOSSIBLE"
		return
	gcd_v = reduce(gcd, l)
	if k%gcd_v==0:
		print "POSSIBLE"
	else:
		print "IMPOSSIBLE"


if __name__ == "__main__":
	get_difference()

Submission status: Runtime Error

Solution code:
def get_difference():
	# get input from raw_input()
	n, k = map(int, raw_input().split(' '))
	l = [int(e) for e in raw_input().split(' ')]
	if k in l:
		print "POSSIBLE"
		return
	if k>max(l):
		print "INPOSSIBLE"
		return
	gcd_v = reduce(gcd, l)
	if k%gcd_v==0:
		print "POSSIBLE"
	else:
		print "INPOSSIBLE"


if __name__ == "__main__":
	get_difference()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,K = map(int,raw_input().split())
src = map(int,raw_input().split())

def solve():
  if N == 1: return src[0] == K
  mx = max(src)
  if K > mx: return False
  g = src[0]
  for i in range(1,N):
    g = gcd(g, src[i])
    if g == 1:
      return True
  return K % g == 0

print ('POSSIBLE' if solve() else 'IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
# encoding:utf-8
import functools as ft
import math

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

	max_num = max(nums)
	g = ft.reduce(lambda x, y: math.gcd(x, y), nums)

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

if __name__ == '__main__':
	main()

Submission status: Runtime Error

Solution code:
# encoding:utf-8
import functools as ft
import math

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

	max_num = max(nums)
	g = ft.reduce(lambda x, y: math.gcd(x, y), nums)

	if K <= max_num and K % g == 0:
		return("POSSIBLE")
	else:
		return("IMPOSSIBLE")

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

Submission status: Runtime Error

Solution code:
# encoding:utf-8
from functools import reduce
import math


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

	max_num = max(nums)
	g = reduce(lambda x, y: math.gcd(x, y), nums)

	# 最大値が越えてたらだめ
	if K <= max_num and K % g == 0:
		return("POSSIBLE")
	else:
		return("IMPOSSIBLE")


def gcdList(nums):
	tmp = nums[0]
	for x in nums[1:]:
		tmp = math.gcd(tmp, x)
	return(tmp)

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

Submission status: Runtime Error

Solution code:
# encoding:utf-8
import math

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

	max_num = max(nums)
	min_num = min(nums)

	# 最大値が越えてたらだめ
	if K > max_num:
		return("IMPOSSIBLE")

	gcd_val = gcdList(nums)

	if K % gcd_val > 0:
		return("IMPOSSIBLE")
	else:
		return("POSSIBLE")

def gcdList(nums):
	tmp = nums[0]
	for x in nums[1:]:
		tmp = math.gcd(tmp, x)
	return(tmp)

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

Submission status: Runtime Error

Solution code:
# encoding:utf-8
import math

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

	max_num = max(nums)
	min_num = min(nums)

	# 最大値が越えてたらだめ
	if K > max_num:
		return("IMPOSSIBLE")

	gcd_val = gcdList(nums)

	if K % gcd_val > 0:
			return("IMPOSSIBLE")
	else:
		return("POSSIBLE")

def gcdList(nums):
	tmp = nums[0]
	for x in nums[1:]:
		tmp = math.gcd(tmp, x)
	return(tmp)

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

Submission status: Runtime Error

Solution code:
X, Y, Z = list(map(int, input().split(" ")))

import numpy as np

ABC = []

for i in range(X+Y+Z):
    ABC.append(list(map(int, input().split(" "))))

ABC = sorted(ABC, key=lambda row: row[0]-row[1])    

ans = 0

ABC_bk = ABC_np[:Y]
ABC_ak = ABC_np[Y:]

for k in range(Y, Y+Z):
    
    ABC_bk = ABC_bk + ABC_ak[0]
    ABC_ak = ABC_ak.pop(0)
    
    
    before_k = np.asarray(sorted(ABC_bk.tolist(), key=lambda row: row[1]-row[2]))
    after_k = np.asarray(sorted(ABC_ak.tolist(), key=lambda row: row[0]-row[2]) )      
    
    bk_sum = before_k[-Y:].sum(axis=0)[1] + before_k[:-Y].sum(axis=0)[2]
    ak_sum = after_k[-X:].sum(axis=0)[0] + after_k[:-X].sum(axis=0)[2]
    
    tmp = ak_sum + bk_sum
                          
    if ans < tmp:
        ans = tmp
    
print (ans)

Submission status: Runtime Error

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

def gcd_list(lst):
    a = gcd(lst[0],lst[1])
    i=2
    while a > 0 and i<len(lst):
        a = gcd(a, lst[i])
        if a == 1:
            return 1
            break
        i+=1
    return a
    
n, k = (int(i) for i in input().split())
a = list(int(i) for i in input().split())  
maxA=max(a)

if maxA >= k and k%gcd_list(a) == 0:
    print("POSSIBLE")
elif k in a:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
def gcd(a,b):
    while b > 0:
        a, b = b, a%b
    return a

def gcd_list(lst):
    a = gcd(lst[0],lst[1])
    i=2
    while a > 0 and i<len(lst):
        a = gcd(a, lst[i])
        if a == 1:
            return 1
            break
        i+=1
    return a
    
n, k = (int(i) for i in input().split())
a = list(int(i) for i in input().split())  
maxA=max(a)

if maxA >= k and gcd_list(a)%k == 0:
    print("POSSIBLE")
elif k in a:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

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

def gcd_list(lst):
    a = gcd(lst[0],lst[1])
    i=2
    while a > 0 and i<len(lst):
        a = gcd(a, lst[i])
        if a == 1:
            return 1
            break
        i+=1
    return a
    
n, k = (int(i) for i in input().split())
print(n,k)
a = list(int(i) for i in input().split())  
print(a)
maxA=max(a)

if maxA >= k and gcd_list(a)%k == 0:
    print("POSSIBLE")
elif k in a:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from fractions import gcd

PO = "POSSIBLE"
IM = "IMPOSSIBLE"
ans = ""


N, K = map(int, input().split())		# 5 7
a = sorted(list(map(int, input().split())))	# 1 2 3 4 5 ...

if max(a)<K:
	print(IM)
	sys.exit()

if K in a:
	print(PO)
	sys.exit()

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

if K%g==0:
	ans=PO
else:
	ans=IM


print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd

PO = "POSSIBLE"
IM = "IMPOSSIBLE"
ans = ""


N, K = map(int, input().split())		# 5 7
a = sorted(list(map(int, input().split())))	# 1 2 3 4 5 ...
#p(a)

if max(a)<K:
	print(IM)
	sys.exit()

if K in a:
	print(PO)
	sys.exit()

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

if K%g==0:
	ans=PO
else:
	ans=IM


print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd

PO = "POSSIBLE"
IM = "IMPOSSIBLE"
ans = ""


N, K = map(int, input().split())		# 5 7
a = sorted(list(map(int, input().split())))	# 1 2 3 4 5 ...
#p(a)

if max(a)<K:
	print(IM)
	sys.exit()

if K in a:
	print(PO)
	sys.exit()

g=a[0]
for i in range(1, N):
	g = gcd(g,a[i])
	if K%g==0:
		ans=PO
		break
else:
	ans=IM


print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd

PO = "POSSIBLE"
IM = "IMPOSSIBLE"
ans = ""


N, K = map(int, input().split())		# 5 7
a = sorted(list(map(int, input().split())))	# 1 2 3 4 5 ...
#p(a)

if max(a)<K:
	print(IM)
	sys.exit()

if K in a:
	print(PO)
	sys.exit()

g=a[0]
for i in range(N):
	g = gcd(g,a[i])
	if K%g==0:
		ans=PO
		break
else:
	ans=IM


print(ans)

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd

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

m = max(an)
g = reduce(lambda x, y: gcd(x, y), an)

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

Submission status: Runtime Error

Solution code:
from itertools import combinations
from math import gcd

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

m = max(an)
g = max(map(lambda x:gcd(x[0],x[1]), combinations(an, 2)))

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

Submission status: Runtime Error

Solution code:
from itertools import combinations
from math import gcd

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

m = max(an)
g = max(map(lambda x:gcd(x[0],x[1]), combinations(an, 2)))

if K <=m and k % g == 0:
    print 'POSSIBLE'
else:
    print 'IMPOSSIBLE'

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))


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

Submission status: Runtime Error

Solution code:
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))

import math

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

Submission status: Runtime Error

Solution code:
from functools import reduce
import math
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split() if int(i) > 1]
g = reduce(lambda x,y: math.gcd(x,y), A)
if max(A) > K and g == 1:
    print('POSSIBLE')
elif max(A) > K and K % g == 0:
    print('POSSIBLE')
elif K in A:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
from functools import reduce
import math
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
g = reduce(lambda x,y: math.gcd(x,y), A)
if max(A) > K and g == 1:
    print('POSSIBLE')
elif max(A) > K and K % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
from fractions import gcd


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


if K > A[-1]:
    print('IMPOSSIBLE')
else:
    flag = True
    tmp = reduce(gcd, A)
    if tmp != 1:
        flag = False
    for a in A:
        if a == K or (K - a) % tmp == 0:
            flag = True
            break
    if flag:
        print("POSSIBLE")
    else:
        print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
from functools import reduce
import math
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
g = reduce(lambda x,y: math.gcd(x,y), A)
if K > max(A):
    print('IMPOSSIBLE')
elif K % g == 0:
    print('POSSIBLE')
elif g > 1:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
nn = list(map(int,input().split()))
nnn = nn.copy()

if b in nn:
    print('POSSIBLE')
    exit()
if b > max(nn):
    print("IMPOSSIBLE")
    exit()
len_nn = [0]
while 1:
    lnn = len(nn)
    for x in range(len(nn)):
        for y in range(len(nn) - x -len_nn):
            y = len(nn)-y-1
            #print(x,y)
            num = abs(x-nn[y])
            if num == b or num == 1:
                print('POSSIBLE')
                exit()
            elif num not in nn and num != 0:
                nn.append(num)
    len_nn += lnn
    if nn == nnn:
        print('IMPOSSIBLE')
        exit()

Submission status: Runtime Error

Solution code:
from functools import reduce
import math
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
if K > max(A):
    print('IMPOSSIBLE')
else:
    if reduce(lambda x,y: math.gcd(x,y), A) > 1:
        print('IMPOSSIBLE')
    else:
        print('POSSIBLE')

Submission status: Runtime Error

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

if K in A:
    print("POSSIBLE")
elif K > max(A):
    print("IMPOSSIBLE")
else:
    A.sort()
    mind = A[0]
    l = N
    d = list({A[i + 1] - A[i] for i in range(N - 1)})
    d.sort()
    while l != 1 and mind != 1:
        d2 = {d[i + 1] - d[i] for i in range(len(d) - 1)}
        l = len(d2)
        mind = min(d2)
        d = list(d2)
        d.sort()

    if mind == 1:
        print("POSSIBLE")
    elif len(d) == 1:
        dels = [(i - K) % mind for i in A if i > K]
        if 0 in dels:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")

Submission status: Runtime Error

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

if K in A:
    print("POSSIBLE")
elif K > max(A):
    print("IMPOSSIBLE")
else:
    A.sort()
    mind = A[0]
    l = N
    d = list({A[i + 1] - A[i] for i in range(N - 1)})
    d.sort()
    while l != 1 and mind != 1:
        d2 = {d[i + 1] - d[i] for i in range(len(d) - 1)}
        l = len(d2)
        mind = min(d2)
        d = list(d2)
        d.sort()

    if mind == 1:
        print("POSSIBLE")
    elif len(d) == 1:
        dels = [(i - K) % mind for i in A if i > K]
        if 0 in dels:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from functools import reduce
import math
import sympy as sym
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
if K > max(A):
    print('IMPOSSIBLE')
else:
    if reduce(lambda x,y: math.gcd(x,y), A) > 1:
        print('IMPOSSIBLE')
    else:
        print('POSSIBLE')

Submission status: Runtime Error

Solution code:
import sys

n,k = map(int, input().split())
a = list(map(int, input().split()))
if k > max(a) :
    print('IMPOSSIBLE')
    sys.exit()
elif k in a or 1 in a:
    print('POSSIBLE')
    sys.exit()

a.sort()
l = []
for i in range(n-1,-1,-1) :
    if a[i] < k :
        break
    else :
        l.append(a[i]-k)
else :
    l = list(set(l))

diff = [0]*(n-1)
for i in range(n-1) :
    diff[i] = a[i+1] - a[i]
else :
    diff = list(set(diff))
    diff.sort()

for d in diff :
    for ll in l :
        if ll%d == 0 or ll%d in diff :
            print('POSSIBLE')
            sys.exit()
else :
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
from functools import reduce
import sympy as sym
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
if K > max(A):
    print('IMPOSSIBLE')
else:
    if reduce(lambda x,y: sym.gcd(x,y), A) > 1:
        print('IMPOSSIBLE')
    else:
        print('POSSIBLE')

Submission status: Runtime Error

Solution code:
from functools import reduce
import sympy as sym
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
if K > max(A):
    print('IMPOSSIBLE')
if reduce(lambda x,y: sym.gcd(x,y), A) > 1:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Runtime Error

Solution code:
n, k = map(int, raw_input().split(" "))
s = set(map(int, raw_input().split(" ")))
 
if k in s:
  print "POSSIBLE"
  exit()
while 1:
  print s
  ar = sorted(s)
  changed = False
  prev = None
  deltas = [0]
  for a in ar:
    if not prev:
      prev = a
      continue
    v = a - prev
    for i in xrange(len(deltas)):
      n = deltas[i] + v
      deltas[i] += v
      if n not in s:
        s.add(n)
        changed = True
    deltas.append(v)
    prev = a
  if k in s:
    print "POSSIBLE"
    exit()
  elif not changed:
    print "IMPOSSIBLE"
    exit()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
arys = []
for i in range(N):
    tmp = input()
    ary = [int(a) - 1 for a in tmp.split()]
    arys.append(ary)


s = set([i for i in range(M)])
min_num = None
while len(s) > 0:
    dic = {}
    for ary in arys:
        del_i = None
        for i, a in enumerate(ary):
            if a in s:
                if a not in dic:
                    dic[a] = 1
                else:
                    dic[a] += 1
                break
            del_i = i
        if del_i is not None:
            ary = ary[del_i + 1:]
    max_v = None
    max_k = None
    for k, v in dic.items():
        if max_v is None or max_v < v:
            max_v = v
            max_k = k
    if min_num is None or min_num > max_v:
        min_num = max_v
    s.remove(max_k)
print(min_num)

Submission status: Runtime Error

Solution code:
X = input().split()
N = int(X[0])
K = int(X[1])

ch = 0

Y = input().split()
A = []
B = []
C = []
D = []

for i in range(N):
    A.append(int(Y[i]))
    if int(Y[i]) == K:
        ch = 1
    if int(Y[i]) > K:
        C.append(int(Y[i]))

if ch == 1:
    print("POSSIBLE")

else:
    B = sorted(A)
    D = sorted(C)
    
    y = len(C)
    
    s1 = int(B[0])
    s2 = int(B[1])
    
    sa = s2 - s1
    
    for i in range(y):
        a = int(C[y - i -1])
        
        z = (a - K)%sa
        
        if z == 0:
            ch = 1
            break
    
    if ch == 1:
        print("POSSIBLE")
    
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

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


if K > A[-1]:
    print('IMPOSSIBLE')
else:
    flag = True
    for i in range(N - 1):
        if A[i] % (A[i + 1] - A[i]) == 0 or \
           (A[i + 1] - A[i]) % A[i] == 0 or \
           A[i + 1] % (A[i + 1] - A[i]) == 0:
            flag = False
            break
    if flag:
        print("POSSIBLE")
    else:
        print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

#箱に N 個のボールが入っていて、i 番目のボールには整数 Ai が書かれています。 
#すぬけ君は、次の操作を好きな回数だけ行うことができます。
#
#箱から二つのボールを取り出し、
#その二つのボールに書かれている数の差の絶対値を書いた新しいボールと一緒に箱に戻す。
#すぬけ君が、整数 K の書かれたボールが箱の中に入っている状態にできるかどうか判定してください。

#すぬけ君が、整数 K がかかれたボールが箱の中に入っている状態にできる場合には 
#POSSIBLE、 できない場合には IMPOSSIBLE と出力せよ。

X = input().split()
N = int(X[0])
K = int(X[1])

ch = 0

Y = input().split()
A = []
B = []
C = []

for i in range(N):
    A.append(int(Y[i]))
    if int(Y[i]) == K:
        ch = 1
    if int(Y[i]) > K:
        C.append(int(Y[i]))

if ch == 1:
    print("POSSIBLE")

else:
    B = sorted(A)
    
    s1 = int(B[0])
    s2 = int(B[1])
    
    sa = s2 - s1
    
    for i in range(len(C)):
        a = int(C[i])
        
        z = (a - K)%sa
        
        if z == 0:
            ch = 1
            break
    
    if ch == 1:
        print("POSSIBLE")
    
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
mn = min(*A)
mx = max(*A)
f = True
for x in A:
    if x % mn != 0:
        f = False
        break
if (f == False or K % mn == 0) and mx >= K:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

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


if K > A[-1]:
    print('IMPOSSIBLE')
else:
    flag = True
    for i in range(N - 1):
        if A[i] % (A[i + 1] - A[i]) == 0 or \
           (A[i + 1] - A[i]) % A[i] == 0:
            flag = False
            break
    if flag:
        print("POSSIBLE")
    else:
        print('IMPOSSIBLE')

Submission status: Runtime Error

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

def calc(seq, target):
    from math import gcd
    if target in seq:
        return 'POSSIBLE'
    if max(seq) < target:
        return 'IMPOSSIBLE'
    dif = []
    target_diff = []
    seq = list(sorted(seq))
    for idx,s in enumerate(seq):
        if target < s:
            target_diff.append(s - target)
        if idx==0:
            continue
        d = gcd(s,seq[idx-1])
        if d == 1:
            return 'POSSIBLE'
        dif.append(d)
    dif = list(sorted(list(set(dif))))
    for d in dif:
        for td in target_diff:
            if td%d == 0:
                return 'POSSIBLE'
    return 'IMPOSSIBLE'

print(calc(As, K))

Submission status: Runtime Error

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

def calc(seq, target):
    from math import gcd
    if target in seq:
        return 'POSSIBLE'
    if max(seq) < target:
        return 'IMPOSSIBLE'
    dif = []
    target_diff = []
    seq = list(sorted(seq))
    for idx,s in enumerate(seq):
        if target < s:
            target_diff.append(s - target)
        if idx==0:
            continue
        d = gcd(s,seq[idx-1])
        if d == 1:
            return 'POSSIBLE'
        dif.append(d)
    dif = sorted(list(set(dif)))
    for d in dif:
        for td in target_diff:
            if td%d == 0:
                return 'POSSIBLE'
    return 'IMPOSSIBLE'

print(calc(As, K))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

#箱に N 個のボールが入っていて、i 番目のボールには整数 Ai が書かれています。 
#すぬけ君は、次の操作を好きな回数だけ行うことができます。
#
#箱から二つのボールを取り出し、
#その二つのボールに書かれている数の差の絶対値を書いた新しいボールと一緒に箱に戻す。
#すぬけ君が、整数 K の書かれたボールが箱の中に入っている状態にできるかどうか判定してください。

#すぬけ君が、整数 K がかかれたボールが箱の中に入っている状態にできる場合には 
#POSSIBLE、 できない場合には IMPOSSIBLE と出力せよ。

X = input().split()
N = int(X[0])
K = int(X[1])

ch = 0

Y = input().split()
A = []
B = []
C = []

for i in range(N):
    A.append(int(Y[i]))
    if int(Y[i]) == K:
        ch = 1
    if int(Y[i]) > K:
        C.append(int(Y[i]))

if ch == 1:
    print("POSSIBLE")

else:
    B = sorted(A)
    
    s1 = int(B[0])
    s2 = int(B[1])
    
    sa = s2 - s1
    
    for i in range(len(C)):
        a = int(C[i])
        
        z = (a - K)%sa
        
        if z == 0:
            ch = 1
    
    if ch == 1:
        print("POSSIBLE")
    
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import math as mt
n,k = [int(x) for x in input().split(' ')]
list = [int(x) for x in input().split(' ')]
gcd = list[0]
maxi = list[0]
for i in range(n-1):
    gcd = mt.gcd(gcd, list[i+1])
    if maxi < list[i+1]:
        maxi = list[i+1]

if maxi < k:
    print("IMPOSSIBLE")
else:
    if k % gcd == 0 or gcd == 1:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import math as mt
n,k = [int(x) for x in input().split(' ')]
list = [int(x) for x in input().split(' ')]
gcd = list[0]
maxi = list[0]
for i in range(n-1):
    gcd = mt.gcd(gcd, list[i+1])
    if maxi < list[i+1]:
        maxi = list[i+1]

if maxi < k:
    print("IMPOSSIBLE")
    exit()
else:
    if k % gcd == 0 or gcd == 1:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()

Submission status: Runtime Error

Solution code:
# import numpy as np

# while True:
# A, B = np.random.randint(100) * 2 + 1, np.random.randint(100) * 2 + 1
# if A < B:
#     A, B = B, A
# ori_a, ori_b = A, B
# while True:
#     print(A, B)
#     mid = abs(A - B)
#     A, B = mid, B
#     if A < B:
#         A, B = B, A
#     # print(A, B)
#     if B == 1:
#         print("clear")
#         break
#     elif B == 0:
#         print(ori_a, ori_b, "wrong")
#         break


def eratos(n):
    if n <= 1:
        return []
    used = [False] * n
    used[0] = used[1] = True
    primes = []
    for i in range(n):
        if used[i] is False:
            primes.append(i)
            for j in range(i * 2, n, i):
                used[j] = True
    return primes


N, K = map(int, input().split())
A = list(map(int, input().split()))
max_a = max(A)
primes = eratos(K + 1)

defactors = []
x = A[0]
for prime in primes:
    if x == 1:
        continue
    while x % prime == 0:
        defactors.append(prime)
        x //= prime
cand = list(set(defactors))

if K > max_a:
    print('IMPOSSIBLE')
else:
    for c in cand:
        next_a = []
        for i in range(len(A)):
            if (A[i] % c != 0):
                next_a.append(A[i])
        A = next_a
    # print(list(filter(lambda x: x != 0, A)))
    if len(list(filter(lambda x: x != 0, A))):
        print("POSSIBLE")
    else:
        print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
import math as mt
n,k = [int(x) for x in input().split(' ')]
max = 0
list = [int(x) for x in input().split(' ')]
gcd = list[0]
max = list[0]
for i in range(n-1):
    gcd = mt.gcd(gcd, list[i+1])
    if max < list[i+1]:
        max = list[i+1]

if max < k:
    print("IMPOSSIBLE")
    exit()
else:
    if k % gcd == 0 or gcd == 1:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

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

def calc(seq, target):
    if target in seq:
        return 'POSSIBLE'
    if max(seq) < target:
        return 'IMPOSSIBLE'
    dif = []
    target_diff = []
    seq = list(sorted(seq))
    for idx,s in enumerate(seq):
        if target < s:
            target_diff.append(s - target)
        if idx==0:
            continue
        d = abs(s-seq[idx-1])
        if d == 1:
            return 'POSSIBLE'
        dif.append(d)
    dif = sorted(list(set(dif)))
    for d in dif:
        for td in target_diff:
            if td%d == 0:
                return 'POSSIBLE'
    return 'IMPOSSIBLE'

print(calc(As, K))

Submission status: Runtime Error

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

def calc(seq, target):
    if target in seq:
        return 'POSSIBLE'
    if max(seq) < target:
        return 'IMPOSSIBLE'
    dif = []
    target_diff = []
    seq = sorted(seq)
    for idx,s in enumerate(seq):
        if target < s:
            target_diff.append(s - target)
        if idx==0:
            continue
        d = abs(s-seq[idx-1])
        if d == 1:
            return 'POSSIBLE'
        dif.append(d)
    dif = sorted(list(set(dif)))
    for d in dif:
        for td in target_diff:
            if td%d == 0:
                return 'POSSIBLE'
    return 'IMPOSSIBLE'

print(calc(As, K))

Submission status: Runtime Error

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    N,K = LI()
    a = LI()
    if max(a) < K:
        return 'IMPOSSIBLE'
    if K in a:
        return 'POSSIBLE'
    t = a[0]
    for c in a[1:]:
        t = math.gcd(c, t)
        if t <= 1:
            return 'POSSIBLE'
    for c in a:
        if (c > K) and (((c-K) % t) == 0):
            return 'POSSIBLE'

    return 'IMPOSSIBLE'


print(main())

Submission status: Runtime Error

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    N,K = LI()
    a = LI()
    if max(a) < K:
        return 'IMPOSSIBLE'
    if K in a:
        return 'POSSIBLE'
    t = a[0]
    for c in a[1:]:
        t = math.gcd(c, t)
    if t <= 1:
        return 'POSSIBLE'
    for c in a:
        if (c > K) and (((c-K) % t) == 0):
            return 'POSSIBLE'

    return 'IMPOSSIBLE'


print(main())