Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
count = 0
for i in range(Q):
    input_list = input().split()
    if input_list[0] == "1":
        count += 1
        continue

    if count % 2 == 0:  # even
        if input_list[1] == "1":
            S = input_list[2] + S
        else:
            S = S + input_list[2]
    else:
        if input_list[1] == "2":
            S = input_list[2] + S
        else:
            S = S + input_list[2]

if count % 2 == 0:
    print(S)
else:
    print(S[::-1])


Fixed submission:
from collections import deque

S = deque(input())
Q = int(input())
count = 0
for i in range(Q):
    input_list = input().split()
    if input_list[0] == "1":
        count += 1
        continue

    if count % 2 == 0:  # even
        if input_list[1] == "1":
            S.appendleft(input_list[2])
        else:
            S.append(input_list[2])
    else:
        if input_list[1] == "2":
            S.appendleft(input_list[2])
        else:
            S.append(input_list[2])

if count % 2 == 0:
    ans = ''.join(S)
    print(ans)
else:
    S.reverse()
    ans = ''.join(S)
    print(ans)
Buggy python submission (verdict: Runtime Error):
X = int(input())
ans = 0
tmp = str(X)
if len(tmp) >= 2:
    upper = int(tmp[:-2])
    under = int(tmp[-2:])
    if upper * 5 < under:
        ans = 0
    else:
        ans = 1
else:
    ans = 0

print(ans)

Fixed submission:
X = int(input())
ans = 0
tmp = str(X)
if len(tmp) > 2:
    upper = int(tmp[:-2])
    under = int(tmp[-2:])
    if upper * 5 < under:
        ans = 0
    else:
        ans = 1
else:
    ans = 0

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = "No"
if N % 2 == 0:
    x = N//2
    if s[:x] == s[x:]:
        ans = "Yes"

print(ans)

Fixed submission:
N = int(input())
S = input()
ans = "No"
if N % 2 == 0:
    x = N//2
    if S[:x] == S[x:]:
        ans = "Yes"

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
D_list = list(map(int, input().split()))
mod = 998244353
ans = 1
count_dir = collections.Counter(D_list)
if max(D_list) >= N:
    ans = 0
else:
    for i in range(max(D_list) + 1):
        if i not in D_list:
            ans = 0
            break
        if i >= 2:
            ans *= count_dir[i-1]**count_dir[i]

if D_list[0] != 0 or count_dir[0] >= 2:
    ans = 0

print(ans%mod)

Fixed submission:
N = int(input())
D_list = list(map(int, input().split()))
mod = 998244353
ans = 1
count_list = [0]*(max(D_list) + 1)
if max(D_list) >= N:
    ans = 0
else:
    for i in range(len(D_list)):
        count_list[D_list[i]] += 1
    if count_list[1] == 0:
        ans = 0
    else:
        for i in range(2, len(count_list)):
            if count_list[i] == 0:
                ans = 0
                break
            ans *= count_list[i-1]**count_list[i]

if D_list[0] != 0 or count_list[0] >= 2:
    ans = 0

print(ans%mod)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = "No"
for i in range(N):
    if N % i == 0:
        if int(N / i) == N // i and len(str(N // i)) == 1:
            ans = "Yes"

print(ans)

Fixed submission:
N = int(input())
ans = "No"
for i in range(1, 10):
    for j in range(1, 10):
        if N == i*j:
            ans = "Yes"
print(ans)
Buggy python submission (verdict: Runtime Error):
for i in range(int(N**0.5), 0, -1):
    if N % i == 0:
        x = i
        y = N // i
        break
print(x+y-2)

Fixed submission:
N = int(input())

for i in range(int(N**0.5), 0, -1):
    if N % i == 0:
        x = i
        y = N // i
        break
print(x+y-2)
Buggy python submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())

if abs(((a**2) * b) / 2 - x) < 1e-5:
    print(45)
elif ((a**2) * b) / 2 < x:
    atan = math.degrees(math.atan((a**3)/(2*b*(a**2) - 2*x)))
    print(90-atan)
else:
    atan = math.degrees(math.atan((2*x)/(a*(b**2))))
    print(90-atan)

Fixed submission:
import math
a, b, x = map(int, input().split())

