Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys

S = sys.stdin.readline().strip()

N = 2019
L = len(S)
dp = [[0 for _ in range(N)] for _ in range(L) ]
for i in range(L):
    t = int(S[i])
    dp[i][t] = 1

    for j in range(N):
        dp[i][(j*10 + t)%N] += dp[i-1][j]

res = 0
for i in range(L):
    res += dp[i][0]
print(res)

Fixed submission:
import sys

S = sys.stdin.readline().strip()

N = 2019
L = len(S)
curr = 0
seen = {}
INV = 210
seen[curr] = 1
for i in range(L):
    curr = (curr * 10 + int(S[i])) % N
    t = (curr * pow(10, L-i, N)) %N
    if t not in seen: seen[t] = 0
    seen[t] += 1

res = 0
for i in range(N):
    if i not in seen: continue
    t = seen[i]
    res += t * (t-1)//2
print(res)

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

S = sys.stdin.readline().strip()

N = 2019
prev, curr = {}, {}
res = 0
for i in range(len(S)):
    curr = {}
    curr[int(S[i])] = 1
    for k in prev.keys():
        tmp = (k*10 + int(S[i])) % N
        if tmp not in curr: curr[tmp] = 0
        curr[tmp] += prev[k]
    if 0 in curr: res += curr[0]
    prev = curr
print(res)

Fixed submission:
import sys

S = sys.stdin.readline().strip()

N = 2019
L = len(S)
curr = 0
seen = {}
INV = 210
seen[curr] = 1
for i in range(L):
    curr = (curr * 10 + int(S[i])) % N
    t = (curr * pow(10, L-i, N)) %N
    if t not in seen: seen[t] = 0
    seen[t] += 1

res = 0
for i in range(N):
    if i not in seen: continue
    t = seen[i]
    res += t * (t-1)//2
print(res)
Buggy python submission (verdict: Runtime Error):
A, B, C, K = [int(x) for x in input().strip().split()]
k = K
res = 0
if A > K:
	print(K)
else:
	k -= A
	res += A
    if b > k:
        print(res)
    else:
        k -= b
        if k > 0:
            res -= k * -1
            print(res)
  

Fixed submission:
a, b, c, k = [int(x) for x in input().split()]
res = 0
i = 0
t = [a, b, c]
j = [1, 0, -1]
while k > 0:
  m = min(k, t[i])
  k -= m
  res += j[i] * m
  i += 1
print(res)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(int, input().split())
for i in A:
    if not(i % 3 == 0 or i % 5 == 0):
        print("DENIED")
        break
else:
    print("APPROVED")

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
for i in A:
    if i % 2 == 0:
        if not(i % 3 == 0 or i % 5 == 0):
            print("DENIED")
            break
else:
    print("APPROVED")
Buggy python submission (verdict: Runtime Error):
get = map(int, input().split())
a = get[0]
b = get[1]
if a <= b:
  print(str(a) * b)
elif a > b:
  print(str(b) * a)

Fixed submission:
get = list(map(int, input().split()))
a = get[0]
b = get[1]
if a <= b:
  print(str(a) * b)
elif a > b:
  print(str(b) * a)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = 0
for i in range(N):
    if S[i] == "A" and i <= N - 2:
        if S[i + 1] == "B":
            if S[i + 2] == "C":
                ans += 1
print(ans)

Fixed submission:
N = int(input())
S = input()
ans = 0
for i in range(N - 2):
    if S[i] == "A" :
        if S[i + 1] == "B":
            if S[i + 2] == "C":
                ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = 0
for i in range(N):
    if S[i] == "A":
        if S[i + 1] == "B":
            if S[i + 2] == "C":
                ans += 1
print(ans)

Fixed submission:
N = int(input())
S = input()
ans = 0
for i in range(N - 2):
    if S[i] == "A" :
        if S[i + 1] == "B":
            if S[i + 2] == "C":
                ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
get = map(int, input().split())
A = get[0]
B = get[1]
if A >= 10 or B >= 10:
  print(-1)
else:
  print(A * B)

