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: Wrong Answer

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)))

n, k = rli()
a = rli()
print("POSSIBLE")

Submission status: Wrong Answer

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

if b in nn:
    print('POSSIBLE')
    exit()
if b > max(nn):
    print("IMPOSSIBLE")
    exit()


while 1:
    for x in range(len(nn)):
        for y in range(len(nn) - x):
            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:
                nn.append(num)
    if nn == nnn:
        print('IMPOSSIBLE')
        exit()

Submission status: Wrong Answer

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]
    d = list({A[i + 1] - A[i] for i in range(N - 1)})
    l = len(d)
    d.sort()
    while l != 1 and mind != 1:
        d2 = {d[i + 1] - d[i] for i in range(l - 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: Wrong Answer

Solution code:
# coding: utf-8
# Here your code !
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
diff_list = set([])
bigger_val_list = set([])
cand_diff_list = []

biggest_in_a = 0
last_val = 0
for i in a_list:
    diff_list.add(abs(last_val - i))
    if i > k:
        bigger_val_list.add(i - k)
    if i > biggest_in_a:
        biggest_in_a = i
    last_val = i

tmp_diff_list = set([0])
sum_diff_list = set([0])
for i in range(n):
    for j in diff_list:
        for kk in tmp_diff_list:
            sum_diff_list.add(j + kk)
    tmp_diff_list = tmp_diff_list.union(sum_diff_list)

ans_set = sum_diff_list&bigger_val_list
if len(ans_set) > 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

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()

while 1:
    for x in range(len(nn)):
        for y in range(len(nn) - x):
            y = len(nn)-y-1
            #print(x,y)
            num = abs(x-nn[y])
            if num == b:
                print('POSSIBLE')
                exit()
            elif num not in nn:
                nn.append(num)
    if nn == nnn:
        print('IMPOSSIBLE')
        exit()

Submission status: Wrong Answer

Solution code:
# coding:utf-8
from itertools import combinations
N, K = map(int, raw_input().split(' '))
A = set()
A.update(map(int, raw_input().split(' ')))


def difference(data_pair, data_set, goal, calced_pair=set()):
    diff_data = set()

    for d1, d2 in data_pair:
        if (d1, d2) in calced_pair:
            continue
        calced_pair.add((d1, d2))
        diff = abs(d1-d2)
        if diff == goal:
            return 'POSSIBLE'
        if diff not in data_set:
            diff_data.add(diff)

    if len(diff_data) == 0:
        return 'INPOSSIBLE'
    elif 1 in diff_data:
        return 'POSSIBLE'

    data_pair = []
    for d1 in data_set:
        for d2 in diff_data:
            if d1 < d2:
                data_pair.append((d1, d2))
            else:
                data_pair.append((d2, d1))
    for pair in combinations(sorted(diff_data), 2):
        data_pair.append(pair)
    data_set.update(diff_data)
    return difference(data_pair, data_set, goal, calced_pair)


if K >= max(A):
    print 'INPOSSIBLE'
elif K in A or 1 in A:
    print 'POSSIBLE'
else:
    print difference(combinations(sorted(A), 2), A, K)

Submission status: Wrong Answer

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)))

n, k = rli()
a = rli()
if(max(a) < k):
    print("IMPOSSIBLE")
elif(k in a):
    print("POSSIBLE")
else:
    sa = 114514810
    sorted(a)
    for i in range(n-1):
        if(abs(a[i] - a[i+1]) != 0):
            sa = min(sa, abs(a[i] - a[i+1]))
    for i in range(n):
        if(abs(a[i] - sa) != 0):
            sa = min(sa, abs(a[i] - sa))
    if(sa == 114514810):
        print("IMPOSSIBLE")
    elif(sa == 1):
        print("POSSIBLE")
    else:
        sa = min(a[0],sa)
        flag = False
        for i in range(n-1):
            if(abs(a[i] - a[i+1]) % sa != 0):
                flag = True
                break
        for i in range(n):
            if(k % sa == a[i] % sa):
                flag = True
        if(flag):
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")

Submission status: Wrong Answer

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

a = list(map(int, input().split()))
b = []

ans = k in a
if ans == True:
    print("POSSIBLE")