if abs(((a**2) * b) / 2 - x) < 1e-2:
    print(45)
elif ((a**2) * b) == x:
    print(0)
elif ((a**2) * b) / 2 < x:
    atan = math.degrees(math.atan((a**3)/(2*b*(a**2) - 2*x)))
    print(90-atan)
else:
    atan = math.degrees(math.atan((2*x)/(a*(b**2))))
    print(90-atan)

Buggy python submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())
if ((a**2) * b) / 2 == x:
    print(45)
elif ((a**2) * b) / 2 < x:
    atan = math.degrees(math.atan((a**3)/(2*b*(a**2) - 2*x)))
    print(90-atan)
else:
    atan = math.degrees(math.atan((2*x)/(a*(b**2))))
    print(90-atan)

Fixed submission:
import math
a, b, x = map(int, input().split())

if abs(((a**2) * b) / 2 - x) < 1e-2:
    print(45)
elif ((a**2) * b) == x:
    print(0)
elif ((a**2) * b) / 2 < x:
    atan = math.degrees(math.atan((a**3)/(2*b*(a**2) - 2*x)))
    print(90-atan)
else:
    atan = math.degrees(math.atan((2*x)/(a*(b**2))))
    print(90-atan)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions

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


def sieve_of_eratosthenes(N):
    prime_list = [True for _ in range(N + 1)]
    prime_list[0] = False
    prime_list[1] = False
    for p in range(2, int(N ** 0.5) + 1):
        if prime_list[p]:
            for i in range(2 * p, N + 1, p):
                prime_list[i] = False

    return prime_list


gcd_ = fractions.gcd(a, b)
prime_list = sieve_of_eratosthenes(gcd_)
ans = 1
for i in range(1, gcd_+1):
    if gcd_ % i == 0:
        if prime_list[i]:
            ans += 1
print(ans)

Fixed submission:
import fractions


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


