Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
count = 0
l_array = []
r_array = []
for i, X in enumerate(A):
    l_array.append(i + X)
    r_array.append(i - X)

for x in l_array:
    count += r_array.count(x)
print(count)


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
count = 0
l_array = []
r_array = []
for i, X in enumerate(A):
    l_array.append(i + X)
    r_array.append(i - X)

counter = Counter(r_array)

for x in l_array:
    count += counter.get(x, 0)
print(count)

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

N = int(input())
A = list(map(int, input().split()))
array = list(itertools.combinations(range(N), 2))
count = 0

for x in array:
    if (A[x[1]] + A[x[0]]) == (x[1] - x[0]):
        count += 1
print(count)


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
count = 0
l_array = []
r_array = []
for i, X in enumerate(A):
    l_array.append(i + X)
    r_array.append(i - X)

counter = Counter(r_array)

for x in l_array:
    count += counter.get(x, 0)
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
maxFloor = 0


def floor(x):
    num = int(x // 1)
    return num


for x in range(N + 1):
    check = floor(A * x / B) - A * floor(x / B)
    maxFloor = max(maxFloor, check)
print(maxFloor)


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

maxFloor = 0


def floor(x):
    num = int(x // 1)
    return num


if B - 1 <= N:
    check = floor(A * (B - 1) / B) - A * floor((B - 1) / B)
    print(check)
else:
    check = floor(A * N / B) - A * floor(N / B)
    print(check)
Buggy python submission (verdict: Runtime Error):
S = input()

count = 0
mod_check = {}
mod_check[0] = 1
check_S = 0
for i in reversed(S):
    check_S += int(i) * (10 ** count)
    mod = check_S % 2019
    mod_check.setdefault(mod, 0)
    mod_check[mod] += 1
    count += 1
mod_match = 0
for x in mod_check.values():
    mod_match += x * (x - 1) // 2
print(mod_match)


Fixed submission:
S, W = map(int, input().split())
if S <= W:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Runtime Error):
import math
R = int(input())
print(R*2*math.pi)


Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
sumA = sum(A)
remain = N - sumA
if remain >= 0:
    print(remain)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
for x in range(N):
    print(A.count(x+1))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count_array = [0] * N
for x in range(N - 1):
    count_array[A[x] - 1] += 1
for y in count_array:
    print(y)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
for x in range(N):
    print(A.count(x+1))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count_array = [0] * N
for x in range(N - 1):
    count_array[A[x] - 1] += 1
for y in count_array:
    print(y)
Buggy python submission (verdict: Time Limit Exceeded):
import math

K = int(input())
sumGCD = K * K * K
for a in range(2, K + 1, 1):
    for b in range(2, K + 1, 1):
        for c in range(2, K + 1, 1):
            arr = [a, b, c]
            gcdNum = math.gcd(math.gcd(a, b), c)
            # if gcdNum != 1:
            # print(arr)
            # print(gcdNum)
            sumGCD += gcdNum - 1
print(sumGCD)


Fixed submission:
import math

K = int(input())
sumGCD = K * K * K
for a in range(2, K + 1, 1):
    for b in range(2, K + 1, 1):
        for c in range(2, K + 1, 1):
            arr = [a, b, c]
            gcdNum = math.gcd(math.gcd(a, b), c)
            # if gcdNum != 1:
            # print(arr)
            # print(gcdNum)
            sumGCD += gcdNum - 1
print(sumGCD)

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


def gcd(*numbers):
    return reduce(math.gcd, numbers)


K = int(input())
sumGCD = K * K * K
for a in range(2, K + 1, 1):
    for b in range(2, K + 1, 1):
        for c in range(2, K + 1, 1):
            arr = [a, b, c]
            gcdNum = gcd(*arr)
            # if gcdNum != 1:
            # print(arr)
            # print(gcdNum)
            sumGCD += gcdNum - 1
print(sumGCD)


Fixed submission:
import math

K = int(input())
sumGCD = K * K * K
for a in range(2, K + 1, 1):
    for b in range(2, K + 1, 1):
        for c in range(2, K + 1, 1):
            arr = [a, b, c]
            gcdNum = math.gcd(math.gcd(a, b), c)
            # if gcdNum != 1:
            # print(arr)
            # print(gcdNum)
            sumGCD += gcdNum - 1
print(sumGCD)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
dictA = {}
for x in A:
    dictA[x] = 0
for x1 in A:
    dictA[x1] += 1

for x2 in A:
    dictB = dictA.copy()
    combisum = 0
    dictB[x2] -= 1
    for x3 in dictB.values():
        combisum += x3 * (x3 - 1) // 2
    print(combisum)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
dictA = {}
for x in A:
    dictA[x] = 0
for x1 in A:
    dictA[x1] += 1

combisum = 0
for y in dictA.values():
    combisum += y * (y - 1) // 2

for z in range(N):
    print(combisum - dictA[A[z]] + 1)
Buggy python submission (verdict: Runtime Error):
import numpy as np
a, b, c = map(int, input().split())
if np.sqrt(a) + np.sqrt(b) < np.sqrt(c):
    print("Yes")
else:
    print("No")


Fixed submission:
a, b, c = map(int, input().split())
if a * b * 4 < (c - (a + b))**2 and c - (a + b) > 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
A = []
out = []
for x in range(3):
    A.append(list(map(int, input().split())))
    out.append([0, 0, 0])
N = int(input())
b = []
for B in range(N):
    b.append(int(input()))
for pick in b:
    for y in range(3):
        for x in range(3):
            if pick == A[y][x]:
                out[y][x] = 1

bingo = False
for x in range(3):
    if out[x][0] == 1 and out[x][1]　== 1 and out[x][2] == 1:
        bingo = True

for x in range(3):
    if out[0][x] == 1 and out[1][x] == 1 and out[2][x] == 1:
        bingo = True

for x in range(3):
    if out[0][0] == 1 and out[1][1] == 1 and out[2][2] == 1:
        bingo = True

    if out[2][0] == 1 and out[1][1] == 1 and out[2][0] == 1:
        bingo = True

if bingo:
    print("Yes")
else:
    print("No")


Fixed submission:
A = []
out = []
for x in range(3):
    A.append(list(map(int, input().split())))
    out.append([0, 0, 0])
N = int(input())
b = []
for B in range(N):
    b.append(int(input()))
for pick in b:
    for y in range(3):
        for x in range(3):
            if pick == A[y][x]:
                out[y][x] = 1

bingo = False
for x in range(3):
    if out[x][0] == 1 and out[x][1] == 1 and out[x][2] == 1:
        bingo = True

for x in range(3):
    if out[0][x] == 1 and out[1][x] == 1 and out[2][x] == 1:
        bingo = True

for x in range(3):
    if out[0][0] == 1 and out[1][1] == 1 and out[2][2] == 1:
        bingo = True

    if out[2][0] == 1 and out[1][1] == 1 and out[2][0] == 1:
        bingo = True

if bingo:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N,R = map(int,input().split())

if N <= 10:
    R = R + (10 - N) * 100
    
print(R)py

Fixed submission:
N,R = map(int,input().split())

if N <= 10:
    R = R + (10 - N) * 100
    
print(R)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = []
D = {}
for _ in range(N):
    x = input()
    L.append(x)

for x in L:
    D[x] = 0
    
for x in L:
    D[x] += 1

max_k_list = [kv[0] for kv in D.items() if kv[1] == max(D.values())]
print("\n".join(sorted(max_k_list)))


Fixed submission:
N = int(input())
L = []
D = {}
for _ in range(N):
    x = input()
    L.append(x)

for x in L:
    D[x] = 0
    
for x in L:
    D[x] += 1

SortD = sorted(D.items(), key=lambda x:x[1])
maxD = SortD[-1][1]
ans = []
for x in reversed(SortD):
    if x[1] == maxD:
        ans.append(x[0])
    else:
        break
for x in sorted(ans):
    print(x)

Buggy python submission (verdict: Runtime Error):
import collections
import itertools

N = int(input())
L = []
D = {}
for _ in range(N):
    x = input()
    L.append(x)

counter = collections.Counter(L)

mode_v = counter.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, counter.most_common()
)