else:
    for i in range(n-1):
        an = abs(a[i] - a[i+1])
        b.append(an)
    a.extend(b)
    
    ans = k in a
    if ans == True:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
import copy
N, K = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)[::-1]
diff =  list(filter(lambda n:n>K, A) )
if diff:
     diff = [d-K for d in diff]
     cnt =0
     while True:
          if list(set(set(diff) & set(A))):
               print("POSSIBLE")
               break
          elif 1 in A:
               print("POSSIBLE")
               break
          else:
               cnt +=1
               if cnt >1:
                   addition = list(set(A)-set(tmpA))
                   tmpA=copy.copy(A)
                   for a in addition:
                        A += [abs(a-aa) for aa in tmpA]
                        A += [abs(a-aa) for aa in addition]
               else:
                   tmpA=copy.copy(A)
                   for i,a in enumerate(tmpA):
                        A += [abs(a-aa) for aa in tmpA[i:]]
               A = list(set(A))
               if sorted(tmpA)==sorted(A):
                   print("IMPOSSIBLE")
                   break
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

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)))

n, k = rli()
a = rli()
if(max(a) < k):
    print("IMPOSSIBLE")
elif(k in a):
    print("POSSIBLE")
else:
    sa = 114514810
    sorted(a)
    for i in range(n-1):
        if(abs(a[i] - a[i+1]) != 0):
            sa = min(sa, abs(a[i] - a[i+1]))
    for i in range(n):
        if(abs(a[i] - sa) != 0):
            sa = min(sa, abs(a[i] - sa))
    if(sa == 114514810):
        print("IMPOSSIBLE")
    elif(sa == 1):
        print("POSSIBLE")
    else:
        sa = min(a[0],sa)
        flag = False
        for i in range(n-1):
            if(abs(a[i] - a[i+1]) % sa != 0):
                flag = True
                break
        if(k % sa == 0):
            flag = True
        if(flag):
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
import copy
N, K = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)[::-1]
diff =  list(filter(lambda n:n>K, A) )
if diff:
     diff = [d-K for d in diff]
     cnt =0
     while True:
          if list(set(set(diff) & set(A))):
               print("POSSIBLE")
               break
          else:
               cnt +=1
               if cnt >1:
                   addition = list(set(A)-set(tmpA))
                   tmpA=copy.copy(A)
                   for a in addition:
                        A += [abs(a-aa) for aa in tmpA]
                        A += [abs(a-aa) for aa in addition]
               else:
                   tmpA=copy.copy(A)
                   for i,a in enumerate(tmpA):
                        A += [abs(a-aa) for aa in tmpA[i:]]
               A = list(set(A))
               if sorted(tmpA)==sorted(A):
                   print("IMPOSSIBLE")
                   break
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
n, k = map(int, raw_input().split())
if n == 1:
    a = int(raw_input())
    if a == k:
        print "POSSIBLE"
    else:
        print "IMPOSSIBLE"
    exit()
a = map(int, raw_input().split())
a.sort()
if k in a:
    print "POSSIBLE"
    exit()
if k > a[n - 1]:
    print "IMPOSSIBLE"
    exit()

d = a[1] - a[0]
ok = False
for i in xrange(n - 1):
    if a[i + 1] - a[i] == d:continue
    ok = True
if ok:
    print "POSSIBLE"
else:
    if (k - a[0]) % d == 0 and 0 <= (k - a[0]) / d <= n - 1:
        print "POSIIBLE"
    else :
        print "IMPOSSIBLE"

Submission status: Wrong Answer

Solution code:
N,K=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
a=sorted(a)
if K in a:
    print("POSSIBLE")
    import sys
    sys.exit()
def gc(i):
    for j in a:
        if j%i!=0:
            return False
    return True
if a[-1]>=K:
    for i in range(2,a[0]):
        if gc(i):
            print("IMPOSSIBLE")
            import sys
            sys.exit()
    print("POSSIBLE")
print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
N,K=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
a=sorted(a)
if K in a:
    print("POSSIBLE")
    import sys
    sys.exit()
def gc(i):
    for j in a:
        if j%i!=0:
            return False
    return True
