Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ip = []

for i in range(n):
  a = int(input())
  ip.append(a)
  for j in range(a):
    x,y = map(int,input().split())
    ip.append([x,y])

max = 0    
for i in range(n) :
  max += 2**i

ans = 0
for i in range(0,max+1) :
  s = [2 for _ in range(n)]
  bit = i
  count = 0
  index = 0
  check = 0
  for j in range(n) :
    if bit%2 == 1 :
      if s[j] == 0 :
        check = 1
      s[j] = 1
    else :
      if s[j] == 1 :
        check = 1
      s[j] = 0
    bit = bit//2
    for k in range(ip[index]) :
      if s[j] == 1 :
        if ip[index+1+k][1] == 1 :
          if s[ip[index+1+k][0]-1] == 0 :
            check = 1
          s[ip[index+1+k][0]-1] = 1
        elif ip[index+1+k][1] == 0 :
          if s[ip[index+1+k][0]-1] == 1 :
            check = 1
          s[ip[index+1+k][0]-1] = 0
    index += ip[index] + 1
  if ans < s.count(1) and check ==0 :
    ans = s.count(1)

print(ans)

Fixed submission:
n = int(input())
ip = []

for i in range(n):
  a = int(input())
  ip.append(a)
  for j in range(a):
    x,y = map(int,input().split())
    ip.append([x,y])

max = 0    
for i in range(n) :
  max += 2**i

ans = 0
for i in range(0,max+1) :
  s = [2 for _ in range(n)]
  bit = i
  count = 0
  index = 0
  check = 0
  for j in range(n) :
    if bit%2 == 1 :
      if s[j] == 0 :
        check = 1
        break
      s[j] = 1
    else :
      if s[j] == 1 :
        check = 1
        break
      s[j] = 0
    bit = bit//2
    for k in range(ip[index]) :
      if s[j] == 1 :
        if ip[index+1+k][1] == 1 :
          if s[ip[index+1+k][0]-1] == 0 :
            check = 1
            break
          s[ip[index+1+k][0]-1] = 1
        elif ip[index+1+k][1] == 0 :
          if s[ip[index+1+k][0]-1] == 1 :
            check = 1
            break
          s[ip[index+1+k][0]-1] = 0
    if check == 1 :
      break
    index += ip[index] + 1
  if ans < s.count(1) and check ==0 :
    ans = s.count(1)

print(ans)
Buggy python submission (verdict: Runtime Error):
print(int(int(input()**2)))

Fixed submission:
print(int(input())**2)
Buggy python submission (verdict: Runtime Error):
import math

a,b,x = map(int,input().split())

if a*b/2 >= x/a :
  ax = 2*x/a/b
  print(math.degrees(math.atan(b/ax)))
else : 
  bx = 2*x/a/a - b
  print(90-math.degrees(math.atan(a/(b-bx))))

Fixed submission:
import math

a,b,x = map(int,input().split())

if a*a*b == x :
  print(0)
elif a*b/2 >= x/a :
  ax = 2*x/a/b
  print(math.degrees(math.atan(b/ax)))
else : 
  bx = 2*x/a/a - b
  print(90-math.degrees(math.atan(a/(b-bx))))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))

ans = 0
for i in range(n-2) :
  for j in range(i+1,n-1) :
    for k in range(j+1,n) :
      if l[i] < l[j]+l[k] and l[j] < l[i]+l[k] and l[k] < l[j]+l[i] :
        ans += 1

print(ans)

Fixed submission:
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()

ans = 0
for i in range(n-2) :
  for j in range(i+1,n-1) :
    index = bisect.bisect_left(l,l[i]+l[j])
    ans += index-1-j

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]