Fixed submission:
get = list(map(int, input().split()))
A = get[0]
B = get[1]
if A >= 10 or B >= 10:
  print(-1)
else:
  print(A * B)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())
train = A * N
if train <= B:
    print(train)
else:
    print(B)

Fixed submission:
get = input().split()
N = int(get[0])
A = int(get[1])
B = int(get[2])
train = A * N
if train <= B:
    print(train)
else:
    print(B)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())
train = A * N
if train <= B:
    print(train)
else:
    print(B)

Fixed submission:
get = input().split()
N = int(get[0])
A = int(get[1])
B = int(get[2])
train = A * N
if train <= B:
    print(train)
else:
    print(B)

Buggy python submission (verdict: Runtime Error):
N, A, B= int(input()), int(input()), int(input())
train = A * N
if train <= B:
    print(train)
else:
    print(B)

Fixed submission:
get = input().split()
N = int(get[0])
A = int(get[1])
B = int(get[2])
train = A * N
if train <= B:
    print(train)
else:
    print(B)
Buggy python submission (verdict: Runtime Error):
S = input()
chars = []
for i in range(len(S)):
    chars.append(S[i])
if chars.count(chars[0]) == 2:
    for i in range(1, len(S) + 1):
        if chars[i] == 2:
            print("Yes")
else:
    print("No")

Fixed submission:
S = input()
chars = []
for i in range(len(S)):
    chars.append(S[i])
if chars.count(chars[0]) == 2:
    for i in range(len(S)):
        if chars.count(chars[i]) != 2:
            print("No")
            break
    else:
        print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a = input()
b = int(a[:2])
c = int(a[2:])
 
if b > 12 and c > 12:
  print("NA")
elif b > 12 or b == 0: # bがYY
  if c < 1:
  	print("NA")
  else:
	print("YYMM")
elif c > 12 or c == 0: # cがYY
  if b < 1:
    print("NA")
  else:
    print("MMYY")
else:
  print("AMBIGUOUS")

Fixed submission:
a = input()
b = int(a[:2])
c = int(a[2:])
 
if b > 12 and c > 12:
  print("NA")
elif b > 12 or b == 0: # bがYY
  if c < 1:
    print("NA")
  else:
    print("YYMM")
elif c > 12 or c == 0: # cがYY
  if b < 1:
    print("NA")
  else:
    print("MMYY")
else:
  print("AMBIGUOUS")
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]

ab.sort()
ans = 0
while m != 0:
    tab = ab.pop(0)
    ans += min(tab[1], m)* tab[0]
    m = max(0, m - tab[1])
print(ans)

Fixed submission:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]

ab.sort()
ans = 0
for tab in ab:
    if m < 0:
        break
    ans += min(tab[1], m)* tab[0]
    m -= tab[1]
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ans = [0] * m + [n * (n - 1) // 2]

root = [0] * (n + 1)
count = [1] * (n + 1)

def uf(a):
    if root[a] == 0:
        return a
    else:
        return uf(root[a])

ab.reverse()
for i in range(len(ab)):
    ha = uf(ab[i][0])
    hb = uf(ab[i][1])
    if ha == hb:
        continue
    ans[m - i - 1] = max(0, ans[m - i] - count[ha] * count[hb])
    root[hb] = ha
    count[ha] += count[hb]
ans.pop(0)
for i in ans:
    print(i)

Fixed submission:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ans = [0] * (m - 1) + [n * (n - 1) // 2]

root = [0] * (n + 1)
count = [1] * (n + 1)

def uf(a):
    if root[a] == 0:
        return a
    else:
        return uf(root[a])

for i in range(m - 1, 0, -1):
    ha = uf(ab[i][0])
    hb = uf(ab[i][1])
    if ha == hb:
        ans[i - 1] = ans[i]
        continue
    ans[i - 1] = max(0, ans[i] - count[ha] * count[hb])
    if count[ha] > count[hb]:
        root[hb] = ha
        count[ha] += count[hb]
    else:
        root[ha] = hb
        count[hb] += count[ha]
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))