if a[-1]>=K:
    for i in range(2,a[0]):
        if gc(i):
            print("IMPOSSIBLE")
            import sys
            sys.exit()
print("POSSIBLE")

Submission status: Wrong Answer

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

in_test = map(int, input().split())
A = set(in_test)

new_balls = set()
for a in A:
    for b in A:
        if a - b != 0 and abs(a-b) not in A:
            new_balls.add(abs(a-b))

break_flag = True
while(break_flag):
    if len(new_balls) == 0:
        print('IMPOSSIBLE')
        break
    new_balls_b = set()
    for b in new_balls:
        for a in A:
            if a-b != 0 and abs(b - a) not in A:
                new_balls_b.add(abs(a-b))
    A = A.union(new_balls)
    if K in A:
        print('POSSIBLE')
        break
    new_balls = new_balls_b

Submission status: Wrong Answer

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
    print a,prev,v
    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: Wrong Answer

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: Wrong Answer

Solution code:
length,target = (int(n) for n in input().split(" "))
ball = sorted([int(n) for n in input().split(" ")])
before = ball[0]
not_mul = 0
even,odd = 0,0
for i,b in enumerate(ball):
    if b % before != 0:
        not_mul = 1
    if b % 2 == 0:
        even = 1
    else:
        odd = 1

if target > max(ball):
    print("IMPOSSIBLE")
elif target in ball:
    print("POSSIBLE")
elif not_mul and (even and target % 2 == 0 or odd):
    print("POSSIBLE")
elif not not_mul and target % before == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

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)))

n, k = rli()
a = rli()
if(max(a) < k):
    print("IMPOSSIBLE")
elif(k in a):
    print("POSSIBLE")
else:
    sa = 114514810
    sorted(a)
    for i in range(n-1):
        if(abs(a[i] - a[i+1]) != 0):
            sa = min(sa, abs(a[i] - a[i+1]))
    for i in range(n):
        if(abs(a[i] - sa) != 0):
            sa = min(sa, abs(a[i] - sa))
    if(sa == 114514810):
        print("IMPOSSIBLE")
    elif(sa == 1):
        print("POSSIBLE")
    else:
        flag = False
        mod = 0
        for i in range(n-1):
            if(abs(a[i] - a[i+1]) % sa != 0):
                flag = True
                break
        if(k % sa == 0):
            flag = True
        if(flag):
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
import copy
N, K = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)[::-1]
diff =  list(filter(lambda n:n>K, A) )
if diff:
     diff = [d-K for d in diff]
     while True:
          if list(set(set(diff) & set(A))):
               print("POSSIBLE")
               break
          else:
               tmpA=copy.copy(A)
               for a in tmpA:
                    A += [abs(a-aa) for aa in tmpA]
               A = list(set(A))
               if sorted(A)==sorted(tmpA):
                   print("IMPOSSIBLE")
                   break
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
#! cat input | python3 main.py

n, k = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    if a[0] == k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    __import__("sys").exit()
a.sort()
ma = max(a)

def f(a, k, ma):
    minv = float("inf")
    for i, v in enumerate(a[1:]):
        if v - a[i] != 0:
            minv = min(minv, v - a[i])
    na = a[0]
    while minv < na:
        minv = min(minv, na - minv)
        na -= minv
    minv = min(minv, a[0])

    if minv == 1:
        return False

    a = a[:]
    for i in range(0, ma + minv, minv):
        if i == k:
            return False
        if i < a[0]:
            continue
        if i == a[0]:
            del a[0]
        else:
            return False
    return True

if ma < k:
    print("IMPOSSIBLE")
elif f(a, k, ma):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
length,target = (int(n) for n in input().split(" "))
ball = sorted([int(n) for n in input().split(" ")])
before = ball[0]
not_mul = 0
even,odd = 0,0
for i,b in enumerate(ball):
    if b % before != 0:
        not_mul = 1
    if b % 2 == 0:
        even = 1
    else:
        odd = 1

if target > max(ball):
    print("IMPOSSIBLE")
elif target in ball:
    print("POSSIBLE")
elif not_mul and odd:
    print("POSSIBLE")