ans = [0 for i in range(n)]
c = 0
c1 = n+1
for i in range(n//2+1) :
  f = 0
  f1 = 0
  c += 1
  c1 -= 1
  for j in range(n) :
    if a[j] == c :
      ans[c-1] = j + 1
      f = 1
    if a[j] == c1 :
      ans[c1-1] = j + 1
      f1 = 1
    if f == 1 and f1 == 1 :
      break
print(*ans)

Fixed submission:
import numpy as np

n = int(input())
a = [int(x) for x in input().split()]

ans = np.argsort(a)
ans += 1

print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]

ans = [0 for i in range(n)]
c = 0
c1 = n
for i in range(n) :
  f = 0
  f1 = 0
  c += 1
  for j in range(n) :
    if a[j] == c :
      ans[c-1] = j + 1
      f = 1
    if a[j] == c1 :
      ans[c1-1] = j + 1
      f1 = 1
    if f == 1 and f1 == 1 :
      break
print(*ans)

Fixed submission:
import numpy as np

n = int(input())
a = [int(x) for x in input().split()]

ans = np.argsort(a)
ans += 1

print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]

ans = [0 for i in range(n)]
c = 0
for i in range(n) :
  c += 1
  for j in range(n) :
    if a[j] == c :
      ans[c-1] = j + 1
      break

print(*ans)

Fixed submission:
import numpy as np

n = int(input())
a = [int(x) for x in input().split()]

ans = np.argsort(a)
ans += 1

print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]

ans = [0 for i in range(n)]
c = 0
for i in range(n) :
  c += 1
  for j in range(n) :
    if a[j] == c :
      ans[c-1] = j + 1
      break

print(*ans)

Fixed submission:
import numpy as np

n = int(input())
a = [int(x) for x in input().split()]

ans = np.argsort(a)
ans += 1

print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]

for i in range(n) :
  at = a[i]
  a[i] = 0
  print(max(a))
  a[i] = at

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
a_max = max(a)
max_c = a.count(a_max)

for i in range(n) :
  if a[i] != a_max :
    print(a_max)
  else :
    if max_c == 1 :
      a[i] = 0
      print(max(a))
    else :
      print(a_max)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]

for i in range(n) :
  at = a[i]
  a[i] = 0
  print(max(a))
  a[i] = at

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
a_max = max(a)
max_c = a.count(a_max)

for i in range(n) :
  if a[i] != a_max :
    print(a_max)
  else :
    if max_c == 1 :
      a[i] = 0
      print(max(a))
    else :
      print(a_max)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
x = [0]*n ; y = [0]*n
for i in range(n):
    x[i],y[i] = map(int, input().split())

dc_c = []
dc_c = []
dc_ans = []
for i in range(n-1):
    ii = 0
    d = [[-1]*2 for i in range(n-1)]
    for j in range(i,n):
        if i != j:
            d[ii][0] = abs(x[i]-x[j])
            d[ii][1] = abs(y[i]-y[j])
            ii += 1
    dc = Counter(map(tuple, d))
    dc_ans = Counter(dc_ans) + dc
dc_ans = dc_ans.most_common()
if dc_ans[0][0] == (-1, -1):
    print(n-dc_ans[1][1])
else:
    print(n-dc_ans[0][1])

Fixed submission:
import sys

n = int(input())
x = [0]*n ; y = [0]*n
for i in range(n):
    x[i],y[i] = map(int, input().split())

if n == 1:
    print(1)
    sys.exit()

ans = []
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        p = x[i]-x[j]
        q = y[i]-y[j]
        count = 0
        for k in range(n):
            for l in range(n):
                if p == x[k]-x[l] and q == y[k]-y[l]:
                    count += 1
                ans.append(count)

print(n-max(ans))
Buggy python submission (verdict: Runtime Error):
import sys

n,m = map(int, input().split())
a = [0]
for i in range(m):
    a.append(int(input()))
a.append(n)
    
mod = 1000000007
ans = 1

for i in range(1,len(a)-2):
    if a[i+1]-a[i]==1:
        print(0)
        sys,exit()

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