setnum = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6} 
rset = {}
for i in a:
    if i in rset:
        if rset[setnum[i]] > i:
            rset[i] = setnum[i]
    else:
        rset[i] = setnum[i]

rset = sorted(rset.items(), reverse=True)
dp = [0] * (n + 1)
for i in rset:
    dp[i[1]] = i[0]
    for j in range(1, n + 1 - i[1]):
        if dp[j] != 0:
            dp[j + i[1]] = max(dp[j + i[1]], dp[j] * 10 + i[0])
print(dp[-1])


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

setnum = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6} 
rset = {}
for i in a:
    if i in rset:
        if rset[setnum[i]] > i:
            rset[i] = setnum[i]
    else:
        rset[i] = setnum[i]

rset = sorted(rset.items(), reverse=True)
dp = [0] * (n + 1)
for i in rset:
    if n < i[1]:
        continue
    dp[i[1]] = max(dp[i[1]] , i[0])
    for j in range(i[1], n + 1 - i[1]):
        if dp[j] != 0:
            dp[j + i[1]] = max(dp[j + i[1]], dp[j] * 10 + i[0])
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = a.copy()
count = 1
d = 1
while k >= d:
    count += 1
    d *= 2
else:
    count 1= 1
    d //= 2
anst = 0
for i in range(count):
    level = 0
    for j in range(n):
        tmpb = b[j] // d
        if tmpb >= 1 and tmpb % 2 == 1:
            level += 1
        b[j] %= d
    if k >= anst + d and n > level * 2:
        anst += d
    d //= 2

ans = 0
for i in range(n):
    ans += a[i] ^ anst
print(ans)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = a.copy()
count = 1
d = 1
while k >= d:
    count += 1
    d *= 2
else:
    count -= 1
    d //= 2
anst = 0
for i in range(count):
    level = 0
    for j in range(n):
        tmpb = b[j] // d
        if tmpb >= 1 and tmpb % 2 == 1:
            level += 1
        b[j] %= d
    if k >= anst + d and n > level * 2:
        anst += d
    d //= 2

ans = 0
for i in range(n):
    ans += a[i] ^ anst
print(ans)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = a.copy()
count = 1
d = 1
while k >= d:
    count += 1
    d *= 2
else:
    d //= 2
anst = 0
for i in range(count):
    level = 0
    for j in range(n):
        tmpb = b[j] // d
        if tmpb >= 1 and tmpb % 2 == 1:
            level += 1
        b[j] %= d
    if k >= anst + d and n > level * 2:
        anst += d
    d //= 2

ans = 0
for i in range(n):
    ans += a[i] ^ anst
print(ans)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = a.copy()
count = 1
d = 1
while k >= d:
    count += 1
    d *= 2
else:
    count -= 1
    d //= 2
anst = 0
for i in range(count):
    level = 0
    for j in range(n):
        tmpb = b[j] // d
        if tmpb >= 1 and tmpb % 2 == 1:
            level += 1
        b[j] %= d
    if k >= anst + d and n > level * 2:
        anst += d
    d //= 2

ans = 0
for i in range(n):
    ans += a[i] ^ anst
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = [0] * n
twins = []
now = 1
while now <= a[-1]:
    now *= 2
    twins.append(now)
for i in range(len(a) - 1, 0, -1):
    tmpa = 0
    if b[i] != 0:
        continue
    for j in range(len(twins) - 1, -1, -1):
        if twins[j] <= a[i]:
            break
        tmpa = twins[j] - a[i]
    for j in range(i - 1, -1, -1):
        if a[j] == tmpa and b[j] == 0:
            b[i] = 1
            b[j] = 1
            break
        elif a[j] < tmpa:
            break
