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

Fixed submission:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

H, W = nl()
grid = []
for i in range(H):
    grid.append(s())

ups = [[0]*W for j in range(H)]
downs = [[0]*W for j in range(H)]
lefts = [[0]*W for j in range(H)]
rights = [[0]*W for j in range(H)]

for col in range(W):
    p = 0
    for row in range(H):
        if grid[row][col] == '#':
            p = 0
        else:
            p += 1
        ups[row][col] = p

    p = 0
    for row in range(H-1, -1, -1):
        if grid[row][col] == '#':
            p = 0
        else:
            p += 1
        downs[row][col] = p

for row in range(H):
    p = 0
    for col in range(W):
        if grid[row][col] == '#':
            p = 0
        else:
            p += 1
        lefts[row][col] = p

    p = 0
    for col in range(W-1, -1, -1):
        if grid[row][col] == '#':
            p = 0
        else:
            p += 1
        rights[row][col] = p

res = 0
for row in range(H):
    for col in range(W):
        res = max(res, ups[row][col] + downs[row][col] + lefts[row][col] + rights[row][col] -3)
print(res)

Buggy submission (verdict: Runtime Error):

nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

H, W = nl()
grid = []
for i in range(H):
    grid.append(s())

yoko = [[0] * W for h in range(H)]
for row in range(H):
    prev = 0
    count = 0
    for col in range(W):
            for i in range(prev, col):
                yoko[row][i] = count
            prev = col+1
            count = 0
        else:
            count += 1
    for i in range(prev, W):
        yoko[row][i] = count

tate = [[0] * W for h in range(H)]
for col in range(W):
    prev = 0
    count = 0
    for row in range(H):
            for i in range(prev, row):
                tate[i][col] = count
            prev = col+1
            count = 0
        else:
            count += 1
    for i in range(prev, H):
        tate[i][col] = count

res = 0
for row in range(H):
    for col in range(W):
        res = max(res, yoko[row][col] + tate[row][col] - 1)

print(res)
Problem p03026 (python)

Fixed submission:
import heapq
from collections import defaultdict

nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()


N = n()
M = 0
ds = [None] * N

edges = defaultdict(set)
ranks = [0] * N
for i in range(N-1):
    a, b = nl()
    edges[a-1].add(b-1)
    edges[b-1].add(a-1)
    ranks[a-1] += 1
    ranks[b-1] += 1
cs = sorted(nl())
M = sum(cs[:-1])

h = []
for i in range(N):
    heapq.heappush(h, (ranks[i], i))

for i in range(N):
    rank, node = heapq.heappop(h)
    ds[node] = cs[i]
    for next_node in edges[node]:
        ranks[next_node] -= 1
        heapq.heappush(h, (ranks[next_node], next_node))
        edges[next_node].remove(node)

print(M)
print(' '.join([str(d) for d in ds]))

Buggy submission (verdict: Runtime Error):
import heapq
from collections import defaultdict

nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()


N = n()
M = 0
ds = [None] * N

edges = defaultdict(set)
ranks = [0] * N
for i in range(N-1):
    a, b = nl()
    edges[a-1].add(b-1)
    edges[b-1].add(a-1)
    ranks[a-1] += 1
    ranks[b-1] += 1
cs = sorted(nl())
M = sum(cs[:-1])

h = []
for i in range(N):
    heapq.heappush(h, (ranks[i], i))

for i in range(N):
    rank, node = heapq.heappop(h)
    ds[node] = cs[i]
    for next_node in edges[node]:
        heapq.heappush(h, (ranks[next_node]-1, next_node))
        edges[next_node].remove(node)

print(M)
print(' '.join([str(d) for d in ds]))
Problem p03044 (python)

Fixed submission:
from collections import defaultdict

N = int(input())

colors = [0] * (N+1)
vertices = defaultdict(bool)
edges = defaultdict(dict)
for i in range(1, N):
    u, v, w = map(int, input().split())
    edges[u][v] = w % 2 == 0
    edges[v][u] = w % 2 == 0
    vertices[u] = False
    vertices[v] = False

queue = []
for v in edges[u].keys():
    queue.append((u, v))
