Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

ans = sum(A)
for i in range(N):
  if A[i] < 0:
    if i != N-1:
      A[i] = A[i] * -1
      A[i+1] = A[i+1] * -1
      ans = max(ans, sum(A))

print(ans)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

count = 0
for i in range(N):
  if A[i] <0:
    count = count + 1
    A[i] = A[i] * -1

if 0 in A:
  ans = sum(A)
else:
  if count%2 == 0:
    ans = sum(A)
  else:
    ans = sum(A) - 2*min(A)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

ans = sum(A)
for i in range(N):
  if A[i] < 0:
    if i != N-1:
      A[i] = A[i] * -1
      A[i+1] = A[i+1] * -1
  ans = max(ans, sum(A))

print(ans)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

count = 0
for i in range(N):
  if A[i] <0:
    count = count + 1
    A[i] = A[i] * -1

if 0 in A:
  ans = sum(A)
else:
  if count%2 == 0:
    ans = sum(A)
  else:
    ans = sum(A) - 2*min(A)

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]

ans = sum(A)
for i in range(N):
  if A[i] < 0:
    if i != N-1:
      A[i] = A[i] * -1
      A[i+1] = A[i+1] * -1
      print(A)
  ans = max(ans, sum(A))

print(ans)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

count = 0
for i in range(N):
  if A[i] <0:
    count = count + 1
    A[i] = A[i] * -1

if 0 in A:
  ans = sum(A)
else:
  if count%2 == 0:
    ans = sum(A)
  else:
    ans = sum(A) - 2*min(A)

print(ans)
Buggy python submission (verdict: Runtime Error):
a = [int(i) for i in input().split()]~


output = max(a)

b = a.index(max(a))

a[b] = a[b] - 1

output = output + max(a)

print(output)


Fixed submission:
a = [int(i) for i in input().split()]
output = max(a)

b = a.index(max(a))

a[b] = a[b] - 1

output = output + max(a)

print(output)
Buggy python submission (verdict: Time Limit Exceeded):
input_array = [int(i) for i in input().split()]
S = str(input())

N = int(input_array[0])
K = int(input_array[1])

S_array = list(S)

S_count_array = [0]

count = 0
for i in range(len(S_array)):
  if i == 0:
    S_count_array[count] = 1
  else:
    if S_array[i] == S_array[i-1]:
      S_count_array[count] += 1
    else:
      S_count_array.append(1)
      count += 1

max_sum_number = 0
if S_array[0] == "0":
  for i in range(len(S_count_array)):
    if i % 2 == 0:
      sum_number = sum(S_count_array[i:i+(K*2)])
      if max_sum_number < sum_number:
        max_sum_number = sum_number
    else:
      sum_number = sum(S_count_array[i:i+(K*2)+1])
      if max_sum_number < sum_number:
        max_sum_number = sum_number

else:
  for i in range(len(S_count_array)):
    if (i+1) % 2 == 0:
      sum_number = sum(S_count_array[i:i+(K*2)])
      if max_sum_number < sum_number:
        max_sum_number = sum_number
    else:
      sum_number = sum(S_count_array[i:i+(K*2)+1])
      if max_sum_number < sum_number:
        max_sum_number = sum_number

print(max_sum_number)

Fixed submission:
n,k = map(int,input().split())
s = input()

l = [0]

for i in range(n-1):
  if s[i] != s[i+1]:
    l.append(i+1)

l.append(n)

ans = 0
for i in range(len(l)-1):
  index = min(i+2*k + int(s[l[i]]=="1"), len(l)-1)
  ans = max(ans, l[index] - l[i])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
input_array = [int(i) for i in input().split()]
S = str(input())

N = int(input_array[0])
K = int(input_array[1])

S_array = list(S)

S_count_array = [0]

count = 0
for i in range(len(S_array)):
  if i == 0:
    S_count_array[count] = 1
  else:
    if S_array[i] == S_array[i-1]:
      S_count_array[count] += 1
    else:
      S_count_array.append(1)
      count += 1

sum_s_number = []
if S_array[0] == "0":
  for i in range(len(S_count_array)):
    if (i+1) % 2 == 0:
      sum_s_number.append(sum(S_count_array[i:i+(K*2)+1]))
    else:
      sum_s_number.append(sum(S_count_array[i:i+(K*2)]))

