Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
for i in range(n):
    s.append("".join(sorted(input())))
s.sort()

a = 0
r = 0
i = 1
l = len(s)
while i < l:
    if s[i] == s[i-1]:
        r = r+1
    else:
        a = a + sum(range(r+1))
        r = 0
    i = i+1

if r > 0: a = a + sum(range(r+1))
print(a)

Fixed submission:
n = int(input())

s = []
for i in range(n):
    s.append("".join(sorted(input())))
s.sort()

a = 0
r = 0
i = 1
l = len(s)
while i < l:
    if s[i] == s[i-1]:
        r = r+1
    else:
        a = a + sum(range(r+1))
        r = 0
    i = i+1

if r > 0: a = a + sum(range(r+1))
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

s = []
for i in range(n):
    s.append("".join(sorted(input())))
s.sort()

a = 0
for i in range(len(s)-1):
    for j in range(i+1, len(s)):
        if s[i] == s[j]: a = a+1
        else: break
print(a)

Fixed submission:
n = int(input())

s = []
for i in range(n):
    s.append("".join(sorted(input())))
s.sort()

a = 0
r = 0
i = 1
l = len(s)
while i < l:
    if s[i] == s[i-1]:
        r = r+1
    else:
        a = a + sum(range(r+1))
        r = 0
    i = i+1

if r > 0: a = a + sum(range(r+1))
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

s = []
for i in range(n):
    s.append("".join(sorted(input())))
s.sort()

a = 0
for i in range(len(s)-1):
    for j in range(i+1, len(s)):
        if s[i] == s[j]: a = a+1
print(a)

Fixed submission:
n = int(input())

s = []
for i in range(n):
    s.append("".join(sorted(input())))
s.sort()

a = 0
r = 0
i = 1
l = len(s)
while i < l:
    if s[i] == s[i-1]:
        r = r+1
    else:
        a = a + sum(range(r+1))
        r = 0
    i = i+1

if r > 0: a = a + sum(range(r+1))
print(a)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
C = [ 0 for _ in range(N)]
r = 0
for i in range(N-1):
  if H[i]  H[i+1]:
    if i ==0:
      C[i] = 1
      continue
    C[i] = C[i-1] + 1
    if C[r] >=C[i]:
      r = i
print(r)


Fixed submission:
N = int(input())
H = list(map(int, input().split()))
c = 0
m = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    c +=1
  else:
    m = c if c>m else m
    c = 0
m = c if c>m else m
print(m)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
As = list(map(int, input().split())) *K

count_base =0
for i in range(N*K):
    for j in range(i, N*K):
        if As[i] > As[j]:
            count_base += 1
print(int(count_base % (pow(10, 9) + 7)))


Fixed submission:
 # -*- coding: utf-8 -*-