dp = []
for i in range(10**6):
    if i == 0:
        dp.append(1)
        continue
    if i == 1:
        dp.append(1)
        continue
    if i == 2:
        dp.append(2)
        continue
    dp.append((dp[i-1]+dp[i-2])%mod)

for i in range(len(b)):
    l = b[i]
    ans = (ans*dp[l])%mod
    
print(b)

Fixed submission:
import sys

n,m = map(int, input().split())
a = [0]
for i in range(m):
    a.append(int(input()))
a.append(n)
    
mod = 1000000007
ans = 1

for i in range(1,len(a)-2):
    if a[i+1]-a[i]==1:
        print(0)
        sys,exit()

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

dp = []
for i in range(10**6):
    if i == 0:
        dp.append(1)
        continue
    if i == 1:
        dp.append(1)
        continue
    if i == 2:
        dp.append(2)
        continue
    dp.append((dp[i-1]+dp[i-2])%mod)

if m == 0:
  print(dp[n])
  sys.exit()
    
for i in range(len(b)):
    l = b[i]
    ans = (ans*dp[l])%mod
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
h = list(map(int,input().split()))

# dp[i] = 足場i(0~n-1)に到着するコストの最小値
dp = [10**18]*(n)
dp[0] = 0

for i in range(n) :
    for j in range(1,k+1) :
        if i+j >= n :
            continue
        dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))

print(dp[n-1])

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

# dp[i] = 足場i(0~n-1)に到着するコストの最小値
dp = [10**18]*(n)
dp[0] = 0

for i in range(n) :
    for j in range(1,k+1) :
        if i+j >= n :
            continue
        dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))

print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,W = map(int,input().split())
w = [0]*n ; v = [0]*n
for i in range(n) :
    w[i],v[i] = map(int,input().split())
max_v = max(v)


# dp[i][j] = i番目までの荷物をいくつか選んで価値をjぴったりにしたときの重さの最小値
dp = [[10**18]*(n*max_v+1) for i in range(n)]
# 価値を0ぴったりにする重さの最小値は0
for i in range(n) :
    dp[i][0] = 0

for i in range(n) :
    for j in range(n*max_v+1) :
        if j-v[i] >= 0 : # i番目の荷物を選んで価値をjぴったりにできる場合
            dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]]+w[i])
        dp[i][j] = min(dp[i][j], dp[i-1][j])

for j in range(n*max_v,-1,-1) :
    if dp[n-1][j] <= W :
        print(j)
        break

Fixed submission:
n,W = map(int,input().split())
w = [0]*n ; v = [0]*n
for i in range(n) :
    w[i],v[i] = map(int,input().split())
max_v = max(v)


# dp[i][j] = i番目までの荷物をいくつか選んで価値をjぴったりにしたときの重さの最小値
dp = [[10**18]*(n*max_v+1) for i in range(n)]
# 価値を0ぴったりにする重さの最小値は0
for i in range(n) :
    dp[i][0] = 0

for i in range(n) :
    for j in range(n*max_v+1) :
        if j-v[i] >= 0 : # i番目の荷物を選んで価値をjぴったりにできる場合
            dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]]+w[i])
        dp[i][j] = min(dp[i][j], dp[i-1][j])

for j in range(n*max_v,-1,-1) :
    if dp[n-1][j] <= W :
        print(j)
        break
Buggy python submission (verdict: Runtime Error):
import sys

n = int(input())
v = list(map(int,input().split()))

a1 = {}
a2 = {}
for i in range(n) :
  a = v[i]
  if i%2 == 0 :
    if a in a1 :
      a1[a] += 1
    else :
      a1[a] = 1
  else :
    if a in a2 :
      a2[a] += 1
    else :
      a2[a] = 1

a1_s = sorted(a1.items(), key = lambda x : x[1], reverse = True)
a2_s = sorted(a2.items(), key = lambda x : x[1], reverse = True)