elif not not_mul and target % before == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
n, k = map(int, raw_input().split())
if n == 1:
    a = int(raw_input())
    if a == k:
        print "POSSIBLE"
    else:
        print "IMPOSSIBLE"
    exit()
a = map(int, raw_input().split())
a.sort()
if k in a:
    print "POSSIBLE"
    exit()
if k > a[n - 1]:
    print "IMPOSSIBLE"
    exit()

d = a[1] - a[0]
ok = False
for i in xrange(n - 1):
    if a[i + 1] - a[i] == d:continue
    ok = True
if ok:
    print "POSSIBLE"
else:
    if (k - a[0]) % d == 0:
        print "POSIIBLE"
    else :
        print "IMPOSSIBLE"

Submission status: Wrong Answer

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

in_test = map(int, input().split())
A = set(in_test)
break_flag = True
while(break_flag):
    size = len(A)
    A_array = list(A)
    # print(A_array)
    for i in range(0, size - 1):
        for j in range(i+1, size):
            # print(size, i, j, A_array)
            A.add(abs(A_array[i] - A_array[j]))
        # print(A, K, size, len(A))
        if K in A:
            print('POSSIBLE')
            break_flag = False
            break
    if size == len(A):
        print('IMPOSSIBLE')
        break_flag = False

Submission status: Wrong Answer

Solution code:
#! cat input | python3 main.py

n, k = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    if a[0] == k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    __import__("sys").exit()
a.sort()
ma = max(a)

def f(a, k, ma):
    minv = float("inf")
    for i, v in enumerate(a[1:]):
        if v - a[i] != 0:
            minv = min(minv, v - a[i])
    minv = min(minv, a[0])

    if minv == 1:
        return False

    a = a[:]
    for i in range(0, ma + minv, minv):
        if i == k:
            return False
        if i < a[0]:
            continue
        if i == a[0]:
            del a[0]
        else:
            return False
    return True

if ma < k:
    print("IMPOSSIBLE")
elif f(a, k, ma):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]

    input_raw = list(read_func().strip().split())
    A = set([])
    for i in range(len(input_raw)):
        A.add(int(input_raw[i]))
    A_list = list(A)
    possible_flag = False
    if len(filter(lambda x:x >=K , A)) != 0:

        for i in range(len(A_list)):
            x = A_list[i]
            if x == K:
                possible_flag = True
                break;
            for j in range(i + 1, len(A_list)):
                diff = abs(x - A_list[j])
                if diff not in A or diff == K:
                    possible_flag = True
            if possible_flag == True:
                break

    if possible_flag == True:
        print "POSSIBLE"
    else:
        print "IMPOSSIBLE"


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, k = map(int, raw_input().split())
if n == 1:
    a = int(raw_input())
    if a == k:
        print "POSSIBLE"
    else:
        print "IMPOSSIBLE"
    exit()
a = map(int, raw_input().split())
a.sort()
if k in a:
    print "POSSIBLE"
    exit()
if k > a[n - 1]:
    print "IMPOSSIBLE"
    exit()

d = a[1] - a[0]
ok = False
for i in xrange(n - 1):
    if a[i + 1] - a[i] == d:continue
    ok = True
if ok:
    print "POSSIBLE"
else:
    if a[0] == d:
        print "IMPOSSIBLE"
    else:
        print "POSSIBLE"

Submission status: Wrong Answer

Solution code:
# coding:utf-8
from itertools import combinations
N, K = map(int, raw_input().split(' '))
A = set()
A.update(map(int, raw_input().split(' ')))


def difference(set_data, goal):
    diff_data = set()
    diff_data.update([abs(d1 - d2) for d1, d2 in combinations(set_data, 2)])

    if goal in diff_data:
        return 'POSSIBLE'
    elif 1 in diff_data:
        return 'POSSIBLE'
    elif diff_data <= set_data:
        return 'INPOSSIBLE'

    new_data = set_data | diff_data
    return difference(new_data, goal)


if K >= max(A):
    print 'INPOSSIBLE'
elif K in A or 1 in A:
    print 'POSSIBLE'
else:
    print difference(A, K)

Submission status: Wrong Answer

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

