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

Fixed submission:
N = int(input())

data = [[] for _ in range(N+1)]

for i in range(N-1):
    a, b, c = map(int, input().split())

    data[a].append((b,c))
    data[b].append((a,c))


ans = [0] * (N+1)
went = [False] * (N+1)

went[0] = True
went[1] = True
go = [1]

while len(go) > 0:
    before = go.pop()
    for i, c in data[before]:
        if not went[i]:
            went[i] = True
            if c % 2 == 0:
                ans[i] = ans[before]
            else:
                ans[i] = 1 - ans[before]
            go.append(i)

for i in range(1, N+1):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
N = int(input())

data = [[] for _ in range(N+1)]

for i in range(N-1):
    a, b, c = map(int, input().split())

    data[a].append((b,c))
    data[b].append((a,c))


ans = [0] * (N+1)
went = [False] * (N+1)

went[0] = True
went[1] = True
before = 1

def f(before):
    for i, c in data[before]:
        if not went[i]:
            went[i] = True
            if c % 2 == 0:
                ans[i] = ans[before]
            else:
                ans[i] = 1 - ans[before]
            return f(i)
    return

f(1)

for i in range(1, N+1):
    print(ans[i])
Problem p03128 (python)

Fixed submission:
N, M = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=1)
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [0] * (N+1)

for i in range(1, N+1):
    now = - 10 ** 9
    for aa in a:
        if i - num[aa] >= 0:
            now = max(now, dp[i-num[aa]]+1)
    dp[i] = now

answer = ''
for i in range(dp[-1]):
    for aa in a:
        if N >= num[aa]:
            if dp[N-num[aa]] == dp[N] - 1:
                answer += str(aa)
                N -= num[aa]
                break
print(answer)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=1)
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [0] * (N+1)

for i in range(1, N+1):
    now = - 10 ** 9
    for aa in a:
        if i - num[aa] >= 0:
            now = max(now, dp[i-num[aa]]+1)
    dp[i] = now

answer = ''
for i in range(dp[-1]):
    for aa in a:
        if dp[N-num[aa]] == dp[N] - 1:
            answer += str(aa)
            N -= num[aa]
            break
print(answer)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=1)
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [0] * (N+1)

for i in range(1, N+1):
    now = - 10 ** 18
    for aa in a:
        if i - num[aa] >= 0:
            now = max(now, dp[i-num[aa]]+1)
    dp[i] = now

answer = ''
for i in range(dp[-1]):
    for aa in a:
        if dp[N-num[aa]] == dp[N] - 1:
            answer += str(aa)
            N -= num[aa]
            break
print(answer)
Problem p03192 (python)

Fixed submission:
N = str(input())

print(N.count('2'))

Buggy submission (verdict: Runtime Error):
import math

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

now_max = 1

for i in range(round(math.pow(P, 1 / N)) + 1, 0, -1):
    if P % (i ** N) == 0:
        now_max = i
        break

print(now_max)

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

now = 1

x = 2
while P >= x ** N:
    while P % (x ** N) == 0:
        now *= x
        P = P / (x ** N)
    while P % x == 0:
        P = P / x
    x += 1

print(now)
Problem p03194 (python)

Fixed submission:
n, p = map(int, input().split())
if n == 1:
    print(p)
else:
    for i in range(1, round(p**(1/n))+1):
        if p % i**n ==0:
            res = i
    print(res)

Buggy submission (verdict: Runtime Error):
import math
N, P = list(map(int, input().split()))


def cal(x):
    if P % (x ** N) == 0:
        return x
    else:
        return cal(x-1)


print(cal(int(math.pow(P, 1/ N))+1))

Buggy submission (verdict: Runtime Error):
import math
N, P = list(map(int, input().split()))

def cal(x):
    if P % (x ** N) == 0:
        return x
    return cal(x-1)

print(cal(int(math.pow(P, 1/ N))+1))
Problem p03274 (python)