print(b.count(1) // 2)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = {}
for i in range(len(a)):
    if a[i] in b:
        b[a[i]] += 1
    else:
        b[a[i]] = 1
twins = []
now = 1
while now <= a[-1]:
    now *= 2
    twins.append(now)
for i in range(len(a) - 1, -1, -1):
    tmpa = 0
    if  b[a[i]] == 0:
        continue
    for j in range(len(twins) - 1, -1, -1):
        if twins[j] <= a[i]:
            break
        tmpa = twins[j] - a[i]
    if tmpa == a[i]:
        if b[tmpa] >= 2:
            b[tmpa] -= 2
    elif tmpa in b and b[tmpa] != 0:
        b[tmpa] -= 1
        b[a[i]] -= 1
countb = 0
for i in b:
    countb += b[i]
print((n - countb) // 2)
Buggy python submission (verdict: Runtime Error):
(n, x) = list(map(int, input().split()))
num = 1
pate = 1
for i in range(n):
    num = num * 2 + 3
    pate = pate * 2 + 1
def culc(l, idx, num, pate):
    npate = (pate - 1) // 2
    nnum = (num - 3) // 2
    mid = (num + 1) // 2
    if idx == 1:
        return 0
    elif mid == idx:
        return npate + 1
    elif mid < idx:
        return npate + 1 + culc(l - 1, idx - mid, nnum, npate)
    else:
        return culc(l - 1, idx - 1, nnum, npate)
print(culc(n, x, num, pate))


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

num = 1
pate = 1
for i in range(n):
    num = num * 2 + 3
    pate = pate * 2 + 1

def culc(l, idx, num, pate):
    npate = (pate - 1) // 2
    nnum = (num - 3) // 2
    mid = (num + 1) // 2
    if l == 1:
        if idx == 0:
            return 0
        elif idx == 1:
            return 0
        elif idx == 2:
            return 1
        elif idx == 3:
            return 2
        elif idx == 4:
            return 3
        else:
            return 3
    elif mid == idx:
        return npate + 1
    elif mid < idx:
        return npate + 1 + culc(l - 1, idx - mid, nnum, npate)
    else:
        return culc(l - 1, idx - 1, nnum, npate)
print(culc(n, x, num, pate))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())
if n == 1:
    print("Hello World")
else:
    print(a + b)


Fixed submission:
n = int(input())
if n == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a + b)
Buggy python submission (verdict: Runtime Error):
(n, t) = map(int, input().split())
cts = []
for i in range(n):
    ct = list(map(int, input().split()))
    if ct[1] <= t:
        cts.append(ct)
cts.sort()
print(cts[0][0])

Fixed submission:
(n, t) = map(int, input().split())
cts = []
for i in range(n):
    ct = list(map(int, input().split()))
    if ct[1] <= t:
        cts.append(ct)
if len(cts) == 0:
    print("TLE")
else:
    cts.sort()
    print(cts[0][0])
Buggy python submission (verdict: Runtime Error):
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
ans = 0
for param in params:
    if n > m / iparam:
        break
    ans = param
print(ans)

Fixed submission:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {m:1}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if n > m / i:
        break
    maxans = i
print(maxans)

Buggy python submission (verdict: Runtime Error):
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if n > m / i:
        break
    maxans = i
print(maxans)

Fixed submission:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {m:1}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if n > m / i:
        break
    maxans = i
print(maxans)
Buggy python submission (verdict: Runtime Error):
n = input().split()
vs = list(map(int, input().split()))

eve = {}
odd = {}

for i in range(len(vs)):
    if i % 2 == 0:
        if vs[i] in eve:
            eve[vs[i]] += 1
        else:
            eve[vs[i]] = 1
    else:
        if vs[i] in odd:
            odd[vs[i]] += 1
        else:
            odd[vs[i]] = 1

es = sorted(eve.items(), key=lambda x: -x[1])
os = sorted(odd.items(), key=lambda x: -x[1])

if es[0][0] == os[0][0]:
    if es[0][1] > os[0][1]:
        del es[0]
        if len(os) > 1 :
            del os[1]
    elif es[0][1] < os[0][1]:
        del os[0]
        if len(es) > 1 :
            del es[1]
    else:
        if len(es) == 1:
            del es[0]
            del os[1]
        elif len(os) == 1:
            del es[1]
            del os[0]
        else:
            if es[1][1] < os[1][1]:
                del es[0]
                del os[1]
            else:
                del es[0]
                del os[1]



else:
    del os[0]
    del es[0]