def main():
    if K in number_ls:
        return 1
    elif max(number_ls) < K:
        return 0
    else:
        number_ls.sort()
        dis = number_ls[1] - number_ls[0]
        i = 0
        while i < len(number_ls) - 1:
            if dis == number_ls[i + 1] - number_ls[i]:
                i += 1
                continue
            else:
                return  1
            i += 1
        return 0

if main() == 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    if a[0] == k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    __import__("sys").exit()
a.sort()
ma = max(a)

def f(a, k, ma):
    minv = float("inf")
    for i, v in enumerate(a[1:]):
        if v - a[i] != 0:
            minv = min(minv, v - a[i])
    minv = min(minv, a[0])

    if minv == 1:
        return False

    a = a[:]
    for i in range(0, ma, minv):
        if i == k:
            return False
        if i < a[0]:
            continue
        if i == a[0]:
            del a[0]
        else:
            return False
    if a: return False
    return True

if ma < k:
    print("IMPOSSIBLE")
elif f(a, k, ma):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
n, k = map(int, raw_input().split())
if n == 1:
    a = int(raw_input())
    if a == k:
        print "POSSIBLE"
    else:
        print "IMPOSSIBLE"
    exit()
a = map(int, raw_input().split())
a.sort()
if k in a:
    print "POSSIBLE"
    exit()
if k > a[n - 1]:
    print "IMPOSSIBLE"
    exit()

d = a[1] - a[0]
ok = False
for i in xrange(n - 1):
    if a[i + 1] - a[i] == d:continue
    ok = True
if ok:
    print "POSSIBLE"
else:
    if k % 2 == 0:
        print "POSSIBLE"
    else:
        print "IMPOSSIBLE"

Submission status: Wrong Answer

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

if K > max(args):
    print("IMPOSSIBLE")
    exit()

m = min(args)
for i in range(2, math.floor(m / 2)):
    if m % i == 0:
        m = m / i
same = True
even = 0
for i in range(0, len(args)):
    if args[i] == K:
        print("POSSIBLE")
        exit()
    else:
        if args[i] % m != 0:
            same = False
        if args[i] % 2 == 0:
            even = even + 1

if same or even == len(args):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
# coding:utf-8
from itertools import combinations
N, K = map(int, raw_input().split(' '))
A = set()
A.update(map(int, raw_input().split(' ')))


def difference(set_data, goal):
    diff_data = set()
    diff_data.update([abs(d1 - d2) for d1, d2 in combinations(set_data, 2)])

    if goal in diff_data:
        return 'POSSIBLE'
    if diff_data <= set_data:
        return 'INPOSSIBLE'
    else:
        new_data = set_data | diff_data
        return difference(new_data, goal)


if K in A:
    print 'POSSIBLE'
elif K >= max(A):
    print 'INPOSSIBLE'
else:
    print difference(A, K)

Submission status: Wrong Answer

Solution code:
#! cat input | python3 main.py

n, k = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    if a[0] == k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    __import__("sys").exit()
a.sort()
ma = max(a)

def f(a, k, ma):
    minv = float("inf")
    for i, v in enumerate(a[1:]):
        if v - a[i] != 0:
            minv = min(minv, v - a[i])
    minv = min(minv, a[0])

    if minv == 1:
        return False

    a = a[:]
    for i in range(0, ma, minv):
        if i == k:
            return False
        if i < a[0]:
            continue
        if i == a[0]:
            del a[0]
        else:
            return False
    return True

if ma < k:
    print("IMPOSSIBLE")
elif f(a, k, ma):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)[::-1]
print(A)
diff = A[0]-K
if diff<0:
    print("IMPOSSIBLE")
else:
     tmp = [a+diff for a in A]
     sa = list(set(tmp) & set(A))
     if len(sa)>0:
          print("POSSIBLE")
     else:
          print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, A = map(int, input().split())
tmp = input()
ary = [int(a) for a in tmp.split()]

maximum = max(ary)


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


