Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = str(input())

max = 0
x = 0

for i in range(N):
    if S[i] == 'I':
        x += 1
    else:
        x -= 1
    if x > max:
        max = x

print(max)


Fixed submission:
A,B,C,D = [int(i) for i in input().split()]

S1 = int(A*B)
S2 = int(C*D)

if S1 >= S2:
    print(S1)
elif S2 > S1:
    print(S2)

Buggy python submission (verdict: Runtime Error):
A,B,C,D = [int(i) for i in input().split()]

S1 = int(A*B)
S2 = int(C*D)

if S1 >= S2:
    print(S1)
else:
    return 0
if S2 >= S1:
    print(S2)
else:
    return 0


Fixed submission:
A,B,C,D = [int(i) for i in input().split()]

S1 = int(A*B)
S2 = int(C*D)

if S1 >= S2:
    print(S1)
elif S2 > S1:
    print(S2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = int(input())

max = 0
x = 0

for i in range(N):
    if S[i] == 'I':
        x += 1
    else:
        x -= 1
    if x > max:
        max = x

print(max)


Fixed submission:
N = int(input())
S = str(input())

max = 0
x = 0

for i in range(N):
    if S[i] == 'I':
        x += 1
    else:
        x -= 1
    if x > max:
        max = x

print(max)
Buggy python submission (verdict: Runtime Error):
A,B,C = [str(i) for i in input().split()]
N = str()

N = A[0] + B[0] + C[0]

ptint(N)

Fixed submission:
s = input()
print('A' + s[8] + 'C')
Buggy python submission (verdict: Runtime Error):
N,K = [int(i) for i in input().split()]

print(K * (K-1) ** (N-1))


Fixed submission:
a,b,c = [int(i) for i in input().split()]
n = 3
if a == b and a == c:
    print(1)
else:
    if a == b:
        n = n-1
    elif b == c:
        n = n-1
    elif a == c:
        n = n-1
    print(n)
Buggy python submission (verdict: Runtime Error):
if (b * 10 + c) % 4 == 0:
    print('YES')
else:
    print('NO')


Fixed submission:
a, b, c = map(int, input().split())
if (b * 10 + c) % 4 == 0:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
def prime_factors(n):
    i = 2
    factors = 1
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors = i
    if n > 1:
        factors = i
    return factors
N = int(input())
large_factor = prime_factors(N)
print(int(large_factor+(N/large_factor)-2))

Fixed submission:
A, B = map(int, input().split())
if A > 9 or B > 9:
  print (-1)
else:
  print(A*B)

Buggy python submission (verdict: Runtime Error):
A, B = map(int, raw_input().split())
if A > 9 or B > 9:
  print (-1)
else:
  print(A*B)

Fixed submission:
A, B = map(int, input().split())
if A > 9 or B > 9:
  print (-1)
else:
  print(A*B)
Buggy python submission (verdict: Runtime Error):
N = int(input)
isDiv = 'No'
for i in range(1, 10):
  if N % i == 0:
    if N / i <= 9:
    	isDiv = 'Yes'
    	break
print(isDiv)


Fixed submission:
N = int(input())
isDiv = 'No'
for i in range(1, 10):
  if N % i == 0:
    if N / i <= 9:
    	isDiv = 'Yes'
    	break
print(isDiv)

Buggy python submission (verdict: Runtime Error):
N = int(input)
isDiv = 'No'
for i in range(1, 10):
  if N % i == 0:
    isDiv = 'Yes'
    break
print(isDiv)

Fixed submission:
N = int(input())
isDiv = 'No'
for i in range(1, 10):
  if N % i == 0:
    if N / i <= 9:
    	isDiv = 'Yes'
    	break
print(isDiv)
Buggy python submission (verdict: Runtime Error):
def prime_factors(n):
    i = 2
    factors = 1
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors = i
    if n > 1:
        factors = i
    return factors
N = int(input())
large_factor = prime_factor(N)
print(large_factor+(N/large_factor)-2)

Fixed submission:
N = int(input())
def findSteps(n):
  for x in range(int(n**(1/2)), 1, -1):
    if (n % x == 0):
      return (int(x + n/x - 2))
  return (N-1)
 
print(findSteps(N))

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

Fixed submission:
N = int(input())
def findSteps(n):
  for x in range(int(n**(1/2)), 1, -1):
    if (n % x == 0):
      return (int(x + n/x - 2))
  return (N-1)
 
print(findSteps(N))
Buggy python submission (verdict: Runtime Error):
A, B = int(input().split())
if A - 2 * B <= 0:
  print(0)
else:
  print(A-2*B)

Fixed submission:
A, B = map(int, input().split())
if A - 2 * B <=0:
  print(0)
else:
  print(A - 2 * B)
Buggy python submission (verdict: Runtime Error):
l = [0]*100
for i in range(1, 10):
    for j in range(1, 10):
        l[i*j] = 1
n = int(input())
if l[n] == 1:
    print("Yes")
else:
    print("No")

Fixed submission:
l = [0]*101
for i in range(1, 10):
    for j in range(1, 10):
        l[i*j] = 1
n = int(input())
if l[n] == 1:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b,x = map(int, input().split())
if x < (b*a**2)/2:
    c = 2*x / a**2
    print(90 - math.degrees(math.atan(c/a)))
else:
    x2 = x - b*a**2
    c = 2*x2 / a**2
    print(-math.degrees(math.atan(c/a)))

Fixed submission:
import math
a,b,x = map(int, input().split())
if x < (b*a**2)/2:
    c = (2*x) / (a*b)
    print(90 - math.degrees(math.atan(c/b)))
else:
    x2 = x - b*a**2
    c = (2*x2) / (a*a)
    print(-math.degrees(math.atan(c/a)))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ac_lst = []
for i in range(m):
    a, b = map(int, input().split())
    lst = list(map(int, input().split()))
    ac_lst.append((a, lst))
    
dp = [[10**10] * (2**n) for _ in range(m+1) ]
for i in range(m+1):
    dp[i][0] = 0

for i in range(1, m+1):
    a, c_lst = ac_lst[i-1]
    d = 0
    for k in c_lst:
        d = d | (2**(k-1))
    for j in range(2**n):
        k = j | d
        dp[i][j] = min(dp[i][j], dp[i-1][j])
        dp[i][k] = min(dp[i][k], dp[i-1][k], dp[i-1][j] + a)
        
print(dp[-1][-1]) if dp[-1][-1] != 10**10 else print(-1)

Fixed submission:
n, m = map(int, input().split())
ac_lst = []
for i in range(m):
    a, b = map(int, input().split())
    lst = list(map(int, input().split()))
    ac_lst.append((a, lst))
    
dp = [[10**10] * (2**n) for _ in range(m+1) ]
for i in range(m+1):
    dp[i][0] = 0

for i in range(1, m+1):
    a, c_lst = ac_lst[i-1]
    d = 0
    for k in c_lst:
        d = d | (2**(k-1))
    for j in range(2**n):
        k = j | d
        dp[i][j] = min(dp[i][j], dp[i-1][j])
        dp[i][k] = min(dp[i][k], dp[i-1][k], dp[i-1][j] + a)
        
print(dp[-1][-1]) if dp[-1][-1] != 10**10 else print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())
s = input()