# スペース区切りの整数の入力
M, D = map(int, input().split())
result =0
for i in range(4,M+1):
    for j in range(22, D+1):
        d1 =(j % 10)
        d2 =(j // 10)
        if d1 <2 or d2<2 or (d1*d2!=i):
            continue
        result += 1
print(result)
Buggy python submission (verdict: Runtime Error):
a = int(input())
c =0
for a in range(1,a+1):
  if ((len(str(a))% 2) == 1):
    c += 1 
print(c)

Fixed submission:
a, b, c = map(int, input().split())
left_in_c = c - (a -b )
if left_in_c <=0:
  left_in_c =0
print("{}".format(left_in_c));

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
left_in_c = c - (a -b )
if left_in_c < 0
	left_in_c = 0 
print("{}".format(left_in_c));

Fixed submission:
a, b, c = map(int, input().split())
left_in_c = c - (a -b )
if left_in_c <=0:
  left_in_c =0
print("{}".format(left_in_c));

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
left_in_c = c - (a -b )
left_in_c = 0 if left_in_c < 0
print("{}".format(left_in_c));

Fixed submission:
a, b, c = map(int, input().split())
left_in_c = c - (a -b )
if left_in_c <=0:
  left_in_c =0
print("{}".format(left_in_c));
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = int(input())
if a <=9:
  print("{}".format(a));
elif a <=99:
  print("9")
elif a < 999:
  print("{}".format(9+a-99))
elif a <= 9999:
  print('909')
else
  print("{}".format(909+a-1000))

Fixed submission:
a = int(input())
if a <10:
  print("{}".format(a))
elif a <100:
  print("9")
elif a < 1000:
  print("{}".format(9+a-99))
elif a < 10000:
  print('909')
elif a < 100000:
  print("{}".format(909+a-9999))
else:
  print('90909')

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = int(input())
if a <=9:
  print("{}".format(a));
  return
if a <=99:
  print('9')
  return;
if a < 999:
  print("{}".format(9+a-99))
  return
if a <= 9999:
  print('909')
  return
print("{}".format(909+a-9999))

Fixed submission:
a = int(input())
if a <10:
  print("{}".format(a))
elif a <100:
  print("9")
elif a < 1000:
  print("{}".format(9+a-99))
elif a < 10000:
  print('909')
elif a < 100000:
  print("{}".format(909+a-9999))
else:
  print('90909')

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
l = int(input())
if l <=9:
  print("{}".format(a));
  return
if l <=99:
  print('9')
  return;
if l < 999:
  print("{}".format(9+a-99))
  return
if l <= 9999:
  print('909')
  return
print("{}".format(909+a-9999))

Fixed submission:
a = int(input())
if a <10:
  print("{}".format(a))
elif a <100:
  print("9")
elif a < 1000:
  print("{}".format(9+a-99))
elif a < 10000:
  print('909')
elif a < 100000:
  print("{}".format(909+a-9999))
else:
  print('90909')

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = int(input())
if l <=9:
  print("{}".format(a));
  return
if l <=99:
  print('9')
  return;
if l < 999:
  print("{}".format(9+a-99))
  return
if l <= 9999:
  print('909')
  return
print("{}".format(909+a-9999))

Fixed submission:
a = int(input())
if a <10:
  print("{}".format(a))
elif a <100:
  print("9")
elif a < 1000:
  print("{}".format(9+a-99))
elif a < 10000:
  print('909')
elif a < 100000:
  print("{}".format(909+a-9999))
else:
  print('90909')
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

prev = H[0]
for i in range(1,N):
  if prev < H[i]:
    H[i] -= 1
    prev = H[i]
    continue
  if prev == H[i]:
    continue
  print('No')
  return
print('Yes')


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

prev = H[0]
r = True
for i in range(1,N):
  if prev < H[i]:
    H[i] -= 1
    prev = H[i]
    continue
  if prev == H[i]:
    continue
  r = False
  break

if r:
  print('Yes')
else:
  print('No')

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

prev = H[0]
for i in range(1,N):
  if prev < H[i]:
    H[i] -= 1
    prev = H[i]
    continue
  if prev == H[i]
    continue
  print('No')
  return
print('Yes')


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

prev = H[0]
r = True
for i in range(1,N):
  if prev < H[i]:
    H[i] -= 1
    prev = H[i]
    continue
  if prev == H[i]:
    continue
  r = False
  break

if r:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
a , b = input().split()
print((a*3+b)//2)

Fixed submission:
a,b =input().split()
print((int(a)*3+int(b))//2)

Buggy python submission (verdict: Runtime Error):
a, b = input()
print((a*3+b)//2)


Fixed submission:
a,b =input().split()
print((int(a)*3+int(b))//2)
Buggy python submission (verdict: Runtime Error):
import math

a, b =map(int, input().split())

if b!=1:
  num = math.ceil(((b-1)/(a-1))
else:
  num = b

print(num)

Fixed submission:
import math

a, b =map(int, input().split())

if b!=1:
  num = math.ceil((b-1)/(a-1))
else:
  num = 0

print(num)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())

num_list = [int(input()) for i in range(N)]

array = np.array(num_list)

[print((np.delete(array, i).max())) for i in range(N)]

Fixed submission:
N = int(input())

num_list = [int(input()) for i in range(N)]

sort_num_list = sorted(num_list)
max_n = sort_num_list[-1]
smax_n = sort_num_list[-2]

for i in num_list:
  if i==max_n:
    print(smax_n)
  else:
    print(max_n)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import copy

N = int(input())

num_list = []

for i in range(N):
  num = int(input())
  num_list.append(num)
    
for i in range(N):
  dummy_list = copy.copy(num_list)
  del dummy_list[i]
  print(np.amax(dummy_list))

Fixed submission:
N = int(input())

num_list = [int(input()) for i in range(N)]

sort_num_list = sorted(num_list)
max_n = sort_num_list[-1]
smax_n = sort_num_list[-2]

for i in num_list:
  if i==max_n:
    print(smax_n)
  else:
    print(max_n)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ans = []

for i in range(n):
	j = n - 1 - i
	k = (j + 1) + (j + 1)
	if k > n:
		if a[j] == 1:
			ans.append(j+1)
	else:
		count = 0
		while k <= n:
			if k in ans:
				count = count + 1
			k = k + (j + 1)
		count_01 = count % 2
		if a[j] == 0:
			if count_01 == 1:
				ans.append(j+1)
		elif a[j] == 1:
			if count_01 == 0:
				ans.append(j+1)
if not ans:
	print(0)
else:
	print(str(len(ans))+"\n" + " ".join(list(map(str,ans))))


Fixed submission:
r = int(input())
print(3 * r * r)
Buggy python submission (verdict: Time Limit Exceeded):
l, r = list(map(int,input().split()))
Set = set([l%2019])
for i in range(r-l):
	Set.add((l+1+i)%2019)
List = list(Set)
if(0 in List):
	print(0)
else:
	answer = (l * r) % 2019
	k = 0
	for i in range(len(List)):
		for j in range(len(List)):
			if(i < j):
					if(answer > (List[i] * List[j])% 2019):
						answer = (List[i] * List[j])% 2019
						k = 1
	print(answer)

Fixed submission:
l, r = list(map(int,input().split()))
lmod = l % 2019
rmod = r % 2019
if(r-l) >= 2018:
	answer = 0
elif(lmod > rmod):
	answer = 0
else:
	answer = (rmod * lmod)% 2019
	for i in range(rmod - lmod + 1):
		for j in range(rmod - lmod + 1):
			if(i < j):
				if(answer > (lmod + i) * (lmod + j) % 2019):
					answer = (lmod + i) * (lmod + j) % 2019
print(answer)

Buggy python submission (verdict: Runtime Error):
l, r = list(map(int,input().split()))
Set = set([l%2019])
for i in range(r-l):
	Set.add((l+1+i)%2019)
List = list(Set)
answer = (l * r) % 2019
k = 0
for i in range(len(List)):
	for j in range(len(List)):
		if(i < j):
			if(k == 0 or (i >= 45 and j >= 46))
				if(answer > (List[i] * List[j])% 2019):
					answer = (List[i] * List[j])% 2019
					k = 1
print(answer)

Fixed submission:
l, r = list(map(int,input().split()))
lmod = l % 2019
rmod = r % 2019
if(r-l) >= 2018:
	answer = 0
elif(lmod > rmod):
	answer = 0
else:
	answer = (rmod * lmod)% 2019
	for i in range(rmod - lmod + 1):
		for j in range(rmod - lmod + 1):
			if(i < j):
				if(answer > (lmod + i) * (lmod + j) % 2019):
					answer = (lmod + i) * (lmod + j) % 2019
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
l, r = list(map(int,input().split()))
Set = set([l%2019])
for i in range(r-l):
	Set.add((l+1+i)%2019)
List = list(Set)
answer = (l * r) % 2019
for i in range(len(List)):
	for j in range(len(List)):
		if(i < j):
			if(answer > (List[i] * List[j])% 2019):
				answer = (List[i] * List[j])% 2019
print(answer)

Fixed submission:
l, r = list(map(int,input().split()))
lmod = l % 2019
rmod = r % 2019
if(r-l) >= 2018:
	answer = 0
elif(lmod > rmod):
	answer = 0
else:
	answer = (rmod * lmod)% 2019
	for i in range(rmod - lmod + 1):
		for j in range(rmod - lmod + 1):
			if(i < j):
				if(answer > (lmod + i) * (lmod + j) % 2019):
					answer = (lmod + i) * (lmod + j) % 2019
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
n,a = list(map(int,input().split()))
x = list(map(int,input().split()))
import collections

def Count(j,k,s):
	if(j==0 and k==0 and s==0):
		return 1
	elif(j >= 1 and s < x[j-1]):
		return Count(j-1,k,s)
	elif(j >= 1 and k>=1 and s >= x[j-1]):
		return Count(j-1,k,s) + Count(j-1,k-1,s-x[j-1])
	elif(j < k):
		return 0
	else:
		return 0

sum=0
for i in range(1,n+1):
	sum += Count(n,i,i*a)
print(sum)

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

def Count(n,k,a):
	s = sum(x)
	dp=[[[0 for l in range(s+1)] for j in range(k+1)] for i in range(n+1)]
	dp[0][0][0]=1
	Sum=0
	for i in range(n):
		for j in range(k+1):
			for l in range(s+1):
				if l < x[i]:
					dp[i+1][j][l] = dp[i][j][l]
				if j >=1 and l >= x[i]:
					dp[i+1][j][l] = dp[i][j][l] + dp[i][j-1][l-x[i]]
				if j <= i+1 and l ==j*a and j >= 1:
					if dp[i+1][j][l]>=1:	
						Sum += dp[i+1][j][l]-dp[i][j][l]
	return Sum

print(Count(n,n,a))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

def main(argv):
  i = int(argv[0])
  if i >= 0 and 999 >= i:
    print('ABC')
  elif i > 999:
    print('ABD')
    
if __name__ == '__main__':
  main(sys.argv[1:])

Fixed submission:
# -*- coding: utf-8 -*-
import sys
    
if __name__ == '__main__':
  i = int(input())
  if i >= 0 and 999 >= i:
    print('ABC')
  elif i > 999:
    print('ABD')

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

def main(argv):
  i = int(argv[0])
  if i => 0 and 999 <= i:
    print('ABC')
  elif i > 999:
    print('ABD')
if __name__ == '__main__':
  main(sys.argv[1:])

Fixed submission:
# -*- coding: utf-8 -*-
import sys
    
if __name__ == '__main__':
  i = int(input())
  if i >= 0 and 999 >= i:
    print('ABC')
  elif i > 999:
    print('ABD')
Buggy python submission (verdict: Runtime Error):
a, b, c = map(input().split(), int)
print(c-a+b)

Fixed submission:
a, b, c = map(int, input().split())
print(max(c-a+b,0))
Buggy python submission (verdict: Runtime Error):
a, p = map(int, input().split())
num = a*3 // p
print(num)

Fixed submission:

a, p = map(int, input().split())
num = (a*3 + p) // 2
print(num)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
ans = ''
for i in range(n):
    if s[i] == s[k]:
        ans += s[k]
    else:
        ans += '*'
print(ans)

Fixed submission:
n = int(input())
s = input()
k = int(input())
ans = ''
for i in range(n):
    if s[i] == s[k-1]:
        ans += s[k-1]
    else:
        ans += '*'
print(ans)
Buggy python submission (verdict: Runtime Error):

a, b = map(int, input().split())
 
if a > b:
    print(a+a-1)
elif a < b:
    print(b+b-1)
else
    print(a+b)

Fixed submission:

a, b = map(int, input().split())
 
if a > b:
    print(a+a-1)
elif a < b:
    print(b+b-1)
else:
    print(a+b)

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
 
if a > b:
  print(a+a-1)
elif a < b:
  print(b+b-1)
else
  print(a+b)

Fixed submission:

a, b = map(int, input().split())
 
if a > b:
    print(a+a-1)
elif a < b:
    print(b+b-1)
else:
    print(a+b)

Buggy python submission (verdict: Runtime Error):
a,b = map(int, input())
if a > b:
  print(a*2-1)
else:
  print(b*2-1)

Fixed submission:

a, b = map(int, input().split())
 
if a > b:
    print(a+a-1)
elif a < b:
    print(b+b-1)
else:
    print(a+b)

Buggy python submission (verdict: Runtime Error):
a,b = map(int, input())
print(max(a,b)*2-1)

Fixed submission:

a, b = map(int, input().split())
 
if a > b:
    print(a+a-1)
elif a < b:
    print(b+b-1)
else:
    print(a+b)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()
s_length = len(s)
t_length = len(t)

def char2int(char):
    return ord(char) - 97

def search_index(t_atom, last_index, d):
    if d[char2int(t_atom)] == []:
        return -1

    for i in d[char2int(t_atom)]:
        if last_index < i:
            return i

    return d[char2int(t_atom)][0]

def solve():
    last_index = -1
    t_index = []
    loop_cost = 1

    d = [[] for _ in range(26)]
    for i in range(s_length):
        char = s[i]
        d[char2int(char)].append(i)

    for i in range(t_length):
        t_atom = t[i]
        t_atom_index = search_index(t_atom, last_index, d)
        if t_atom_index == -1:
            return -1
        else:
            t_index.append(t_atom_index)
            last_index = t_atom_index

    remainder_cost = t_index[-1] + 1

    for i in range(1, t_length):
        if t_index[i - 1] >= t_index[i]:
            loop_cost += 1

    return s_length * (loop_cost - 1) + remainder_cost

print(solve())


Fixed submission:
import bisect

s = input()
t = input()
s_length = len(s)
t_length = len(t)

def char2int(char):
    return ord(char) - 97

def search_index(t_atom, last_index, d_list):
    t_atom_int = char2int(t_atom)
    d = d_list[t_atom_int]

    if d == []:
        return -1

    c = bisect.bisect_right(d, last_index)

    if c != len(d):
        return d[c]
    else:
        return d[0]

def solve():
    last_index = -1
    t_index = []
    loop_cost = 1

    d = [[] for _ in range(26)]
    for i in range(s_length):
        char = s[i]
        d[char2int(char)].append(i)

    for i in range(t_length):
        t_atom = t[i]
        t_atom_index = search_index(t_atom, last_index, d)
        if t_atom_index == -1:
            return -1
        else:
            t_index.append(t_atom_index)
            last_index = t_atom_index

    remainder_cost = t_index[-1] + 1

    for i in range(1, t_length):
        if t_index[i - 1] >= t_index[i]:
            loop_cost += 1

    return s_length * (loop_cost - 1) + remainder_cost

print(solve())
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

for _ in range(m):
    b, c = [int(i) for i in input().split()]
    a += [c] * b

a_sorted = sorted(a, reverse=True)

print(sum(a_sorted[0:n]))


Fixed submission:
import bisect

n, m = [int(i) for i in input().split()]
a_list = [int(i) for i in input().split()]

new_cards_info = {}

for a in a_list:
    if a in new_cards_info:
        new_cards_info[a] += 1
    else:
        new_cards_info[a] = 1

for _ in range(m):
    b, c = [int(i) for i in input().split()]
    if c in new_cards_info:
        new_cards_info[c] += b
    else:
        new_cards_info[c] = b

new_cards_info = sorted(new_cards_info.items(), key=lambda x:x[0], reverse=True)

sum = 0
count = 0

for key, size in new_cards_info:
    sum += key * size
    over = count + size - n
    if over >= 0:
        sum -= key * over
        break
    count += size

print(sum)

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

n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

a_sorted = sorted(a)

for _ in range(m):
    b, c = [int(i) for i in input().split()]
    for __ in range(b):
        if a_sorted[0] < c:
            a_sorted.pop(0)
            bisect.insort(a_sorted, c)
        else:
            break

print(sum(a_sorted))


Fixed submission:
import bisect

n, m = [int(i) for i in input().split()]
a_list = [int(i) for i in input().split()]

new_cards_info = {}

for a in a_list:
    if a in new_cards_info:
        new_cards_info[a] += 1
    else:
        new_cards_info[a] = 1

for _ in range(m):
    b, c = [int(i) for i in input().split()]
    if c in new_cards_info:
        new_cards_info[c] += b
    else:
        new_cards_info[c] = b

new_cards_info = sorted(new_cards_info.items(), key=lambda x:x[0], reverse=True)

sum = 0
count = 0

for key, size in new_cards_info:
    sum += key * size
    over = count + size - n
    if over >= 0:
        sum -= key * over
        break
    count += size

print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
v = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

max_v_minus_c = 0

for i in range(2**n):
    flugs = bin(i)[2:].zfill(n)
    sum_v = 0
    sum_c = 0
    j = 0
    for flug in str(flugs):
        if flug == '1':
            sum_v += v[j]
            sum_c += c[j]
        j += 1

    if (max_v_minus_c < sum_v - sum_c):
        max_v_minus_c = sum_v - sum_c

print(max_v_minus_c)


Fixed submission:
n = int(input())
v_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]

b_list = [v - c for (v, c) in zip(v_list, c_list)]
print(sum([b for b in b_list if b > 0]))
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n = int(input())
a = [int(i) for i in input().split()]

left_gcd = [0]
right_gcd = [0]

for i in range(n):
    left_gcd.append(gcd(left_gcd[-1], a[i]))
    right_gcd.insert(0, gcd(right_gcd[0], a[(n - 1) - i]))

max_gcd = 0

for i in range(n):
    get_gcd = gcd(left_gcd[i], right_gcd[i + 1])
    if get_gcd > max_gcd:
        max_gcd = get_gcd

print(max_gcd)


Fixed submission:
from collections import deque

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n = int(input())
a = [int(i) for i in input().split()]

left_gcd = deque()
left_gcd.append(0)
right_gcd = deque()
right_gcd.append(0)

for i in range(n):
    left_gcd.append(gcd(left_gcd[-1], a[i]))
    right_gcd.appendleft(gcd(right_gcd[0], a[(n - 1) - i]))

max_gcd = 0

for i in range(n):
    get_gcd = gcd(left_gcd[i], right_gcd[i + 1])
    if get_gcd > max_gcd:
        max_gcd = get_gcd

print(max_gcd)

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

n = int(input())
a = [int(i) for i in input().split()]

left_gcd = [0]
right_gcd = [0]

for i in range(n):
    left_gcd.append(math.gcd(left_gcd[-1], a[i]))
    right_gcd.insert(0, math.gcd(right_gcd[0], a[(n - 1) - i]))

max_gcd = 0

for i in range(n):
    gcd = math.gcd(left_gcd[i], right_gcd[i + 1])
    if gcd > max_gcd:
        max_gcd = gcd

print(max_gcd)


Fixed submission:
from collections import deque

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n = int(input())
a = [int(i) for i in input().split()]

left_gcd = deque()
left_gcd.append(0)
right_gcd = deque()
right_gcd.append(0)

for i in range(n):
    left_gcd.append(gcd(left_gcd[-1], a[i]))
    right_gcd.appendleft(gcd(right_gcd[0], a[(n - 1) - i]))

max_gcd = 0

for i in range(n):
    get_gcd = gcd(left_gcd[i], right_gcd[i + 1])
    if get_gcd > max_gcd:
        max_gcd = get_gcd

print(max_gcd)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

min_cost = n

for i in range(n+1):
    s_left = s[:i]
    s_right = s[i:]
    cost = s_left.count('#') + s_right.count('.')
    if cost < min_cost:
        min_cost = cost

print(min_cost)


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

def calc():
    min_cost = n
    left_cost = 0
    right_cost = s.count('.')

    cost = left_cost + right_cost
    if cost < min_cost:
        min_cost = cost

    for i in range(n):
        if s[i] == '#':
            left_cost += 1
        else:
            right_cost -= 1
        cost = left_cost + right_cost
        if cost < min_cost:
            min_cost = cost

    return(min_cost)

print(calc())

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

s_bin = '0b' + s.replace('.', '0').replace('#', '1')
min_cost = n

for i in range(n+1):
    cand_s_bin = '0b' + ('0' * i) + ('1' * (n-i))
    diff = bin(int(s_bin, 2) ^ int(cand_s_bin, 2))
    cost = diff.count('1')
    if cost < min_cost:
        min_cost = cost

print(min_cost)


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

def calc():
    min_cost = n
    left_cost = 0
    right_cost = s.count('.')

    cost = left_cost + right_cost
    if cost < min_cost:
        min_cost = cost

    for i in range(n):
        if s[i] == '#':
            left_cost += 1
        else:
            right_cost -= 1
        cost = left_cost + right_cost
        if cost < min_cost:
            min_cost = cost

    return(min_cost)

print(calc())