a, b = map(int, input().split())
gcd_ = fractions.gcd(a, b)
L = prime_factorize(gcd_)
print(len(list(set(L)))+1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans=0
ans = (n-1)*(n)//2
print(ians)

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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans=0
for i in range(1, n):
    ans += i
print(ans)
        


Fixed submission:
n = int(input())
ans=0
ans = (n-1)*(n)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
s = input()
count = 0
ans = 1 
for i, x in enumerate(s):
    if (i%2 == 0 and x == "B") or (i%2 == 1 and x == "W"): # B:1(R), W:0(L)
        count += 1
    else:
        ans *= count
        count -= 1
ans *= math.factorial(n)
if count != 0:
    print(0)
else:
    print(ans%(10**9+7))


Fixed submission:
n = int(input())
s = input()
count = 0
ans = 1 
for i, x in enumerate(s):
    if (i%2 == 0 and x == "B") or (i%2 == 1 and x == "W"): # B:1(R), W:0(L)
        count += 1
    else:
        ans *= count
        count -= 1
        ans %= (10**9+7)
if count != 0:
    print(0)
else:
    for i in range(1, n+1):
        ans *= i
        ans %= (10**9+7)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
sL = [] # B:1(R), W:0(L)
for i, x in enumerate(s):
    if i%2 == 0:
        if x == "W":
            sL.append(1)
        else:
            sL.append(0)
    if i%2 == 1:
        if x == "B":
            sL.append(1)
        else:
            sL.append(0)

count = 0
ans = 1
for i, x in enumerate(sL):
    if x==0:
        count += 1
    else:
        ans *= count
        count -= 1
for i in range(1, n+1):
    ans *= i     
if count != 0:
    print(0)
else:
    print(ans%(10**9+7))


Fixed submission:
n = int(input())
s = input()
count = 0
ans = 1 
for i, x in enumerate(s):
    if (i%2 == 0 and x == "B") or (i%2 == 1 and x == "W"): # B:1(R), W:0(L)
        count += 1
    else:
        ans *= count
        count -= 1
        ans %= (10**9+7)
if count != 0:
    print(0)
else:
    for i in range(1, n+1):
        ans *= i
        ans %= (10**9+7)
    print(ans)

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

n = int(input())
s = list(input())
sL = [] # B:1(R), W:0(L)
for i, x in enumerate(s):
    if i%2 == 0:
        if x == "W":
            sL.append(1)
        else:
            sL.append(0)
    if i%2 == 1:
        if x == "B":
            sL.append(1)
        else:
            sL.append(0)

count = 0
ans = 1
for i, x in enumerate(sL):
    if x==0:
        count += 1
    else:
        ans *= count
        count -= 1
ans *= math.factorial(n)
if count != 0:
    print(0)
else:
    print(ans%(10**9+7))

Fixed submission:
n = int(input())
s = input()
count = 0
ans = 1 
for i, x in enumerate(s):
    if (i%2 == 0 and x == "B") or (i%2 == 1 and x == "W"): # B:1(R), W:0(L)
        count += 1
    else:
        ans *= count
        count -= 1
        ans %= (10**9+7)
if count != 0:
    print(0)
else:
    for i in range(1, n+1):
        ans *= i
        ans %= (10**9+7)
    print(ans)
Buggy python submission (verdict: Runtime Error):
N,Q = map(int, input().split())
abL = [[int(x) for x in input().split()] for _ in range(N-1)]
tree = [[0]*(N+1) for _ in range(N+1)]
graph = [[] for _ in range(N+1)]
for a,b in abL:
    graph[a].append(b)
 
for a in range(N, 0, -1):
    incL = graph[a]
    for b in incL:
        for i in range(a):
            if a in graph[i]:
                graph[i].append(b)
    graph[a].append(a)
 
pxL = [[int(x) for x in input().split()] for _ in range(Q)]
 
for p,x in pxL:
    tmpL = graph[p]
    for b in tmpL:
        tree[p][b] += x
 
for i in range(1, N+1):
    sum_ = 0
    for j in range(1, N+1):
        sum_ += tree[j][i]
    print(sum_, end=" ")

Fixed submission:
a = int(input())
s = input()
if a>= 3200:
  print(s)
else:
  print("red")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
 
n = int(input())
aL = [list(set(Counter(input()).most_common())) for i in range(n)]
count = 0

for i in range(n-1):
    if aL[i] != "":  
      for j in range(i+1, n):
          if aL[i] == aL[j]:
            tmp = aL.count(aL[i])
            if tmp == 2:
              count += 1
            else:
              count += (tmp-1)*(tmp-2)//2
            aL = ["" if k == aL[i] else i for k in aL]
print(count)


Fixed submission:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
counter = Counter()
ans = 0
for s in S:
    a = ''.join(sorted(list(s)))
    if a in counter:
        ans += counter[a]
    counter[a] += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
aL = [set(Counter(input()).most_common()) for i in range(n)]
count = 0

for i in range(n-1):
    for j in range(i+1, n):
        if aL[i] == aL[j]:
            count +=1

print(count)

Fixed submission:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
counter = Counter()
ans = 0
for s in S:
    a = ''.join(sorted(list(s)))
    if a in counter:
        ans += counter[a]
    counter[a] += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
aL = [set(Counter(input()).most_common()) for i in range(n)]
count = 0

for i in range(n):
    for j in range(n):
        if i<j:
            if aL[i] == aL[j]:
                count +=1

print(count)

Fixed submission:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
counter = Counter()
ans = 0
for s in S:
    a = ''.join(sorted(list(s)))
    if a in counter:
        ans += counter[a]
    counter[a] += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
aL = [input() for i in range(n)]
count = 0

countL = [Counter(aL[i]).most_common() for i in range(n)] 

for i in range(n):
    for j in range(n):
        if i<j:
            if set(countL[i]) == set(countL[j]):
                count +=1

print(count)

Fixed submission:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
counter = Counter()
ans = 0
for s in S:
    a = ''.join(sorted(list(s)))
    if a in counter:
        ans += counter[a]
    counter[a] += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if 0<N<10:
  num = N

if 10=<N<100:
  num = 9

if 100=<N<1000:
  num = 9 + N - 99
  
if 1000=<N<10000:
  num = 9 + 900

if 10000=<N<100000:
  num = 909 + N - 9999

if N==100000:
  num=909+90000
  
print(num)

Fixed submission:
N = int(input())
if 0<N<10:
  num = N
 
if 10<=N<100:
  num = 9
 
if 100<=N<1000:
  num = 9 + N - 99
  
if 1000<=N<10000:
  num = 9 + 900
 
if 10000<=N<100000:
  num = 909 + N - 9999
 
if N==100000:
  num=909+90000
  
print(num)
Buggy python submission (verdict: Runtime Error):
import math
n, k = map(int, input().split())
mod = 10**9+7
for i in range(1, k+1):
    count = 0
    i_poss_count = math.factorial(n-k+1) \
                   // (math.factorial(n-k-i+1) * math.factorial(i))
    split_count = math.factorial(k-1) \
                  // (math.factorial(k-i) * math.factorial(i-1))
    count = i_poss_count * split_count
    print(count % mod)

Fixed submission:
import math
n, k = map(int, input().split())
mod = 10**9+7
for i in range(1, k+1):
    if i > n-k+1:
        print(0)
        continue
    count = 0
    i_pos_count = math.factorial(n-k+1) \
                   // (math.factorial(n-k-i+1) * math.factorial(i))
    split_count = math.factorial(k-1) \
                  // (math.factorial(k-i) * math.factorial(i-1))
    count = i_pos_count * split_count
    print(count % mod)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n, m = map(int, input().split())
A_list = list(map(int, input().split()))
B_list = [0]*m
C_list = [0]*m
for i in range(m):
    b, c = map(int, input().split())
    B_list[i] = b
    C_list[i] = c
heap = []
ans = 0
for a in A_list:
    heapq.heappush(heap, a)
for i in range(m):
    for _ in range(B_list[i]):
        min_ = heapq.heappop(heap)
        if min_ < C_list[i]:
            heapq.heappush(heap, C_list[i])
        else:
            heapq.heappush(heap, min_)
while heap:
    ans += heapq.heappop(heap)
print(ans)

Fixed submission:
n, m = map(int, input().split())
A_list = list(map(int, input().split()))
BC_list = []
for _ in range(m):
    BC_list.append(list(map(int, input().split())))
A_list.sort()
BC_list.sort(key=lambda x: x[1], reverse=True)
C_list = []
for i in range(m):
    for _ in range(BC_list[i][0]):
        if len(C_list) < n:
            C_list.append(BC_list[i][1])
        else:
            break
    else:
      continue
    break

for i in range(min(n, len(C_list))):
    if A_list[i] < C_list[i]:
        A_list[i] = C_list[i]
    else:
        break

ans = sum(A_list)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
move_num_list = [0]*5
for i in range(5):
    move_num_list[i] = int(input())

num_list = [0]*6
num_list[0] = N
time = 0
while sum(num_list) != 0:
    time += 1
    for i in range(4, -1, -1):
        num = move_num_list[i]
        if i == 4:
            if num_list[i] > 0:
                if num_list[i] >= num:
                    num_list[i] -= num
                else:
                    num_list[i] = 0
        if num_list[i] > 0:
            if num_list[i] >= num:
                num_list[i] -= num
                num_list[i+1] += num
            else:
                num_list[i+1] += num_list[i]
                num_list[i] = 0

print(time)

Fixed submission:
N = int(input())
move_num_list = [0]*5
for i in range(5):
    move_num_list[i] = int(input())

min_ = min(move_num_list)
print(-(-N//min_)+4)
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()
lr_list = [list(map(int, input().split())) for _ in range(q)]
pos_list = []

for i in range(n):
    if s[i] == "A":
        if s[i+1] == "C":
            pos_list.append(i+1)

cnt = 0
for i in range(q):
    cnt = 0
    for pos in range(lr_list[i][0], lr_list[i][1]):
        if pos in pos_list:
            cnt += 1
    print(cnt)

Fixed submission:
n, q = map(int, input().split())
s = input()
cnt_list = [0]*(n)
tmpi = 0
for i in range(1, n):
    if s[i-1] == "A":
        if s[i] == "C":
            cnt_list[i] = cnt_list[i-1] + 1
        else:
            cnt_list[i] = cnt_list[i-1]
    else:
        cnt_list[i] = cnt_list[i-1]

for i in range(q):
    l, r = map(int, input().split())
    print(cnt_list[r-1] - cnt_list[l-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = map(int, input().split())

A_set = set(A)
if len(A_set) == 1:
    print(A_set[0])
else:
    A = list(A_set)
    A = sorted(A)
    if (A[0] % 2 == 0) and (A[1] % 2 ==0):
        print("2")
    else:
        print("1")

Fixed submission:
import fractions

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

minA = A[0]

for i in A:
    minA = fractions.gcd(minA, i) 

print(minA)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
hL = list(map(int, input().split()))

dp = [10**10]*(n)
dp[0] = 0
for i in range(0,n):
    if i+k<=n-1:
        for j in range(1,k+1):
            dp[i+j] = min(dp[i+j], dp[i]+abs(hL[i+j]-hL[i]))
    else:
        for j in range(1, n-i):
            dp[i+j] = min(dp[i+j], dp[i]+abs(hL[i+j]-hL[i]))

print(dp[n-1])



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

dp = [10**10]*(n)
dp[0] = 0
for i in range(0,n):
    if i+k<=n-1:
        for j in range(1,k+1):
            dp[i+j] = min(dp[i+j], dp[i]+abs(hL[i+j]-hL[i]))
    else:
        for j in range(1, n-i):
            dp[i+j] = min(dp[i+j], dp[i]+abs(hL[i+j]-hL[i]))

print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))
hL = [0]*(10**5+k)
for i in range(n):
    hL[i] = h[i]

dp = [10**10]*(10**5+k)
dp[0] = 0
for i in range(0,n):
    for j in range(1,k+1):
        dp[i+j] = min(dp[i+j], dp[i]+abs(hL[i+j]-hL[i]))

print(dp[n-1])


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

dp = [10**10]*(n)
dp[0] = 0
for i in range(0,n):
    if i+k<=n-1:
        for j in range(1,k+1):
            dp[i+j] = min(dp[i+j], dp[i]+abs(hL[i+j]-hL[i]))
    else:
        for j in range(1, n-i):
            dp[i+j] = min(dp[i+j], dp[i]+abs(hL[i+j]-hL[i]))

print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int, input().split()))
hL = [0]*(n**5)
for i in range(n):
    hL[i] = h[i]

dp = [10**10]*(n**5)
dp[0] = 0
for i in range(0,n):
    for j in range(1,k+1):
        dp[i+j] = min(dp[i+j], dp[i]+abs(hL[i+j]-hL[i]))

print(dp[n-1])


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

dp = [10**10]*(n)
dp[0] = 0
for i in range(0,n):
    if i+k<=n-1:
        for j in range(1,k+1):
            dp[i+j] = min(dp[i+j], dp[i]+abs(hL[i+j]-hL[i]))
    else:
        for j in range(1, n-i):
            dp[i+j] = min(dp[i+j], dp[i]+abs(hL[i+j]-hL[i]))

print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
pL = [input() for i in range(n)]
print(int(sum(pL)-(max(pL)/2)))

Fixed submission:
n = int(input())
pL = [int(input()) for i in range(n)]
print(int(sum(pL)-(max(pL)/2)))

Buggy python submission (verdict: Runtime Error):
n = int(input())
pL = [input() for i in range(n)]
print(int(sum(pL)-(max(pL)/2))

Fixed submission:
n = int(input())
pL = [int(input()) for i in range(n)]
print(int(sum(pL)-(max(pL)/2)))

Buggy python submission (verdict: Runtime Error):
n = int(input())
pL = [input() for i in range(n)]
print(sum(pL)-max(pL)/2)

Fixed submission:
n = int(input())
pL = [int(input()) for i in range(n)]
print(int(sum(pL)-(max(pL)/2)))
Buggy python submission (verdict: Runtime Error):
import bisect

n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(m)]  # 市iの順番を保つ
py_list = [[] for _ in range(m)]  # 市iの(属する県, 誕生年)

for p, y in data:
    py_list[p-1].append(y)

for i in range(n):
    py_list[i].sort()

for p, y in data:
    pos = bisect.bisect_left(py_list[p-1], y) + 1
    print("%06d%06d" % (p, pos))

Fixed submission:
import bisect

n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(m)]  # 市iの順番を保つ
py_list = [[] for _ in range(n)]  # 市iの(属する県, 誕生年)