print(sorted(*(k for k, v in it)))


Fixed submission:
N = int(input())
L = []
D = {}
for _ in range(N):
    x = input()
    L.append(x)

for x in L:
    D[x] = 0
    
for x in L:
    D[x] += 1

SortD = sorted(D.items(), key=lambda x:x[1])
maxD = SortD[-1][1]
ans = []
for x in reversed(SortD):
    if x[1] == maxD:
        ans.append(x[0])
    else:
        break
for x in sorted(ans):
    print(x)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
D = {}
for _ in range(N):
    x = input()
    if D.get(x):
        D[x] += 1
    else:
        D[x] = 1
max_k_list = [kv[0] for kv in D.items() if kv[1] == max(D.values())]
print("\n".join(sorted(max_k_list)))


Fixed submission:
N = int(input())
L = []
D = {}
for _ in range(N):
    x = input()
    L.append(x)

for x in L:
    D[x] = 0
    
for x in L:
    D[x] += 1

SortD = sorted(D.items(), key=lambda x:x[1])
maxD = SortD[-1][1]
ans = []
for x in reversed(SortD):
    if x[1] == maxD:
        ans.append(x[0])
    else:
        break
for x in sorted(ans):
    print(x)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
D = {}
for _ in range(N):
    x = input()
    if x in D:
        D[x] = D[x] + 1
    else:
        D[x]=1