vertices[u] = True

while len(queue) > 0:
    u, v = queue.pop(0)
    if vertices[v]:
        continue
    vertices[v] = True
    if colors[u] == colors[v]:
        if not edges[u][v]:
            colors[v] = 1 - colors[u]
    else:
        if edges[u][v]:
            colors[v] = colors[u]

    for nv in edges[v].keys():
        if not vertices[nv]:
            queue.append((v, nv))

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

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

colors = [0] * (N+1)
vertices = defaultdict(bool)
edges = defaultdict(dict)
for i in range(1, N):
    u, v, w = map(int, input().split())
    edges[u][v] = w % 2 == 0
    edges[v][u] = w % 2 == 0
    vertices[u] = False
    vertices[v] = False

queue = [(u, v)]
while len(queue) > 0:
    u, v = queue.pop(0)
    vertices[u] = True
    if vertices[v]:
        continue
    vertices[v] = True
    if colors[u] == colors[v] and not edges[u][v]:
        colors[v] = 1 - colors[u]

    for nv in edges[v].keys():
        if not vertices[nv]:
            queue.append((v, nv))

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

Fixed submission:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
As = nl()

from fractions import gcd
gcds_left = [0] * N
gcds_right = [0] * N
gcds_left[0] = As[0]
gcds_right[N-1] = As[N-1]

for i in range(1, N):
    gcds_left[i] = gcd(As[i], gcds_left[i-1])
    gcds_right[N-1-i] = gcd(As[N-1-i], gcds_right[N-i])

max_gcd = -1
for i in range(1, N-1):
    g = gcd(gcds_left[i-1], gcds_right[i+1])
    if g > max_gcd:
        max_gcd = g
print(max(max_gcd, gcds_right[1], gcds_left[N-2]))

Buggy submission (verdict: Runtime Error):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
As = nl()

from math import gcd      #3.5
gcds_left = [0] * N
gcds_right = [0] * N
gcds_left[0] = As[0]
gcds_right[N-1] = As[N-1]

for i in range(1, N):
    gcds_left[i] = gcd(As[i], gcds_left[i-1])
    gcds_right[N-1-i] = gcd(As[N-1-i], gcds_right[N-i])

max_gcd = -1
for i in range(1, N-1):
    g = gcd(gcds_left[i-1], gcds_right[i+1])
    if g > max_gcd:
        max_gcd = g
print(max(max_gcd, gcds_left[1], gcds_right[N-2]))
Problem p03064 (python)

Fixed submission:
import numpy as np

mod = 998244353
N = int(input())
a = np.array([int(input()) for i in range(N)])
sum_a = np.sum(a)
dp = np.zeros((N+1, sum_a+1))
dp[0,0] = 1

for i in range(1, N+1):
    a_i = a[i-1]
    dp[i,a_i:] += dp[i-1,:-a_i]
    dp[i,:] += dp[i-1,:] * 2
    dp[i,:] %= mod