for p, y in data:
    py_list[p-1].append(y)

for i in range(n):
    py_list[i].sort()

for p, y in data:
    pos = bisect.bisect_left(py_list[p-1], y) + 1
    print("%06d%06d" % (p, pos))

Buggy python submission (verdict: Runtime Error):
import bisect

n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(m)]  # 市iの順番を保つ
py_list = [[] for _ in range(m)]  # 市iの(属する県, 誕生年)

for p, y in data:
    py_list[p-1].append(y)

for i in range(m):
    py_list[i].sort()

for p, y in data:
    pos = bisect.bisect_left(py_list[p-1], y) + 1
    print("%06d%06d" % (p, pos))

Fixed submission:
import bisect

n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(m)]  # 市iの順番を保つ
py_list = [[] for _ in range(n)]  # 市iの(属する県, 誕生年)

for p, y in data:
    py_list[p-1].append(y)

for i in range(n):
    py_list[i].sort()

for p, y in data:
    pos = bisect.bisect_left(py_list[p-1], y) + 1
    print("%06d%06d" % (p, pos))
Buggy python submission (verdict: Runtime Error):
import fractions

N, X = map(int, input().split())
x_list = list(map(int, input().split()))

if N == 1:
    if X < x_list[0]:
        x_list.insert(0, X)
    else:
        x_list.insert(1, X)