if s[0] == 'W' or s[-1] == 'W':
    print(0)
else:    
    s_lr = 'L'
    for i in range(len(s)-1):
        if s[i+1] == s[i]:
            if s_lr[-1] == 'L':
                s_lr += 'R'
            else:
                s_lr += 'L'
        else:
            if s_lr[-1] == 'L':
                s_lr += 'L'
            else:
                s_lr += 'R'    
    l_cnt = 0
    r_cnt = 0
    lst = []
    for i in s_lr:
        if i == 'L':
            l_cnt += 1
            lst.append(0)
        else:
            if l_cnt - r_cnt <= 0:
                print(0)
                break
            else:
                lst.append(l_cnt - r_cnt)
            r_cnt += 1
    else:
        if l_cnt != r_cnt:
            print(0)
        else:
            res = 1
            for i in lst:
                if i > 0:
                    res = res * i % (10**9 + 7)
            print(res * math.factorial(n) % (10**9 + 7) )

Fixed submission:
import math

n = int(input())
s = input()

if s[0] == 'W' or s[-1] == 'W':
    print(0)
else:    
    s_lr = 'L'
    for i in range(len(s)-1):
        if s[i+1] == s[i]:
            if s_lr[-1] == 'L':
                s_lr += 'R'
            else:
                s_lr += 'L'
        else:
            if s_lr[-1] == 'L':
                s_lr += 'L'
            else:
                s_lr += 'R'    
    l_cnt = 0
    r_cnt = 0
    lst = []
    for i in s_lr:
        if i == 'L':
            l_cnt += 1
            lst.append(0)
        else:
            if l_cnt - r_cnt <= 0:
                print(0)
                break
            else:
                lst.append(l_cnt - r_cnt)
            r_cnt += 1
    else:
        if l_cnt != r_cnt:
            print(0)
        else:
            res = 1
            for i in lst:
                if i > 0:
                    res = res * i % (10**9 + 7)
            print(res * math.factorial(n) % (10**9 + 7) )
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