ans = n
for i in range(2) :
  for j in range(2) :
    if a1_s[i][0] == a2_s[j][0] :
      continue
    ans = min(ans,n-a1_s[i][1]-a2_s[j][1])
    
print(ans)

Fixed submission:
import sys

n = int(input())
v = list(map(int,input().split()))

a1 = {}
a2 = {}
for i in range(n) :
  a = v[i]
  if i%2 == 0 :
    if a in a1 :
      a1[a] += 1
    else :
      a1[a] = 1
  else :
    if a in a2 :
      a2[a] += 1
    else :
      a2[a] = 1

a1_s = sorted(a1.items(), key = lambda x : x[1], reverse = True)
a2_s = sorted(a2.items(), key = lambda x : x[1], reverse = True)

ans = n
for i in range(min(2,len(a1_s))) :
  for j in range(min(2,len(a2_s))) :
    if a1_s[i][0] == a2_s[j][0] :
      continue
    ans = min(ans,n-a1_s[i][1]-a2_s[j][1])

if len(a1_s) == 1 and len(a2_s) == 1 and ans == n :
  ans = n//2

print(ans)
Buggy python submission (verdict: Runtime Error):
import fractions

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

ans = fractions.gcd(abs(a[0]-x),abs(a[1]-x))
for i in range(2,n) :
  ans = fractions.gcd(ans,abs(a[i]-x))
  
print(ans)

Fixed submission:
import fractions
import sys

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

if n == 1 :
  print(abs(a[0]-x))
  sys.exit()

ans = fractions.gcd(abs(a[0]-x),abs(a[1]-x))
for i in range(2,n) :
  ans = fractions.gcd(ans,abs(a[i]-x))
  
print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect
import sys

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

index = bisect.bisect_left(x,0)

if x[0] >= 0 :
  print(x[k-1])
  sys.exit()
  
if x[-1] <= 0 :
  print(x[n-k]*(-1))
  sys.exit()

ans = 10**9
if min(index+k,n) == index+k :
  ans = x[index+k-1]

if max(0,index-k) == index - k :
  ans = min(ans,x[index-k]*(-1))
  
c = 0
for i in range(index,min(index+k,n)) :
  c += 1
  ans = min(ans,x[i]*2+x[i-(k-1)]*(-1))

c = 0
for i in range(max(0,index-k),index) :
  c += 1
  ans = min(ans,x[i]*(-1)*2+x[i+(k-1)])
  
print(ans)

Fixed submission:
import bisect
import sys

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

index = bisect.bisect_left(x,0)

if x[0] >= 0 :
  print(x[k-1])
  sys.exit()
  
if x[-1] <= 0 :
  print(x[n-k]*(-1))
  sys.exit()

ans = 10**9
if min(index+k,n) == index+k :
  ans = x[index+k-1]

if max(0,index-k) == index - k :
  ans = min(ans,x[index-k]*(-1))
  
c = 0
for i in range(index,min(index+k,n)) :
  c += 1
  if i <= n-1 and i-(k-1) <= n-1 and i-(k-1) >= 0 :
    ans = min(ans,x[i]*2+x[i-(k-1)]*(-1))

c = 0
for i in range(max(0,index-k),index) :
  c += 1
  if i <= n-1 and i+(k-1) <= n-1 :
    ans = min(ans,x[i]*(-1)*2+x[i+(k-1)])
  
print(ans)
Buggy python submission (verdict: Runtime Error):
# XとYの二部グラフの最大マッチング X={0,1,2,...|X|-1} Y={0,1,2,...,|Y|-1}
#   edges[x]: xとつながるYの頂点のset
#   matched[y]: yとマッチングされたXの頂点(暫定)
 
def dfs(v, visited):
    """
    :param v: X側の未マッチングの頂点の1つ
    :param visited: 空のsetを渡す（外部からの呼び出し時）
    :return: 増大路が見つかればTrue
    """
    for u in edges[v]:
        if u in visited:
            continue
        visited.add(u)
        if matched[u] == -1 or dfs(matched[u], visited):
            matched[u] = v
            return True
    return False
 
 
