Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import bisect
import math

n=int(input())
a=[int(i) for i in input().split()]
a.sort()
m=0
ans1=max(a)
ams2=min(a)

for i in range(1,n):
  b = bisect.bisect_left(a[:i],a[i]/2)
  r = math.factorial(a[i])/(math.factorial(a[b])*math.factorial(a[i]-a[b]))
  if b-1<=0:
    j=b
  else:
    if abs(a[b]-a[i]/2)<=abs(a[b-1]-a[i]/2):
      j=b
    else:
      j=b-1
      
  r = math.factorial(a[i])/(math.factorial(a[j])*math.factorial(a[i]-a[j]))
  if r>m:
    ans1=a[i]
    ans2=a[j]
print(ans1,ans2)


Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
m=max(a)
m2 = m / 2

f = m
ans = -m
for i in a:
  if i != m and abs(m2 - i) <=f:
    f = abs(m2 - i)
    ans = i
print(m,ans)

Buggy python submission (verdict: Runtime Error):
import bisect
import math
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
m=0
for i in range(1,n):
  b=bisect.bisect_left(a[:i],a[i]/2)

  r=math.factorial(a[i])/(math.factorial(a[b])*math.factorial(a[i]-a[b]))
  if b-1>=0:
    l=math.factorial(a[i])/(math.factorial(a[b-1])*math.factorial(a[i]-a[b-1]))
  else:
    l=0
  if max(r,l)>m:
    m=max(r,l)
    ans1=a[i]
    if r>l:
      ans2=a[b]
    else:
      ans2=a[b-1]
print(ans1,ans2)


Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
m=max(a)
m2 = m / 2

f = m
ans = -m
for i in a:
  if i != m and abs(m2 - i) <=f:
    f = abs(m2 - i)
    ans = i
print(m,ans)
Buggy python submission (verdict: Time Limit Exceeded):
m,n,x=[int(i) for i in input().split()]
a=set(range(m,m+x))
b=set(range(n-x+1,n+1))
c=set(range(m,n+1))
for i in sorted(list((a|b)&c)):
  print(i)

Fixed submission:
m,n,x=[int(i) for i in input().split()]
a=set([i for i in range(m,m+x) if i<=n])
b=set([i for i in range(n-x+1,n+1) if i>=m])
for i in sorted(list(a|b)):
  print(i)
Buggy python submission (verdict: Runtime Error):
a=[0]*4
for i in range(4):
  a[i]=int(input())
print(min(a[2])+min(a[2:4]))

Fixed submission:
a=[0]*4
for i in range(4):
  a[i]=int(input())