MaxDarray = [k for k, v in D.items() if v == max(D.values())]
print("\n".join(sorted(MaxDarray)))


Fixed submission:
N = int(input())
L = []
D = {}
for _ in range(N):
    x = input()
    L.append(x)

for x in L:
    D[x] = 0
    
for x in L:
    D[x] += 1

SortD = sorted(D.items(), key=lambda x:x[1])
maxD = SortD[-1][1]
ans = []
for x in reversed(SortD):
    if x[1] == maxD:
        ans.append(x[0])
    else:
        break
for x in sorted(ans):
    print(x)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
p = tuple(map(int,input().split()))
count = 0
MaxSum = 0
for _ in p:
    tmp_SumSlice = sum(p[count:count + K])
    if MaxSum < tmp_SumSlice:
        MaxSum = tmp_SumSlice
    count += 1 
print((MaxSum+K)/2)

Fixed submission:
N, K = map(int,input().split())
p = tuple(map(int,input().split()))
MaxSum = sum(p[:K])
tmp_SumSlice = MaxSum
for i in range(K, N):
    tmp_SumSlice = tmp_SumSlice + p[i] - p[i - K]
    if MaxSum < tmp_SumSlice:
        MaxSum = tmp_SumSlice
print((MaxSum+K)/2)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
p = list(map(int,input().split()))
count = 0
MaxSum = 0
for i in p:
    tmp_slice = p[count:count + K]
    if MaxSum < sum(tmp_slice):
        MaxSum = sum(tmp_slice)
    count += 1 
print((MaxSum+K)/2)

Fixed submission:
N, K = map(int,input().split())
p = tuple(map(int,input().split()))
MaxSum = sum(p[:K])
tmp_SumSlice = MaxSum
for i in range(K, N):
    tmp_SumSlice = tmp_SumSlice + p[i] - p[i - K]
    if MaxSum < tmp_SumSlice:
        MaxSum = tmp_SumSlice
print((MaxSum+K)/2)

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

N, K = map(int,input().split())
p = list(map(int,input().split()))

count = 0
MaxSum = 0

for i in p:
    tmp_slice = p[count:count + K]
    if MaxSum < sum(tmp_slice):
        MaxSum = sum(tmp_slice)
    count += 1 

print((MaxSum+K)/2)


Fixed submission:
N, K = map(int,input().split())
p = tuple(map(int,input().split()))
MaxSum = sum(p[:K])
tmp_SumSlice = MaxSum
for i in range(K, N):
    tmp_SumSlice = tmp_SumSlice + p[i] - p[i - K]
    if MaxSum < tmp_SumSlice:
        MaxSum = tmp_SumSlice