else:
  for i in range(len(S_count_array)):
    if (i+1) % 2 == 0:
      sum_s_number.append(sum(S_count_array[i:i+(K*2)]))
    else:
      sum_s_number.append(sum(S_count_array[i:i+(K*2)+1]))

print(max(sum_s_number))



Fixed submission:
n,k = map(int,input().split())
s = input()

l = [0]

for i in range(n-1):
  if s[i] != s[i+1]:
    l.append(i+1)

l.append(n)

ans = 0
for i in range(len(l)-1):
  index = min(i+2*k + int(s[l[i]]=="1"), len(l)-1)
  ans = max(ans, l[index] - l[i])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = (int(i) for i in input().split())
S = str(input())
LR = []
for i in range(Q):
  LR.append([int(i) for i in input().split()])

for l,r in LR:
  check_s = S[l-1:r]
  ans = 0
  start_index = 0
  for end_index in range(len(check_s)):
    if check_s[start_index] == "A":
      if check_s[end_index] == "C":
        ans +=1
      else:
        start_index = end_index
    else:
      start_index = end_index

  print(ans)


Fixed submission:
N, Q = (int(i) for i in input().split())
S = str(input())

ac_count = [0] *(N+1)

for i in range(N):
  if S[i:i+2] == "AC":
    ac_count[i+1] = ac_count[i] + 1
  else:
    ac_count[i+1] = ac_count[i]

LR = []
for i in range(Q):
  LR.append([int(i) for i in input().split()])

for l,r in LR:
  ans = ac_count[r-1] - ac_count[l-1]
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = (int(i) for i in input().split())
AB = []
values = []

for i in range(N):
  A,B = (int(i) for i in input().split())
  values.extend([A]*B)

values.sort()

count = 0
ans = 0

for i in range(len(values)):
  if count < M:
    count +=1
    ans += values[i]
  else:
    break



print(ans)


Fixed submission:
N,M = (int(i) for i in input().split())
AB = []

for i in range(N):
  AB.append([int(i) for i in input().split()])

AB = sorted(AB,key=lambda x:x[0])

count = 0
ans = 0

for A,B in AB:
  if count + B > M:
    ans += A*(M-count)
    break
  else:
    ans += A*B
    count += B


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A,B = (int(i) for i in input().split())

ans = A
for i in range(A+1,B+1):
  ans = i ^ ans

print(ans)


Fixed submission:
A ,B=map(int,input().split())

ans=0

for i in range(4):
    if (A+i)%4==0:
        break
    ans=ans^(A+i)
for i in range(B-3,B+1):
    if i%4==3:
        end=i+1
        break

for i in range(end,B+1):
    ans=ans^i

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())

ans = len(S)
for i in range(len(S)):
  if len(S) == len(S.replace("01","")) and len(S) == len(S.replace("10","")):
    break
  else:
    S = S.replace("01","")
    S = S.replace("10","")

print(ans-len(S))


Fixed submission:
S = str(input())

count_0 = S.count("0")
count_1 = S.count("1")

ans = min(count_0 ,count_1) * 2
print(ans)
Buggy python submission (verdict: Runtime Error):
 N = int(input())

 ans = 0
 for i in range(N):
   x,u=map(str, input().split())
   if u == "JPY":
     ans += float(x)
   else:
     ans += float(x) * 380000.0

 print(ans)


Fixed submission:
N = int(input())

ans = 0
for i in range(N):
  x,u=map(str, input().split())
  if u == "JPY":
    ans += float(x)
  else:
    ans += float(x) * 380000.0

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = [int(i) for i in input().split()]

ans = A[0]

for a in A:
  ans = math.gcd(ans,a)

print(ans)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

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

ans = A[0]

for a in A:
  ans = gcd(ans,a)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

def attack(A):
  A = list(set(A))
  A.sort()
  if A[0] ==0:
    A.pop(0)
  attack_mons = A[0]
  new_A = [A[0]]
  for i in range(1,len(A)):
    new_A.append(A[i]%min(A))
  return new_A

new_A = attack(A)
while A!=new_A:
  A = new_A
  new_A = attack(new_A)

print(min(new_A))


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

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

ans = A[0]

for a in A:
  ans = gcd(ans,a)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

def attack(A):
  A = list(set(A))
  if min(A) ==0:
    A.pop(A.index(min(A)))
  attack_mons = min(A)
  attack_mons_index = A.index(min(A))
  new_A = []
  for i in range(len(A)):
    if i != attack_mons_index:
      new_A.append(A[i]%min(A))
    else:
      new_A.append(A[i])
  return new_A