g = None
for a in ary:
    if g is None:
        g = a
        continue
    g = gcd(g, a)
    print(g)

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]

    input_raw = list(read_func().strip().split())
    A = set([])
    for i in range(len(input_raw)):
        A.add(int(input_raw[i]))
    A_list = list(A)
    possible_flag = False
    for i in range(len(A_list)):
        x = A_list[i]
        if x == K:
            possible_flag = True
            break;
        for j in range(i + 1, len(A_list)):
            diff = abs(x - A_list[j])
            if diff not in A or diff == K:
                possible_flag = True
        if possible_flag == True:
            break

    if possible_flag == True:
        print "POSSIBLE"
    else:
        print "IMPOSSIBLE"


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
length,target = (int(n) for n in input().split(" "))
ball = sorted([int(n) for n in input().split(" ")])
before = ball[0]
not_mul = 0
for i,b in enumerate(ball[1:]):
    if b % before != 0:
        not_mul = 1

if target > max(ball):
    print("IMPOSSIBLE")
elif target in ball:
    print("POSSIBLE")
elif not_mul:
    print("POSSIBLE")
elif not not_mul and target % before == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
#! cat input | python3 main.py

n, k = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    if a[0] == k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    __import__("sys").exit()
a.sort()
ma = max(a)

def f(a, k, ma):
    minv = float("inf")
    for i, v in enumerate(a[1:]):
        if v - a[i] != 0:
            minv = min(minv, v - a[i])
    minv = min(minv, a[0])

    if minv == 1:
        return False

    a = a[:]
    for i in range(0, ma, minv):
        if i < a[0]:
            continue
        if i == a[0]:
            del a[0]
        else:
            return False
    return True

if ma < k:
    print("IMPOSSIBLE")
elif f(a, k, ma):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
 
n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
if k in a:
  print "POSSIBLE"
else:
  while len(a)!=1:
    b=a.pop()
    a[0]=gcd(a[0],b)
  print "POSSIBLE" if k%a[0]==0 and (max(a)-min(a))>=k else "IMPOSSIBLE"

Submission status: Wrong Answer

Solution code:
length,target = (int(n) for n in input().split(" "))
ball = sorted([int(n) for n in input().split(" ")])
before = ball[0]
not_mul = 0
for i,b in enumerate(ball[1:]):
    if b % before != 0:
        not_mul = 1

if target > max(ball):
    print("IMPOSSIBLE")
elif target in ball:
    print("POSSIBLE")
elif not_mul:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

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

if K > max(args):
    print("IMPOSSIBLE")
    exit()

m = min(args)
same = True
even = 0
for i in range(0, len(args)):
    if args[i] == K:
        print("POSSIBLE")
        exit()
    else:
        if args[i] % m != 0:
            same = False
        if args[i] % 2 == 0:
            even = even + 1

if same or even == len(args):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

Solution code:

from itertools import combinations

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


while True:
    comb=combinations(an,2)
    prean = an[:]
    for it in comb:
        a = abs(it[0] - it[1])
        if a == K:
            print('POSSIBLE')
            exit()
        an.append(a)
    if set(an) == set(prean):
        print('IMPOSSIBLE')
        break

Submission status: Wrong Answer

Solution code:
n,k = map(int, raw_input().split())
aa = map(int, raw_input().split())

max_a = 0

if n == 1:
  if aa[0] == k:
    print 'POSSIBLE'
  else:
    print 'IMPOSSIBLE'
  exit()

b = aa[0]
for i in range(1,n):
  a = aa[i]
  max_a = max(a, max_a)

  a,b = max(a,b), min(a,b)
  while a % b != 0:
    if a > b:
      a %= b
    else:
      b %= a
    a,b = max(a,b), min(a,b)

if k > max_a:
  print 'IMPOSSIBLE'
elif k % b == 0:
  print 'POSSIBLE'
else:
  print 'IMPOSSIBLE'

Submission status: Wrong Answer

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

if K > max(args):
    print("IMPOSSIBLE")
    exit()

m = min(args)
same = True
for i in range(0, len(args)):
    if args[i] == K:
        print("POSSIBLE")
        exit()
    else:
        if args[i] % m != 0:
            same = False
if same:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
import math

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

def solve(N, K, As):
    if N == 1:
        if K == As[0]:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        return
    g = As[-1]
    for a in As[:-1]:
        g = math.gcd(g, a)
    maxA = max(As)
    if (maxA >= K) and ((maxA - K)%g) == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")