# 標準入力からのグラフ読み取り
n = int(input())

r = [[0,0] for i in range(n)]
for i in range(n) :
  x,y = map(int,input().split())
  r[i][0],r[i][1] = x,y
  
b = [[0,0] for i in range(n)]
for i in range(n) :
  x,y = map(int,input().split())
  b[i][0],b[i][1] = x,y

edges = [set() for _ in range(n)]
matched = [-1] * n
  
for i in range(n) :
  for j in range(n) :
    if r[i][0] < b[j][0] and r[i][1] < b[j][1] :
      edges[i].add(j)
      
# 増大路発見に成功したらTrue(=1)。合計することでマッチング数となる
print(sum(dfs(s, set()) for s in range(xn)))

Fixed submission:
n = int(input())

r = [[0,0,1] for i in range(n)]
for i in range(n) :
  x,y = map(int,input().split())
  r[i][0],r[i][1] = x,y
  
b = [[0,0,1] for i in range(n)]
for i in range(n) :
  x,y = map(int,input().split())
  b[i][0],b[i][1] = x,y
  
r.sort(key=lambda x: x[0],reverse=True)
b.sort(key=lambda x: x[1])

ans = 0
for i in range(n) :
  for j in range(n) :
    if r[i][2] == 0 or b[j][2] == 0 :
      continue
    if r[i][0] < b[j][0] and r[i][1] < b[j][1] :
      r[i][2] = 0 ; b[j][2] = 0
      ans += 1
      
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

n,h = map(int,input().split())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n) :
  a[i],b[i] = map(int,input().split())
  
b.sort(reverse=True)

c = 0
for i in range(n) :
  if b[i] < max(a) :
    break
  h -= b[i]
  c += 1

print(c + math.ceil(h/max(a)))

Fixed submission:
import sys
import math
import bisect

n,h = map(int,input().split())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n) :
  a[i],b[i] = map(int,input().split())
  
b.sort(reverse=True)

c = 0
bs = [b[0]]
am = max(a)
bs_append = bs.append
for i in range(1,n) :
  if b[i] < am :
    break
  bs_append(bs[i-1]+b[i])
  
if b[0] < am :
  print(math.ceil(h/am))
  sys.exit()

if bs[-1] <= h :
  print(len(bs) + math.ceil((h-bs[-1])/am))
else :
  print(bisect.bisect_left(bs,h)+1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

n,h = map(int,input().split())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n) :
  a[i],b[i] = map(int,input().split())
  
b.sort(reverse=True)

c = 0
for i in range(n) :
  if b[i] < max(a) :
    break
  h -= b[i]
  c += 1
  if h <= 0 :
    print(c)
    sys.exit()

print(c + math.ceil(h/max(a)))

Fixed submission:
import sys
import math
import bisect

n,h = map(int,input().split())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n) :
  a[i],b[i] = map(int,input().split())
  
b.sort(reverse=True)

c = 0
bs = [b[0]]
am = max(a)
bs_append = bs.append
for i in range(1,n) :
  if b[i] < am :
    break
  bs_append(bs[i-1]+b[i])
  
if b[0] < am :
  print(math.ceil(h/am))
  sys.exit()

if bs[-1] <= h :
  print(len(bs) + math.ceil((h-bs[-1])/am))
else :
  print(bisect.bisect_left(bs,h)+1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

n,h = map(int,input().split())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n) :
  a[i],b[i] = map(int,input().split())
  
b.sort(reverse=True)

c = 0
for i in range(n) :
  if b[i] < max(a) :
    break
  h -= b[i]
  c += 1
  if h <= 0 :
    print(c)
    sys.exit()

print(c + math.ceil(h/max(a)))

Fixed submission:
import sys
import math
import bisect

n,h = map(int,input().split())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n) :
  a[i],b[i] = map(int,input().split())
  