lst = [[] for _ in range(30)]
ch = 'abcdefghijklmnopqrstuvwxyz'
for k, i in enumerate(s+s):
    lst[ch.find(i)].append(k)

len_s = len(s)

count = 0
index = -1
for i in t:
    if lst[ch.find(i)] == []:
        print(-1)
        break
    next_index = lst[ch.find(i)][bisect.bisect_right(lst[ch.find(i)], index)]
    count += next_index - index
    if next_index >= len_s:
        next_index -= len_s
    index = next_index
else:
    print(count)

Fixed submission:
import bisect

s = input()
t = input()

lst = [[] for _ in range(30)]
ch = 'abcdefghijklmnopqrstuvwxyz'
for k, i in enumerate(s+s):
    lst[ch.find(i)].append(k)

len_s = len(s)

count = 0
index = -1
for i in t:
    if lst[ch.find(i)] == []:
        print(-1)
        break
    next_index = lst[ch.find(i)][bisect.bisect_right(lst[ch.find(i)], index)]
    count += next_index - index
    if next_index >= len_s:
        next_index -= len_s
    index = next_index
else:
    print(count)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

lst = [0] * (len(t) + 1)

t_len = len(t)
count = 0
res = 0
s_new = s[:]
while count < t_len:
    index = s_new.find(t[count])
    if index == -1:
        print(-1)
        break
    res += index + 1
    count += 1
    if index == len(s) - 1:
        pass
    else:
        s_new = s_new[index+1:] + s_new[:index+1]
else:
    print(res)

Fixed submission:
import bisect

s = input()
t = input()

lst = [[] for _ in range(30)]
ch = 'abcdefghijklmnopqrstuvwxyz'
for k, i in enumerate(s+s):
    lst[ch.find(i)].append(k)

len_s = len(s)

count = 0
index = -1
for i in t:
    if lst[ch.find(i)] == []:
        print(-1)
        break
    next_index = lst[ch.find(i)][bisect.bisect_right(lst[ch.find(i)], index)]
    count += next_index - index
    if next_index >= len_s:
        next_index -= len_s
    index = next_index
else:
    print(count)
Buggy python submission (verdict: Runtime Error):
n, m, p = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]
 
for i in range(m):
    lst[i][2] = - (lst[i][2] - p)

d = [10**100] * (n+1)
d[1] = 0
rep = 0
 
while True:
    update = False
    for edge in lst:
        a,b,c = edge
        if d[a] != 10**100 and d[b] > d[a]+ c:
            if rep >= n:
                d[b] = -10**100
            else:
                d[b] = d[a] + c
            update = True
    if not update:
        break
    rep += 1
    if loop:
        break
    if rep > 2*n:
        break


if d[n] <= - 10**100:
    print(-1)
elif -d[n] < 0:
    print(0)
else:
    print(-d[n])

Fixed submission:
n, m, p = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]
 
