Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
  count=n*(n-1)//2
  countt=m*(m-1)//2
print(count+countt)


Fixed submission:
n,m=map(int,input().split())
if n==2:
  count=1
else:
  count=n*(n-1)//2
  
if m==2:
  countt=1
else:
  countt=m*(m-1)//2

print(count+countt)
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
count=0
a=(n-1)//2
b=(n+3)//2
for i in range(n//2):
  if s[i]!=s[-abs(i+1)]:
    count+=1
    
for i in range(a//2):
  c=ord(s[i])
  d=ord(s[(a-1-i)])
  if c!=d:
    count+=1

for i in range((n-b+1)//2):
  c=ord(s[n-i])
  d=ord(s[b-1+i])
  if c!=d:
    count+=1

if count!=0:
  print('No')
else:
  print('Yes')

Fixed submission:
s=input()
n=len(s)
count=0
a=(n-1)//2
b=(n+3)//2
for i in range(n//2):
  if s[i]!=s[-abs(i+1)]:
    count+=1
    
for i in range(a//2):
  c=ord(s[i])
  d=ord(s[(a-1-i)])
  if c!=d:
    count+=1

for i in range((n-b+1)//2):
  c=ord(s[-(i+1)])
  d=ord(s[b-1+i])
  if c!=d:
    count+=1

if count!=0:
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
l=int(input())
print({:.10d}.format(l/3))

Fixed submission:
l=int(input())
i=l/3
print(i**3)
Buggy python submission (verdict: Runtime Error):
s=str(input())
a=len(s)
b=[hi,hihi,hihihi,hihihihi,hihihihihi]
if a%2!=0:
  print('No')
elif s in b:
  print('Yes')
else:
  print('No')


Fixed submission:
s=str(input())
a=len(s)
b=['hi','hihi','hihihi','hihihihi','hihihihihi']
if a%2!=0:
  print('No')
elif s in b:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
s=str(input())
a=len(s)
if a%2!=0:
  print('No')
elif s=[hi,hihi,hihihi,hihihihi,hihihihihi]:
  print('Yes')
else:
  print('No')

Fixed submission:
s=str(input())
a=len(s)
b=['hi','hihi','hihihi','hihihihi','hihihihihi']
if a%2!=0:
  print('No')
elif s in b:
  print('Yes')
else:
  print('No')

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

for i in range(10):
  if s[i]=='h' and s[i+1]=='i':
    print('Yes')
    exit()
  
print('No')    
    

Fixed submission:
s=str(input())
a=len(s)
b=['hi','hihi','hihihi','hihihihi','hihihihihi']
if a%2!=0:
  print('No')
elif s in b:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
s=list(map(int,input().split()))

for i in range(10):
  if s[i]==h and a[i+1]==i:
    print('Yes')
    exit()
    
print('No')    
    

Fixed submission:
s=str(input())
a=len(s)
b=['hi','hihi','hihihi','hihihihi','hihihihihi']
if a%2!=0:
  print('No')
elif s in b:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,a,b=map(int,input().split())
count=0
if a==0:
  print('0')
  sys.exit()
else:
  while n>=a:
    n=n-a
    count+=1
    if n>=b:
      n=n-b
    elif n<b:
      n=0
ball=a*count+n
print(ball)

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

kosuu=n//(a+b)
amari=n%(a+b)

if a>amari:
  print(a*kosuu+amari)
else:
  print(a*kosuu+a)

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
count=0

if a==0:
  print('0')
  exit()
else:
  while n>=a:
    n=n-a
    count+=1
    if n>=b:
      n=n-b
    elif n<b:
      n=0

ball=a*count+n

print(ball)

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

kosuu=n//(a+b)
amari=n%(a+b)

if a>amari:
  print(a*kosuu+amari)
else:
  print(a*kosuu+a)

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
count=0

if a==0:
  print('0')
  exit()
else:
  while n>=a:
    n=n-a
    count+=1
    if n>=b:
      n=n-b
    elif n<b:
      n=0

ball=a*count+n

print(ball)

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

kosuu=n//(a+b)
amari=n%(a+b)

if a>amari:
  print(a*kosuu+amari)
else:
  print(a*kosuu+a)

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
count=0

if a==0:
  print('0')
  exit()
else:
  while n>=a:
    n=n-a
    count+=1
    if n>=b:
      n=n-b
    elif n<b:
      n=0
      

ball=a*count+n

print(ball)

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

kosuu=n//(a+b)
amari=n%(a+b)

if a>amari:
  print(a*kosuu+amari)
else:
  print(a*kosuu+a)
Buggy python submission (verdict: Runtime Error):
n=int(input())
x=list(map(int,input().split()))
count=0
max=0
min=0
sum=0

for i in range(n):
  count+=x[i]
  if max<x[i]:
    max=x[i]
  elif min>x[i]:
    min=x[i]
  num=max+min

p=round(count/round(num/2))

for i in range(0,n):
  power=(x[i]-p)**2
  sum+=power

print(sum) 

Fixed submission:
n=int(input())
x=list(map(int,input().split()))
x=sorted(x)
ans=10**8
count=0
for i in range(x[0],x[-1]+1):
  count=0
  for j in range(n):
    count+=(x[j]-i)**2
  if ans>count:
    ans=count
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N=input()
for i in range(N):
  A[i]=list(map(int,input().split()))

count=0
  
for i=0 in range(N):
  if A[i]%2==0:
    if A[i]%3==0 or A[i]%5==0:
      print('APPROVED')
      count=1
      break
  elif:
    continue
    
if count=0:
  print('DENIED')

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

lst=0
  
for i in range(N):
  if A[i]%2==0:
    if A[i]%3!=0 and A[i]%5!=0:
      lst+=1
      break

    
if lst==1:
  print('DENIED')
else:
  print('APPROVED')
Buggy python submission (verdict: Runtime Error):
s,t=list(map(str,input().split()))
a,b=list(map(int,input().split()))
u=str(input())

if s==u:
  a-=1
elif t==u:
  b-=1
  
print(a b)

Fixed submission:
s,t=list(map(str,input().split()))
a,b=list(map(int,input().split()))
u=str(input())

if s==u:
  a-=1
elif t==u:
  b-=1
  
print(a,b)
Buggy python submission (verdict: Runtime Error):
H,A=int(input().split())
count=0

while H>=0:
  H-=A
  count+=1

print(A)

Fixed submission:
H,A=map(int,input().split())
count=0

while H>0:
  H=H-A
  count+=1

print(count)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=[0]*10**9
h=list(map(int,input().split()))
H=max(h)

for i in range(k):
  H[i]=0

mon=0
for i in range(n):
  mon+=h[i]
  
print(mon)

Fixed submission:
n,k=map(int,input().split())
h=map(int,input().split())
h=sorted(h)
if n<=k:
  print('0')
  exit()
  
for i in range(k):
  h[-i-1]=0
print(sum(h))
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())
count=0
for i in range(n):
  if i<=48:
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      count+=1
    
print(count)

Fixed submission:
k,x=map(int,input().split())
k=k*500
if k>=x:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())
count=0

for i in range(n):
  if i<=48 :
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      count+=1
    
print(count)


Fixed submission:
n=int(input())
s=list(input())
count=0
for i in range(n-2):
  if i<=48 :
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      count+=1
    
print(count)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())
count=0
for i in range(n):
  if i<=48:
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      count+=1
    
print(count)


Fixed submission:
n=int(input())
s=list(input())
count=0
for i in range(n-2):
  if i<=48 :
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      count+=1
    
print(count)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())
count=0
for i in range(n):
  if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
    count+=1
    
print(count)

Fixed submission:
n=int(input())
s=list(input())
count=0
for i in range(n-2):
  if i<=48 :
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      count+=1
    
print(count)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())
count=0
for i in range(n):
  if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
    count+=1
    
print(count)

Fixed submission:
n=int(input())
s=list(input())
count=0
for i in range(n-2):
  if i<=48 :
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      count+=1
    
print(count)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input())