b.sort(reverse=True)

c = 0
bs = [b[0]]
am = max(a)
bs_append = bs.append
for i in range(1,n) :
  if b[i] < am :
    break
  bs_append(bs[i-1]+b[i])
  
if b[0] < am :
  print(math.ceil(h/am))
  sys.exit()

if bs[-1] <= h :
  print(len(bs) + math.ceil((h-bs[-1])/am))
else :
  print(bisect.bisect_left(bs,h)+1)
Buggy python submission (verdict: Runtime Error):
import sys

s = input()
t = input()

tl = len(t) ; sl = len(s)

for i in range(sl,tl-1,-1) :
  st = s[i-tl:i]
  c = 0
  for j in range(tl) :
    if st[j] == '?' :
      continue
    elif st[j] != '?' and st[j] == t[j] :
      continue
    c = 1
    break
  if c == 0 :
    s = s[:i-tl] + t + s[i:]
    break

if c == 1 :
  print('UNRESTORABLE')
else : 
  print(s.replace('?', 'a'))

Fixed submission:
import sys

s = input()
t = input()

tl = len(t) ; sl = len(s)

c = 1
for i in range(sl,tl-1,-1) :
  st = s[i-tl:i]
  c = 0
  for j in range(tl) :
    if st[j] == '?' :
      continue
    elif st[j] != '?' and st[j] == t[j] :
      continue
    c = 1
    break
  if c == 0 :
    s = s[:i-tl] + t + s[i:]
    break

if c == 1 :
  print('UNRESTORABLE')
else : 
  print(s.replace('?', 'a'))

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

tl = len(t)
sl = len(s)
for i in range(sl,tl,-1) :
  st = s[i-tl:i]
  c = 0
  for j in range(tl) :
    if st[j] == '?' :
      continue
    elif st[j] != '?' and st[j] == t[j] :
      continue
    c = 1
    break
  if c == 0 :
    s = s[:i-tl] + t + s[i:]
    break

if c == 1 :
  print('UNRESTORABLE')
else : 
  print(s.replace('?', 'a'))

Fixed submission:
import sys

s = input()
t = input()

tl = len(t) ; sl = len(s)

c = 1
for i in range(sl,tl-1,-1) :
  st = s[i-tl:i]
  c = 0
  for j in range(tl) :
    if st[j] == '?' :
      continue
    elif st[j] != '?' and st[j] == t[j] :
      continue
    c = 1
    break
  if c == 0 :
    s = s[:i-tl] + t + s[i:]
    break

if c == 1 :
  print('UNRESTORABLE')
else : 
  print(s.replace('?', 'a'))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

if k > max(a) :
  print('IMPOSSIBLE')
  sys.exit()
if k in a :
  print('POSSIBLE')
  sys.exit()
  
ans = 'IMPOSSIBLE'
c = 0
for i in range(n-1) :
  a1 = a[i]
  for j in range(i+1,n) :
    a2 = a[j]
    if not abs(a1-a2) in a :
      c = 1
  if c == 1 :
    ans = 'POSSIBLE'
    break

print(ans)

Fixed submission:
import sys
import fractions

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

if k > max(a) :
  print('IMPOSSIBLE')
  sys.exit()
if k in a :
  print('POSSIBLE')
  sys.exit()
  
g = fractions.gcd(a[0],a[1])
for i in range(2,n) :
  g = fractions.gcd(g,a[i])
  
if k%g == 0 :
  print('POSSIBLE')
else :
  print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import math

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

a.sort()

n1 = math.ceil(math.log(1000000000,2))+1

s = [0 for _ in range(n)]
s[0] = a[0]
for i in range(1,n) :
  s[i] = s[i-1]+a[i]

ans = 0
for i in range(n) :
  h = 0
  m = a[i]*2
  for j in range(n1) :
    mg = bisect.bisect_left(a,m)
    if mg <= n-1 and m == a[mg] :
      mg += 1
    m = s[mg-1]*2
    if m >= a[n-1] :
      ans += 1
      break
  