trans = 0

for i in range(len(es)):
    trans += es[i][1]
for i in range(len(os)):
    trans += os[i][1]

print(trans)

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

eve = {}
odd = {}

for i in range(len(vs)):
    if i % 2 == 0:
        if vs[i] in eve:
            eve[vs[i]] += 1
        else:
            eve[vs[i]] = 1
    else:
        if vs[i] in odd:
            odd[vs[i]] += 1
        else:
            odd[vs[i]] = 1

es = sorted(eve.items(), key=lambda x: -x[1])
os = sorted(odd.items(), key=lambda x: -x[1])

if es[0][0] == os[0][0]:
    if es[0][1] > os[0][1]:
        del es[0]
        if len(os) > 1 :
            del os[1]
    elif es[0][1] < os[0][1]:
        del os[0]
        if len(es) > 1 :
            del es[1]
    else:
        if len(es) == 1 and len(os) == 1:
            del os[0]
        elif len(es) == 1 and len(os) != 1:
            del es[0]
            del os[1]
        elif len(es) != 1 and len(os) == 1:
            del es[1]
            del os[0]
        else:
            if es[1][1] < os[1][1]:
                del es[0]
                del os[1]
            else:
                del es[1]
                del os[0]
else:
    del os[0]
    del es[0]

trans = 0

for i in range(len(es)):
    trans += es[i][1]
for i in range(len(os)):
    trans += os[i][1]

print(trans)
Buggy python submission (verdict: Time Limit Exceeded):
(n, m)  =map(int, input().split())

map = {}
i = 2
while m != 1:
    if m % i == 0 :
        m = m / i
        if i in map:
            map[i] += 1
        else:
            map[i] = 1
    else:
        i += 1
sum = 1
for i in map:
    tmpn = n + map[i] - 1
    c = 1
    d = 1
    e = 1
    for j in range(map[i]):
        c = c * (tmpn - j)
        d = d * (map[i] - j)
    e = e * c // d
    
    sum = sum * e % 1000000007
print(sum )

Fixed submission:
import math
(n, m)  =map(int, input().split())
sqm = math.sqrt(m)
map = {}
i = 2
y = m
while m != 1 and sqm >= i:
    if m % i == 0 :
        m = m / i
        if i in map:
            map[i] += 1
        else:
            map[i] = 1
    else:
        i += 1
if m > 1:
    map[m] = 1

sum = 1
for i in map:
    tmpn = n + map[i] - 1
    c = 1
    d = 1
    e = 1
    for j in range(map[i]):
        c = c * (tmpn - j)
        d = d * (map[i] - j)
    e = e * c // d
    
    sum = sum * e % 1000000007
print(sum )

Buggy python submission (verdict: Time Limit Exceeded):
(n, m)  =map(int, input().split())

map = {}
i = 2
while m != 1:
    if m % i == 0 :
        m = m / i
        if i in map:
            map[i] += 1
        else:
            map[i] = 1
    else:
        i += 1
sum = 1
for i in map:
    tmpn = n + map[i] - 1
    c = 1
    d = 1
    e = 1
    for j in range(map[i]):
        c = c * (tmpn - j)
        d = d * (map[i] - j)
    e = e * c // d
    
    sum = sum * e
print(sum % 1000000007)

Fixed submission:
import math
(n, m)  =map(int, input().split())
sqm = math.sqrt(m)
map = {}
i = 2
y = m
while m != 1 and sqm >= i:
    if m % i == 0 :
        m = m / i
        if i in map:
            map[i] += 1
        else:
            map[i] = 1
    else:
        i += 1
if m > 1:
    map[m] = 1

sum = 1
for i in map:
    tmpn = n + map[i] - 1
    c = 1
    d = 1
    e = 1
    for j in range(map[i]):
        c = c * (tmpn - j)
        d = d * (map[i] - j)
    e = e * c // d
    
    sum = sum * e % 1000000007
print(sum )
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a % 2 == 0 or b % 2 == 0:
    print('No')