Fixed submission:
N, K = map(int, input().split())
x = []
y = []
for i in input().split():
    n = int(i)
    if n < 0:
        x.append(-n)
    elif n == 0:
        K -= 1
    else:
        y.append(n)

x = x[::-1]

len_x = len(x)
len_y = len(y)
now = 10 ** 18

if len_x == 0:
    if len_y == 0:
        print(0)
    else:
        print(y[K-1])
elif len_y == 0:
    print(x[K-1])
else:
    for i in range(K+1):
        if K - i > len_y:
            continue
        if len_x < i:
            break
        if i == 0:
            now = min(y[K-1], now)
        elif i == K:
            now = min(x[K-1], now)
        else:
            now = min(min(x[i-1], y[K-i-1]) + x[i-1] + y[K-i-1], now)

    print(now)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
x = []
y = []
for i in input().split():
    n = int(i)
    if n < 0:
        x.append(-n)
    elif n == 0:
        K -= 1
    else:
        y.append(n)

x = x[::-1]

len_x = len(x)
len_y = len(y)
now = 10 ** 18

if len_x == 0:
    if len_y == 0:
        print(0)
    else:
        print(y[K-1])
elif len_y == 0:
    print(x[K-1])
else:
    for i in range(max(K - len_x, 0), K+1):
        if len_x < i:
            break
        if i == 0:
            now = min(x[K-1], now)
        elif i == K:
            now = min(y[K-1], now)
        else:
            now = min(min(x[i-1], y[K-i-1]) + x[i-1] + y[K-i-1], now)

    print(now)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
x = []
y = []
for i in input().split():
    n = int(i)
    if n < 0:
        x.append(-n)
    elif n == 0:
        K -= 1
    else:
        y.append(n)

x = x[::-1]

len_x = len(x)
len_y = len(y)
now = 10 ** 18

if len_x == 0:
    if len_y == 0:
        print(0)
    else:
        print(y[K-1])
elif len_y == 0:
    print(x[K-1])
else:
    for i in range(max(K - len_x, 0), K+1):
        if len_x < i:
            break
        print('x',i, K-i)
        if i == 0:
            now = min(x[K-1], now)
        elif i == K:
            now = min(y[K-1], now)
        else:
            now = min(min(x[i-1], y[K-i-1]) + x[i-1] + y[K-i-1], now)

    print(now)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
x = []
y = []
for i in input().split():
    n = int(i)
    if n < 0:
        x.append(-n)
    elif n == 0:
        K -= 1
    else:
        y.append(n)

x = x[::-1]

now = 10 ** 20
len_x = len(x)
len_y = len(y)

if len_x == 0:
    if len_y == 0:
        print(0)
    else:
        print(y[K-1])
elif len_y == 0:
    print(x[K-1])
else:
    for i in range(max(K - len_x, 0), K):
        if len_x < i:
            break
        now = min(min(x[i-1], y[K-i-1]) + x[i-1] + y[K-i-1], now)

    print(now)
Problem p03328 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)
a, b = map(int, input().split())

def calc(n):
    if n == 1:
        return 1
    else:
        return calc(n-1) + n

