Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
ans = 0
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    A_new = A[:i] + A[i+1:]
    ans = max(ans, gcd(*A_new))
print(ans)


Fixed submission:
import fractions

N = int(input())
a = list(map(int,input().split()))
a1 = [0] * N
a2 = [0] * N
a1[0] = 0
a2[-1] = 0
a1[1] = a[0]
a2[-2] = a[-1]
ans = 0
for i in range(2,N):
    a1[i] = fractions.gcd(a1[i-1], a[i-1])
    a2[-(i+1)] = fractions.gcd(a2[-i], a[-i])
for a,b in zip(a1, a2):
    if a == 0:
        ans = max(ans, b)
    elif b == 0:
        ans = max(ans, a)
    else:
        ans = max(ans, fractions.gcd(a, b))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
ans = 0
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    A_new = A[:i] + A[i+1:]
    ans = max(ans, gcd(*A_new))
print(ans)


Fixed submission:
import fractions

N = int(input())
a = list(map(int,input().split()))
a1 = [0] * N
a2 = [0] * N
a1[0] = 0
a2[-1] = 0
a1[1] = a[0]
a2[-2] = a[-1]
ans = 0
for i in range(2,N):
    a1[i] = fractions.gcd(a1[i-1], a[i-1])
    a2[-(i+1)] = fractions.gcd(a2[-i], a[-i])
for a,b in zip(a1, a2):
    if a == 0:
        ans = max(ans, b)
    elif b == 0:
        ans = max(ans, a)
    else:
        ans = max(ans, fractions.gcd(a, b))
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans = 0
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    A_new = A[:i] + A[i+1:]
    ans = max(ans, gcd(*A_new))
print(ans)


Fixed submission:
import fractions

N = int(input())
a = list(map(int,input().split()))
a1 = [0] * N
a2 = [0] * N
a1[0] = 0
a2[-1] = 0
a1[1] = a[0]
a2[-2] = a[-1]
ans = 0
for i in range(2,N):
    a1[i] = fractions.gcd(a1[i-1], a[i-1])
    a2[-(i+1)] = fractions.gcd(a2[-i], a[-i])
for a,b in zip(a1, a2):
    if a == 0:
        ans = max(ans, b)
    elif b == 0:
        ans = max(ans, a)
    else:
        ans = max(ans, fractions.gcd(a, b))
print(ans)
Buggy python submission (verdict: Runtime Error):
time = [int(input()) for i in range(5)]
result = 0
a = []