new_A = attack(A)
while A!=new_A:
  A = new_A
  new_A = attack(new_A)

print(min(new_A))


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

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

ans = A[0]

for a in A:
  ans = gcd(ans,a)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

A_list = []
for a in A:
  A_list.append(a)
  A_list.append(a+1)
  A_list.append(a-1)

A_unique = list(set(A_list))
A_dict = {}

for a_unique in A_unique:
  count = 0
  for a in A:
    if a_unique == a or a_unique == (a-1) or a_unique == (a+1):
      count +=1
  A_dict[a_unique] = count

ans = max(A_dict.values())
print(ans)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

A_dict = {}
for a in A:
  A_dict[a] = A_dict.get(a,0) + 1
  A_dict[a+1] = A_dict.get(a+1,0) + 1
  A_dict[a-1] = A_dict.get(a-1,0) + 1

ans = max(A_dict.values())
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
P = [int(i) for i in input().split()]

count = 0
for i in range(N):
  if P[i] == i+1:
    P[i],P[i+1] = P[i+1],P[i]
    count += 1

print(count)



Fixed submission:
N = int(input())
P = [int(i) for i in input().split()]

count = 0
for i in range(N):
  if P[i] == i+1:
    if i+1 != N:
      P[i],P[i+1] = P[i+1],P[i]
    else:
      P[i],P[i-1] = P[i-1],P[i]
    count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

ans = []
for i in range(N):
  if i%2 == 0:
    ans.append(A[i])
  else:
    ans.insert(0,A[i])

if len(A)%2 == 1:
  ans = list(reversed(ans))

print(" ".join(map(str, ans)))


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

B_right = A[0::2]
B_left = list(reversed(A[1::2]))

B_left.extend(B_right)
ans = B_left

if len(A)%2 == 1:
  ans = list(reversed(ans))

print(" ".join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):
 N = int(input())
 A = [int(i) for i in input().split()]

 colors = [0,0,0,0,0,0,0,0,0]

 for a in A:
   if a < 400:
     colors[0] +=1
   elif 400<=a and a <800:
     colors[1] +=1
   elif 800<=a and a<1200:
     colors[2] +=1
   elif 1200<=a and a<1600:
     colors[3] +=1
   elif 1600<=a and a<2000:
     colors[4] +=1
   elif 2000<=a and a<2400:
     colors[5] +=1
   elif 2400<=a and a<2800:
     colors[6] +=1
   elif 2800<=a and a<3200:
     colors[7] +=1
   else:
     colors[8] +=1

 ans = 0
 for i in range(len(colors)-1):
   if colors[i] !=0:
     ans +=1

 print(str(ans) + " " + str(colors[8] + ans))


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

colors = [0,0,0,0,0,0,0,0,0]

for a in A:
  if a < 400:
    colors[0] +=1
  elif 400<=a and a <800:
    colors[1] +=1
  elif 800<=a and a<1200:
    colors[2] +=1
  elif 1200<=a and a<1600:
    colors[3] +=1
  elif 1600<=a and a<2000:
    colors[4] +=1
  elif 2000<=a and a<2400:
    colors[5] +=1
  elif 2400<=a and a<2800:
    colors[6] +=1
  elif 2800<=a and a<3200:
    colors[7] +=1
  else:
    colors[8] +=1

ans = 0
for i in range(len(colors)-1):
  if colors[i] !=0 :
    ans +=1

if ans == 0:
  print(str(1) + " " + str(colors[8] + ans))
else:
  print(str(ans) + " " + str(colors[8] + ans))
Buggy python submission (verdict: Runtime Error):
 N = int(input())
 S = [int(input()) for i in range(N)]

 ans = sum(S)
 S.sort()

 for s in S:
   if ans%10 == 0 and s%10 != 0:
     ans = ans - s
     break

 if ans%10 != 0:
   print(ans)
 else:
   print(0)


Fixed submission:
N = int(input())
S = [int(input()) for i in range(N)]

ans = sum(S)
S.sort()

for s in S:
  if ans%10 == 0 and s%10 != 0:
    ans = ans - s
    break

if ans%10 != 0:
  print(ans)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
def main():
    a, b, c = map(int, input().split())
    k = int(input())

    op = 0
    while not (a < b and b < c):
        if not a < b:
            b *= 2
            op += 1
        elif not b < c:
            c *= 2
            op += 1

    if op <= k:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Fixed submission:
X = int(input())

if X <= 599:
    print(8)
elif X <= 799:
    print(7)
elif X <= 999:
    print(6)
elif X <= 1199:
    print(5)
elif X <= 1399:
    print(4)
elif X <= 1599:
    print(3)
elif X <= 1799:
    print(2)
elif X <= 1999:
    print(1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
    S = [input() for i in range(N)]

    a = b = ab = 0
    ans = 0
    for s in S:
        n = len(s)
        for j in range(n-1):
            if s[j] == "A" and s[j+1] == "B":
                ans += 1
        if s[0] == "B" and s[-1] == "A":
            ab += 1
        elif s[0] == "B":
            b += 1
        elif s[-1] == "A":
            a += 1

    if a == 0 and b == 0:
        print(ans+ab-1)
    else:
        print(ans+ab+min(a, b))

Fixed submission:
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    N = int(input())
    S = [input() for i in range(N)]

    a = b = ab = 0
    ans = 0
    for s in S:
        n = len(s)
        for j in range(n-1):
            if s[j] == "A" and s[j+1] == "B":
                ans += 1
        if s[0] == "B" and s[-1] == "A":
            ab += 1
        elif s[0] == "B":
            b += 1
        elif s[-1] == "A":
            a += 1

    if ab == 0:
        print(ans+min(a, b))
    elif a == 0 and b == 0:
        print(ans+ab-1)
    else:
        print(ans+ab+min(a, b))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque


def main():
    n, p = map(int, input().split())

    div = []
    c = 1
    while c * c <= p:
        if not p % c:
            div.append(c)
            if c * c != p:
                div.append(p//c)
        c += 1

    div.sort()
    ans = 1
    for d in div:
        pp = pow(d, n)
        if pp > p:
            break
        if not p % pp:
            ans = max(ans, d)

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
N, P = map(int, input().split())
res = {}


def pf(n):
    c = 2
    while c * c <= n:
        while not n % c:
            res[c] = res.get(c, 0) + 1
            n //= c
        c += 1

    if n != 1:
        res[n] = 1


def main():
    pf(P)

    ans = 1
    for d in res:
        ans *= pow(d, res[d]//N)

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, c = map(int, input().split())
    d = [list(map(int, input().split())) for i in range(c)]
    grid = [list(map(int, input().split())) for i in range(n)]

    group = [[0 for i in range(c)], [0 for i in range(c)], [0 for i in range(c)]]
    for i in range(n):
        for j in range(n):
            for color in range(c):
                group[(i+j) % 3][color] += d[grid[i][j]-1][color]

    min_cost = 1 << 30
    for i in range(c):
        for j in range(c):
            if i != j:
                for k in range(c):
                    if j != k and k != i:
                        min_cost = min(group[0][i]+group[1][j]+group[2][k], min_cost)

    print(min_cost)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n, c = map(int, input().split())
    d = [list(map(int, input().split())) for i in range(c)]
    grid = [list(map(int, input().split())) for i in range(n)]

    group = [[0 for i in range(c)], [0 for i in range(c)], [0 for i in range(c)]]
    for i in range(n):
        for j in range(n):
            group[(i+j) % 3][grid[i][j]-1] += 1

    min_cost = 1 << 30
    for i in range(c):
        for j in range(c):
            if i != j:
                for k in range(c):
                    if j != k and k != i:
                        cost = 0
                        for color in range(c):
                            cost += group[0][color] * d[color][i]
                            cost += group[1][color] * d[color][j]
                            cost += group[2][color] * d[color][k]

                        min_cost = min(cost, min_cost)

    print(min_cost)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
s, k = input(), int(input())
abc = [chr(i) for i in range(ord('a'), ord('a')+26)]

cnt = 0
key_lst = []
for i in abc:
    key_set = set()
    for j in range(len(s)):
        if i == s[j]:
            for l in range(j+1, len(s)+1):
                if s[j:l] not in key_set:
                    key_set.add(s[j:l])

    if cnt + len(key_set) >= k:
        key_lst = list(key_set)
        break
    else:
        cnt += len(key_set)
        k -= len(key_set)

key_lst.sort()

print(key_lst[k-1])


Fixed submission:
s, k = input(), int(input())

sub_str = set()
for i in range(len(s)):
    for j in range(1, k+1):
        if i + j <= len(s):
            sub_str.add(s[i:i+j])

sub_lst = sorted(list(sub_str))
print(sub_lst[k-1])
Buggy python submission (verdict: Runtime Error):
s = input()

if s[0] == s[1] && s[1] == s[2] && s[0] == s[2]:
    print("Yes")
else:
    print("No")


Fixed submission:
s = input()
a, b, c = 0, 0, 0

for i in s:
    if i == "a" and a == 0:
        a += 1
    elif i == "b" and b == 0:
        b += 1
    elif i == "c" and c == 0:
        c += 1
    else:
        print("No")
        break
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
i, x = 0, 0

while a+i <= b and i < k:
    x = a + i
    print(x)
    i += 1

i = k - 1
while b-i <= b:
    y = b - i
    if y <= x:
        i -= 1
        continue
    print(y)
    i -= 1


Fixed submission:
s = input()
a, b, c = 0, 0, 0

for i in s:
    if i == "a" and a == 0:
        a += 1
    elif i == "b" and b == 0:
        b += 1
    elif i == "c" and c == 0:
        c += 1
    else:
        print("No")
        break
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
x = 0

for i in range(k):
    x = a + i
    if x > b:
        break
    print(x)


for i in range(k-1, -1, -1):
    y = b - i
    if y <= x:
        continue
    print(y)


Fixed submission:
s = input()
a, b, c = 0, 0, 0

for i in s:
    if i == "a" and a == 0:
        a += 1
    elif i == "b" and b == 0:
        b += 1
    elif i == "c" and c == 0:
        c += 1
    else:
        print("No")
        break
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
lst = list(map(int, input().split()))
n = 0

while True:
    if lst[0] == lst[1] and lst[1] == lst[2]:
        break
    
    minimum = min(lst)
    maximum = max(lst)

    if maximum-minimum >= 2:
        idx = lst.index(minimum)
        lst[idx] += 2
        
    else:
        idx = lst.index(minimum)
        lst[idx] += 1
        idx = lst.index(minimum)
        lst[idx] += 1
    n += 1
print(n)

Fixed submission:
a, b, c = map(int, input().split())

m = max(a, b, c)
if 3*m%2 == (a+b+c)%2:
    print((3*m-(a+b+c))//2)
else:
    print((3*(m+1)-(a+b+c))//2)

Buggy python submission (verdict: Time Limit Exceeded):
import random

data = list(map(int, input().split()))
lst = data[:]
n = 0
minimum = 1000000

for i in range(1000):
    while True:
        if data[0] == data[1] and data[1] == data[2]:
            data = lst[:]
            if n < minimum:
                minimum = n
            n = 0
            break

        f = random.randint(0, 1)
        if f == 0:
            lst[random.randint(0, 2)] += 1
            lst[random.randint(0, 2)] += 1
        else:
            lst[random.randint(0, 2)] += 2
        n += 1

print(minimum)


Fixed submission:
a, b, c = map(int, input().split())

m = max(a, b, c)
if 3*m%2 == (a+b+c)%2:
    print((3*m-(a+b+c))//2)
else:
    print((3*(m+1)-(a+b+c))//2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
x = 0
c_lst = []

for i in a:
    c = 0
    for j in a:
        if i == j:
            continue

        c += abs(j-x)
        x = j

    c += abs(x-0)
    c_lst.append(c)
    x = 0

for i in c_lst:
    print(i)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
x = 0
c_lst = []

s = 0
for i in a:
    s += abs(i-x)
    x = i
s += abs(0-x)

b, f = 0, 0

for i in range(len(a)):
    if i == 0:
        f, b = 0, a[i+1]
    elif i == len(a)-1:
        f, b = a[i-1], 0
    else:
        f, b = a[i-1], a[i+1]

    c = s + abs(b-f) - (abs(a[i]-f)+abs(b-a[i]))
    c_lst.append(c)

for i in c_lst:
    print(i)
Buggy python submission (verdict: Runtime Error):
def gcd(a0, b0):
    a, b = max(a0, b0), min(a0, b0)
    while b != 0:
        a = a % b
        a, b = b, a

    return a


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

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

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


if __name__ == '__main__':
    main()


Fixed submission:
def gcd(a0, b0):
    a, b = max(a0, b0), min(a0, b0)
    while b != 0:
        a = a % b
        a, b = b, a

    return a


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

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

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


if __name__ == '__main__':
    main()