else:
    print('Yes)

Fixed submission:
a, b = map(int, input().split())
if a % 2 == 0 or b % 2 == 0:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
from math import gcd

[n, x] = map(int, input().split(" "))
xs = list(map(int, input().split(" ")))

xs.append(x)
xs.sort()

gc = xs[1] - xs[0]

for i in range(1, n + 1):
    gc = gcd(gc,  xs[i] - xs[i - 1])

print(gc)

Fixed submission:
def getGcd(num1, num2):
    while True:
        tmp = num1
        num1 = num2 % num1
        num2 = tmp
        if(num1 == 0):
            return tmp

[n, x] = map(int, input().split(" "))
xs = list(map(int, input().split(" ")))

xs.append(x)
xs.sort()

gc = xs[1] - xs[0]

for i in range(1, n + 1):
    gc = getGcd(gc,  xs[i] - xs[i - 1])

print(gc)

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

[n, x] = map(int, input().split(" "))
xs = list(map(int, input().split(" ")))

xs.append(x)
xs.sort()
gc = xs[1] - xs[0]

for i in range(1, n):
    gc = math.gcd(gc,  xs[i] - xs[i - 1])

print(gc)

Fixed submission:
def getGcd(num1, num2):
    while True:
        tmp = num1
        num1 = num2 % num1
        num2 = tmp
        if(num1 == 0):
            return tmp

[n, x] = map(int, input().split(" "))
xs = list(map(int, input().split(" ")))

xs.append(x)
xs.sort()

gc = xs[1] - xs[0]

for i in range(1, n + 1):
    gc = getGcd(gc,  xs[i] - xs[i - 1])

print(gc)

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

[n, x] = map(int, input().split(" "))
xs = list(map(int, input().split(" ")))
xs.append(x)
xs.sort()
gcd =  xs[1] - xs[0]

for i in range(1, n + 1):
    gcd = math.gcd(gcd,  xs[i] - xs[i - 1])

print(gcd)

Fixed submission:
def getGcd(num1, num2):
    while True:
        tmp = num1
        num1 = num2 % num1
        num2 = tmp
        if(num1 == 0):
            return tmp

[n, x] = map(int, input().split(" "))
xs = list(map(int, input().split(" ")))

xs.append(x)
xs.sort()

gc = xs[1] - xs[0]

for i in range(1, n + 1):
    gc = getGcd(gc,  xs[i] - xs[i - 1])

print(gc)

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

[n, x] = map(int, input().split(" "))
xs = list(map(int, input().split(" ")))
xs.append(x)
xs.sort()
gcd =  xs[1] - xs[0]

for i in range(1, n):
    gcd = math.gcd(gcd,  xs[i] - xs[i - 1])

print(gcd)

Fixed submission:
def getGcd(num1, num2):
    while True:
        tmp = num1
        num1 = num2 % num1
        num2 = tmp
        if(num1 == 0):
            return tmp

[n, x] = map(int, input().split(" "))
xs = list(map(int, input().split(" ")))

xs.append(x)
xs.sort()

gc = xs[1] - xs[0]

for i in range(1, n + 1):
    gc = getGcd(gc,  xs[i] - xs[i - 1])

print(gc)

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

[n, x] = map(int, input().split())

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

xs.sort()
gcd =  xs[1] - xs[0]

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

print(gcd)

Fixed submission:
def getGcd(num1, num2):
    while True:
        tmp = num1
        num1 = num2 % num1
        num2 = tmp
        if(num1 == 0):
            return tmp

[n, x] = map(int, input().split(" "))
xs = list(map(int, input().split(" ")))

xs.append(x)
xs.sort()

gc = xs[1] - xs[0]

for i in range(1, n + 1):
    gc = getGcd(gc,  xs[i] - xs[i - 1])

print(gc)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

ok = True
for a in range(k):
    if int(s[a]) != 1:
        print(s[a])
        ok = False
        break

if ok:
    print(s[k])

Fixed submission:
s = input()
k = int(input())
end = False
for i in range(min(len(s), k)):
    if s[i] != '1':
        print(s[i])
        end = True
        break
if end == False:
    print(1)