print(ans)

Fixed submission:
import bisect
import math

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

a.sort()

n1 = math.ceil(math.log(1000000000,2))+1

s = [0 for _ in range(n)]
s[0] = a[0]
for i in range(1,n) :
  s[i] = s[i-1]+a[i]

ans = 0
for i in range(n) :
  h = 0
  m = a[i]*2
  for j in range(n1) :
    mg = bisect.bisect_left(a,m)
    if mg <= n-1 and m == a[mg] :
      mg += 1
    m = s[mg-1]*2
    if m >= a[n-1] :
      ans += 1
      break
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import math

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

a.sort()

ans = 0
for i in range(n) :
  h = 0
  m = a[i]*2
  for j in range(math.ceil(math.log(1000000000,2))+1) :
    mg = bisect.bisect_left(a,m)
    if mg <= n-1 and m == a[mg] :
      mg += 1
    m = sum(a[:mg])*2
  if mg >= n :
    ans += 1
  
print(ans)

Fixed submission:
import bisect
import math

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

a.sort()

n1 = math.ceil(math.log(1000000000,2))+1

s = [0 for _ in range(n)]
s[0] = a[0]
for i in range(1,n) :
  s[i] = s[i-1]+a[i]

ans = 0
for i in range(n) :
  h = 0
  m = a[i]*2
  for j in range(n1) :
    mg = bisect.bisect_left(a,m)
    if mg <= n-1 and m == a[mg] :
      mg += 1
    m = s[mg-1]*2
    if m >= a[n-1] :
      ans += 1
      break
  
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np

n,m = map(int, input().split())
graph = [[] for j in range(n)]
graph = np.array(graph)

for i in range(m):
    a,b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

used = [False]*n
used[0] = True

def DFS(v,used):
    if all(used):
        return 1
    ans = 0
    for i in graph(v):
        if used[i]:
            continue
        used[i] = True
        ans += DFS(i,used)
        used[i] = False
    return ans
  
print(DFS(0,used))

Fixed submission:
# -*- coding: utf-8 -*-
import numpy as np

n,m = map(int, input().split())
graph = [[0 for i in range(n)] for j in range(n)]
graph = np.array(graph)

for i in range(m):
    a,b = map(int, input().split())
    graph[a-1,b-1] = 1
    graph[b-1,a-1] = 1

used = [False]*n
used[0] = True

def DFS(v,used):
    global ans
    if all(used):
        ans += 1
        return 
    for i in range(n):
        if used[i]:
            continue
        if graph[i,v] == 0:
            continue
        used[i] = True
        DFS(i,used)
        used[i] = False
    return

ans = 0
DFS(0,used)

print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np

n,m = map(int, input().split())
graph = [[0 for i in range(n)] for j in range(n)]
graph = np.array(graph)

for i in range(m):
    a,b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

used = [False]*n
used[0] = True

def DFS(v,used):
    if all(used):
        return 1
    ans = 0
    for i in graph(v):
        if used[i]:
            continue
        used[i] = True
        ans += DFS(i,used)
        used[i] = False
    return ans
  
print(DFS(0,used))

Fixed submission:
# -*- coding: utf-8 -*-
import numpy as np

n,m = map(int, input().split())
graph = [[0 for i in range(n)] for j in range(n)]
graph = np.array(graph)

for i in range(m):
    a,b = map(int, input().split())
    graph[a-1,b-1] = 1
    graph[b-1,a-1] = 1

used = [False]*n
used[0] = True

def DFS(v,used):
    global ans
    if all(used):
        ans += 1
        return 
    for i in range(n):
        if used[i]:
            continue
        if graph[i,v] == 0:
            continue
        used[i] = True
        DFS(i,used)
        used[i] = False
    return

ans = 0
DFS(0,used)

print(ans)