exc = np.sum(dp[N, (sum_a+1)//2:]) % mod
res = 3**N % mod - exc * 3

if sum_a % 2 == 0:
    dp = np.zeros((N+1, sum_a+1))
    dp[0,0] = 1
    for i in range(1, N+1):
        a_i = a[i-1]
        dp[i,a_i:] += dp[i-1,:-a_i]
        dp[i,:] += dp[i-1,:]
        dp[i,:] %= mod
    res += dp[N, sum_a//2] * 3

print(int(res % mod))

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

total = 0
A = []
for i in range(N):
    a = int(input())
    total += a
    A.append(a)

mod = 998244353

dp = [[0]*91000 for i in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
    for j in range(300*i, -1, -1):
        dp[i][j+A[i-1]] += dp[i-1][j]
        dp[i][j+A[i-1]] %= mod
        dp[i][j] += 2*dp[i-1][j]
        dp[i][j] %= mod

exc = 0
for j in range((total+1)//2, total+1):
    exc += dp[N][j]
    exc %= mod

res = (3**N % mod) - exc * 3

if total % 2 == 0:
    dp = [[0]*91000 for i in range(N+1)]
    dp[0][0] = 1
    for i in range(1, N+1):
        for j in range(300*i, -1, -1):
            dp[i][j+A[i-1]] += dp[i-1][j]
            dp[i][j+A[i-1]] %= mod
            dp[i][j] += dp[i-1][j]
            dp[i][j] %= mod
    res += dp[N][total/2] * 3

print(res % mod)

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

total = 0
A = []
for i in range(N):
    a = int(input())
    total += a
    A.append(a)

mod = 998244353

dp = [[0]*91000 for i in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
    for j in range(300*i, -1, -1):
        dp[i][j+A[i-1]] += dp[i-1][j]
        dp[i][j+A[i-1]] %= mod
        dp[i][j] += 2*dp[i-1][j]
        dp[i][j] %= mod

exc = 0
for j in range((total+1)//2, total+1):
    exc += dp[N][j]
    exc %= mod

res = (3**N % mod) - exc * 3

if total % 2 == 0:
    dp = [[0]*91000]*(N+1)
    for i in range(1, N+1):
        for j in range(300*i, 0, -1):
            dp[i][j+A[i-1]] += dp[i-1][j]
            dp[i][j+A[i-1]] %= mod
            dp[i][j] += dp[i-1][j]
            dp[i][j] %= mod
    res += dp[N][total/2] * 3

print(res % mod)
Problem p03240 (python)

Fixed submission:
N = int(input())
points = []
f = None
for i in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        f = [x, y, h]
    points.append([x, y, h])

def height(cx, cy):
    H = f[2] + abs(f[0] - cx) + abs(f[1] - cy)
    for p in points:
        if p[2] != max(H - abs(p[0] - cx) - abs(p[1] - cy), 0):
            return 0
    return H

for x in range(101):
    for y in range(101):
        h = height(x, y)
        if h > 0:
            print(' '.join([str(x), str(y), str(h)]))

Buggy submission (verdict: Runtime Error):
N = int(input())
points = []
for i in range(N):
    x, y, h = map(int, input().split())
    points.append([x, y, h])

def height(cx, cy):
    res = set()
    for p in points:
        if p[2] == 0:
            continue
        res.add(p[2] + abs(p[0] - cx) + abs(p[1] - cy))
    return list(res)

def find():
    result = []
    for x in range(101):
        for y in range(101):
            hs = height(x, y)
            if len(hs) == 1:
                result.append([str(x), str(y), str(hs[0])])
    return result

res = find()
if len(res) > 1:
    raise Exception()

print(' '.join(res[0]))
Problem p03633 (python)

Fixed submission:

from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)

nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
common = n()
for i in range(N-1):
    common = lcm(common, n())

print(common)

Buggy submission (verdict: Runtime Error):

from math import gcd      #3.5
def lcm(x, y):
    return (x * y) // gcd(x, y)

nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
common = n()
for i in range(N-1):
    common = lcm(common, n())

print(common)
Problem p03647 (python)

Fixed submission:
from collections import defaultdict

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

import sys

teiki = defaultdict(set)
for i in range(M):
    a, b = map(int, input().split())
    teiki[a].add(b)


if 1 not in teiki:
    print('IMPOSSIBLE')
    sys.exit()

for i in teiki[1]:
    if i in teiki and N in teiki[i]:
        print('POSSIBLE')
        sys.exit()

print('IMPOSSIBLE')

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

import sys

teiki = defaultdict(set)
for i in range(M):
    a, b = map(int, input().split())
    teiki[a].add(b)


if 1 not in teiki:
    print('IMPOSSIBLE')
    sys.exit()

for i in teiki[1]:
    if i in teiki and N in teiki[i]:
        print('POSSIBLE')
        sys.exit()

print('IMPOSSIBLE')
Problem p03779 (python)

Fixed submission:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

X = n()

for x in range(1, X):
    if x * (x + 1) // 2 >= X:
        print(x)
        import sys
        sys.exit()

print(X)

Buggy submission (verdict: Runtime Error):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

X = n()

dp = [0] * (X+1)
dp[1] = 1
for i in range(2, X+1):
    j = dp[i-1]
    if dp[i - j] < dp[i-1]:
        dp[i] = dp[i-1]
    else:
        dp[i] = dp[i-1]+1
print(dp[X])

Buggy submission (verdict: Runtime Error):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

X = n()

dp = [0] * (X+1)
dp[1] = 1
for i in range(2, X+1):
    if dp[i - dp[i-1]] < dp[i-1]:
        dp[i] = dp[i-1]
    else:
        dp[i] = dp[i-1]+1
print(dp[X])

Buggy submission (verdict: Runtime Error):
INF = float("inf")
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

X = n()

dp = [0] * (X+1)
dp[1] = 1
for i in range(2, X+1):
    if dp[i - dp[i-1]] < dp[i-1]:
        dp[i] = dp[i-1]
    else:
        dp[i] = dp[i-1]+1

print(dp[X])
Problem p03838 (python)

Fixed submission:
x, y = map(int, input().split())

if abs(x) == abs(y):
    print(1)
elif abs(x) < abs(y):
    if y > 0:
        if x >= 0:
            print(abs(y) - abs(x))
        else:
            print(abs(y) - abs(x) + 1)
    else:
        if x >= 0:
            print(abs(y) - abs(x) + 1)
        else:
            print(abs(y) - abs(x) + 2)
else:
    if x < 0:
        if y <= 0:
            print(abs(x) - abs(y))
        else:
            print(abs(x) - abs(y) + 1)
    else:
        if y <= 0:
            print(abs(x) - abs(y) + 1)
        else:
            print(abs(x) - abs(y) + 2)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())

if abs(x) == abs(y):
    print(1)
elif abs(x) < abs(y):
    if y > 0:
        if x >= 0:
            print(abs(x - y))
        else:
            print(abs(x - y) + 1)
    else:
        if x >= 0:
            print(abs(x - y) + 1)
        else:
            print(abs(x - y) + 2)
else:
    if x < 0:
        if y <= 0:
            print(abs(x - y))
        else:
            print(abs(x - y) + 1)
    else:
        if y <= 0:
            print(abs(x - y) + 1)
        else y >= 0:
            print(abs(x - y) + 2)
Problem p03966 (python)

Fixed submission:
import math

N = int(input())
pt = 1
pa = 1
for i in range(N):
    t, a = map(int, input().split())

    t_ratio = pt // t
    a_ratio = pa // a
    if pt % t != 0:
        t_ratio += 1
    if pa % a != 0:
        a_ratio += 1
    min_ratio = max(t_ratio, a_ratio)
    pt = t * min_ratio
    pa = a * min_ratio

print(pt+pa)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
ratios = []
for i in range(N):
    t, a = map(int, input().split())
    ratios.append([t, a])

def min_vote(index):
    if index == N-1:
        return ratios[N-1-index]

    mt, ma = min_vote(index+1)
    t, a = ratios[N-1-index]
    min_ratio = max(math.ceil(mt / t), math.ceil(ma / a))
    return [t * min_ratio, a * min_ratio]

print(sum(min_vote(0)))
Problem p04013 (python)

Fixed submission:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, A = nl()
X = nl()

dp = []
for i in range(N+1):
    r = []
    for j in range(N+1):
        r.append([0 for k in range(N*50+1)])
    dp.append(r)

dp[0][0][0] = 1
for i in range(1, N+1):
    for j in range(0, N+1):
        for k in range(N*50+1):
            if k < X[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif j > 0 and k >= X[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i-1]]

total = 0
for k in range(1, N+1):
    total += dp[N][k][k*A]
print(total)

Buggy submission (verdict: Runtime Error):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, A = nl()
X = nl()

dp = []
for i in range(N+1):
    r = []
    for j in range(N+1):
        r.append([0 for k in range(N*max(X)+1)])
    dp.append(r)

dp[0][0][0] = 1
for i in range(1, N+1):
    for j in range(0, N+1):
        for k in range(N*max(X)+1):
            if k < X[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif j > 0 and k >= X[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i-1]]

total = 0
for k in range(1, N+1):
    total += dp[N][k][k*A]
print(total)

Buggy submission (verdict: Runtime Error):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, A = nl()
X = nl()

dp = []
for i in range(N+1):
    r = []
    for j in range(N+1):
        r.append([0 for k in range(N*max(X)+1)])
    dp.append(r)

dp[0][0][0] = 1
for i in range(1, N+1):
    for j in range(0, N+1):
        for k in range(N*max(X)+1):
            if k < X[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif j > 0:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i-1]]

total = 0
for k in range(1, N+1):
    total += dp[N][k][k*A]
print(total)
Problem p04039 (python)

Fixed submission:
import itertools

N, K = map(int, input().split())
Ds = list(map(int, input().split()))
NDs = list(set([i for i in range(10)]) - set(Ds))
NDs = list(map(str, NDs))

min_price = 100000
for p in itertools.product(NDs, repeat=len(str(N))):
    if p[0] == '0':
        continue
    price = int(''.join(p))
    if price < N:
        continue
    min_price = min(price, min_price)

if min_price == 100000:
    for p in itertools.product(NDs, repeat=len(str(N))+1):
        if p[0] == '0':
            continue
        price = int(''.join(p))
        min_price = min(price, min_price)

print(min_price)

Buggy submission (verdict: Runtime Error):
import itertools

N, K = map(int, input().split())
Ds = list(map(int, input().split()))
NDs = list(set([i for i in range(10)]) - set(Ds))
NDs = list(map(str, NDs))

min_price = 10000
for p in itertools.product(NDs, repeat=len(str(N))):
    if p[0] == '0':
        continue
    price = int(''.join(p))
    if price < N:
        continue
    min_price = min(price, min_price)

if min_price == 10000:
    for p in itertools.product(NDs, repeat=len(str(N)+1)):
        if p[0] == '0':
            continue
        price = int(''.join(p))
        min_price = min(price, min_price)

print(min_price)
Problem p03078 (python)

Fixed submission:
import sys

input = sys.stdin.readline

X, Y, Z, K = map(int, input().split())

list_cake_1 = list(map(int, input().split()))
list_cake_2 = list(map(int, input().split()))
list_cake_3 = list(map(int, input().split()))

list_cake_1 = sorted(list_cake_1, reverse=True)
list_cake_2 = sorted(list_cake_2, reverse=True)
list_cake_3 = sorted(list_cake_3, reverse=True)

list_total_sum = []

for i, cake_1 in enumerate(list_cake_1, 1):
	for j, cake_2 in enumerate(list_cake_2, 1):
		for k, cake_3 in enumerate(list_cake_3, 1):
			if i*j*k > K:
				break
			list_total_sum.append(cake_1 + cake_2 + cake_3)

for element in sorted(list_total_sum, reverse=True)[:K]:
	print(element)

Buggy submission (verdict: Runtime Error):
input = sys.stdin.readline

X, Y, Z, K = map(int, input().split())

list_cake_1 = list(map(int, input().split()))
list_cake_2 = list(map(int, input().split()))
list_cake_3 = list(map(int, input().split()))

list_cake_1 = sorted(list_cake_1, reverse=True)
list_cake_2 = sorted(list_cake_2, reverse=True)
list_cake_3 = sorted(list_cake_3, reverse=True)

list_total_sum = []

for i, cake_1 in enumerate(list_cake_1, 1):
	for j, cake_2 in enumerate(list_cake_2, 1):
		for k, cake_3 in enumerate(list_cake_3, 1):
			if i*j*k > K:
				break
			list_total_sum.append(cake_1 + cake_2 + cake_3)

for element in sorted(list_total_sum, reverse=True)[:K]:
	print(element)

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())

list_cake_1 = []
list_cake_2 = []
list_cake_3 = []

while len(list_cake_1) < X:
	element = list(map(int, input().split()))
	list_cake_1.extend(element)

while len(list_cake_2) < Y:
	element = list(map(int, input().split()))
	list_cake_2.extend(element)
	
while len(list_cake_3) < Z:
	element = list(map(int, input().split()))
	list_cake_3.extend(element)

list_cake_1.sort()
list_cake_2.sort()
list_cake_3.sort()
	
list_total_K = []

for i in range(1, X+1):
	for j in range(1, Y+1):
		for k in range(1, Z+1):
			if i*j*k < K:
				continue
			else:
				total_ijk = list_cake_1[i-1]+list_cake_2[j-1]+list_cake_3[k-1]
				list_total_K.append(total_ijk)
				
list_total_K.sort()

for i in range(1, K+1):
	print(list_total_K[-i])

Buggy submission (verdict: Runtime Error):
list_cake_1 = []
list_cake_2 = []
list_cake_3 = []

while len(list_cake_1) < X:
	element = list(map(int, input().split()))
	list_cake_1.extend(element)

while len(list_cake_2) < Y:
	element = list(map(int, input().split()))
	list_cake_2.extend(element)
	
while len(list_cake_3) < Z:
	element = list(map(int, input().split()))
	list_cake_3.extend(element)

list_total = []

for i in list_cake_1:
	for j in list_cake_2:
		for k in list_cake_3:
			total_ijk = i+j+k
			list_total.append(total_ijk)
				
list_total.sort()

for i in range(1, K+1):
	print(list_total[-i])
Problem p03241 (python)

Fixed submission:
import math
n, m = map(int, input().split())
root_m = int(math.sqrt(m))
ans = 1
for a in range(1, root_m):
    # print(a, ans)
    if m % a == 0:
        b = m // a
        if a * n <= m:
            ans = max(ans, a)
        if b * n <= m:
            ans = max(ans, b)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
n, m = map(int, input().split())
if m % n == 0:
    print(m // n)
else:
    gcd = m // n
    for i in range(gcd, 0, -1):
        if m % i == 0:
            j = m // gcd
            if j >= n:
                print(i)
                exit()
Problem p03262 (python)

Fixed submission:
n, x = map(int, input().split())
xl = [int(_) for _ in input().split()]
for i in range(n):
    if x > xl[i]:
        xl[i] = x - xl[i]
    else:
        xl[i] = xl[i] - x


def gcd(a, b):
    if a < b:
        x_a = b
        x_b = a
    else:
        x_a = a
        x_b = b
    while(1):
        if x_a < x_b:
            tmp = x_a
            x_a = x_b
            x_b = tmp
        x_a %= x_b
        if x_a == 0:
            break
    return x_b

    
x_gcd = xl[0]
if n > 1:
    for i in range(1, n):
        x_gcd = gcd(x_gcd, xl[i])
print(x_gcd)

Buggy submission (verdict: Runtime Error):
import math
import sys
sys.setrecursionlimit(2000000)
n, x = map(int, input().split())
xl = [int(_) for _ in input().split()]
for i in range(n):
    if x > xl[i]:
        xl[i] = x - xl[i]
    else:
        xl[i] = xl[i] - x
x_gcd = xl[0]
if n > 1:
    for i in range(1, n):
        x_gcd = math.gcd(x_gcd, xl[i])
print(x_gcd)

Buggy submission (verdict: Runtime Error):
import fraction
n, x = map(int, input().split())
xl = [int(_) for _ in input().split()]
for i in range(n):
    if x > xl[i]:
        xl[i] = x - xl[i]
    else:
        xl[i] = xl[i] - x
x_gcd = xl[0]
if n > 1:
    for i in range(1, n):
        x_gcd = fraction.gcd(x_gcd, xl[i])
print(x_gcd)

Buggy submission (verdict: Runtime Error):
import math
n, x = map(int, input().split())
xl = [int(_) for _ in input().split()]
for i in range(n):
    if x > xl[i]:
        xl[i] = x - xl[i]
    else:
        xl[i] = xl[i] - x
x_gcd = xl[0]
if n > 1:
    for i in range(1, n):
        x_gcd = math.gcd(x_gcd, xl[i])
print(x_gcd)

Buggy submission (verdict: Runtime Error):
import math
n, x = map(int, input().split())
xl = [int(_) for _ in input().split()]
for i in range(n):
    if x > xl[i]:
        xl[i] = x - xl[i]
    else:
        xl[i] = xl[i] - x
x_gcd = xl[0]
for i in range(1, n):
    x_gcd = math.gcd(x_gcd, xl[i])
print(x_gcd)