if a+b+c>=22:
  print('bust')
else:
  print('win')

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

if a+b+c>=22:
  print('bust')
else:
  print('win')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a<10 and b<10:
  print(a*b)
else:
  print('-1')

Fixed submission:
r=int(input())
print(r*r)
Buggy python submission (verdict: Runtime Error):
a,b=int(input())
if a<10 and b<10:
  print(a*b)
else:
  print('No')

Fixed submission:
a,b=map(int,input().split())
if a<10 and b<10:
  print(a*b)
else:
  print('-1')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
  for j in range(n):
    if a[j]==i:
      print(j+1,end=' ')

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
cou={}
for i in range(n):
  cou[a[i]]=i+1
b=sorted(cou.items())
for i in range(n):
  print(b[i][1],end=" ")

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
  for j in range(n):
    if a[j]==i:
      print(j+1,end=' ')

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
cou={}
for i in range(n):
  cou[a[i]]=i+1
b=sorted(cou.items())
for i in range(n):
  print(b[i][1],end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=0
for i in range(1,n):
  a+=i
print(a)

Fixed submission:
n=int(input())
print(n*(n-1)//2)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
ans=0
for i in range(1,n+1):
  a.append(i)
b=a.copy()
b.append(a[0])
del b[0]

for i in range(n):
  ans+=a[i]%b[i]
  
print(ans)

Fixed submission:
n=int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
  b=int(input())
  a.append(b)
s=a.copy()
for i in range(n):
  if s[i]==max(s):
    print(s[i])
  else:
    del s[i]
    print(max(s))

Fixed submission:
n=int(input())
a=[]
for i in range(n):
  b=int(input())
  a.append(b)
s=a.copy()
a=sorted(a,reverse=True)

if a[0]==a[1]:
  for i in range(n):
    print(a[0])
  exit()
for i in range(n):
  if s[i]==a[0]:
    print(a[1])
  else:
    print(a[0])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for i in range(n):
  b=int(input())
  a.append(b)
for i in range(n):
  s=a.copy()
  del s[i]
  print(max(s))

Fixed submission:
n=int(input())
a=[]
for i in range(n):
  b=int(input())
  a.append(b)
s=a.copy()
a=sorted(a,reverse=True)

if a[0]==a[1]:
  for i in range(n):
    print(a[0])
  exit()
for i in range(n):
  if s[i]==a[0]:
    print(a[1])
  else:
    print(a[0])
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
zen=int(b-a)
c=int(zen//c)
d=int(zen//d)
kasa=int(zen/(c*d))

ans=zen-c-d+kasa

print(ans)

Fixed submission:
import math
a,b,c,d=map(int,input().split())
count=b-a+1

A=a-1
l=c*d//math.gcd(c,d)
acou=(A//c)+(A//d)-int((A//l))
bcou=(b//c)+(b//d)-int((b//l))

print(count-(bcou-acou))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
count=0
s=[0]*(n+1)
 
for i in range(m):
  l,r=map(int,input().split())
  for j in range(l,r+1):
    s[j]+=1
    
for i in range(n+1):
  if s[i]==m:
    count+=1
    
print(count)

Fixed submission:
n,m=map(int,input().split())
L=1
R=n
for i in range(m):
  l,r=map(int,input().split())
  L=max(l,L)
  R=min(r,R)

if (R-L+1)>=0:
  print(R-L+1)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
n=int(input())
k=0
b=0
for i in range(n):
  x,u=input().split()
  x=float(x)

for i in range(n):
  if u[i]=='JPY':
    k+=x[i]
  else:
    b+=x[i]*380000
print(k+b)


Fixed submission:
n=int(input())
x=[0]*n
u=[0]*n
k=0
b=0
for i in range(n):
  x[i],u[i]=map(str,input().split())
  x[i]=float(x[i])

for i in range(n):
  if u[i]=='JPY':
    k+=x[i]
  else:
    b+=x[i]
    
b=b*380000
print(k+b)
Buggy python submission (verdict: Runtime Error):
n=int(input)
if n==1:
  print('Hello World')
else:
  a=int(input())
  b=int(input())
  print(a+b)

Fixed submission:
n=int(input())
if n==1:
  print('Hello World')
else:
  a=int(input())
  b=int(input())
  print(a+b)
Buggy python submission (verdict: Runtime Error):
n=int(input())
for i in range(27):
  for j in range(27):
    if 4*i+7*j==n:
      print('Yes')
      exit()
print('No')

Fixed submission:
n,k=map(int,input().split())
if n%k==0:
  print(0)
else:
  print(1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=1
for i in range(1,n+1):
  ans*=i
  
print(ans%(10**9+7))

Fixed submission:
n=int(input())
ans=1
for i in range(2,n+1):
  ans=(ans*i)%(10**9+7)
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=1
for i in range(1,n+1):
  ans*=i
  
print(ans%(10**9+7)) 

Fixed submission:
n=int(input())
ans=1
for i in range(2,n+1):
  ans=(ans*i)%(10**9+7)
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a=list(map(int,input().split()))
a.sort()
mid=1
ans=10**9
for i in range(2):
  mid*=a[i]
  
for i in range(1,a[-1]+1):
  b=mid*i
  c=mid*(a[-1]-i)
  sa=abs(b-c)
  if ans>sa:
    ans=sa
print(ans)

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

for i in range(3):
  if a[i]%2==0:
    print(0)
    exit()

a.sort()
ma=a[0]*a[1]
print(ma*(a[2]//2+1)-ma*(a[2]//2))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
res = 1
ls = input().split(' ')
for a in ls:
    res = res * int(a)

if res > 1000000000000000000:
    print(-1)
else:
    print(res)


Fixed submission:
n = int(input())
res = 1
ls = input().split(' ')
list.sort(ls)
if int(ls[0]) == 0:
    print(0)
    exit()
for a in ls:
    res = res * int(a)
    if res > 1000000000000000000:
        print(-1)
        exit()
print(res)

Buggy python submission (verdict: Runtime Error):
n = int(input())
res = 1
for i in range(n):
    a = int(input())
    res = res * a
    if res > 1000000000000000000:
        print(-1)
        exit()
print(res)

Fixed submission:
n = int(input())
res = 1
ls = input().split(' ')
list.sort(ls)
if int(ls[0]) == 0:
    print(0)
    exit()
for a in ls:
    res = res * int(a)
    if res > 1000000000000000000:
        print(-1)
        exit()
print(res)
Buggy python submission (verdict: Runtime Error):
import sys

x, n = map(int, input().split())
if n == 0:
    print(x)
    sys.exit()
else:
    p = list(map(int, input().split()))
if x == 1:
    print(0)
    sys.exit()

a = []
b = []

for i in range(1, 100):
    if i not in p:
        a.append(abs(x - i))
        b.append(i)
ans = min(a)
bb = a.index(ans)
print(b[bb])


Fixed submission:
import sys

x, n = map(int, input().split())
if n == 0:
    print(x)
    sys.exit()
else:
    p = list(map(int, input().split()))

a = []
b = []

for i in range(0, 102):
    if i not in p:
        a.append((x - i)**2)
        b.append(i)
ans = min(a)
bb = a.index(ans)
print(b[bb])
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 9)
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

for tt in range(1,t+1):
    res = (w - v) * tt + (b - a)
    if res == 0:
        print('YES')
        sys.exit()

print('NO')

Fixed submission:
s = str(input())
a = s[:3]
print(a)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 9)
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

# if a>=b or w>=v:
#     print('NO')
#     sys.exit()
for tt in range(1,t+1):
    res = (w - v) * tt + (b - a)
    if res == 0:
        print('YES')
        sys.exit()

print('NO')

Fixed submission:
s = str(input())
a = s[:3]
print(a)
Buggy python submission (verdict: Runtime Error):
a,b=map(float,input().split())
a=a
b=format(b,'2f')*100
c=int(a)*int(b)
print(c//100)

Fixed submission:
a,b=input().split()
a=a
b=b.replace('.','')
c=int(a)*int(b)
print(c//100)
Buggy python submission (verdict: Runtime Error):
T=str(input())
cnt=0
cc=[]
count=len(T)
for i in T:
    if i=='P':
        cnt=1
        cc.append('P')

    elif i=='D':
        cnt=0
        cc.append('D')
    else:
        if count == i:
            cc.append('D')

        elif cnt==1:
            cnt=0
            cc.append('D')
        else:
            cnt=1
            cc.append('?')

ccc=1
for i in cc:
    if i=='P':
        print('P',end='')
    elif i=='D':
        print('D',end='')
    else:
        if i==len(cc):
            print('D')
        elif cc[ccc]=='P':
            print('D',end='')
        else:
            print('P',end='')
    ccc+=1

Fixed submission:
T=str(input())
cnt=0
cc=[]
count=len(T)
for i in T:
    if i=='P':
        cnt=1
        cc.append('P')

    elif i=='D':
        cnt=0
        cc.append('D')
    else:
        if count == i:
            cc.append('D')

        elif cnt==1:
            cnt=0
            cc.append('D')
        else:
            cnt=1
            cc.append('?')

ccc=1
for i in cc:
    if i=='P':
        print('P',end='')
    elif i=='D':
        print('D',end='')
    else:
        if ccc==len(cc):
            print('D')
        elif cc[ccc]=='P':
            print('D',end='')
        else:
            print('P',end='')
    ccc+=1

Buggy python submission (verdict: Runtime Error):
T=str(input())
cnt=0
cc=[]
count=len(T)
for i in T:
    if i=='P':
        cnt=1
        cc.append('P')

    elif i=='D':
        cnt=0
        cc.append('D')
    else:
        if count == i:
            cc.append('D')

        elif cnt==1:
            cnt=0
            cc.append('D')
        else:
            cnt=1
            cc.append('?')

ccc=1
for i in cc:
    if i=='P':
        print('P',end='')
    elif i=='D':
        print('D',end='')
    else:
        if cc[ccc]=='P':
            print('D',end='')
        else:
            print('P',end='')
    ccc+=1

Fixed submission:
T=str(input())
cnt=0
cc=[]
count=len(T)
for i in T:
    if i=='P':
        cnt=1
        cc.append('P')

    elif i=='D':
        cnt=0
        cc.append('D')
    else:
        if count == i:
            cc.append('D')

        elif cnt==1:
            cnt=0
            cc.append('D')
        else:
            cnt=1
            cc.append('?')

ccc=1
for i in cc:
    if i=='P':
        print('P',end='')
    elif i=='D':
        print('D',end='')
    else:
        if ccc==len(cc):
            print('D')
        elif cc[ccc]=='P':
            print('D',end='')
        else:
            print('P',end='')
    ccc+=1
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
t=[0]*N
for idx,i in enumerate(N):
    t[i-1]=idx+1
    
    print(t[i],end=' ')

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
t=[0]*N
for idx,i in enumerate(A):
    t[i-1]=idx+1

print(*t)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
t=[0]*N
for i in range(N):
    t[i]=(A.index(i+1))+1

    print(t[i],end=' ')

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
t=[0]*N
for idx,i in enumerate(A):
    t[i-1]=idx+1

print(*t)
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
N=len(S)
s=[]
[s.append(i) for i in S]
cnt=0
cnt_o=10
while cnt!=cnt_o:
    cnt_o=cnt
    for i in range(N-1):
        if s[i]=='B' and s[i+1]=='W':
            cnt+=1
            s[i] = 'W'
            s[i+1]='B'

print(cnt)


Fixed submission:
s = input()

n = len(s)

ans = 0

cnt = 0

for i in range(n):
    if s[i] == "B":
        cnt += 1
    else:
        ans += cnt
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
h=sorted([int(input()) for _ in range(n)])
ans=10**9
for i in range(n-k+1):
    cnt=max(h[i:i+k])-min(h[i:i+k])
    ans=min(cnt,ans)
print(ans)

Fixed submission:
n,k=map(int,input().split())
h=sorted([int(input()) for _ in range(n)])
ans=10**9
for i in range(n-k+1):
    ans=min(h[k+i-1]-h[i],ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import  math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N,X=map(int,input().split())
x=list(sorted(map(int,input().split())))
diff=np.diff(x)
print(gcd_list(diff))


Fixed submission:
import  math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N,X=map(int,input().split())
x=sorted(list((map(int,input().split()))))
y=[abs(i-X) for i in x ]
print(gcd_list(y))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
# B = [0 for i in range(N + 1)]
B=[]
for a in A:
    B[a] += 1
# nums = [b for b in B if b > 0]
nums=B.sort()
n = len(nums)
print(0 if n<=K else sum(nums[:n - K]))

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0 for i in range(N + 1)]

for a in A:
    B[a] += 1
nums = [b for b in B if b > 0]
nums.sort()
n = len(nums)
print(0 if n<=K else sum(nums[:n - K]))

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
A=list(map(int,input().split()))
A_unq=set(A)
b=[]
for i in A_unq:
       b.append(A.count(i))
b.sort()
print('0' if k>=len(A_unq) else sum(b[:len(A_unq)-k]))

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0 for i in range(N + 1)]

for a in A:
    B[a] += 1
nums = [b for b in B if b > 0]
nums.sort()
n = len(nums)
print(0 if n<=K else sum(nums[:n - K]))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[int(input()) for _ in range(n)]
B=set(A)
ans=0
for i in B:
    c=A.count(i)
    ans+=c%2
print(ans)

Fixed submission:
n=int(input())
A=[int(input()) for _ in range(n)]
B={}
for i in A:
    if i in B:
        B[i]=(1+B[i])%2
    else:
        B[i]=1
print(sum(B.values()))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[]
for i in range(n):
    a=int(input())
    if a in A:
        del A[A.index(a)]
    else:
        A.append(a)
print(len(A))

Fixed submission:
n=int(input())
A=[int(input()) for _ in range(n)]
B={}
for i in A:
    if i in B:
        B[i]=(1+B[i])%2
    else:
        B[i]=1
print(sum(B.values()))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n=int(input())
a=deque(map(int,input().split()))
b=[]
for i in range(n):
    b.append(a.popleft())
    b=b[::-1]
print(*b)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
b=[0]*n
cnt=0
for i in range(n):
    if i%2==0:
        b[cnt]=A.pop()
        cnt+=1
    else:
        b[-cnt]=A.pop()

print(*b)
Buggy python submission (verdict: Runtime Error):
import numpy as np

W,H,N = map(int,input().split())
l = np.zeros((H,W)) 

for i in range(N):
  x,y,a = map(int,input().split())

  if a==1:
    l[:,:x] = 1
    #print(l[:,x:])
  elif a==2:
    l[:,x:] = 1
  elif a==3:
    l[:y,:] = 1
  elif a==4:
    l[y:,:] = 1
print(H*W-int(l.sum()))


Fixed submission:
W,H,N = map(int,input().split())
w = W*[1]
h = H*[1]

for n in range(N):
  x,y,a = map(int,input().split())
  if a == 1:
    w[:x] = x*[0]
  elif a == 2:
    w[x:] = (W-x)*[0]
  elif a == 3:
    h[:y] = y*[0]
  else:
    h[y:] = (H-y)*[0]

print(w.count(1)*h.count(1))