for i in range(m):
    lst[i][2] = - (lst[i][2] - p)

d = [10**100] * (n+1)
d[1] = 0
rep = 0
 
while True:
    update = False
    for edge in lst:
        a,b,c = edge
        if d[a] != 10**100 and d[b] > d[a]+ c:
            if rep >= n:
                d[b] = -10**100
            else:
                d[b] = d[a] + c
            update = True
    if not update:
        break
    rep += 1
    if rep > 2*n:
        break

if d[n] <= - 10**100:
    print(-1)
elif -d[n] < 0:
    print(0)
else:
    print(-d[n])

Buggy python submission (verdict: Time Limit Exceeded):
n, m, p = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]

for i in range(m):
    lst[i][2] = - (lst[i][2] - p)

def bellmanford():
    rep = 0
    while rep < n:
        update = False
        for edge in lst:
            a,b,c = edge
            if d[a] != 10**100 and d[b] > d[a]+ c:
                d[b] = d[a] + c
                update = True
        if not update:
            break
        rep += 1
    return False if rep != n else True

not_N_reach_list = []
not_1_reach_list = []
for i in range(1, n):
    d = [10**100] * (n+1)
    d[i] = 0
    bellmanford()
    if i == 1:
        for j in range(2, n):
            if d[j] == 10**100:
                not_1_reach_list.append(j)
    else:
        if d[n] == 10**100:
            not_N_reach_list.append(i)
        
exclude_lst = set(not_N_reach_list + not_1_reach_list)

new_lst = []
for edge in lst:
    a, b, c = edge
    if a not in exclude_lst and b not in exclude_lst:
        new_lst.append(edge)
        
lst = new_lst

d = [10**100] * (n+1)
d[1] = 0
a = bellmanford()
if a:
    print(-1)
else:
    print(0) if -d[n] < 0 else print(-d[n])

Fixed submission:
n, m, p = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]
 
for i in range(m):
    lst[i][2] = - (lst[i][2] - p)

d = [10**100] * (n+1)
d[1] = 0
rep = 0
 
while True:
    update = False
    for edge in lst:
        a,b,c = edge
        if d[a] != 10**100 and d[b] > d[a]+ c:
            if rep >= n:
                d[b] = -10**100
            else:
                d[b] = d[a] + c
            update = True
    if not update:
        break
    rep += 1
    if rep > 2*n:
        break

if d[n] <= - 10**100:
    print(-1)
elif -d[n] < 0:
    print(0)
else:
    print(-d[n])
Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
lst = [input() for _ in range(h)]

res = 0
L = [[0] * w for _ in range(h)]
R = [[0] * w for _ in range(h)]
U = [[0] * w for _ in range(h)]
D = [[0] * w for _ in range(h)]

for i in range(w):
    for j in range(h):
        if lst[j][i] == '.':
            if i == 0:
                L[j][i] = 1
            else:
                L[j][i] = L[j][i-1] + 1

for i in range(h):
    for j in range(w):
        if lst[i][j] == '.':
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

for i in reversed(range(h)):
    for j in reversed(range(w)):
        if lst[i][j] == '.':
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1

for i in reversed(range(w)):
    for j in reversed(range(h)):
        if lst[j][i] == '.':
            if i == w-1:
                R[j][i] = 1
            else:
                R[j][i] = R[j][i+1] + 1

                