for i in range(5):
    if time[i] % 10 == 0:
        result += time[i]
    else:
        result += ((time[i] // 10)+1)*10
        a.append(time[i] % 10)
print(result - (10 - min(a)))


Fixed submission:
time = [int(input()) for i in range(5)]
result = 0
a = [10]

for i in range(5):
    if time[i] % 10 == 0:
        result += time[i]
    else:
        result += ((time[i] // 10)+1)*10
        a.append(time[i] % 10)
print(result - (10 - min(a)))

Buggy python submission (verdict: Runtime Error):
time = [int(input()) for i in range(5)]
result = 0
a = []

for i in range(5):
    if time[i] % 10 == 0:
        result += time[i]
        print(result)
    else:
        result += ((time[i] // 10)+1)*10
        a.append(time[i] % 10)
        print(result)
print(result - (10 - min(a)))


Fixed submission:
time = [int(input()) for i in range(5)]
result = 0
a = [10]

for i in range(5):
    if time[i] % 10 == 0:
        result += time[i]
    else:
        result += ((time[i] // 10)+1)*10
        a.append(time[i] % 10)
print(result - (10 - min(a)))
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate

N, Q = map(int,input().split())
S = input()
L = [0] * Q
R = [0] * Q
for i in range(Q):
    L[i], R[i] = map(int,input().split())

s_list = [0]*(N+1)
for i in range(1,N+1):
    if S[i-1] == 'A':
        if S[i] == 'C':
            s_list[i] = 1
s_list = list(accumulate(s_list))
for i,j in zip(L, R):
    print(s_list[j-1]-s_list[i-1])


Fixed submission:
from itertools import accumulate

N, Q = map(int,input().split())
S = list(input())
L = [0] * Q
R = [0] * Q
for i in range(Q):
    L[i], R[i] = map(int,input().split())

S = ['0'] + S
check = [0] * N

for i in range(N):
    if S[i] == 'A':
        if S[i+1] == 'C':
            check[i] = 1

check = list(accumulate(check))
for left, right in zip(L, R):
    print(check[right-1] - check[left-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
a = [list(map(int,input().split())) for i in range(Q)]

for i in range(Q):
    r = a[i]
    S1 = S[r[0]-1:r[1]]
    print(S1.count("AC"))


Fixed submission:
from itertools import accumulate

N, Q = map(int,input().split())
S = list(input())
L = [0] * Q
R = [0] * Q
for i in range(Q):
    L[i], R[i] = map(int,input().split())

S = ['0'] + S
check = [0] * N

for i in range(N):
    if S[i] == 'A':
        if S[i+1] == 'C':
            check[i] = 1

check = list(accumulate(check))
for left, right in zip(L, R):
    print(check[right-1] - check[left-1])
Buggy python submission (verdict: Runtime Error):
a,b,k = map(int, input().split())
l =[]
if a <= b:
    for i in range(1,a):
        if a % i == 0  and b % i == 0:
            l.append(i)
else:
    for i in range(1,b):
        if a % i == 0  and b % i == 0:
            l.append(i)
print(l[k-1])


Fixed submission:
a,b,k = map(int, input().split())
l =[]
if a <= b:
    for i in range(1,a + 1):
        if a % i == 0  and b % i == 0:
            l.append(i)
else:
    for i in range(1,b + 1):
        if a % i == 0  and b % i == 0:
            l.append(i)
print(l[len(l)-k])
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
HP = input().split()

while True:
    a = math.gcd(int(HP[-1]),int(HP[0]))
    del HP[-1]
    del HP[0]
    HP.append(str(a))
    if len(HP) == 1:
        print(HP[0])
        break


Fixed submission:
import fractions
from functools import reduce

N = int(input())
A = list(map(int,input().split()))
print(reduce(lambda a, b: fractions.gcd(a,b), A))

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

N = int(input())
HP = input().split()

while True:
    a = math.gcd(int(HP[-1]),int(HP[0]))
    del HP[-1]
    del HP[0]
    HP.append(str(a))
    if len(HP) == 2:
        print(math.gcd(int(HP[-1]),int(HP[0])))
        break


Fixed submission:
import fractions
from functools import reduce

N = int(input())
A = list(map(int,input().split()))
print(reduce(lambda a, b: fractions.gcd(a,b), A))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A,B=map(int,input().split())
p = list(map(int,input().split()))
c=[]
d=[]
e=[]
for i in range(N):
    if p[i]<=A:
        c.append(p[i])
    if A+1 <= p[i] <= B:
        d.append(p[i])
    if B+1 <= p[i]:
        e.append(p[i])

        
print(min(len(c),len(d),len(e))))


Fixed submission:
N=int(input())
A,B=map(int,input().split())
p = list(map(int,input().split()))
c=[]
d=[]
e=[]
for i in range(N):
    if p[i]<=A:
        c.append(p[i])
    if A+1 <= p[i] <= B:
        d.append(p[i])
    if B+1 <= p[i]:
        e.append(p[i])

        
print(min(len(c),len(d),len(e)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [0]*N
b = [0]*N
c = [0]*N
for i in range(N):
    a[i],b[i],c[i] = map(int,input().split())

inf = -float('inf')
dp = [[inf] * N for _ in range(3)]
dp[0][0] = a[0]
dp[1][0] = b[0]
dp[2][0] = c[0]

for i in range(1,N):
    dp[0][i] = max(dp[1][i-1] + a[i],dp[2][i-1] + a[i])
    dp[1][i] = max(dp[0][i-1] + b[i],dp[2][i-1] + b[i])
    dp[2][i] = max(dp[0][i-1] + c[i],dp[1][i-1] + c[i])

print(max(dp[0][N-1],dp[1][N-1],dp[2][N-1]))


Fixed submission:
N = int(input())
h = list(map(int,input().split()))
dp = [0] * (N+1)
dp[2] = abs(h[1]-h[0])
for i in range(3, N+1):
    dp[i] = min(dp[i-1]+abs(h[i-1]-h[i-2]), dp[i-2]+abs(h[i-1]-h[i-3]))
print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
h = list(map(int,input().split()))
dp = [float('inf')] * (N+1)
dp[0:2] = [0,0]
for i in range(2, N+1):
    for j in range(1,K+1):
        if i-j <= 0:
            break
        dp[i] = min(dp[i], dp[i-j]+abs(h[i-1]-h[i-j-1]))
print(dp[N])


Fixed submission:
N, K = map(int,input().split())
h = list(map(int,input().split()))
dp = [float('inf')] * (N+1)
dp[0:2] = [0,0]
for i in range(2, N+1):
    for j in range(1,K+1):
        if i-j <= 0:
            break
        dp[i] = min(dp[i], dp[i-j]+abs(h[i-1]-h[i-j-1]))
print(dp[N])
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
average = sum(a) / N
A = list(map(lambda n:abs(n-average), a))
A.sort()
A1 = int(average - A[0])
A2 = int(average + A[0])
print(min(a.index(A1), a.index(A2)))


Fixed submission:
a=int(input())
f = list(map(int,input().split()))
b=[]
ave=sum(f)/a

for i in f:
    diff=abs(i-ave)
    b.append(diff)
print(b.index(min(b)))
Buggy python submission (verdict: Runtime Error):
from fractions import gcd

N, M = map(int,input().split())
S = input()
T = input()
L = (N*M)//gcd(N,M)
ans = [0] * (L+1)
for i in range(1,N+1):
    ans[1+(i-1)*(L//N)] = S[i-1]

for i in range(1,M+1):
    if ans[1+(i-1)*(L//M)] == 0:
        ans[1+(i-1)*(L//M)] = T[i-1]
    else:
        if ans[1+(i-1)*(L//M)] == T[i-1]:
            pass
        else:
            print(-1)
            exit()

print(L)
        

Fixed submission:
from fractions import gcd

N, M = map(int,input().split())
S = input()
T = input()
L = (N*M)//gcd(N,M)
S_a = L // N
T_a = L // M
L_a = (S_a*T_a)//gcd(S_a,T_a)

S_b = L_a // S_a
T_b = L_a // T_a
i = 0
j = 0
while True:
    if S[i] != T[j]:
        print('-1')
        break
    i += S_b
    j += T_b
    if i >= N or j >= M:
        print(L)
        break

Buggy python submission (verdict: Runtime Error):
from fractions import gcd

N, M = map(int,input().split())
S = input()
T = input()
L = N*M//gcd(N,M)
ans = [0] * (L+1)
for i in range(1,N+1):
    ans[1+(i-1)*(L//N)] = S[i-1]

for i in range(1,M+1):
    if ans[1+(i-1)*(L//M)] == 0:
        ans[1+(i-1)*(L//M)] = T[i-1]
    else:
        if ans[1+(i-1)*(L//M)] == T[i-1]:
            pass
        else:
            print(-1)
            exit()

print(L)
        

Fixed submission:
from fractions import gcd

N, M = map(int,input().split())
S = input()
T = input()
L = (N*M)//gcd(N,M)
S_a = L // N
T_a = L // M
L_a = (S_a*T_a)//gcd(S_a,T_a)

S_b = L_a // S_a
T_b = L_a // T_a
i = 0
j = 0
while True:
    if S[i] != T[j]:
        print('-1')
        break
    i += S_b
    j += T_b
    if i >= N or j >= M:
        print(L)
        break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = [0] * N
Y = [0] * N
H = [0] * N
for i in range(N):
    X[i], Y[i], H[i] = map(int,input().split())

for Cx in range(101):
    for Cy in range(101):
        for T in range(min(H), min(H)+101):
            flag = 0
            for x,y,h in zip(X,Y,H):
                if h == max(T - abs(x-Cx) - abs(y-Cy),0):
                        flag += 1
                if flag == N:
                    print(Cx,Cy,T)
                    exit()


Fixed submission:
from operator import itemgetter

N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=itemgetter(2))
xyh.reverse()
for Cx in range(101):
    for Cy in range(101):
        H_MAX = -1
        H = -1
        for i in range(N):
            x = xyh[i][0]
            y = xyh[i][1]
            h = xyh[i][2]
            if h > 0 and i == 0:
                H = h + abs(x-Cx) + abs(y-Cy)
            elif h > 0:
                if H == h + abs(x-Cx) + abs(y-Cy):
                    pass
                else:
                    break
            elif h < 0 and i == 0:
                H_MAX = abs(x-Cx) + abs(y-Cy)
                if H_MAX == 0:
                    break
            else:
                if H_MAX == -1:
                    if H <= abs(x-Cx) + abs(y-Cy):
                        pass
                    else:
                        break
                else:
                    H_MAX = abs(x-Cx) + abs(y-Cy)
                    if H_MAX == 0:
                        break
            if i == N-1:
                print(Cx,Cy,max(H,H_MAX))
                exit()
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
N, M = map(int,input().split())
MIN = 0
MAX = 10**9
while MAX - MIN > 1:
    MID = (MAX+MIN)//2
    if M/MID > N:
        MIN = MID
    else:
        MAX = MID

for i in range(MAX,0,-1):
    if i == 1:
        print(i)
    else:
        if M % i == 0:
            print(i)
            exit()

Fixed submission:
N,M = map(int,input().split())
MAX = int(M**(1/2))
ans = 0
for i in range(MAX,0,-1):
    if M % i == 0:
        j = M // i
        if j >= N:
            ans = max(ans,i)
        if i >= N:
            ans = max(ans,j)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in n:
    if i == 1:
        i = 9
    elif i == 9:
        i = 1
print(n)


Fixed submission:
n = int(input())
print(1110 - n)
Buggy python submission (verdict: Runtime Error):
import collections

n = int(input())
v = list(map(int,input().split()))
v1 = v[::2]
v2 = v[1::2]
v1 = collections.Counter(v1)
v2 = collections.Counter(v2)
ans = 0
if v1.most_common()[0][0] == v2.most_common()[0][0]:
    if v1.most_common()[0][1] < v2.most_common()[0][1]:
        ans += n//2 - v2.most_common()[0][1]
        ans += n//2 - v1.most_common()[1][1]
        print(ans)
    elif v1.most_common()[0][1] > v2.most_common()[0][1]:
        ans += n//2 - v1.most_common()[0][1]
        ans += n//2 - v2.most_common()[0][1]
        print(ans)
    else:
        if v1.most_common()[0][1] == n//2:
            print(N//2)
        else:
            if v1.most_common()[1][1] > v2.most_common()[1][1]:
                ans += n//2 - v2.most_common()[0][1]
                ans += n//2 - v1.most_common()[1][1]
                print(ans)
            else:
                ans += n//2 - v1.most_common()[0][1]
                ans += n//2 - v2.most_common()[1][1]
                print(ans)
else:
    ans += n//2 - v1.most_common()[0][1]
    ans += n//2 - v2.most_common()[0][1]
    print(ans)


Fixed submission:
import collections

n = int(input())
v = list(map(int,input().split()))
v1 = v[::2]
v2 = v[1::2]
v1 = collections.Counter(v1)
v2 = collections.Counter(v2)
ans = 0
if v1.most_common()[0][0] == v2.most_common()[0][0]:
    if v1.most_common()[0][1] < v2.most_common()[0][1]:
        ans += n//2 - v2.most_common()[0][1]
        ans += n//2 - v1.most_common()[1][1]
        print(ans)
    elif v1.most_common()[0][1] > v2.most_common()[0][1]:
        ans += n//2 - v1.most_common()[0][1]
        ans += n//2 - v2.most_common()[0][1]
        print(ans)
    else:
        if v1.most_common()[0][1] == n//2:
            print(n//2)
        else:
            if v1.most_common()[1][1] > v2.most_common()[1][1]:
                ans += n//2 - v2.most_common()[0][1]
                ans += n//2 - v1.most_common()[1][1]
                print(ans)
            else:
                ans += n//2 - v1.most_common()[0][1]
                ans += n//2 - v2.most_common()[1][1]
                print(ans)
else:
    ans += n//2 - v1.most_common()[0][1]
    ans += n//2 - v2.most_common()[0][1]
    print(ans)
Buggy python submission (verdict: Runtime Error):
a = list[int(input().split()) for i in range(3)]
a.remove(max(a))
result = 0
for i in range(2):
    result += a[i]
print(int(max(a) * 10 + result))


Fixed submission:
a = list(input().split())
b = int(max(a))
a.remove(max(a))
result = 0
for i in range(2):
    result += int(a[i])
print(b * 10 + int(result))
Buggy python submission (verdict: Runtime Error):
S = list(input())
T = list(input())
dic = {}
for i in range(len(S)):
    if i == 0:
        dic[S[i]] = T[i]
        dic[T[i]] = S[i]
        S[i] = T[i]
    else:
        if T[i] in S[:i]:
            if dic[S[i]] != T[i]:
                print('No')
                exit()
        else:
            dic[S[i]] = T[i]
            dic[T[i]] = S[i]
            S[i] = T[i]
print('Yes')


Fixed submission:
S = input()
T = input()
dict1 = {}
dict2 = {}

for s,t in zip(S,T):
    if s in dict1:
        if dict1[s] == t:
            pass
        else:
            print('No')
            exit()
    else:
        dict1[s] = t
    if t in dict2:
        if dict2[t] == s:
            pass
        else:
            print('No')
            exit()
    else:
        dict2[t] = s
print('Yes')
Buggy python submission (verdict: Runtime Error):
import math

N,X = map(int,input().split())
x = list(map(int,input().split()))
distance = []

for i in x:
    distance.append(abs(i-X))

while len(distance) > 1:
        cd = math.gcd(distance[0],distance[1])
        del distance[0]
        del distance[0]
        distance.append(cd)

print(distance[0])


Fixed submission:
A,B = map(int, input().split())
if A * B % 2 == 0:
    print("No")
else:
    print("Yes")

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

N,X = map(int,input().split())
x = list(map(int,input().split()))
distance = []

for i in x:
    distance.append(abs(i-X))



Fixed submission:
A,B = map(int, input().split())
if A * B % 2 == 0:
    print("No")
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
A,B = int(input().split())
if A * B % 2 == 0:
    print("No")
else:
    print("Yes")


Fixed submission:
A,B = map(int, input().split())
if A * B % 2 == 0:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
x1,y1,x2,y2 = map(int,input().split())
x12 = x2 - x1
y12 = y2 - y1

for x in range(-100, 101):
    for y in range(-100, 101):
        if x*x12 + y*y12 == 0 and x12**2 + y12**2 == x**2 + y**2:
            x += x1
            y += y1
            if x12 >= 0 and y12 <= 0:
                if 0 <= x and 0 <= y:
                    x4 = x
                    y4 = y
            elif x12 >= 0 and y12 >= 0:
                if 0 >= x and 0 <= y:
                    x4 = x
                    y4 = y
            elif x12 <= 0 and y12 >= 0:
                if 0 >= x and 0 >= y:
                    x4 = x
                    y4 = y
            elif x12 <= 0 and y <= 0:
                if x >= 0 and y <= 0:
                    x4 = x
                    y4 = y

for x in range(-300,301):
    for y in range(-300,301):
        if (x2-x)**2 + (y2-y)**2 == (x4-x)**2 + (y4-y)**2 == x12**2 + y12**2 and x != x1 and y != y1:
            x3 = x
            y3 = y
print(x3,y3,x4,y4)


Fixed submission:
import math

x1,y1,x2,y2 = map(int,input().split())
x12 = x2 - x1
y12 = y2 - y1

r = (x12**2+y12**2)**(1/2)
θ = math.asin(abs(y12)/r)
if 0 >= x12 and 0 <= y12:
    θ = math.pi - θ
elif 0 >= x12 and 0 > y12:
    θ += math.pi
elif 0 < x12 and y12 < 0:
    θ = 2*math.pi - θ
x3 = round((2**(1/2)*r)*math.cos(θ + (math.pi/4)) + x1)
y3 = round((2**(1/2)*r)*math.sin(θ + (math.pi/4)) + y1)
x4 = round(r*math.cos(θ + (math.pi/2)) + x1)
y4 = round(r*math.sin(θ + (math.pi/2)) + y1)
print(x3,y3,x4,y4)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
count = 0


for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(1,N+1):
            a = (i+j) % K
            b = (j+k) % K
            c = (k+i) % K
            if a == 0 and b == 0 and c == 0:
                count += 1
print(count)


Fixed submission:
N, K = map(int,input().split())
count_0 = 0
count_2 = 0

for i in range(1,N+1):
    if i % K == 0:
        count_0 += 1
    if i % K == K / 2:
        count_2 += 1
if K % 2 == 0:
    print(count_0**3 + count_2**3)
else:
    print(count_0**3)
Buggy python submission (verdict: Runtime Error):
s = list(input())
count = 0

if s[0] == "A":
    for i in range(2,len(s)-1):
        if s[i] == "C":
            count += 1
    if count != 1:
        print("WA")
        exit()
    else:
        number = s.index("C")
else:
    print("WA")
    exit()

s.remove(0)
s.remove(number)

for j in s:
    c = j.lower()
    if c == j:
        continue
    else:
        print("WA")
        exit()
print("AC")


Fixed submission:
s = list(input())
count = 0

if s[0] == "A":
    for i in range(2,len(s)-1):
        if s[i] == "C":
            count += 1
    if count != 1:
        print("WA")
        exit()
    else:
        number = s.index("C")
else:
    print("WA")
    exit()

del s[number]
del s[0]

for j in s:
    c = j.lower()
    if c == j:
        continue
    else:
        print("WA")
        exit()
print("AC")
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate

N = int(input())
A = list(map(int,input().split()))
A = list(accumulate(A))
ans = []

for i in range(N-3):
    for j in range(i+1, N-2):
        for k in range(j+1, N-1):
            list = []
            p = A[i]
            q = A[j]-A[i]
            r = A[k]-A[j]
            s = A[-1]-A[k]
            list = [p, q, r, s]
            ans.append(max(list) - min(list))

print(min(ans))


Fixed submission:
N = int(input())
if N % 2 == 0:
    print(N)
else:
    print(2 * N)

Buggy python submission (verdict: Runtime Error):
 N = int(input())
if N % 2 == 0:
    print(N)
else:
    print(2 * N)


Fixed submission:
N = int(input())
if N % 2 == 0:
    print(N)
else:
    print(2 * N)
Buggy python submission (verdict: Runtime Error):
K = int(input())

if K < 9:
    for i in range(1,K+1):
        print(i)
else:
    for i in range(1,9):
        print(i)
    for i in range(K-8):
        print((i+1) * 10 -1)


Fixed submission:
S = input()
result = 0
for i in S:
    if i == "+":
        result += 1
    else:
        result -= 1
print(result)
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int, input().split())
if abs(a - c) > d:
    if abs(b - a) > d or abs(b - c) > d:
        pint("No")
    else:
        print("Yes")
else:
    print("Yes")


Fixed submission:
a,b,c,d = map(int, input().split())
if abs(a - c) > d:
    if abs(b - a) > d or abs(b - c) > d:
        print("No")
    else:
        print("Yes")
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
S = []
for i in range(1,len(s)+1):
    for j in range(len(s)):
        if j+1 > len(s):
            break
        if s[j:j+i] not in  S:
            S.append(s[j:j+i])
S.sort()
print(S[K-1])


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

for k in range(1, K+1):
    for j in range(len(s)):
        if j+k == len(s)+1:
            break
        t.add(s[j:j+k])
t = sorted(t)
print(t[K-1])
Buggy python submission (verdict: Runtime Error):
H, W = map(int,input().split())
s = [list(input()) for _ in range(H)]
for i in range(H):
    s[i] = [0] + s[i] + [0]
s = [[0]*W] + s + [[0]*W]
for i in range(1,H+1):
    for j in range(1,W+1):
        if s[i][j] == '#':
            if s[i-1][j] == '#' or s[i][j-1] == '#' or s[i][j+1] == '#' or s[i+1][j] == '#':
                continue
            else:
                print('No')
                exit()
print('Yes')


Fixed submission:
H, W = map(int,input().split())
s = [list(input()) for _ in range(H)]
for i in range(H):
    s[i] = [0] + s[i] + [0]
s = [[0]*(W+2)] + s + [[0]*(W+2)]
for i in range(1,H+1):
    for j in range(1,W+1):
        if s[i][j] == '#':
            if s[i-1][j] == '#' or s[i][j-1] == '#' or s[i][j+1] == '#' or s[i+1][j] == '#':
                continue
            else:
                print('No')
                exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 0

def combination(n,r):
    return math.factorial(n) / (math.factorial(n-r) * math.factorial(r))

for i in range(1,N):
    for j in range(0,i):
        if ans < combination(a[i], a[j]):
            ans = combination(a[i], a[j])
            n = a[i]
            r = a[j]
print(n, r)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
MAX = max(A)
r_A = MAX / 2
del A[A.index(MAX)]
B = list(map(lambda a:abs(a-r_A),A))
B.sort()
r1 = int(r_A + B[0])
r2 = int(r_A - B[0])
if r1 in A:
    print(MAX, r1)
else:
    print(MAX, r2)