Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import bisect
import math

N, M = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

A.sort()
if len(A) < 2:
    ans = int(A[0] / (2**M))
else:
    fst = A[-1]
    scd = A[-2]

    while M > 0:
        if fst == scd:
            Y = 1
        else:
            Y = math.ceil(math.log2(fst/scd))
        print(Y)
        largest = A.pop(-1)
        largest = int(largest / (2**Y))
        print(largest)
        M = M - Y
        bisect.insort(A, largest)
        fst = A[-1]
        scd = A[-2]
        print(A)
    ans = sum(A)

print(ans)

Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

A = [-1 * i for i in A]
heapq.heapify(A)

for i in range(M):
    fst = heapq.heappop(A)
    fst = int(fst / 2)
    heapq.heappush(A, fst)
    
ans = -1 * sum(A)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
first_input = input().split(' ')

s_length = int(first_input[0])
num_of_Q = int(first_input[1])

input_string = input()

for q in range(num_of_Q):
    l_r = input().split(' ')
    l = int(l_r[0])
    r = int(l_r[1])

    sub_str = input_string[l-1:r]
    num_of_ac = sub_str.count('AC')

    print(num_of_ac)

Fixed submission:
first_input = input().split(' ')

s_length = int(first_input[0])
num_of_Q = int(first_input[1])

input_string = input()

seq = [0]*s_length
count = 0

for s in range(s_length):
    if s > 0 and input_string[s-1:s+1] == 'AC':
        count += 1
    seq[s] = count

for q in range(num_of_Q):
    l_r = input().split(' ')
    l = int(l_r[0])
    r = int(l_r[1])

    print(seq[r-1] - seq[l-1])
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop

n, m = map(int, input().split())
A = input().split()
hq = []
for a in A:
    heappush(hq, -1 * int(a))