print(calc(b - a) - b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

def calc(n):
    count = 0
    for i in range(1, n+1):
        count += i
    reversed(count)

print(calc(b - a) - b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

def calc(n):
    if n == 1:
        return 1
    else:
        return calc(n-1) + n

print(calc(b - a) - b)
Problem p03353 (python)

Fixed submission:
s = input()
K = int(input())

n = len(s)

ex = [s[:min(K, n)]]
for i in range(n):
    if i + K - 1 < n:
        if ex[0] > s[i:i+K]:
            ex[0] = s[i:i+K]
    else:
        if ex[0][:n-i] > s[i:]:
            ex.insert(0, s[i:])


for n in range(len(ex)):
    for i in range(len(ex[n])):
        for j in range(i+1, len(ex[n])+1):
            ex.append(ex[n][i:j])

ex = set(ex)
ex = sorted(list(ex))

print(ex[K-1])

Buggy submission (verdict: Runtime Error):
s = input()
K = int(input())

n = len(s)

ex = [s[:min(K, n)]]
for i in range(n):
    if i + K - 1 < n:
        if ex[0] > s[i:i+K]:
            ex[0] = s[i:i+K]
    else:
        if ex[0][:n-i] > s[i:]:
            ex.insert(0, s[i:])


if K > len(ex[-1]):
    for i in range(len(ex[0])):
        for j in range(i+1, len(ex[0])+1):
            ex.append(ex[0][i:j])
    ex = set(ex)
    ex = sorted(list(ex))
    print(ex[K-1])
else:
    print(ex[-1])
Problem p03436 (python)

Fixed submission:
H, W = map(int, input().split())
map = [input() for _ in range(H)]

white = 0
for d in map:
    white += d.count('.')

memory = [(0,0)]
data = [[0] * W for _ in range(H)]
data[0][0] = 1
direction = [(0,1), (0,-1), (1,0), (-1,0)]
while True:
    if len(memory) == 0:
        print(-1)
        exit()
    x, y = memory.pop(0)
    for dx, dy in direction:

        if x + dx == H - 1 and y + dy == W-1:
            print(white - (data[x][y] + 1))
            exit()
        if 0 <= x + dx < H and 0 <= y + dy < W:
            if map[x+dx][y+dy] == '.' and data[x+dx][y+dy] == 0:
                data[x+dx][y+dy] = data[x][y] + 1
                memory.append((x+dx, y+dy))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
map = [input() for _ in range(H)]

white = 0
for d in map:
    white += d.count('.')

memory = [(0,0)]
data = [[0] * W for _ in range(H)]
data[0][0] = 1
direction = [(0,1), (0,-1), (1,0), (-1,0)]
while True:
    x, y = memory.pop(0)
    for dx, dy in direction:

        if x + dx == H - 1 and y + dy == W-1:
            print(white - (data[x][y] + 1))
            exit()
        if 0 <= x + dx < H and 0 <= y + dy < W:
            if map[x+dx][y+dy] == '.' and data[x+dx][y+dy] == 0:
                data[x+dx][y+dy] = data[x][y] + 1
                memory.append((x+dx, y+dy))
Problem p03450 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9
N ,M = map(int,input().split())

G = [[] for i in range(N+1)]

for _ in range(M):
    l, r, d = map(int, input().split())
    G[l].append((r, d))
    G[r].append((l, -d))

dp = [INF] * (N+1)

def dfs(l):
    for r, d in G[l]:
        if dp[r] == INF:
            dp[r] = dp[l] + d
            if not dfs(r):
                return False
        elif dp[r] != dp[l] + d:
            return False
    return True

for i in range(1, N+1):
    if dp[i] == INF:
        dp[i] = 0
        if not dfs(i):
            print('No')
            exit()

print('Yes')

Buggy submission (verdict: Runtime Error):
N ,M = map(int,input().split())
data = [list(map(int, input().split())) for _ in range(M)]

data = sorted(data)

INF = 10 ** 9
L = [INF] * (N + 1)
L[data[0][0]] = 0

for l, r, d in data:
    if L[r] == INF:
        L[r] = L[l] + d
    else:
        if L[l] == INF:
            L[l] = L[r] - d
        else:
            if L[r] != L[l] + d:
                print('No')
                exit()
print('Yes')
Problem p03565 (python)

Fixed submission:
S = input()
T = input()

s = len(S)
t = len(T)


for i in range(s-t, -1, -1):
    n = 0
    for j in range(t-1, -1, -1):
        if S[j+i] != '?' and S[j+i] != T[j]:
            break
        n += 1

    if n == t:
        for x in range(s):
            if i <= x < i+t:
                print(T[x-i], end='')
            else:
                if S[x] == '?':
                    print('a', end='')
                else:
                    print(S[x], end='')
        exit()

print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
S = input()
T = input()

s = len(S)
t = len(T)


for i in range(s-t, -1, -1):
    n = 0
    for j in range(t-1, -1, -1):
        if S[j+i] != '?' and S[j+i] != T[j]:
            break
        n += 1

    if n == t:
        for x in range(s):
            if i <= x <= i+t:
                print(T[x-i], end='')
            else:
                if S[x] == '?':
                    print('a', end='')
                else:
                    print(S[x], end='')
        exit()

print('UNRESTORABLE')
Problem p03573 (python)

Fixed submission:
A, B, C = map(int, input().split())

if A == B:
    print(C)
elif A == C:
    print(B)
else:
    print(A)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(N)]

ans = 10 ** 19
for a in range(N):
    for b in range(N):
        for c in range(N):
            for d in range(N):
                x0 = data[a][0]
                x1 = data[b][0]
                y0 = data[c][1]
                y1 = data[d][1]
                if x0 < x1 and y0 < y1:
                    count = 0
                    for i, j in data:
                        if x0 <= i <= x1 and y0 <= j <= y1:
                            count += 1
                    if count >= K:
                        ans = min(ans, (x1 - x0)*(y1 - y0))

print(ans)
Problem p03599 (python)

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

per = 0
ans = []

for i in range(f//(100*a) + 1):
    for j in range(f//(100*b) + 1):
        w = i * a * 100 + j * b * 100
        if w > f or w == 0:
            break
        for k in range((e * w//100)//c + 1):
            for l in range((e * w//100)//d + 1):
                if e * w//100 < c * k + d * l or w + c * k + d * l > f:
                    break
                now = 100 * (c*k+d*l) / (w+c*k+d*l)
                if per < now:
                    per = now
                    ans = [w+c*k+d*l, c*k+d*l]
if ans == []:
    print(100*a, 0)
else:
    print(ans[0], ans[1])

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,f = map(int, input().split())

per = 0
ans = []

for i in range(f//(100*a) + 1):
    for j in range(f//(100*b) + 1):
        w = i * a * 100 + j * b * 100
        if w > f or w == 0:
            break
        for k in range((e * w//100)//c + 1):
            for l in range((e * w//100)//d + 1):
                if e * w//100 < c * k + d * l or w + c * k + d * l > f:
                    break
                now = 100 * (c*k+d*l) / (w+c*k+d*l)
                if per < now:
                    per = now
                    ans = [w+c*k+d*l, c*k+d*l]
if ans = []:
    print(100*a, 0)
else:
    print(ans[0], ans[1])

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,f = map(int, input().split())

per = 0
ans = []

for i in range(f//(100*a) + 1):
    for j in range(f//(100*b) + 1):
        w = i * a * 100 + j * b * 100
        if w > f or w == 0:
            break
        for k in range((e * w//100)//c + 1):
            for l in range((e * w//100)//d + 1):
                if e * w//100 < c * k + d * l or w + c * k + d * l > f:
                    break
                now = 100 * (c*k+d*l) / (w+c*k+d*l)
                if per < now:
                    per = now
                    ans = [w+c*k+d*l, c*k+d*l]

print(ans[0], ans[1])
Problem p03611 (python)

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

c = [0] * (10**5 + 1)

for i in a:
    c[i] += 1
    if i != 0 and i != 10 ** 5:
        c[i-1] += 1
        c[i+1] += 1
    elif i == 0:
        c[i+1] += 1
    else:
        c[i-1] += 1

print(max(c))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split())

c = [0] * (10**5 + 1)

for i in a:
    c[i] += 1
    if i != 0 and i != 10 ** 5:
        c[i-1] += 1
        c[i+1] += 1
    elif i == 0:
        c[i+1] += 1
    else:
        c[i-1] += 1

print(max(c))
Problem p03633 (python)

Fixed submission:
N = int(input())
T = [int(input()) for i in range(N)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


if N == 1:
    print(T[0])
    exit()

now = lcm(T[0], T[1])
for i in range(1, N):
    now = lcm(now, T[i])

print(now)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = [int(input()) for i in range(N)]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b / gcd(a, b)

now = lcm(T[0], T[1])
for i in range(1, N):
    now = lcm(now, T[i])

print(now)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = [int(input()) for i in range(N)]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

now = lcm(T[0], T[1])
for i in range(1, N):
    now = lcm(now, T[i])

print(now)
Problem p03844 (python)

Fixed submission:
a, x, b = input().split()

if x == '+':
    ans = int(a)+int(b)
else:
    ans = int(a)-int(b)

print(ans)

Buggy submission (verdict: Runtime Error):
a, x, b = input()

if x == '+':
    ans = int(a)+int(b)
else:
    ans = int(a)-int(b)

print(ans)
Problem p02681 (python)

Fixed submission:
s = input()
t = input()

if t[0:len(s)] == s and len(t) == len(s)+1:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())  # a 1 b 0 c -1

if K <= A:
    print(K)

else:
    maxvalue = A
    K -= A
    if B >= 0:
        if K > 0:
            K = K - B
            if K <= 0:
                print(maxvalue)
    maxvalue -= K * -1
    print(maxvalue)

Buggy submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())  # a 1 b 0 c -1

max_value = 0
m = 0
while(A>0):
    if m < K:
        max_value+=1
        m += 1
        A = A - 1
    else:
        break
        
while(B>0):
    if m < K:
        m += 1
        B = B - 1
    else:
        break
while(C>0):
    if m < k:
        max_value -= 1
        m += 1
        C = C - 1
    else:
        break
        

print(max_value)

Buggy submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())  # a 1 b 0 c -1

max_value = 0
m = 0
while(A>0):
    if m < K:
        max_value+=1
        m += 1
        A = A - 1
    else:
        break
        
while(B>0):
    if m < K:
        m += 1
        B = B - 1
    else:
        break
while(C>0):
    if m < k:
        max_value -= 1
        m += 1
        C = C - 1
    else:
        break
Problem p02957 (python)

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

buf = a + b

if buf % 2 == 0:
	print(buf // 2)
else:
	print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

buf = a - b

if buf % 2 = 0:
	print(buf // 2)
else:
	print("IMPOSSIBLE")
Problem p03102 (python)

Fixed submission:
n, m, c = map(int, input().split())
B = list(map(int, input().split()))
ans = 0

for i in range(n):
    cnt = c
    A = list(map(int, input().split()))
    for j in range(m):
        cnt += A[j] * B[j]
    if cnt > 0:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n, m, c = map(int, input().split())
B = [*map(int, input().split())]
ans = 0

for i in range(n):
    cnt = c
    A = [*map(int, input().split())]
    for j in range(m):
        cnt += A[j] * B[j]
    if cnt > 0:
        ans += 1

print(ans)
Problem p03145 (python)

Fixed submission:
def main() -> None:
    ab, bc, ca = map(int, input().split())
    print(ab * bc // 2)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main() -> None:
    ab, bc, ca = map(int, input())
    print(ab * bc // 2)


if __name__ == "__main__":
    main()
Problem p03160 (python)

Fixed submission:
INF = 10 ** 9
N = int(input())
h = [int(x) for x in input().split()]

dp = [INF] * N
dp[0] = 0

for i in range(N - 1):
    for j in range(1, 3):
        if i + j < N:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))

print(dp[N - 1])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(sys.maxsize)

n = int(input())
h = [int(x) for x in input().split()]
dp = [-1 for _ in range(n)]


def rec_dp(i: int) -> int:
    global h, dp
    if i == 0:
        return 0
    if dp[i] != -1:
        return dp[i]
    res = rec_dp(i - 1) + abs(h[i] - h[i - 1])
    if i - 2 >= 0:
        res = min(rec_dp(i - 2) + abs(h[i] - h[i - 2]), res)
    dp[i] = res
    return res


print(rec_dp(n - 1))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 4)

n = int(input())
h = [int(x) for x in input().split()]
dp = [-1 for _ in range(n)]


def rec_dp(i: int) -> int:
    global h, dp
    if i == 0:
        return 0
    if dp[i] != -1:
        return dp[i]
    res = rec_dp(i - 1) + abs(h[i] - h[i - 1])
    if i - 2 >= 0:
        res = min(rec_dp(i - 2) + abs(h[i] - h[i - 2]), res)
    dp[i] = res
    return res


print(rec_dp(n - 1))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = [int(x) for x in input().split()]
dp = [-1 for _ in range(n)]


def rec_dp(i: int) -> int:
    global h, dp
    if i == 0:
        return 0
    if dp[i] != -1:
        return dp[i]
    res = rec_dp(i - 1) + abs(h[i] - h[i - 1])
    if i - 2 >= 0:
        res = min(rec_dp(i - 2) + abs(h[i] - h[i - 2]), res)
    dp[i] = res
    return res


print(rec_dp(n - 1))
Problem p03262 (python)

Fixed submission:
import fractions

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

x = [X] + list(map(int, input().split()))
x.sort()

dic = []

for i in range(len(x) - 1):
    tmp = x[i + 1] - x[i]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(len(dic) - 1):
    ans = min(ans, fractions.gcd(dic[i], dic[i + 1]))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

x = [X] + list(map(int, input().split()))
x.sort()

dic = []

for i in range(len(x) - 1):
    tmp = x[i + 1] - x[i]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

if len(dic) > 1:
    for i in range(len(dic) - 1):
        ans = min(ans, math.gcd(dic[i], dic[i + 1]))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

x = [X] + list(map(int, input().split()))
x.sort()

dic = []

for i in range(len(x) - 1):
    tmp = x[i + 1] - x[i]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(len(dic) - 1):
    ans = min(ans, math.gcd(dic[i], dic[i + 1]))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

x = [X] + list(map(int, input().split()))
x.sort()

dic = []

for i in range(1, len(x)):
    tmp = x[i] - x[i - 1]
    if tmp not in dic:
        dic.append(tmp)

dic.sort()
ans = dic[0]

for i in range(1, len(dic)):
    ans = min(ans, math.gcd(dic[i], dic[i - 1]))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

x = list(map(int, input().split()))
x.append(X)
x.sort()

dic = []

for i in range(1, len(x)):
    tmp = x[i] - x[i - 1]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(1, len(dic)):
    ans = min(ans, math.gcd(dic[i], dic[i - 1]))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

x = [X] + list(map(int, input().split()))
x.sort()

dic = []

for i in range(1, len(x)):
    tmp = x[i] - x[i - 1]
    if len(dic) == 0 or tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(1, len(dic)):
    ans = min(ans, math.gcd(dic[i], dic[i - 1]))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

x = [X] + list(map(int, input().split()))
x.sort()

dic = []

for i in range(1, len(x)):
    tmp = x[i] - x[i - 1]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(1, len(dic)):
    ans = min(ans, math.gcd(dic[i], dic[i - 1]))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

x = [X]
dic = []

x += list(map(int, input().split()))
x.sort()

for i in range(1, len(x)):
    tmp = x[i] - x[i - 1]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(1, len(dic)):
    ans = min(ans, math.gcd(dic[i], dic[i - 1]))

print(ans)
Problem p03351 (python)

Fixed submission:
a, b, c, d = map(int,input().split())
if abs(a - c) <= d:
    print('Yes')
elif abs(a - b) <= d and abs(b - c) <= d:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
x =int(input())
for n in range(x, 0, -1):
    for b in range(1, n + 1):
        for p in range(2, n + 1):
            if b ** p == n:
                print(n)
                exit()
            elif b ** p > n:
                break
print(1)
Problem p03359 (python)

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

print(a - (a > b))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input())

ans = a - 1 + (a == b)