else:
    for i in range(N-1):
        if x_list[i] < X < x_list[i+1]:
            x_list.insert(i+1, X)

x_list.sort()

x_diff = [0]*N
for i in range(N):
    x_diff[i] = x_list[i+1] - x_list[i]

ans = x_diff[0]
for i in range(1, N):
    ans = fractions.gcd(ans, x_diff[i])
print(ans)

Fixed submission:
import fractions

N, X = map(int, input().split())
x_list = list(map(int, input().split()))

if N == 1:
    if X < x_list[0]:
        x_list.insert(0, X)
    else:
        x_list.insert(1, X)
else:
    for i in range(N-1):
        if x_list[i] < X < x_list[i+1]:
            x_list.insert(i+1, X)
        else:
            x_list.append(X)

x_list.sort()

x_diff = [0]*N
for i in range(N):
    x_diff[i] = x_list[i+1] - x_list[i]

ans = x_diff[0]
for i in range(1, N):
    ans = fractions.gcd(ans, x_diff[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
sL = [input() for i in range(h)]

ans = "Yes"

for y in range(h):
    for x in range(w):
        if sL[y][x] == ".":
            continue
        for dx, dy in dxy:
            if y-1 < 0 or y+1 > h-1 or x-1 < 0 or x+1 > w-1:
                continue
            if sL[y+1][x] == sL[y-1][x]  == sL[y][x+1] == sL[y][x-1] == ".":
                ans = "No"
                break

print(ans)

Fixed submission:
h, w = map(int, input().split())
sL = [input() for i in range(h)]

ans = "Yes"

for y in range(h):
    for x in range(w):
        if sL[y][x] == ".":
            continue
        if y-1 < 0 or y+1 > h-1 or x-1 < 0 or x+1 > w-1:
            continue
        if sL[y+1][x] == sL[y-1][x]  == sL[y][x+1] == sL[y][x-1] == ".":
            ans = "No"
            break

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
sL = [input() for i in range(n)]
m = int(input())
tL = [input() for i in range(m)]
L = list(set(sL))
maxnum = 0
for i in range(len(L)):
    num = max(0, max(sL.count(L[i])-tL.count(L[i])))
    if num > maxnum:
        maxnum = num
print(maxnum)

Fixed submission:
n = int(input())
sL = [input() for i in range(n)]
m = int(input())
tL = [input() for i in range(m)]
L = list(set(sL))
maxnum = 0
for i in range(len(L)):
    num = max(0, sL.count(L[i])-tL.count(L[i]))
    if num > maxnum:
        maxnum = num
print(maxnum)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
counter = 0

for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      x = 500*a + 100*b + 50*c
      if X == x:
        counter += 1

        
print(counter)

Fixed submission:
x = int(input())
a = int(input())
b = int(input())
print(x - a - b * ((x - a) // b))