for _ in range(m):
    tmp = -1 * heappop(hq)
    print(hq)
    heappush(hq, -1 * (tmp // 2))

print(-sum(hq))

Fixed submission:
from heapq import heapify, heappush, heappop

n, m = map(int, input().split())
A = list(map(lambda x: int(x) * -1, input().split()))
heapify(A)

for _ in range(m):
    tmp = -1 * heappop(A)
    heappush(A, -1 * (tmp // 2))

print(-sum(A))
Buggy python submission (verdict: Runtime Error):
import re

s = input()
ans = max(
    len(m.group()) for m in re.findall('[AGCT]+', s),
    default=0
)

print(ans)


Fixed submission:
import re

s = input()
ans = max(
    map(len, re.findall('[AGCT]+', s)),
    default=0
)

print(ans)

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

s = input()
ans = max(
    len(m.group()) for m in re.findall('[AGCT]+'),
    default=0
)

print(ans)


Fixed submission:
import re

s = input()
ans = max(
    map(len, re.findall('[AGCT]+', s)),
    default=0
)

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100_000)

N = int(input())
A = list(map(int,input().split()))
dp = [-1]*(N+2)
dp[0] = 0
dp[1] = abs(A[1] - A[0])


def rec(i):
  if dp[i] != -1:
    return dp[i]
  dp[i] = min(rec(i-1) + abs(A[i-1] - A[i]), rec(i-2) + abs(A[i-2] - A[i]))
  return dp[i]

print(rec(N-1))

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

N = int(input())
A = list(map(int,input().split()))
dp = [-1]*(N+2)
dp[0] = 0
dp[1] = abs(A[1] - A[0])


def rec(i):
  if dp[i] != -1:
    return dp[i]
  dp[i] = min(rec(i-1) + abs(A[i-1] - A[i]), rec(i-2) + abs(A[i-2] - A[i]))
  return dp[i]

print(rec(N-1))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    s=input()
    n=len(s)
    ans=0
    from itertools import product
    for A in product(range(2),repeat=n-1):
        k=s[0]
        for i in range(n-1):
            k+='+' if A[i] else ''
            k+=s[i+1]
        ans+=eval(k)
    print(ans)
resolve()


Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
def resolve():
    s=input()
    n=len(s)
    ans=0
    from itertools import product
    for A in product(range(2),repeat=n-1):
        k=s[0]
        for i in range(n-1):
            k+='+' if A[i] else ''
            k+=s[i+1]
        ans+=eval(k)
    print(ans)
resolve()
Buggy python submission (verdict: Runtime Error):
n=int(raw_input())
N=[]
for i in range(n):
	N.append(int(raw_input()))
N.sort()
ans=1
for i in range(1,n):
	if N[i]!=N[i-1]:
		ans+=1
print ans

Fixed submission:
print "2018"+raw_input()[4:]
Buggy python submission (verdict: Runtime Error):
n=int(raw_input())
N=map(int,raw_input().split())
N.sort()
ans=1
for i in range(1,n):
	if N[i]!=N[i-1]:
		ans+=1
print ans

Fixed submission:
n=int(raw_input())
N=[]
for i in range(n):
	N.append(int(raw_input()))
N.sort()
ans=1
for i in range(1,n):
	if N[i]!=N[i-1]:
		ans+=1
print ans
Buggy python submission (verdict: Runtime Error):
foo={}
bar={}
n=int(raw_input())
for x in map(int,raw_input().split()):
    if x not in foo:
        foo[x]=0
    foo[x]+=1
n=int(raw_input())
for x in map(int,raw_input().split()):
    if x not in bar:
        bar[x]=0
    bar[x]+=1
for i in foo:
    if i not in bar:
        continue
    if foo[i]<bar[i]:
        print "NO"
        exit(0)
print "YES"


Fixed submission:
y=list(raw_input())
y.reverse()
foo=''
for i in range(len(y)):
    foo+=y[i]
    if foo=='LAVITSEF':
        j=i
        break
x=y[j+1:]
x.reverse()
print ''.join(x)

Buggy python submission (verdict: Runtime Error):
foo=[0]*(300000)
bar=[0]*(300000)
n=int(raw_input())
for x in map(int,raw_input().split()):
    foo[x]+=1
n=int(raw_input())
for x in map(int,raw_input().split()):
    bar[x]+=1
for i in range(200001):
    if foo[i]<bar[i]:
        print "NO"
        exit(0)
print "YES"


Fixed submission:
y=list(raw_input())
y.reverse()
foo=''
for i in range(len(y)):
    foo+=y[i]
    if foo=='LAVITSEF':
        j=i
        break
x=y[j+1:]
x.reverse()
print ''.join(x)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,raw_input())
mul1=mul2=1
if abs(n-m)>1:
    print 0
else:
    for i in range(1,n+1):
        mul1*=i
        mul1%=mod
    for i in range(1,m+1):
        mul2*=i
        mul2%=mod
    if n==m:
        print (2*mul1*mul2)%mod
    else:
        print (mul1*mul2)%mod

Fixed submission:
mod=10**9+7
n,m=map(int,raw_input().split())
mul1=mul2=1
if abs(n-m)>1:
    print 0
else:
    for i in range(1,n+1):
        mul1*=i
        mul1%=mod
    for i in range(1,m+1):
        mul2*=i
        mul2%=mod
    if n==m:
        print (2*mul1*mul2)%mod
    else:
        print (mul1*mul2)%mod
Buggy python submission (verdict: Runtime Error):
n,k=map(int,raw_input().split())
a=[0]*25
b=[]
count=0
for i in range(n):
	b.append(raw_input())
b=list(set(b))
for i in b:
	a[ord(i[0])-65]+=1
for i in a:
	if i>0:
		count+=i
if len(set(a))==2:
	print 0
else:
    print count/k

Fixed submission:
n,a,b=map(int,raw_input().split())
count=0
for i in range(n):
	z=int(raw_input())
	if z/a>=1 and z/b<1:
		count+=1
print n-count
Buggy python submission (verdict: Runtime Error):
y=list(raw_input())
k=int(raw_input())
for i in range(len(y)):
	if y[i]=='a':
		continue
	else:
		if 123-ord(y[i])<=k:
			k-=(123-ord(y[i]))
			y[i]='a'
y[len(y)-1]=chr(ord(y[len(y)-1])+k%26)
print ''.join(y)

Fixed submission:
y=raw_input()
print y[:4]+' '+y[4:]

Buggy python submission (verdict: Runtime Error):
n=int(raw_input())
N=map(int,raw_input().split())
count=0
for i in range(n):
	if i==N[N[i]-1]-1:
		count+=1
print count/2


Fixed submission:
y=raw_input()
print y[:4]+' '+y[4:]
Buggy python submission (verdict: Runtime Error):
n=int(raw_input())
N=map(int,raw_input().split())
add=0
if sum(N)%n==0:
    a=sum(N)/n
else:
    a=sum(N)/n +1
for i in N:
    add+=(a-i)**2
print add

Fixed submission:
n=int(raw_input())
print n*(n+1)/2

Buggy python submission (verdict: Runtime Error):
n=int(raw_input())
N=map(int,raw_input().split())
if len(set(N))==1:
    print 0
else:
    add=0
    if sum(N)%n==0:
        a=sum(N)/n
    else:
        a=sum(N)/n+1
    for i in N:
        add+=(a-i)**2
    print add

Fixed submission:
n=int(raw_input())
print n*(n+1)/2
Buggy python submission (verdict: Runtime Error):
n,l=map(int,raw_input().split())
a=[]
for i in range(n):
    a.append(raw_input())
a.sort()
print ''.join(a)
    

Fixed submission:
a,b,c=map(int,raw_input().split())
p=[]
p.append(a)
p.append(b)
p.append(c)
p.sort()
if p==[5,5,7]:
    print "YES"
else:
    print "NO"
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)


n,x=map(int,raw_input().split())
print 3*(n-gcd(n,x))

Fixed submission:
n=int(raw_input())
N=map(int,raw_input().split())
N.sort()
count=0
for i in range(n):
    count+=N[2*i]
print count

Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)


