Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02917 (python)

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

for i in range(N-1):
  if i == 0:
    A.append(B[i])
  elif B[i - 1] <= B[i]:
    A.append(B[i - 1])
  else:
    A.append(B[i])
if A[-1] <= B[N-2]:
  A.append(B[N-2])
else:
  A.append(A[-1])
print(sum(A))

Buggy submission (verdict: Runtime Error):
N = int(input())
B = list(map(int, input().split()))
A = []

for i in range(N-1):
  if i == 0:
    A.append(B[i])
  elif B[i - 1] <= B[i]:
    A.append(B[i - 1])
  else:
    A.append(B[i])
if B[N-3] <= B[N-2]:
  A.append(B[N-2])
else:
  A.append(B[N-1])
print(sum(A))
Problem p02923 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
ans = []
cnt = 0

for i in range(N - 1):
  if H[i] < H[i + 1]:
    ans.append(cnt)
    cnt = 0
  else:
    cnt += 1
ans.append(cnt)
print(max(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
ans = [] 
cnt = 0 

for i in range(N - 1):
  if H[i] < H[i + 1]:
    ans.append(cnt)
    cnt = 0
  else:
    cnt += 1
print(max(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
ans = []
cnt = 0

for i in range(N - 1):
  print(cnt)
  if H[i] < H[i + 1]:
    ans.append(cnt)
    cnt = 0
  else:
    cnt += 1
print(max(ans))
Problem p02953 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
ans = "Yes"
for i in range(0, N - 1):
  diff = H[i + 1] - H[i]
  if diff >= 1:
    H[i + 1] -= 1
  elif diff < 0:
    ans = "No"
print(ans)

Buggy submission (verdict: Runtime Error):
for i in range(N - 1):
  if H[i] > H[i + 1] and H[i] - 1 <= H[i + 1]:
    H[i] = H[i] - 1
  elif H[i] > H[i + 1] or H[i] < max:
    ans = "No"
  max = H[i + 1]
if sorted(H) != H:
  ans = "No"
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
ans = "Yes"
for i in range(N - 1):
  if H[i] > H[i + 1]:
    H[i] = H[i] - 1
    if H[i] > H[i + 1]:
      ans = "No"
    if max(H[:i]) != H[i]:
      ans = "No"
print(ans)
Problem p02958 (python)

Fixed submission:
N = int(input())
P = input().split()
P = [int(s) for s in P]
T = range(1, N+1)
count=[]
for i in range(N):
  if P[i] != T[i]:
    count.append(i)
if len(count) != 2 and len(count) != 0:
  print("NO")
elif len(count) == 0:
  print("YES")
else:
  P[count[0]], P[count[1]] = P[count[1]], P[count[0]]
  if list(T) == P:
    print("YES")
  else:
    print("NO")

Buggy submission (verdict: Runtime Error):
N = int(input())
P = input().split()
P = [int(s) for s in P]
T = range(1, N+1)
count=[]
for i in range(N):
  if P[i] != T[i]:
    count.append(i)
if len(count) != 2 and len(count) != 0:
  print("NO")
else:
  P[count[0]], P[count[1]] = P[count[1]], P[count[0]]
  if list(T) == P:
    print("YES")
  else:
    print("NO")
Problem p03000 (python)

Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=[0]*(n+1)
ans=0
for i in range(n):
  d[i+1]=d[i]+l[i]
for i in range(n+1):
  if d[i]<=x:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
d=[0]*(n+1)
ans=0
for i in range(n):
  d[i+1]=d[i]+int(input())
for i in range(n):
  if d[i]<=x:
    ans+=1
print(ans)
Problem p03379 (python)

Fixed submission:
n=int(input())
x=list(map(int,input().split()))
y=sorted(x)
a=y[n//2-1]
b=y[n//2]
for i in range(n):
  if x[i]<=a:
    print(b)
  else:
    print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
x=list(map(int,input().split()))
sorted_x=sorted(x)
for i in range(n):
  if x[i]<sorted_x[n//2]:
    print(x[n//2-1])
  else:
    print(x[n//2+1])

Buggy submission (verdict: Runtime Error):
n=int(input())
x=list(map(int,input().split()))
indices = [*range(len(x))]
index = sorted(indices, key=lambda i: x[i])
x.sort()
ans=[]
for i in range(n):
  if i < n//2:
    ans.append(x[(n//2)+1])
  else:
    ans.append(x[(n//2)-1])
for i in range(n):
  j=index.index(i)
  print(ans[j])
Problem p03427 (python)

Fixed submission:
n=list(map(int,input()))
s=sum(n)
k=len(n)
print(max((n[0]-1)+9*(k-1),s))

Buggy submission (verdict: Runtime Error):
n=list(map(int,input()))
s=sum(n)
k=len(n)
print(max(n[0]-1)+9*(k-1),s))

Buggy submission (verdict: Runtime Error):
n=list(map(int,input()))
s=sum(n)
k=len(n)
print(max(n[0]-1)+9*(k-1),s)
Problem p03448 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      tmp = i * 500 + j * 100 + k * 50
      if tmp == x:
        ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(a):
  for j in range(b):
    for k in range(c:
      tmp = i * 500 + j * 100 + k * 50
      if tmp == x:
        ans+=1

print(ans)
Problem p03486 (python)

Fixed submission:
s=sorted(input())
t=sorted(input(),reverse=True)
print("Yes" if s<t else "No")

Buggy submission (verdict: Runtime Error):
import string
s=input()
t=input()
a=string.ascii_lowercase
cnt1=0
for i in range(len(s)):
  n = a.find(s[i])
  if cnt1 < n:
    cnt1 = n

cnt2=0
for i in range(len(t)):
  n = a.find(s[i])
  if cnt2 < n:
    cnt2 = n
if cnt1 < cnt2:
  print("Yes")
else:
  print("No")
Problem p03493 (python)

Fixed submission:
s=list(input())
print(s.count("1"))

Buggy submission (verdict: Runtime Error):
a = int(input())
b, c = map(int, input().split())
s = input()
print("{} {}".format(a+b+c, s))
Problem p03574 (python)

Fixed submission:
h,w=map(int,input().split())
list1=[[0 for i in range(w)]for j in range(h)]
list2=[[0 for i in range(w)]for j in range(h)]
dx=[-1,-1,-1,0,0,1,1,1]
dy=[-1,0,1,-1,1,-1,0,1]
for j in range(h):
 s=input()
 for i in range(w):
  list1[j][i]=s[i]
for j in range(h):
  for i in range(w):
   if list1[j][i]=="#":
    for k in range(8):
     xk=i+dx[k]
     yk=j+dy[k]
     if xk>=0 and xk<w and yk>=0 and yk<h:
      list2[yk][xk]+=1
for j in range(h):
  for i in range(w):
    if list1[j][i]=="#":
      list2[j][i]="#"
    else:
      list2[j][i]=str(list2[j][i])
for j in range(h):
 print("".join(list2[j]))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
list2=[[0 for i in range(w)]for j in range(h)]
list1 =  [input().split() for _ in range(w)]
dx=[-1,-1,-1,0,0,1,1,1]
dy=[-1,0,1,-1,1,-1,0,1]
for j in range(h):
  for i in range(w):
   if list1[j][i]=="#":
    for k in range(8):
     xk=i+dx[k]
     yk=j+dy[k]
     if xk>=0 and xk<w and yk>=0 and yk<h:
      list2[yk][xk]+=1
for j in range(h):
  for i in range(w):
    if list1[j][i]=="#":
      list2[j][i]="#"
    else:
      list2[j][i]=str(list2[j][i])
for j in range(h):
 print("".join(list2[j]))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
list2=[[0 for i in range(w)]for j in range(h)]
list1 =  [input().split() for _ in range(h)]
dx=[-1,-1,-1,0,0,1,1,1]
dy=[-1,0,1,-1,1,-1,0,1]
for j in range(h):
  for i in range(w):
   if list1[j][i]=="#":
    for k in range(8):
     xk=i+dx[k]
     yk=j+dy[k]
     if xk>=0 and xk<w and yk>=0 and yk<h:
      list2[yk][xk]+=1
for j in range(h):
  for i in range(w):
    if list1[j][i]=="#":
      list2[j][i]="#"
    else:
      list2[j][i]=str(list2[j][i])
for j in range(h):
 print("".join(list2[j]))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
list2=[[0 for i in range(w)]for j in range(h)]
list1 =  [for _ in range(h) input().split()[]
dx=[-1,-1,-1,0,0,1,1,1]
dy=[-1,0,1,-1,1,-1,0,1]
for j in range(h):
  for i in range(w):
   if list1[j][i]=="#":
    for k in range(8):
     xk=i+dx[k]
     yk=j+dy[k]
     if xk>=0 and xk<w and yk>=0 and yk<h:
      list2[yk][xk]+=1
for j in range(h):
  for i in range(w):
    if list1[j][i]=="#":
      list2[j][i]="#"
    else:
      list2[j][i]=str(list2[j][i])
for j in range(h):
 print("".join(list2[j]))
Problem p03606 (python)

Fixed submission:
N=int(input())
cnt = [0]*100002
for i in range(N):
  l, r = map(int, input().split())
  for j in range(l, r+1):
    cnt[j]=1
print(sum(cnt))

Buggy submission (verdict: Runtime Error):
N=int(input())
cnt = [0]*100000
for i in range(N):
  l, r = map(int, input().split())
  for j in range(l, r+1):
    cnt[j]=1
print(sum(cnt))

Buggy submission (verdict: Runtime Error):
N=int(input())
cnt = [0]*100000
for i in range(N):
  l, r = map(int, input().split())
  for j in range(l, r+1):
    cnt[j]+=1
print(sum(cnt))
Problem p03607 (python)

Fixed submission:
n = int(input())
d = set()
for i in range(n):
    a = int(input())
    if a in d:
        d.remove(a)
    else:
        d.add(a)
print(len(d))

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=[0]*1000000002
for i in range(n):
  num=int(input())
  if ans[num] == 0:
    ans[num]+=1
  else:
    ans[num]=0
print(sum(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=[0]*100002
for i in range(n):
  num=int(input())
  if ans[num] == 0:
    ans[num]+=1
  else:
    ans[num]=0
print(sum(ans))
Problem p03611 (python)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
cnt = [0]*100002
for a in A:
  cnt[a-1]+=1
  cnt[a]+=1
  cnt[a+1]+=1
print(max(cnt))

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
cnt = [0]*100002
for a in A:
  cnt[a-1]+=1
  cnt[a]+=1
  cnt[a+1]+=1
print(max(cnt)
Problem p03612 (python)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n-1):
  if i+1 == p[i]:
    p[i+1]=p[i]
    cnt+=1
if p[n-1] == n:
  cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n):
  if i+1 == p[i]:
    p[i+1]=p[i]
    cnt+=1
print(cnt)
Problem p03625 (python)

Fixed submission:
c={}
input()
for i in list(map(int,input().split())):
    if i in c:
        c[i]+=1
    else:
        c[i]=1
d=[i for i in c.items() if i[1]>1]
c=sorted(d)
if len(d)==0 or (len(d)==1 and c[-1][1]<4):
    print(0)
else:
    if c[-1][1]>3:
        print(c[-1][0]**2)
    else:
        print(c[-1][0]*c[-2][0])

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
c=[0]*(n+1)
for i in A:
  c[i] += 1
cnt=0
ans=0
for j in reversed(range(n)):
  if c[j]>=2 and cnt==0:
    ans=j
    cnt+=1
  elif c[j]>= 2 and cnt==1:
    ans*=j
    break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
C=[0]*(n+1)
for i in A:
  C[i] += 1
cnt=0
ans=0
for j in reversed(range(n)):
  if C[j]>=2 and cnt==0:
    ans=j
    cnt+=1
  elif C[j]>= 2 and cnt==1:
    ans*=j
    break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=[0]*(n+1)
for i in list(map(int, input().split())):
  A[i] += 1
cnt=0
ans=0
for j in reversed(range(n)):
  if A[j]>=2 and cnt==0:
    ans=j
    cnt+=1
  elif A[j]>= 2 and cnt==1:
    ans*=j
    break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=[0]*(n+1)
for i in list(map(int, input().split())):
  A[i] += 1
cnt=0
ans=0
for j in reversed(range(n)):
  if A[j]>=2 and cnt==0:
    ans=j
    cnt+=1
  elif A[j]>= 2 and cnt==1:
    ans*=j
    break
print(ans)
Problem p03633 (python)

Fixed submission:
n=int(input())
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

def lcm(a, b):
  return (a * b) // gcd(a, b)
num = 1
for i in range(n):
  num = lcm(num, int(input()))

print(num)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
def lcm(a, b):
  return (a * b) // math.gcd(a, b)
num = 1
for i in range(n):
  num = lcm(num, int(input()))

print(num)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
n=int(input())
T=[int(input())for _ in range(n)]
def lcm(a, b):
  return (a * b) // math.gcd(a, b)

def lcm_list(num):
  return reduce(lcm, num, 1)

print(lcm_list(T))
Problem p03651 (python)

Fixed submission:
from fractions import gcd
n,k=map(int,input().split())
A=list(map(int,input().split()))
ans=""
if max(A)<k:
  ans="IMPOSSIBLE"
elif k in A:
  ans="POSSIBLE"
else:
  g=gcd(A[0], A[1])
  for i in range(2,n):
    g=gcd(g,A[i])
  if g!=0 and k%g==0:
    ans="POSSIBLE"
  else:
    ans="IMPOSSIBLE"
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
n,k=map(int,input().split())
A=list(map(int,input().split()))
ans=""
if max(A)<k:
  ans="IMPOSSIBLE"
elif k in A:
  ans="POSSIBLE"
else:
  g=gcd(A[0], A[1])
  for i in range(2,n):
    g=gcd(g,A[i])
  if g!=0 and k%g==0:
    ans="POSSIBLE"
  else:
    ans="IMPOSSIBLE"
print(ans)
Problem p03681 (python)

Fixed submission:
from math import factorial
n,m=map(int,input().split())
MOD=10**9+7
if abs(n-m)>1:
  print(0)
elif abs(n-m)==1:
  print(factorial(n)*factorial(m)%MOD)
else:
  print(2*factorial(n)*factorial(m)%MOD)

Buggy submission (verdict: Runtime Error):
from math import factorial
n,m=map(int,input().split())
mod=10**9+7
f=factorial(n)
if abs(n-m)>1:
  print(0)
elif abs(n-m)==1:
  print((f**2)%mod)
else :
  print((2*f**2%mod)
Problem p03695 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
c = 0
s = set()

for a in A:
  if a >= 3200:
    c += 1
  else:
    s.add(a//400)
print(max(1, len(s)), len(s) + c)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
c = 0
s = set()

for a in A:
  if a >= 3200:
    c += 1
  else:
    s.add(a//400
print(max(1, len(s)), len(s) + c)
Problem p03699 (python)

Fixed submission:
N = int(input())
S = [int(input()) for _ in range(N)]
total = sum(S)
if total % 10 != 0:
  print(total)
else:
  num = [n for n in S if n % 10 != 0]
  if len(num) == 0:
    print(0)
  else:
    print(total - min(num))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [int(input()) for _ in range(N)]
S.sort(reverse=True)
ans = sum(S)
while (ans % 10) == 0:
  ans -= S.pop(0)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [int(input()) for _ in range(N)]
S.sort()
ans = sum(S)
while (ans % 10) == 0:
  ans -= S.pop(0) 
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [int(input()) for _ in range(N)]
sorted(S, reverse=True)
ans = sum(S)
while (ans % 10) == 0:
  ans -= S.pop(0)
print(ans)
Problem p03828 (python)

Fixed submission:
N = int(input())
MOD = 10 ** 9 + 7
x = 1
for i in range(2, N + 1):
  x *= i

count = 1
ans = 1
for i in range(2, N + 1):
  if x % i != 0:
    continue
  count = 1
  while x % i == 0:
    x //= i
    count += 1
  ans *= count
print(ans % MOD)

Buggy submission (verdict: Runtime Error):
N = int(input())
MOD = 10 ** 9 + 7
x = 1
for i in range(2, N + 1):
  x *= i

count = 1
for i in range(2, N + 1):
  if x % i != 0:
    continue
  count = 1
  while x % i == 0:
    x //= i
    count += 1
  ans *= count
print(ans % MOD)
Problem p03543 (python)

Fixed submission:
# run on python 3.4.3
from sys import stdin


def main():
    n = list(stdin.readline().strip())
    s0 = set()
    s1 = set()
    for i in range(3):
        s0.add(n[i])
    for i in range(1, 4):
        s1.add(n[i])
    ans = len(s0) == 1 or len(s1) == 1
    print(['No', 'Yes'][ans])


main()

Buggy submission (verdict: Runtime Error):
# run on python 3.4.3
from sys import stdin


def main():
    digits = map(int, stdin.readline())
    dict = {}
    for digit in digits:
        dict[digit] = 1 + dict.get(digit, 0)
    ans = 3 <= max(dict.values())
    print(['No', 'Yes'][ans])


main()
Problem p02946 (python)

Fixed submission:
K,X=map(int,input().split())
print(*[x for x in range(X-K+1,X+K)])

Buggy submission (verdict: Runtime Error):
K,X=map(int(),input().split())
print(*[x for x in range(X-K+1,X+K)])

Buggy submission (verdict: Runtime Error):
K,X=map(int,input().split())
print(*[x for x in range(X-K+1,X+K)]
Problem p03470 (python)

Fixed submission:
a=[int(input()) for i in range(int(input()))]
print(len(set(a)))

Buggy submission (verdict: Runtime Error):
a=[int(input()) for i range(int(input()))]
print(len(set(a)))
Problem p03636 (python)

Fixed submission:
s=input()
print(s[0]+str(len(s)-2)+s[-1])

Buggy submission (verdict: Runtime Error):
s=input()
print(s[0]+int(len(s)-2)+s[-1])
Problem p03777 (python)

Fixed submission:
a,b=input().split()
if a=="H":
  print(b)
else:
  if b=="H":
    print("D")
  else:
    print("H")

Buggy submission (verdict: Runtime Error):
a,b=input().split()
if a=H:
  print(b)
else:
  if b=H:
    print(D)
  else:
    print(H)
Problem p04011 (python)

Fixed submission:
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n>k:
  print(x*k+y*(n-k))
else:
  print(n*x)

Buggy submission (verdict: Runtime Error):
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n>k:
  print(x*k+y*(n-k)
else:
  print(x*n)

Buggy submission (verdict: Runtime Error):
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n>k:
  print(x*k+y*(n-k)
else:
        print(x*n)
Problem p03448 (python)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

counter = 0

N_maxA = min( int(X // 500), A )

for i in range(N_maxA + 1):
	Res = X - (i * 500)
	N_maxB = min( int(Res // 100) , B )
	
	for j in range(N_maxB + 1):
		Res1 = Res - j*100
		if int(Res1 // 50) <= C:
			
			counter += 1

print(counter)

Buggy submission (verdict: Runtime Error):
import comb

A = int(input())*500//50
B = int(input())*100//50
C = int(input())*50//50
X = int(input())//50

#Aが最大何ユニット使えるかを調べる

if A == 0:
	Max_A = 0

else:
	Max_A = X // 10


counter = 0
# H = 0

for i in range(Max_A + 1):
	res_X = X - 10*i
	## B, Cだけで埋めていく
	if B == 0:
		Max_B = 0
	else:
		Max_B = res_X // 2
	for  j in range(min(Max_B + 1, B//2 + 1)):
		res_X = X - 10*i - 2*j

		# print(Max_A,Max_B,i,j,res_X,C, res_X <= C)
		# H += 1

		if res_X <= C:
			counter += 1
		# # if res_X > C:
		# # 	continue
		# # #二項係数の計算　Aのユニット数はA//10　Bのユニット数はB//10　Cはそのまま
		# # else:
		# 	counter += 1
		# 	# counter += comb.comb(A//10, i)*comb.comb(B//2, j)*comb.comb(C, res_X)
			# print(comb.comb(A//10, i)*comb.comb(B//2, j)*comb.comb(C, res_X), 
				# comb.comb(A//10, i), comb.comb(B//2, j), comb.comb(C, res_X))


print(int(counter))
# print(H)
Problem p03030 (python)

Fixed submission:
n = int(input())
city_score = {}
for i in range(n):
    city, score = input().split()
    city_score[city] = city_score.get(city, []) + [(int(score), i)]

for city in sorted(city_score.keys()):
  for score in sorted(city_score[city], reverse=True):
    print(score[1]+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
city_score = {}
for i in range(n):
	city, score = input.split()
    city_score[city] = city_score.get(city, []). + [(int(score), i)]

for city in sorted(city_score.keys()):
  for score in sorted(city_score[city]):
    print(score[1])
Problem p03076 (python)

Fixed submission:
ans = 0
used = False
mins = [int(input()) for _ in range(5)]
maa = list(map(lambda x:(x%10, x), filter(lambda x:x%10, mins)))
m = (0,0) if len(maa) == 0 else sorted(maa)[0]
for menu in mins:
  if used==False and menu==m[1]:
    used=True
    continue
  ans += (menu//10)*10 + 10*(menu%10>0)
print(ans + m[1])

Buggy submission (verdict: Runtime Error):
ans = 0
used = False
mins = [int(input()) for _ in range(5)]
m = min(map(lambda x:(x%10, x), filter(lambda x:x%10, mins)))
for menu in mins:
  if used==False and menu==m[1]:
    continue
  ans += (menu//10)*10 + 10*(menu%10>0)
print(ans + m[1])
Problem p03262 (python)

Fixed submission:
from fractions import gcd

N, X = map(int, input().split())
xs = list(map(int, input().split()))
xs.append(X)
xs = sorted(xs)
m = 999999999999999999
diffs = []
for idx,e in enumerate(xs):
  if idx==0:
    continue
  diff = abs(e - xs[idx-1])
  diffs.append(diff)
diffs = sorted(diffs)
for idx,dif in enumerate(diffs):
  if idx == 0:
    continue
  if gcd(diffs[idx], diffs[idx-1]) < m:
    m = gcd(diffs[idx], diffs[idx-1])
if len(diffs) == 1:
  m = diffs[0]
print(m)

Buggy submission (verdict: Runtime Error):
from math import gcd

N, X = map(int, input().split())
xs = list(map(int, input().split()))
xs.append(X)
xs = sorted(xs)
m = 999999999999999999
diffs = []
for idx,e in enumerate(xs):
  if idx==0:
    continue
  diff = abs(e - xs[idx-1])
  diffs.append(diff)
diffs = sorted(diffs)
for idx,dif in enumerate(diffs):
  if idx == 0:
    continue
  if gcd(diffs[idx], diffs[idx-1]) < m:
    m = gcd(diffs[idx], diffs[idx-1])
if len(diffs) == 1:
  m = diffs[0]
print(m)

Buggy submission (verdict: Runtime Error):
from fraction import gcd

N, X = map(int, input().split())
xs = list(map(int, input().split()))
xs.append(X)
xs = sorted(xs)
m = 999999999999999999
diffs = []
for idx,e in enumerate(xs):
  if idx==0:
    continue
  diff = abs(e - xs[idx-1])
  diffs.append(diff)
diffs = sorted(diffs)
for idx,dif in enumerate(diffs):
  if idx == 0:
    continue
  if gcd(diffs[idx], diffs[idx-1]) < m:
    m = gcd(diffs[idx], diffs[idx-1])
print(m)

Buggy submission (verdict: Runtime Error):
from math import gcd

N, X = map(int, input().split())
xs = list(map(int, input().split()))
xs.append(X)
xs = sorted(xs)
m = 999999999999999999
diffs = []
for idx,e in enumerate(xs):
  if idx==0:
    continue
  diff = abs(e - xs[idx-1])
  diffs.append(diff)
diffs = sorted(diffs)
for idx,dif in enumerate(diffs):
  if idx == 0:
    continue
  if gcd(diffs[idx], diffs[idx-1]) < m:
    m = gcd(diffs[idx], diffs[idx-1])
print(m)
Problem p03316 (python)

Fixed submission:
N = input()
SN = sum(map(int, list(N)))
print('Yes' if int(N)%SN == 0 else 'No')

Buggy submission (verdict: Runtime Error):
N = input()
SN = sum(map(int, list(N)))
print('Yes' if N%SN == 0 else 'No')
Problem p03323 (python)

Fixed submission:
A, B = map(int, input().split())
if A < 9 and B < 9:
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if A < 9 and B < 9:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if a < 9 and b < 9:
  print('Yay!')
else:
  print(':(')
Problem p03425 (python)

Fixed submission:
import itertools as it

def c(n,k):
  if k>n:
    return 0
  ret = 1
  for i in range(n, n-k, -1):
    ret *= i
  for i in range(k, 1, -1):
    ret /= i
  return ret


n = int(input())
dic = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
for person in range(n):
  name = input()
  if name[0] in 'MARCH':
    dic[name[0]] += 1

answer = 0
for a,b,c in it.combinations('MARCH', 3):
  answer += dic[a] * dic[b] * dic[c]
print(answer)

Buggy submission (verdict: Runtime Error):
import itertools as it

def c(n,k):
  if k>n:
    return 0
  ret = 1
  for i in range(n, n-k, -1):
    ret *= i
  for i in range(k, 1, -1):
    ret /= i
  return ret


n = int(input())
dic = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
for person in range(n):
  name = input()
  if name[0] in 'MARCH':
    dic[name[0]] += 1

answer = 0
for a,b,c = it.combinations('MARCH', 3):
  answer += dic[a] * dic[b] * dic[c]
print(answer)
Problem p03633 (python)

Fixed submission:
def gcd(a, b):
    if b>a:
        a,b = b,a
    if b==0:
        return a
    return gcd(b, a%b)

N = int(input())
ret = 1
for i in range(N):
    hoge = int(input())
    ret = (ret * hoge)//gcd(ret, hoge)
print(ret)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if min(a,b) == 0:
        return max(a,b)
    if a==b:
        return a
    if b>a:
        a,b = b,a
    return gcd(b, a%b)

N = int(input())
ret = 1
for i in range(N):
    hoge = int(input())
    ret = int((ret * hoge)/gcd(ret, hoge))
print(ret)

Buggy submission (verdict: Runtime Error):
from math import gcd

N = int(input())
ret = 1
for i in range(N):
    hoge = int(input())
    ret = int((ret * hoge)/gcd(ret, hoge))
print(ret)
Problem p03643 (python)

Fixed submission:
print('ABC' + input())

Buggy submission (verdict: Runtime Error):
print('ABC' input())