print((MaxSum+K)/2)
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(A * B // math.gcd(A, B))


Fixed submission:
from fractions import gcd
A, B = map(int, input().split())
print(A * B // gcd(A, B))

Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(A * B // math.gcd(A, B))


Fixed submission:
from fractions import gcd
A, B = map(int, input().split())
print(A * B // gcd(A, B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
count = 1
broke = 0
suceed = False
while True:
    if count in a:
        suceed = True
        broke += a.index(count)
        a = a[a.index(count) + 1:]
        count += 1
    else:
        broke += len(a)
        break
if suceed:
    print(broke)
else:
    print(-1)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
count = 1
broke = 0

if 1 not in a:
    print(-1)
    exit()

for x in range(N):
    if a[x] == count:
        count += 1

print(N - count + 1)
Buggy python submission (verdict: Runtime Error):
S = list(input())

firstS = S[:len(S) // 2]
secondS = list(reversed(S[len(S) // 2 + 1:]))

count = 0

for x in range(len(firstS)):
    if firstS[x] != secondS[x]:
        count += 1
print(count)


Fixed submission:
S = list(input())

firstS = S[:len(S) // 2]
if len(S) % 2 == 0:
    secondS = list(reversed(S[len(S) // 2:]))
else:
    secondS = list(reversed(S[len(S) // 2 + 1:]))

count = 0

for x in range(len(firstS)):
    if firstS[x] != secondS[x]:
        count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
str = input()
print(str*str)

Fixed submission:
str = int(input())
answer = str * str
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
N_array = [K] * N
np = np.array(N_array)
for x in A:
    np -= 1
    np[x - 1] += 1
for z in np:
    if z > 0:
        print("Yes")
    else:
        print("No")


Fixed submission:
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
N_array = [K - Q] * N
for x in A:
    N_array[x - 1] += 1
for z in N_array:
    if z > 0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Runtime Error):
10 13 15
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9

Fixed submission:
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
N_array = [K - Q] * N
for x in A:
    N_array[x - 1] += 1
for z in N_array:
    if z > 0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Runtime Error):
import numpy as np

N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
N_array = [K] * N
np = np.array(N_array)
for x in A:
    np -= 1
    np[x - 1] += 1
for z in np:
    if z > 0:
        print("Yes")
    else:
        print("No")


Fixed submission:
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
N_array = [K - Q] * N
for x in A:
    N_array[x - 1] += 1
for z in N_array:
    if z > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)

for x in range(M):
    A[0] = A[0] // 2
    A = sorted(A, reverse=True)
print(sum(A))


Fixed submission:
import heapq

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
A = list(map(lambda x: x * (-1), A))
heapq.heapify(A)

for x in range(M):
    maxA = heapq.heappop(A)
    heapq.heappush(A, -1 * ((-1 * maxA) // 2))
A = list(map(lambda x: x * (-1), A))

print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
# maxA = max(A)
for x in range(len(A)):
    a_tmp = A[x]
    A[x] = 0
    print(max(A))
    A[x] = a_tmp


Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
maxA = max(A)
copy_A = A[:]
copy_A.remove(maxA)
secondA = max(copy_A)
for x in A:
    if x == maxA:
        print(secondA)
    else:
        print(maxA)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
for x in range(len(A)):
    a_copy = A[:]
    a_copy[x] = 0
    print(max(a_copy))


Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
maxA = max(A)
copy_A = A[:]
copy_A.remove(maxA)
secondA = max(copy_A)
for x in A:
    if x == maxA:
        print(secondA)
    else:
        print(maxA)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
for x in range(len(A)):
    a_copy = A[:]
    a_copy.pop(x)
    print(max(a_copy))


Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
maxA = max(A)
copy_A = A[:]
copy_A.remove(maxA)
secondA = max(copy_A)
for x in A:
    if x == maxA:
        print(secondA)
    else:
        print(maxA)
Buggy python submission (verdict: Runtime Error):
S = input()
S = S.strip(S[0])

if len(S[0]) > 0:
    S = S.strip(S[0])
    if len(S) == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Fixed submission:
S = input()
S = S.replace(S[0],"")
if len(S) > 0:
    S = S.replace(S[0],"")
    if len(S) == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
S = input()
S = S.strip(S[0])

if len(S[0]) > 0:
    S = S.strip(S[0])
    if len(S) == 0:
        print("YES")
    else:
        print("NO")
else:
    print("NO")


Fixed submission:
S = input()
S = S.replace(S[0],"")
if len(S) > 0:
    S = S.replace(S[0],"")
    if len(S) == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
min_ID = 0
max_ID = N
for _ in range(M):
    L, R = map(int, input().split())
    if min_ID < L:
        min_ID = L
    if max_ID > R:
        max_ID = R

if max_ID < min_ID:
    print(0)
else:
    print(max_ID - min_ID + 1)



Fixed submission:
A, B = map(int, input().split())
if A >= 13:
    print(B)
elif A >= 6:
    print(B//2)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
import Levenshtein

S = list(input())
lenS = len(S)

patternA = []
patternB = []
countA = 0
countB = 0

for x in range(lenS):
    print(S[x])
    if x % 2 == 0:
        if S[x] == "0":
            countA += 1
        else:
            countB += 1
    else:
        if S[x] == "1":
            countA += 1
        else:
            countB += 1

if countA < countB:
    print(countA)
else:
    print(countB)
    

Fixed submission:
S = list(input())
lenS = len(S)

patternA = []
patternB = []
countA = 0
countB = 0

for x in range(lenS):
    if x % 2 == 0:
        if S[x] == "0":
            countA += 1
        else:
            countB += 1
    else:
        if S[x] == "1":
            countA += 1
        else:
            countB += 1

if countA < countB:
    print(countA)
else:
    print(countB)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]

ab_hash = {}
count = 0
price_sum = 0
for x in ab:
    ab_hash[x[0]] = x[1]
ab_key_sorted = sorted(ab_hash.items(), key=lambda x: x[0])
while M > 0:
    if M > ab_key_sorted[count][1]:
        price_sum += ab_key_sorted[count][0] * ab_key_sorted[count][1]
    else:
        price_sum += ab_key_sorted[count][0] * M
    M = M - ab_key_sorted[count][1]
    count += 1

print(price_sum)


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

ab_hash = {}
count = 0
price_sum = 0
for x in range(len(ab)):
    ab_hash[x] = [ab[x][0], ab[x][1]]
ab_key_sorted = sorted(ab_hash.items(), key=lambda x: x[1][0])

for y in ab_key_sorted:
    if M > y[1][1]:
        price_sum += y[1][0] * y[1][1]
    else:
        price_sum += y[1][0] * M
    M -= y[1][1]
    if M <= 0:
        break

print(price_sum)

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

ab_hash = {}
count = 0
price_sum = 0
for x in ab:
    ab_hash[x[0]] = x[1]
ab_key_sorted = sorted(ab_hash.items(), key=lambda x: x[0])
while M > 0:
    if M > ab_key_sorted[count][1]:
        price_sum += ab_key_sorted[count][0] * ab_key_sorted[count][1]
    else:
        price_sum += M * ab_key_sorted[count][0]
    M = M - ab_key_sorted[count][1]
    count += 1

print(price_sum)


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

ab_hash = {}
count = 0
price_sum = 0
for x in range(len(ab)):
    ab_hash[x] = [ab[x][0], ab[x][1]]
ab_key_sorted = sorted(ab_hash.items(), key=lambda x: x[1][0])

for y in ab_key_sorted:
    if M > y[1][1]:
        price_sum += y[1][0] * y[1][1]
    else:
        price_sum += y[1][0] * M
    M -= y[1][1]
    if M <= 0:
        break

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

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

gcd = 0

for x in range(N):
    gcd = math.gcd(abs(a[x] - X), gcd)
print(gcd)


Fixed submission:
import fractions

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

gcd = 0

for x in range(N):
    gcd = fractions.gcd(abs(a[x] - X), gcd)
print(gcd)

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

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

gcd = 0

for x in range(N):
    gcd = math.gcd(abs(a[x] - X), gcd)
print(gcd)


Fixed submission:
import fractions

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

gcd = 0

for x in range(N):
    gcd = fractions.gcd(abs(a[x] - X), gcd)
print(gcd)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

count = 0
while True:
    if S[count] == "1":
        count += 1
    else:
        break

if K > count:
    print(S[count])
else:
    print(1)


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

count = 0
while count < len(S):
    if S[count] == "1":
        count += 1
    else:
        break
if K > count:
    print(S[count])
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))

count = 0

for x in range(N):
    if x != N - 1:
        if a[x] == a[x + 1]:
            if x + 1 < N:
                if a[x + 2] == 10000:
                    a[x + 1] = 9999
                    count += 1
                else:
                    a[x + 1] = 10000
                    count += 1
            else:
                a[x + 1] = 10000
                count += 1
print(count)


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

count = 0

for x in range(N):
    if x != N - 1:
        if a[x] == a[x + 1]:
            if x < N - 2:
                if a[x + 2] == 10000:
                    a[x + 1] = 9999
                    count += 1
                else:
                    a[x + 1] = 10000
                    count += 1
            else:
                a[x + 1] = 10000
                count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))
# print(p)
count = 0
for i in range(len(p)):
    # print(p[i])
    if i + 1 == p[i]:
        tmp = p[i]
        p[i] = p[i + 1]
        p[i + 1] = tmp
        count += 1
print(count)


Fixed submission:
N = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(len(p)):
    if i + 1 == p[i]:
        if i + 1 != len(p):
            tmp = p[i]
            p[i] = p[i + 1]
            p[i + 1] = tmp
            count += 1
        else:
            tmp = p[i]
            p[i] = p[i - 1]
            p[i - 1] = tmp
            count += 1

print(count)