n,x=map(int,raw_input().split())
print 3*(n-gcd(n,x))


Fixed submission:
n=int(raw_input())
N=map(int,raw_input().split())
N.sort()
count=0
for i in range(n):
    count+=N[2*i]
print count
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N = int(input())
S = input()
first = S[:N]
last = S[::-1][:N]

d = defaultdict(int)
ans = 0

def paint(str, ptn):
  return (red, blue)

for i in range(2**N):
  red = ''.join(s for j, s in enumerate(first) if 2**j & ptn)
  blue = ''.join(s for j, s in enumerate(first) if not 2**j & ptn)
  d[paint(red, blue)] += 1
  
for i in range(2**N):
  red = ''.join(s for j, s in enumerate(last) if 2**j & ptn)
  blue = ''.join(s for j, s in enumerate(last) if not 2**j & ptn)
  ans += d[paint(red, blue)]
  
print(ans)


Fixed submission:
from collections import defaultdict

N = int(input())
S = input()
first = S[:N]
last = S[::-1][:N]

d = defaultdict(int)
ans = 0

def paint(str, ptn):
  p = ['', '']
  for i in range(N):
    p[int(2**i & ptn > 0)] += str[i]
  return tuple(p)

for i in range(2**N):
  d[paint(first, i)] += 1
  
for i in range(2**N):
  ans += d[paint(last, i)]
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

N = int(input())
S = input()
first = S[:N]
last = S[::-1][:N]

d = defaultdict(int)
ans = 0

def paint(str, ptn):
  red = ''.join(s for i, s in enumerate(str) if 2**i & ptn)
  blue = ''.join(s for i, s in enumerate(str) if not 2**i & ptn)
  return (red, blue)

for i in range(2**N):
  d[paint(first, i)] += 1
  
for i in range(2**N):
  ans += d[paint(last, i)]
  
print(ans)


Fixed submission:
from collections import defaultdict

N = int(input())
S = input()
first = S[:N]
last = S[::-1][:N]

d = defaultdict(int)
ans = 0

def paint(str, ptn):
  p = ['', '']
  for i in range(N):
    p[int(2**i & ptn > 0)] += str[i]
  return tuple(p)

for i in range(2**N):
  d[paint(first, i)] += 1
  
for i in range(2**N):
  ans += d[paint(last, i)]
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

N = int(input())
S = input()
first = S[:N]
last = S[::-1][:N]
d = defaultdict(int)
ans = 0

def paint(str, ptn):
  red = ''.join(s for i, s in enumerate(str) if 2**i & ptn)
  blue = ''.join(s for i, s in enumerate(str) if not 2**i & ptn)
  return (red, blue)

for i in range(2**N):
  d[paint(first, i)] += 1
  