for i in range(h):
    for j in range(w):
        res = max(res, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
        
print(res)

Fixed submission:
h, w = map(int, input().split())
lst = [input() for _ in range(h)]

res = 0
L = [[0] * w for _ in range(h)]
R = [[0] * w for _ in range(h)]
U = [[0] * w for _ in range(h)]
D = [[0] * w for _ in range(h)]

for i in range(w):
    for j in range(h):
        if lst[j][i] == '.':
            if i == 0:
                L[j][i] = 1
            else:
                L[j][i] = L[j][i-1] + 1

for i in range(h):
    for j in range(w):
        if lst[i][j] == '.':
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

for i in reversed(range(h)):
    for j in reversed(range(w)):
        if lst[i][j] == '.':
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1

for i in reversed(range(w)):
    for j in reversed(range(h)):
        if lst[j][i] == '.':
            if i == w-1:
                R[j][i] = 1
            else:
                R[j][i] = R[j][i+1] + 1

                
for i in range(h):
    for j in range(w):
        res = max(res, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
        
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n, m = map(int, input().split())
a_lst = list(map(int, input().split()))
bc_lst = [list(map(int, input().split())) for _ in range(m)]

aa_lst = a_lst[:]

heapq.heapify(aa_lst)
for bc in bc_lst:
    for i in range(bc[0]):
        if aa_lst[0] < bc[1]:
            heapq.heapreplace(aa_lst, bc[1])
        else:
            break
        
print(sum(aa_lst))

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

bc_lst = sorted(bc_lst, key = lambda x: -x[1])
aa_lst = a_lst[:]

heapq.heapify(aa_lst)
for bc in bc_lst:
    for i in range(bc[0]):
        if aa_lst[0] < bc[1]:
            heapq.heapreplace(aa_lst, bc[1])
        else:
            break
        
print(sum(aa_lst))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n, m = map(int, input().split())
a_lst = list(map(int, input().split()))
bc_lst = [list(map(int, input().split())) for _ in range(m)]

aa_lst = a_lst[:]

heapq.heapify(aa_lst)
for bc in bc_lst:
    for i in range(bc[0]):
        if aa_lst[0] < bc[1]:
            heapq.heapreplace(aa_lst, bc[1])
        
print(sum(aa_lst))

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

bc_lst = sorted(bc_lst, key = lambda x: -x[1])
aa_lst = a_lst[:]

heapq.heapify(aa_lst)
for bc in bc_lst:
    for i in range(bc[0]):
        if aa_lst[0] < bc[1]:
            heapq.heapreplace(aa_lst, bc[1])
        else:
            break
        
print(sum(aa_lst))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

res = 0
for i in range(1, n+1):
    a = k / i
    b = format(math.ceil(a) - 1, 'b')
    num = 0 if b == '0' else len(b)
    res +=  (1/n) *  (1/2)**num
print(res)

Fixed submission:
import math

n, k = map(int, input().split())
res = 0
for i in range(1, n+1):
    a = k / i
    b = format(math.ceil(a) - 1, 'b')
    num = 0 if b == '0' else len(b)
    res +=  (1/n) *  (1/2)**num
print(res)
Buggy python submission (verdict: Runtime Error):
n = int(input())
lst = [list(map(int, input().split())) for _ in range(n-1)]

neighbor = [[] for _ in range(n+1)]
for edge in lst:
    neighbor[edge[0]].append((edge[1], edge[2]))
    neighbor[edge[1]].append((edge[0], edge[2]))

    
color = [-1] * (n+1)

#startをbwで塗る
def dfs(start, bw):
    color[start] = bw
    for pair in neighbor[start]:
        if color[pair[0]] != -1:
            continue
        elif pair[1] % 2 == 0:
            dfs(pair[0], bw)
        else:
            dfs(pair[0], (bw + 1) % 2)

dfs(1, 0)
        
for i in range(1, n+1):
    print(color[i])

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

n = int(input())
lst = [list(map(int, input().split())) for _ in range(n-1)]

neighbor = [[] for _ in range(n+1)]
for edge in lst:
    neighbor[edge[0]].append((edge[1], edge[2]))
    neighbor[edge[1]].append((edge[0], edge[2]))

    
color = [-1] * (n+1)

#startをbwで塗る
def dfs(start, bw):
    color[start] = bw
    for pair in neighbor[start]:
        if color[pair[0]] != -1:
            continue
        elif pair[1] % 2 == 0:
            dfs(pair[0], bw)
        else:
            dfs(pair[0], (bw + 1) % 2)

dfs(1, 0)
        
for i in range(1, n+1):
    print(color[i])

Buggy python submission (verdict: Runtime Error):
n = int(input())
lst = [list(map(int, input().split())) for _ in range(n-1)]

neighbor = [[] for _ in range(n+1)]
for edge in lst:
    neighbor[edge[0]].append((edge[1], edge[2]))
    neighbor[edge[1]].append((edge[0], edge[2]))

    
color = [-1] * (n+1)

#startをbwで塗る
def dfs(start, bw):
    color[start] = bw
    for pair in neighbor[start]:
        if color[pair[0]] != -1:
            continue
        elif pair[1] % 2 == 0:
            dfs(pair[0], bw)
        else:
            dfs(pair[0], (bw + 1) % 2)

for i in range(1, n+1):
    if color[i] == -1:
        dfs(i, 0)
        
for i in range(1, n+1):
    print(color[i])

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

n = int(input())
lst = [list(map(int, input().split())) for _ in range(n-1)]

neighbor = [[] for _ in range(n+1)]
for edge in lst:
    neighbor[edge[0]].append((edge[1], edge[2]))
    neighbor[edge[1]].append((edge[0], edge[2]))

    
color = [-1] * (n+1)

#startをbwで塗る
def dfs(start, bw):
    color[start] = bw
    for pair in neighbor[start]:
        if color[pair[0]] != -1:
            continue
        elif pair[1] % 2 == 0:
            dfs(pair[0], bw)
        else:
            dfs(pair[0], (bw + 1) % 2)

dfs(1, 0)
        
for i in range(1, n+1):
    print(color[i])
Buggy python submission (verdict: Time Limit Exceeded):
import functools
 
n = int(input())
lst = list(map(int, input().split()))
 
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
 
lst_2 = lst[:]
res = 0
for i in range(n):
    lst_2 = lst[:]
    lst_2.pop(i)
    res = max(res, functools.reduce(gcd, lst_2))
print(res)

Fixed submission:
import functools
 
n = int(input())
lst = list(map(int, input().split()))
 
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
    
lst_forward = []
a = lst[0]
for i in lst:
    a = gcd(a, i)
    lst_forward.append(a)

lst_backward = []
a = lst[-1]
for i in lst[::-1]:
    a = gcd(a, i)
    lst_backward.append(a)
lst_backward = list(reversed(lst_backward))

s = max(lst_backward[1], lst_forward[-2])
for i in range(1, n-1):
    s = max(s, gcd(lst_forward[i-1], lst_backward[i+1]))
print(s)

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

n = int(input())
lst = list(map(int, input().split()))

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

lst_2 = lst[:]
res = 0
for i in range(n):
    lst_2 = lst[:]
    lst_2.pop(i)
    res = max(res, functools.reduce(gcd, lst_2))
print(res)

Fixed submission:
import functools
 
n = int(input())
lst = list(map(int, input().split()))
 
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
    
lst_forward = []
a = lst[0]
for i in lst:
    a = gcd(a, i)
    lst_forward.append(a)

lst_backward = []
a = lst[-1]
for i in lst[::-1]:
    a = gcd(a, i)
    lst_backward.append(a)
lst_backward = list(reversed(lst_backward))

s = max(lst_backward[1], lst_forward[-2])
for i in range(1, n-1):
    s = max(s, gcd(lst_forward[i-1], lst_backward[i+1]))
print(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

a,b = 0,0
for i in s:
    if i == '.':
        a += 1 #白の個数
    else:
        b += 1 #黒の個数

min_c = 10**10
if s[0] == '.':
    counta, countb = 0, 0
    for k, i in enumerate(s):
        if s[k] == '.':
            counta += 1
        if s[k] == '#':
            countb += 1
            c = (a - counta) + (countb - 1)
        if min_c > c:
            min_c = c
        
print(min(a,b, min_c))

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

a,b = 0,0
for i in s:
    if i == '.':
        a += 1 #白の個数
    else:
        b += 1 #黒の個数

min_c = c = 10**10
counta, countb = 0, 0
for k, i in enumerate(s):
    if s[k] == '.':
        counta += 1
    if s[k] == '#':
        countb += 1
        c = (a - counta) + (countb - 1)
    if min_c > c:
        min_c = c
        
print(min(a,b, min_c))