print(min(a[:2]) + min(a[2:4]))
Buggy python submission (verdict: Runtime Error):
a=input().strip()
b=input().strip()
c=input().strip()
print("".join([a[0],b[1],c[0]])

Fixed submission:
a=input().strip()
b=input().strip()
c=input().strip()
print("".join([a[0],b[1],c[2]]))
Buggy python submission (verdict: Runtime Error):
=int(input())
b=int(input())
c=int(input())
m=int(input())
s=0
for i in range(a+1):
  for j in range(b+1):
    x,y=divmod(m-i*500-j*100,50)
    if y==0 and 0<=x<=c:
      s+=1
print(s)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
m=int(input())
s=0
for i in range(a+1):
  for j in range(b+1):
    x,y=divmod(m-i*500-j*100,50)
    if y==0 and 0<=x<=c:
      s+=1
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
I=lambda:map(int,input().split())
n,m=I()
r=range(n)
y=[[] for i in r]
z=[None for i in r]

for _ in [0]*m:
  i,j,k=I()
  y[i-1]+=[[j-1, k]]
  y[j-1]+=[[i-1,-k]]

for i in r:
  if z[i]==None:
    z[i]=0
    q=[i]
    while q:
      p=q.pop()
      for j,k in y[p]:
        if z[j]==None:
          q+=[j]
          z[j]=z[p]+k
        elif z[j]!=z[p]+k:
          print("No")
          exit()
print("Yes")


Fixed submission:
I=lambda:map(int,input().split())
n,m=I()
r=range(n)
y=[[] for i in r]
z=[None for i in r]

for _ in [0]*m:
  i,j,k=I()
  y[i-1]+=[[j-1, k]]
  y[j-1]+=[[i-1,-k]]

for i in r:
  if z[i]==None:
    z[i]=0 
  q=[i]
  while q:
    p=q.pop()
    for j,k in y[p]:
      if z[j]==None:
        q+=[j]
        z[j]=z[p]+k
      elif z[j]!=z[p]+k:
        print("No")
        exit()
print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
I=lambda:map(int,input().split())
n,m=I()
r=range(n)
y=[[] for i in r]
z=[None for i in r]

for _ in [0]*m:
  i,j,k=I()
  y[i-1]+=[[j-1, k]]
  y[j-1]+=[[i-1,-k]]

for i in r:
  if z[i]==None:
    z[i]=0 
  q=[i]
  while q:
    p=q.pop()
    for j,k in y[p]:
      if z[j]==None:
        q+=[j]
        z[j]=z[p]+k
      elif z[j]!=z[p]+k:
        print("No")
        exit()
print("Yes")

Fixed submission:
I=lambda:map(int,input().split())
n,m=I()
r=range(n)
y=[[] for i in r]
z=[None for i in r]

for _ in [0]*m:
  i,j,k=I()
  y[i-1]+=[[j-1, k]]
  y[j-1]+=[[i-1,-k]]

for i in r:
  if z[i]==None:
    z[i]=0 
  q=[i]
  while q:
    p=q.pop()
    for j,k in y[p]:
      if z[j]==None:
        q+=[j]
        z[j]=z[p]+k
      elif z[j]!=z[p]+k:
        print("No")
        exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
n=int(input())
t0=0
x0=0
y0=0
for i in range(n):
  t,x,y=[int(i) for i in input().split()]
  if (t-t0-(abs(x-x0)+abs(y-y0)))%2 == 1 or t-t0<(abs(x-x0)+abs(y-y0)):
    print('No')
    break
  t0,x0,y0=t,x,
else:
  print('Yes')
  

Fixed submission:
n=int(input())
t0=0
x0=0
y0=0
for i in range(n):
  t,x,y=[int(i) for i in input().split()]
  if (t-t0-(abs(x-x0)+abs(y-y0)))%2 == 1 or t-t0<(abs(x-x0)+abs(y-y0)):
    print('No')
    break
  t0,x0,y0=t,x,y
else:
  print('Yes')

Buggy python submission (verdict: Runtime Error):
n=int(input())
t0=0
x0=0
y0=0
for i in range(n):
  t,x,y=[int(i) for i in input().split()]
  if (t-t0-(abs(x-x0)+abs(y-y0)))%2 == 1 or t-t0<(abs(x-x0)+abs(y-y0)):
    print('No')
    break
  t0,x0,y0=t,x,
else:
  print('Yes')
  

Fixed submission:
n=int(input())
t0=0
x0=0
y0=0
for i in range(n):
  t,x,y=[int(i) for i in input().split()]
  if (t-t0-(abs(x-x0)+abs(y-y0)))%2 == 1 or t-t0<(abs(x-x0)+abs(y-y0)):
    print('No')
    break
  t0,x0,y0=t,x,y
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
mport math
n,m=[int(i) for i in input().split()]
a=[]
b=[]
for i in range(n):
  a0,b0=[int(i) for i in input().split()]
  a.append(a0)
  b.append(b0)
a.sort(reverse=True)
b.sort(reverse=True)
x=0
while m>0:
  if b==[]:
    x+=math.ceil(m/a[0])
    break
  else:
    if b[0]>a[0]:
      m-=b[0]
      del b[0] 
      x+=1
    else:
      x+=math.ceil(m/a[0])
      break
    
print(x)

Fixed submission:
import math
n,m=[int(i) for i in input().split()]
a=[]
b=[]
for i in range(n):
  a0,b0=[int(i) for i in input().split()]
  a.append(a0)
  b.append(b0)
a.sort(reverse=True)
b.sort(reverse=True)
x=0
while m>0:
  if b==[]:
    x+=math.ceil(m/a[0])
    break
  else:
    if b[0]>a[0]:
      m-=b[0]
      del b[0] 
      x+=1
    else:
      x+=math.ceil(m/a[0])
      break
    
print(x)

Buggy python submission (verdict: Runtime Error):
import math
n,m=[int(i) for i in input().split()]
a=[]
b=[]
for i in range(n):
  a0,b0=[int(i) for i in input().split()]
  a.append(a0)
  b.append(b0)
a.sort(reverse=True)
b.sort(reverse=True)
x=0
while m>0:
  if b[0]>a[0]:
    m-=b[0]
    del b[0] 
    x+=1
  else:
    x+=math.ceil(m/a[0])
    break
    
  
print(x)

Fixed submission:
import math
n,m=[int(i) for i in input().split()]
a=[]
b=[]
for i in range(n):
  a0,b0=[int(i) for i in input().split()]
  a.append(a0)
  b.append(b0)
a.sort(reverse=True)
b.sort(reverse=True)
x=0
while m>0:
  if b==[]:
    x+=math.ceil(m/a[0])
    break
  else:
    if b[0]>a[0]:
      m-=b[0]
      del b[0] 
      x+=1
    else:
      x+=math.ceil(m/a[0])
      break
    
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import lru_cache

n=int(input())
@lru_cache()
def sosu(l):
  if l ==2:
    return 1
  elif l % 2==0 or l==1 or l==3/2:
    return 0
  else:
    for d in range(3, math.floor(math.sqrt(l))+1,2):
      if l % d == 0:
        return 0
        break
    else:
      return 1

li=[]
for j in range(1,100001):
  li.append(sosu(j)*sosu((j+1)/2))

for i in range(n):
  a,b=[int(i) for i in input().split()]
  print(sum(li[a-1:b]))

Fixed submission:
import math
from functools import lru_cache

n=int(input())
@lru_cache()
def sosu(l):
  if l ==2:
    return 1
  elif l % 2==0 or l==1 or l==3/2 or l==0:
    return 0
  else:
    for d in range(3, math.floor(math.sqrt(l))+1,2):
      if l % d == 0:
        return 0
        break
    else:
      return 1

m=0
li=[]
for j in range(0,100001):
  m+=sosu(j)*sosu((j+1)/2)
  li.append(m)

for i in range(n):
  a,b=[int(i) for i in input().split()]
  print(li[b]-li[a-1])

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import lru_cache

n=int(input())
@lru_cache()
def sosu(l):
  
  if l ==2:
    return 1
  elif l % 2==0 or l==1 or l==3/2:
    return 0
  else:
    for d in range(3, math.floor(math.sqrt(l))+1,2):
      if l % d == 0:
        return 0
        break
    else:
      return 1

li=[]
for j in range(1,100001):
  li.append(sosu(j)*sosu((j+1)/2))

for i in range(n):
  a,b=[int(i) for i in input().split()]
  print(sum(li[a-1:b]))

Fixed submission:
import math
from functools import lru_cache

n=int(input())
@lru_cache()
def sosu(l):
  if l ==2:
    return 1
  elif l % 2==0 or l==1 or l==3/2 or l==0:
    return 0
  else:
    for d in range(3, math.floor(math.sqrt(l))+1,2):
      if l % d == 0:
        return 0
        break
    else:
      return 1

m=0
li=[]
for j in range(0,100001):
  m+=sosu(j)*sosu((j+1)/2)
  li.append(m)

for i in range(n):
  a,b=[int(i) for i in input().split()]
  print(li[b]-li[a-1])
Buggy python submission (verdict: Runtime Error):
l=input()
n=len(l)

for i in range(1,n):
  x = n
  nx=0
  if l[i-1] != l[i]:
    nx = max(i, n-i)
  x = min(x,nx)
print(x)

Fixed submission:
l=input()
n=len(l)
x = n
for i in range(1,n):
  if l[i-1] != l[i]:
    nx = max(i, n-i)
    x = min(x,nx)
print(x)
Buggy python submission (verdict: Runtime Error):
imput numpy as np

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

if abs(max(a)) >= abs(min(a)):
  ma  = max(a)
  ma_i= np.argmax(a)
  mi  = 0
  mi_i= 0
else:
  mi  = min(a)
  mi_i= np.argmin(a)
  ma  = 0
  ma_i= 0

if ma==0:
  for i in range(n):
    if a[i] > 0:
      a[i] = a[i] + mi
      print(mi_i,i)
  for i in reversed(range(1,n)):
    if a[i-1] > a[i]:
      a[i-1] = a[i-1] + a[i]
      print(i-1, i)
else:
  for i in range(n):
    if a[i] < 0:
      a[i] = a[i] + ma
      print(mi_a,i)
  for i in range(1,n):
    if a[i-1] > a[i]:
      a[i] = a[i] + a[i-1]
      print(i-1,i)

Fixed submission:
import numpy as np

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

if abs(max(a)) >= abs(min(a)):
  ma  = max(a)
  ma_i= np.argmax(a)
  mi  = 0
  mi_i= 0
else:
  mi  = min(a)
  mi_i= np.argmin(a)
  ma  = 0
  ma_i= 0

xa=[]
if ma == 0:
  for i in range(n):
    if a[i] > 0:
      a[i] = a[i] + mi
      xa.append([mi_i+1, i+1])
  for i in reversed(range(1,n)):
    if a[i-1] > a[i]:
      a[i-1] = a[i-1] + a[i]
      xa.append([i+1, i-1+1])
else:
  for i in range(n):
    if a[i] < 0:
      a[i] = a[i] + ma
      xa.append([ma_i+1, i+1])
  for i in range(1,n):
    if a[i-1] > a[i]:
      a[i] = a[i] + a[i-1]
      xa.append([i-1+1,i+1])

print(len(xa))
for i in range(len(xa)):
  print(xa[i][0],xa[i][1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=input().split(' ')
a=[int(i) for i in input().split(' ')]
n=np.array(a)

x=0
m = n.max()
mx= n.argmax()
k = n.min()
kx= n.argmin()
e=[]
if abs(m) > abs(k) and m > 0:
  for i in range(len(a)-1):
    while n[i] > n[i+1]:
      n[i+1] = n[i+1] + m
      e.append([mx+1 ,i+1 +1])
      x+=1
    m =n.max()
    mx= n.argmax()
else:
  for i in range(len(a)-1,0,-1):
    while n[i-1] > n[i]:
      n[i-1] = n[i-1] + k
      e.append([kx+1 ,i])
      x+=1
    k =n.max()
    kx= n.argmax()
    
print(x)
for j in e:
  print(" ".join([str(i) for i in j]))

Fixed submission:
import numpy as np

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

if abs(max(a)) >= abs(min(a)):
  ma  = max(a)
  ma_i= np.argmax(a)
  mi  = 0
  mi_i= 0
else:
  mi  = min(a)
  mi_i= np.argmin(a)
  ma  = 0
  ma_i= 0

xa=[]
if ma == 0:
  for i in range(n):
    if a[i] > 0:
      a[i] = a[i] + mi
      xa.append([mi_i+1, i+1])
  for i in reversed(range(1,n)):
    if a[i-1] > a[i]:
      a[i-1] = a[i-1] + a[i]
      xa.append([i+1, i-1+1])
else:
  for i in range(n):
    if a[i] < 0:
      a[i] = a[i] + ma
      xa.append([ma_i+1, i+1])
  for i in range(1,n):
    if a[i-1] > a[i]:
      a[i] = a[i] + a[i-1]
      xa.append([i-1+1,i+1])

print(len(xa))
for i in range(len(xa)):
  print(xa[i][0],xa[i][1])
Buggy python submission (verdict: Runtime Error):
a=input()
x=int(a)

y=0
for i in len(a):
  y+=int(a[i])

if x % y==0:
  print('Yes')
else:
  print('No')

Fixed submission:
a=input()
x=int(a)

y=0
for i in a:
  y+=int(i)

if x % y==0:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
a=input()
x=int(a)

y=0
for i in len(n):
  y+=int(i)

if x % y==0:
  print('Yes')
else:
  print('No')

Fixed submission:
a=input()
x=int(a)

y=0
for i in a:
  y+=int(i)

if x % y==0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n,c=[int(i) for i in input().split()]
s=[]
t=[]
for _ in range(n):
  a=[int(i) for i in input().split()]
  s.append(a[0]-0.5)
  t.append(a[1])

s.sort()
t.sort()
x=0
m=0
while s !=[] or t !=[]:
  if s==[]:
    x-=1
    del t[0]
  elif t==[]:
    x+=1
    del s[0]
  else:
    if s[0] < t[0]:
      x+=1
      del s[0]
    else:
      x-=1
      del t[0]
  m=max(m,x)
print(m)

Fixed submission:
n,c=[int(i) for i in input().split()]
s0=[]
t0=[]
for _ in range(n):
  a=[int(i) for i in input().split()]
  s0.append((a[0],a[2]))
  t0.append((a[1],a[2]))
s1=set(s0)
t1=set(t0)
s2=list(s1.difference(t0))
t2=list(t1.difference(s0))
s=[i[0]-0.5 for i in s2]
t=[i[0] for i in t2]

s.sort()
t.sort()
x=0
m=0
si=0
ti=0
while si != len(s):
  if s[si] < t[ti]:
    x+=1
    si+=1
  else:
    x-=1
    ti+=1
  m = max(m,x)
print(m)
Buggy python submission (verdict: Runtime Error):
a,b=[int('x',i) for i in input.split(' ')]
if a==b:
  print('=')
else a>b:
  print('>')
else:
  print('<')

Fixed submission:
a,b=[int(i,16) for i in input().split(' ')]
if a==b:
  print('=')
elif a>b:
  print('>')
else:
  print('<')
Buggy python submission (verdict: Runtime Error):
n,z,w=[int(i) for i in input().split(' ')]
a=[int(i) for i in input().split(' ')]

l0=abs(a[-1]-a[-2])
l1=abs(a[-1]-w)

if l1>l0:
  print(l1)
else:
  print(l0)

Fixed submission:
n,z,w=[int(i) for i in input().split(' ')]
a=[int(i) for i in input().split(' ')]

if len(a)>1:
  l0=abs(a[-1]-a[-2])
else:
  l0=-1000000000000000000
l1=abs(a[-1]-w)

if l1>l0:
  print(l1)
else:
  print(l0)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n=int(input())
a=[int(i) for i in input().split(" ")]
b=[int(i) for i in input().split(" ")]
c=[int(i) for i in input().split(" ")]

b.sort()
c.sort()
lc=len(c)

print(sum([sum([lc-bisect.bisect_right(c,j) for j in b[bisect.bisect_right(b,i):]]) for i in a])
)

Fixed submission:
import bisect

n=int(input())
a=[int(i) for i in input().split(" ")]
b=[int(i) for i in input().split(" ")]
c=[int(i) for i in input().split(" ")]

a.sort()
c.sort()
lc=len(c)
print(sum([(lc-bisect.bisect_right(c,j))*(bisect.bisect_left(a,j)) for j in b]))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
from collections import defaultdict
e=defaultdict(dict)
 
n=int(input())
a=[int(i) for i in input().split(" ")]
b=[int(i) for i in input().split(" ")]
c=[int(i) for i in input().split(" ")]

b.sort()
c.sort()
for i in b:
  e[i]=len(c)-bisect.bisect_right(c,i)
n=0

for i in a:
  
  n+=sum([e[j] for j in b[bisect.bisect_right(b,i):]] )
print(n)

Fixed submission:
import bisect

n=int(input())
a=[int(i) for i in input().split(" ")]
b=[int(i) for i in input().split(" ")]
c=[int(i) for i in input().split(" ")]

a.sort()
c.sort()
lc=len(c)
print(sum([(lc-bisect.bisect_right(c,j))*(bisect.bisect_left(a,j)) for j in b]))

Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache

n=int(input())
a=[int(i) for i in input().split(" ")]
b=[int(i) for i in input().split(" ")]
c=[int(i) for i in input().split(" ")]
a.sort
b.sort
c.sort

@lru_cache()
def e(x): 
  return len([j for j in c if j>x])
  
n=0
for i in a:
  n+=sum([e(j) for j in b if j>i])
print(n)

Fixed submission:
import bisect

n=int(input())
a=[int(i) for i in input().split(" ")]
b=[int(i) for i in input().split(" ")]
c=[int(i) for i in input().split(" ")]

a.sort()
c.sort()
lc=len(c)
print(sum([(lc-bisect.bisect_right(c,j))*(bisect.bisect_left(a,j)) for j in b]))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
e=defaultdict(dict)

n=int(input())
a=[int(i) for i in input().split(" ")]
b=[int(i) for i in input().split(" ")]
c=[int(i) for i in input().split(" ")]

n=0
for i in a:
  n+=sum([len([k for k in c if k > j]) for j in b if j > i])
print(n)

Fixed submission:
import bisect

n=int(input())
a=[int(i) for i in input().split(" ")]
b=[int(i) for i in input().split(" ")]
c=[int(i) for i in input().split(" ")]

a.sort()
c.sort()
lc=len(c)
print(sum([(lc-bisect.bisect_right(c,j))*(bisect.bisect_left(a,j)) for j in b]))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
e=defaultdict(dict)

n=int(input())
a=[int(i) for i in input().split(" ")]
b=[int(i) for i in input().split(" ")]
c=[int(i) for i in input().split(" ")]

for i in b:
  e[i]=len([j for j in c if j>i])
n=0
for i in a:
  n+=sum([e[j] for j in b if j>i])
print(n)

Fixed submission:
import bisect

n=int(input())
a=[int(i) for i in input().split(" ")]
b=[int(i) for i in input().split(" ")]
c=[int(i) for i in input().split(" ")]

a.sort()
c.sort()
lc=len(c)
print(sum([(lc-bisect.bisect_right(c,j))*(bisect.bisect_left(a,j)) for j in b]))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=1
b=1
c=1
z=0
while a<=3500:
    b=a
    if z==1:
        break
    while b<=3500:
        if 4*a*b- b*n -a*n !=0:
            c=a*b*n/(4*a*b- b*n -a*n)
            if int(c)==c and c>0:
                print(a, b, int(c)) 
                z=1
                break 
        b+=1
    a+=1


Fixed submission:
n=int(input())
a=1
b=1
c=1
z=0
while a<=3500:
    b=a
    if z==1:
        break
    while b<=3500:
        d=4*a*b- b*n -a*n
        if  d > 0:
            c=a*b*n/(d)
            if int(c)==c:
                print(a, b, int(c)) 
                z=1
                break 
        b+=1
    a+=1
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
from collections import Counter

n=list(input())

a=len(list(itertools.combinations(n,2)))

counter = Counter(n)
for w, c in counter.most_common():
  a -= len(list(itertools.combinations(w*c,2)))
print(a+1)    

Fixed submission:
from collections import Counter

n=list(input())
l=len(n)
a=l*(l-1)/2

counter = Counter(n)
for w, c in counter.most_common():
  a -= c*(c-1)/2
print(int(a+1))
Buggy python submission (verdict: Runtime Error):
a=int(input())
k=0
while x<a:
  x=2**k
  k+=1
print(x)

Fixed submission:
a=int(input())
k=0
x=0
while x<=a:
  x=2**k
  k+=1
print(int(x/2))
Buggy python submission (verdict: Runtime Error):
n,c= [int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.sort()
a1=max(a)
s=a1
for a0 in a:
  s = min(s,abs(a0-a1))
  a1=a0
  
ma=max(a)
if s==0:
  print('IMPOSSIBLE')
if all([i % s==0 for i in a])==False:
  print('POSSIBLE')
else:
  while c<=ma:
    ma-=s
    if c==ma:
      print('POSSIBLE')
      break
  else:
    print('IMPOSSIBLE')

Fixed submission:
from fractions import gcd

n,c= [int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.sort()
b=a[0]
for i in range(1,n):
  b=gcd(b,a[i])

if c > a[n-1]:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE' if c % b==0 else "IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(i) for i in input().split()]
m=float("inf") 

for i in range(1,n):
  m = min(abs(sum(a[:i]) - sum(a[i:])),m)
print(int(m))


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

x=a[0]
y=sum(a[1:])
m=abs(x - y)

i=1

while i < n-1:
  x+=a[i]
  y-=a[i]
  m = min(abs(x - y),m)
  i+=1
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a=[]
c=1

for i in input().split():
  if c % 2 ==1:
    a=a+[i]
  else:
    a=[i]+a
  c+=1
  
if c % 2 ==1:
  print(*a)
else:
  print(*a[::-1])

Fixed submission:
n = int(input())
a=input().split()
l=n - n %2-1
e=[i for i in a[l::-2]]  
o=[i for i in a[::2]]
e.extend(o)
if n==1:
  print(*a)
elif n % 2 ==0:
  print(*e)
else:
  print(*e[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a=[]
c=1
p=1
for i in input().split():
  if c % 2 ==1:
    a=a+[i]
  else:
    a=[i]+a
  c+=1
  p=p*-1
  
print(*a[::p])


Fixed submission:
n = int(input())
a=input().split()
l=n - n %2-1
e=[i for i in a[l::-2]]  
o=[i for i in a[::2]]
e.extend(o)
if n==1:
  print(*a)
elif n % 2 ==0:
  print(*e)
else:
  print(*e[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
import math
n, a, b=[int(i) for i in input().split()]
ab=a-b
t=[int(input()) for i in range(n)]
mx = sum([i//a +1 for i in t])
mi = 1

while mx - mi > 1:
  i = (mx + mi) // 2
    
  ti= [j- i * b for j in t]
  if sum([max(math.ceil(j/ab),0) for j in ti]) <= i:
    mx = i
  else:
    mi = i
  
print(mx)

Fixed submission:
import math
n, a, b=[int(i) for i in input().split()]
ab=a-b
t=[int(input()) for i in range(n)]
mx = sum([i//a +1 for i in t])
mi = 1

while mx - mi > 1:
  i = (mx + mi) // 2
    
  if sum([max(math.ceil((j- i * b) /ab),0) for j in t ]) <= i:
    mx = i
  else:
    mi = i
  
print(mx)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n, a, b=[int(i) for i in input().split()]
ab=a-b
t=[int(input()) for i in range(n)]
mx = max(t)//b + 1
mi = 1

while mx-mi>=1:    
  i = (mx + mi) // 2
    
  ti= [j- i * b for j in t]
  if sum([max(math.ceil(j/ab),0) for j in ti]) <= i:
    mx=i
  else:
    mi=i
print(mx)

Fixed submission:
import math
n, a, b=[int(i) for i in input().split()]
ab=a-b
t=[int(input()) for i in range(n)]
mx = sum([i//a +1 for i in t])
mi = 1

while mx - mi > 1:
  i = (mx + mi) // 2
    
  if sum([max(math.ceil((j- i * b) /ab),0) for j in t ]) <= i:
    mx = i
  else:
    mi = i
  
print(mx)
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input())
print("#"*(w+2))
for i in range(h):
  print("#"+input().strip()+"#")
print("#"*(w+2))

Fixed submission:
h,w=map(int,input().split())
print("#"*(w+2))
for i in range(h):
  print("#"+input().strip()+"#")
print("#"*(w+2))
Buggy python submission (verdict: Runtime Error):
h, w=map(int,input().split())
m = h * w

if h % 3 == 0 or w % 3 == 0:
  print(0)
  exit()

def chk(h,w):
  a = m
  for i in range(1, h):
    l = i * w
    o = (h - i) // 2 * w
    g = m - l - o
    a = min(a, max(abs(l - o), abs(g - o), abs(g - l)))

  for i in range(1, h):
    l = i * w
    o = (h - i) * (w // 2)
    g = m - i - o
    a = min(a, max(abs(l - o), abs(g - o), abs(g - l)))

  return a

print(min(chk(h, w), cck(w, h)))


Fixed submission:
h, w = map(int,input().split())
m = h * w
  
def d(a,b,c):
  return max(abs(a - b), abs(b - c), abs(a - c))

def c(h,w):
  a = m
  for i in range(1, h):
    l = i * w
    y = (h - i) // 2 * w
    t = (h - i) * (w // 2)
    a = min(a, d(l, y , m - l - y), d(l, t, m - l - t))
  return a

print(min(c(h, w), c(w, h)))
Buggy python submission (verdict: Runtime Error):
a,b,c=[int(i) for i in input().split()]
print("YES" if a[-1]==b[0] and b[-1]== c[0] else "NO")

Fixed submission:
a,b,c=input().split()
print("YES" if a[-1]==b[0] and b[-1]== c[0] else "NO")
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print("YES" if b-a=c-b else "NO")


Fixed submission:
a,b,c=map(int,input().split())
print("YES" if b-a==c-b else "NO")
Buggy python submission (verdict: Runtime Error):
import numpy as np
n,m=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]

def kk(z):
  zk=[]
  zi=z[0]
  ns=0
  nl=len(z)
  
  for i in z:
    if zi!=i:
      zk.append(abs(i-zi) *(ns*(nl-ns))% (10**9 + 7))
    zi=i
    ns+=1
  return zk

nx=np.array(kk(x), dtype = 'int64').reshape(len(x)-1,1)
ny=np.array(kk(y), dtype = 'int64')
nxy=nx*ny
print((nxy.sum()) % (10**9 + 7))

Fixed submission:
I=lambda:[int(i)for i in input().split()]
n,m=I()
N=I()
M=I()
F=lambda x,y:sum(j*(y-1-2*i)for i,j in enumerate(x))
print(F(N,n)*F(M,m)%(10**9+7))