for i in range(2**N):
  ans += d[paint(last, i)]

print(ans)

Fixed submission:
from collections import defaultdict

N = int(input())
S = input()
first = S[:N]
last = S[::-1][:N]

d = defaultdict(int)
ans = 0

def paint(str, ptn):
  p = ['', '']
  for i in range(N):
    p[int(2**i & ptn > 0)] += str[i]
  return tuple(p)

for i in range(2**N):
  d[paint(first, i)] += 1
  
for i in range(2**N):
  ans += d[paint(last, i)]
  
print(ans)
Buggy python submission (verdict: Runtime Error):
stay = int(input())
change_day = int(input())
first_cost = int(input())
change_cost = int(input())
total_cost = 0

for i in range(stay):
 if(i < change_day):
 total_cost += first_cost
else:
 total_cost += change_cost

print(total_cost)

Fixed submission:
stay = int(input())
change_day = int(input())
first_cost = int(input())
change_cost = int(input())
total_cost = 0
 
for i in range(stay):
 if(i < change_day):
  total_cost += first_cost
 else:
  total_cost += change_cost
print(total_cost)
Buggy python submission (verdict: Runtime Error):
stay = int(input())
change_day = int(input())
first_cost = int(input())
change_cost = int(input())
total_cost = 0
 
for i in range(stay):
 if(i < change_day):
  total_cost += first_cost
 else:
  total_cost += change_cost
print(total_cost)

Fixed submission:
number = int(input())
total = 0

for i in range(number+1):
 total += i

print(total)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n = get_int()
    X, Y = get_data(n, [int, int])
    vecs = Counter()
    for i in range(n):
        for j in range(i+1, n):
            if X[i] > X[j] or (X[i] == X[j] and Y[i] > Y[j]):
                vecs[(X[i]-X[j], Y[i]-Y[j])] += 1
            else:
                vecs[(X[j]-X[i], Y[j]-Y[i])] += 1
    print(n-vecs.most_common()[0][1])
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


Fixed submission:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n = get_int()
    if n == 1:
        print(1)
        return
    X, Y = get_data(n, [int, int])
    vecs = Counter()
    for i in range(n):
        for j in range(i+1, n):
            if X[i] > X[j] or (X[i] == X[j] and Y[i] > Y[j]):
                vecs[(X[i]-X[j], Y[i]-Y[j])] += 1
            else:
                vecs[(X[j]-X[i], Y[j]-Y[i])] += 1
    print(n-vecs.most_common()[0][1])
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n, k = get_li()
    s = get_str()
    if s[k-1] == 'A':
        s[k-1] = 'a'
    elif s[k-1] == 'B':
        s[k-1] = 'b'
    else:
        s[k-1] = 'c'
    print(s)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


Fixed submission:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n, k = get_li()
    s = get_lc()
    if s[k-1] == 'A':
        s[k-1] = 'a'
    elif s[k-1] == 'B':
        s[k-1] = 'b'
    else:
        s[k-1] = 'c'
    print(''.join(s))
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    r, g, b, n = get_li()
    ans = 0
    for x in range(n // r + 1):
        for y in range(n // g + 1):
            z = n - r * x - g * y
            if z % b != 0 or z < 0:
                continue
            ans += 1
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


Fixed submission:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    r, g, b, n = get_li()
    ans = 0
    for x in range(n // r + 1):
        for y in range(n // g + 1):
            z = n - r * x - g * y
            if z % b != 0 or z < 0:
                continue
            ans += 1
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n = get_int()
    a = get_li()
    ans = 1
    for i in range(len(a)):
        ans = max(ans, reduce(gcd, a[:i] + a[i+1:]))
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


Fixed submission:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


# globals
inf = float('inf')
N = 0
A = []


def set_inputs():
    global N, A
    N = get_int()
    A = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    forward = [A[0]]
    for a in A[1:]:
        forward.append(gcd(forward[-1], a))
    backward = [A[-1]]
    for a in reversed(A[:-1]):
        backward.append(gcd(backward[-1], a))
    backward.reverse()
    ans = max(forward[-2], backward[1])
    for i in range(1, len(A)-1):
        ans = max(ans, gcd(forward[i-1], backward[i+1]))
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()