Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def g(S):
    N=len(S)
    if palindrome(S)==True and palindrome(S[((N+3)//2)-1])==True and palindrome(S[(N-1)//2])==True:
        return "Yes"
    else:
        return "No"
S=input()
print(g(S))

Fixed submission:
def palindrome(S):
    N=len(S)
    for i in range(N):
        if S[i]!=S[N-i-1]:
            return False
    return True
def g(S):
    N=len(S)
    if palindrome(S)==True and palindrome(S[(((N+3)//2)-1):])==True and palindrome(S[:((N-1)//2)])==True:
        return "Yes"
    else:
        return "No"
S=input()
print(g(S))
Buggy python submission (verdict: Runtime Error):
def f(h,k):
    N=len(h)
    t=0
    h.sort()
    for i in range(k-1):
        t+=h[i]
    return sum(h)-t
N,k=map(int,input().split())
h=list(map(int,input().split()))
print(f(h,k))

        

Fixed submission:
def f(h,k):
    N=len(h)
    t=0
    h.sort()
    for i in range(N-k):
        t+=h[i]
    return t
N,k=map(int,input().split())
h=list(map(int,input().split()))
print(f(h,k))
Buggy python submission (verdict: Runtime Error):
def f(X,s,t):
    N=len(s)
    i=0
    c=0
    while s[i]!=X:
        c+=int(t[i])
        i+=1
    return sum(t)-(c+int(t[i]))
N=int(input())
s=[0]*N
t=[0]*N
for a in range(0,N):
    (s[a],t[a])=map(str,input().split())
X=input()
print(f(X,s,t))
        

Fixed submission:
def f(X,s,t):
    N=len(s)
    i=0
    c=0
    b=0
    while i<N and s[i]!=X:
        c+=int(t[i])
        i+=1
    #print(c)
    #print(i)
    for k in range(N):
        b+=int(t[k])
    #print(b)
    return b-(c+int(t[i]))
N=int(input())
s=[0]*N
t=[0]*N
for a in range(0,N):
    (s[a],t[a])=map(str,input().split())
X=str(input())
print(f(X,s,t))
Buggy python submission (verdict: Runtime Error):
def f(S,t):
    return T+S
S=input()
T=input()
print(f(S,T))


Fixed submission:
def f(S,T):
    return T+S
S,T= map(str,input().split())
print(f(S,T))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
 
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if N < 2:
  a = cmb(M,2)
elif M < 2:
  a = cmb(N,2)
elif N > 1 and M > 1:
  a = cmb(N,2) + cmb(M,2)
else:
  a = 0

print(int(a))


Fixed submission:
N, M = map(int, input().split())
 
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if N < 2 and M < 2:
  a = 0
elif N < 2:
  a = cmb(M,2)
elif M < 2:
  a = cmb(N,2)
elif N > 1 and M > 1:
  a = cmb(N,2) + cmb(M,2)

print(int(a))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
 
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if N < 2:
  a = cmb(M,2)
elif M < 2:
  a = cmb(N,2)
else:
  a = cmb(N,2) + cmb(M,2)

print(int(a))

Fixed submission:
N, M = map(int, input().split())
 
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if N < 2 and M < 2:
  a = 0
elif N < 2:
  a = cmb(M,2)
elif M < 2:
  a = cmb(N,2)
elif N > 1 and M > 1:
  a = cmb(N,2) + cmb(M,2)

print(int(a))

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

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

id N == 0:
  a = cmb(M,2)
elif M == 0:
  a = cmb(N,2)
else:
  a = cmb(N,2) + cmb(M,2)

print(int(a))

Fixed submission:
N, M = map(int, input().split())
 
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if N < 2 and M < 2:
  a = 0
elif N < 2:
  a = cmb(M,2)
elif M < 2:
  a = cmb(N,2)
elif N > 1 and M > 1:
  a = cmb(N,2) + cmb(M,2)

print(int(a))

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

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

a = cmb(N,2) + cmb(M,2)

print(int(a))

Fixed submission:
N, M = map(int, input().split())
 
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if N < 2 and M < 2:
  a = 0
elif N < 2:
  a = cmb(M,2)
elif M < 2:
  a = cmb(N,2)
elif N > 1 and M > 1:
  a = cmb(N,2) + cmb(M,2)

print(int(a))
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
A = list(map(int, input().split()))

if A[:1] < A[1:]:
  print(abs(A[1:]-A[:1]))
  sys.exit()
if A[:1] > A[1:]:
  print(abs(A[:1]-A[1:]))
  sys.exit()

sep = N//2
for i in range(N):
  if sum(A[:sep]) >= sum(A[sep:]):
    sep -= N//((i+2)**2)
  else:
    sep += N//((i+2)**2)
  if N//((i+2)**2) == 1:
    break
#print(sep)


a = abs(sum(A[:sep])-sum(A[sep:]))
b = abs(sum(A[:sep+1])-sum(A[sep+1:]))
c = abs(sum(A[:sep-1])-sum(A[sep-1:]))
print(min(a,b,c,d,e))

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

sep = N//2
for i in range(N):
  if sum(A[:sep]) >= sum(A[sep:]):
    sep -= N//((i+2)**2)
  else:
    sep += N//((i+2)**2)
  if N//((i+2)**2) == 1:
    break
#print(sep)


a = abs(sum(A[:sep])-sum(A[sep:]))
b = abs(sum(A[:sep+1])-sum(A[sep+1:]))
c = abs(sum(A[:sep-1])-sum(A[sep-1:]))
d = abs(sum(A[:sep+2])-sum(A[sep+2:]))
e = abs(sum(A[:sep-2])-sum(A[sep-2:]))
print(min(a,b,c,d,e))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, K ,Q = map(int, input().split())
participant = np.full(N, K)
As = []
for i in range(Q):
    answer = int(input())
    participant[answer-1] +=1
    participant -= 1
for surviver in np.where(participant>0, "Yes", "No"):
    print(surviver)



Fixed submission:
import numpy as np
N, K ,Q = map(int, input().split())
participant = np.full(N, K)
As = []
for i in range(Q):
    answer = int(input())
    participant[answer-1] +=1
participant -= Q
for surviver in np.where(participant>0, "Yes", "No"):
    print(surviver)
Buggy python submission (verdict: Runtime Error):
N = list(input())
if N in '7':
	print('Yes')
else:
	print('No')

Fixed submission:
N = list(input())
if '7' in N:
	print('Yes')
else:
	print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
K = 200
ans = 0
def gcd(*numbers):
    return reduce(math.gcd, numbers)
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans += gcd(i,j,k)
print(ans)

Fixed submission:
import math
K = int(input())
ans = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    tmp = math.gcd(i,j)
    for k in range(1,K+1):
        ans += math.gcd(tmp,k)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
def divisor_list(num):
  ans = []
  for i in range(1, int(num**0.5)+1):
    if num % i == 0:
      ans.append(i)
      if i != num // i:
        ans.append(num//i)
  return ans
d_list = sorted(divisor_list(N))
ans = 10**12
for i in d_list:
  for j in d_list:
    if i*j == N and ans > i+j-2:
      ans = i+j-2
print(ans)

Fixed submission:
N = int(input())
def divisor_list(num):
  ans = []
  for i in range(1, int(num**0.5)+1):
    if num % i == 0:
      ans.append(i)
      if i != num // i:
        ans.append(num//i)
  return ans
d_list = sorted(divisor_list(N))
ans = 10**12
for i in d_list:
    if ans > i+N//i-2:
      ans = i+N//i-2
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
ans = []
count = 0
for i in range(N-1):
  if i == N-2:
    if H[i] >= H[i+1]:
      ans.append(count+1)
    else:
      ans.append(count)
    break
  if H[i] < H[i+1]:
    ans.append(count)
    count = 0
  else:
    count += 1
print(max(ans))

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
ans = [0]
count = 0
for i in range(N-1):
  if i == N-2:
    if H[i] >= H[i+1]:
      count += 1
    ans.append(count)
    break
  if H[i] < H[i+1]:
    ans.append(count)
    count = 0
  else:
    count += 1
print(max(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(range(1,N))
print(sum(P))

Fixed submission:
N = int(input())
print((N-1)*N//2)
Buggy python submission (verdict: Runtime Error):
import math
def combinations(n, r):
  if n == r:
    return 1
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
s = [sorted(input())]
ans = 0
for i in range(N-1):
  s_i = sorted(input())
  s.append(s_i)
s = sorted(s)
count=1
for j in range(N-1):
  if s[j] == s[j+1]:
    count+=1
  else:
    ans += combinations(count,2)
    count=1
if count != 1:
  ans += combinations(count,2)
print(ans)

Fixed submission:
import math
def combinations(n, r):
  if n == r:
    return 1
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
s = [sorted(input())]
ans = 0
for i in range(N-1):
  s_i = sorted(input())
  s.append(s_i)
s = sorted(s)
count=1
for j in range(N-1):
  if s[j] == s[j+1]:
    count+=1
  else:
    if count != 1:
      ans += combinations(count,2)
    count=1
if count != 1:
  ans += combinations(count,2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
def combinations(n, r):
  if n == r:
    return 1
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
s = [[sorted(input()),1]]
ans = 0
for i in range(N-1):
  s_i = sorted(input())
  flag = 0
  for j in range(len(s)):
    if s[j][0] == s_i:
      flag = 1
      s[j][1] += 1
      break
  if flag != 1:
    s.append([s_i,1])
for j in range(len(s)):
    tmp = s[j][1]
    if tmp != 1:
      ans += combinations(tmp,2)
print(ans)

Fixed submission:
import math
def combinations(n, r):
  if n == r:
    return 1
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
s = [sorted(input())]
ans = 0
for i in range(N-1):
  s_i = sorted(input())
  s.append(s_i)
s = sorted(s)
count=1
for j in range(N-1):
  if s[j] == s[j+1]:
    count+=1
  else:
    if count != 1:
      ans += combinations(count,2)
    count=1
if count != 1:
  ans += combinations(count,2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
def combinations(n, r):
  if n == r:
    return 1
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
s = [[sorted(list(input())),1]]
ans = 0
for i in range(N-1):
  s_i = sorted(list(input()))
  flag = 0
  for j in range(len(s)):
    if s[j][0] == s_i:
      flag = 1
      s[j][1] += 1
      break
  if flag != 1:
    s.append([s_i,1])
for j in range(len(s)):
    tmp = s[j][1]
    if tmp != 1:
      ans += combinations(tmp,2)
print(ans)

Fixed submission:
import math
def combinations(n, r):
  if n == r:
    return 1
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
s = [sorted(input())]
ans = 0
for i in range(N-1):
  s_i = sorted(input())
  s.append(s_i)
s = sorted(s)
count=1
for j in range(N-1):
  if s[j] == s[j+1]:
    count+=1
  else:
    if count != 1:
      ans += combinations(count,2)
    count=1
if count != 1:
  ans += combinations(count,2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int,input().split()))
for i in range(1,N):
  if H[i]-H[i-1] < -1:
    print('No')
    break
  if i!=N-1 and H[i]-min(H[i+1:]) > 1:
    print('No')
    break
else:
  print('Yes')

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
max_H = H[0]
for i in range(1,N):
  if H[i]-H[i-1] < -1:
    print('No')
    break
  if H[i]-max_H < -1:
    print('No')
    break
  if max_H < H[i]:
    max_H = H[i]
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(N):
  ans += min(a[i]+a[i+1],b[i])
  A[i+1] -= max(0,min(A[i+1],B[i]-A[i]))
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(N):
  ans += min(A[i]+A[i+1],B[i])
  A[i+1] -= max(0,min(A[i+1],B[i]-A[i]))
print(ans)
Buggy python submission (verdict: Runtime Error):
S = int(input())
N = 10**9
x = (N - S%N) % N
y = S//x2 + 1
print(0,0,10**9,1,x,y)


Fixed submission:
S = int(input())
x1 = 0
y1 = 0
x2 = 10**9
y2 = 1
x3 = (x2-S%x2)%x2
y3 = -(-S//x2)
print(x1,y1,x2,y2,x3,y3)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
A_max = max(A)
A_max_count = A.count(A_max)
a_ = A[:]
a_ = sorted(a_,reverse = True)
A_next_max = a_[A_max_count]

for i in range(N):
  tmp = A[i]
  if tmp != A_max:
    print(A_max)
  else:
    if A_max_count == 1:
      print(A_next_max)
    else:
      print(A_max)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
A_max = max(A)
A_max_count = A.count(A_max)
if A_max_count != N:
  a_ = A[:]
  a_ = sorted(a_,reverse = True)
  A_next_max = a_[A_max_count]
else:
  A_next_max = A_max_count

for i in range(N):
  tmp = A[i]
  if tmp != A_max:
    print(A_max)
  else:
    if A_max_count == 1:
      print(A_next_max)
    else:
      print(A_max)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
  if i != 0:
    tmp = A[:i]+A[i+1:]
  else:
    tmp = A[1:]
  print(max(tmp))

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
A_max = max(A)
A_max_count = A.count(A_max)
if A_max_count != N:
  a_ = A[:]
  a_ = sorted(a_,reverse = True)
  A_next_max = a_[A_max_count]
else:
  A_next_max = A_max_count

for i in range(N):
  tmp = A[i]
  if tmp != A_max:
    print(A_max)
  else:
    if A_max_count == 1:
      print(A_next_max)
    else:
      print(A_max)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  N,M = map(int,input().split())
  a = [int(input()) for i in range(M)]
  m = 10**9+7

  dp = [0]*(N+1)
  dp[0] = 1
  if 1 not in a:
    dp[1] = 1
  for i in range(2,N+1):
    if i not in a:
      dp[i] = dp[i-1] + dp[i-2]
      dp[i] %= m
  print(dp[-1])

if __name__ == '__main__':
  main()

Fixed submission:
def main():
  N,M = map(int,input().split())
  a = [int(input()) for i in range(M)]
  m = 10**9+7
  
  stair = [0]*(N+1)
  for i in a:
    stair[i] = -1
  
  dp = [0]*(N+1)
  dp[0] = 1
  if 1 not in a:
    dp[1] = 1
  for i in range(2,N+1):
    if stair[i] == 0:
      dp[i] = dp[i-1] + dp[i-2]
      dp[i] %= m
  print(dp[N])

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
a = [int(input()) for i in range(M)]
m = 10**9+7

dp = [0]*(N+1)
dp[0] = 1
if 1 not in a:
	dp[1] = 1
for i in range(2,N+1):
    if i not in a:
    	dp[i] = dp[i-1] + dp[i-2]
    	dp[i] %= m
print(dp[-1])

Fixed submission:
def main():
  N,M = map(int,input().split())
  a = [int(input()) for i in range(M)]
  m = 10**9+7
  
  stair = [0]*(N+1)
  for i in a:
    stair[i] = -1
  
  dp = [0]*(N+1)
  dp[0] = 1
  if 1 not in a:
    dp[1] = 1
  for i in range(2,N+1):
    if stair[i] == 0:
      dp[i] = dp[i-1] + dp[i-2]
      dp[i] %= m
  print(dp[N])

if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
L,R = map(int,input().split())
tmp = list(range(L,R+1))
for i in range(M-1):
  L,R = map(int,input().split())
  ans = []
  for j in tmp:
    if L<=j<=R:
      ans.append(j)
  tmp = ans
print(len(ans))

Fixed submission:
N,M = map(int,input().split())
L,R = map(int,input().split())
for i in range(M-1):
  L_ans,R_ans = map(int,input().split())
  if L < L_ans:
    L = L_ans
  if R > R_ans:
    R = R_ans
print(len(list(range(L,R+1))))
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split())
ans = 0
for i in range(0,N+1,R):
  for j in range(0,N+1,G):
    if i+j<=N and (N-i-j)%B == 0:
        ans+=1
print(ans)


Fixed submission:
R,G,B,N = map(int,input().split())
ans = 0
for i in range(0,N+1,R):
  for j in range(0,N+1,G):
    if i+j<=N:
      if (N-i-j)%B == 0:
        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split())
ans = 0
for i in range(0,int(N/R)+1):
  for j in range(0,int(N/G)+1):
    if i*R+j*G<=N and (N-i*R-j*G)%B == 0:
        ans+=1
print(ans)

Fixed submission:
R,G,B,N = map(int,input().split())
ans = 0
for i in range(0,N+1,R):
  for j in range(0,N+1,G):
    if i+j<=N:
      if (N-i-j)%B == 0:
        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split())
num_list = [R,G,B]
num_list = sorted(num_list,reverse = True)
ans = 0
for i in range(0,int(N/num_list[0])+1):
  for j in range(0,int(N/num_list[1])+1):
    if i*num_list[0]+j*num_list[1]<=N and (N-i*num_list[0]-j*num_list[1])%num_list[2] == 0:
        ans+=1
print(ans)

Fixed submission:
R,G,B,N = map(int,input().split())
ans = 0
for i in range(0,N+1,R):
  for j in range(0,N+1,G):
    if i+j<=N:
      if (N-i-j)%B == 0:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import fractions
from functools import reduce
N = int(input())
A = list(map(int,input().split()))
ans = 0
A = sorted(A)
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
ans = 0
ans_ = 0
if N == 2:
  print(max(A))
elif N == 3:
  tmp = [A[0],A[1],A[N-1]]
  for i in range(len(tmp)):
    tmp_ = tmp[:]
    tmp_.pop(i)
    ans_ = gcd_list(tmp_)
    if ans < ans_:
      ans = ans_
  print(ans)
else:
  tmp = [A[0],A[1],A[N-2],A[N-1]]
  if len(list(set(A))) == 2:
    print(max(A))
  else:
    count = 0
    ans = gcd_list(tmp)
    for j in range(N):
      if A[j]%ans != 0:
        count+=1
    if count = 1:
      print(ans)
    else:
      for i in range(len(tmp)):
        tmp_ = tmp[:]
        tmp_.pop(i)
        ans_ = gcd_list(tmp_)
        if ans < ans_:
          ans = ans_
      print(ans)

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

def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,a%b)

ans = 0
L = [0]*(N+1)
for i in range(N):
  L[i+1] = gcd(L[i],A[i])

R = [0]*(N+1)
for i in range(N-1,-1,-1):
  R[i] = gcd(R[i+1],A[i])
  
for i in range(N):
  M = gcd(L[i],R[i+1])
  if ans < M:
    ans = M
    
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
ans = 0
A_set = list(set(A))
if len(A_set)==2 and (A.count(A_set[0])==1 or A.count(A_set[1])==1):
  print(max(A))
elif len(A_set)==1:
  print(max(A))
else:
  for i in sorted(range(1,max(A)+1),reverse=True):
    tmp = [A[j]%int(i) for j in range(N)]
    tmp_set = list(set(tmp))
    if len(tmp_set)==2:
      if tmp.count(tmp_set[0])==1 or tmp.count(tmp_set[1])==1:
        ans = i
        break
  print(ans)

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

def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,a%b)

ans = 0
L = [0]*(N+1)
for i in range(N):
  L[i+1] = gcd(L[i],A[i])

R = [0]*(N+1)
for i in range(N-1,-1,-1):
  R[i] = gcd(R[i+1],A[i])
  
for i in range(N):
  M = gcd(L[i],R[i+1])
  if ans < M:
    ans = M
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
count = 0
count_b = []
count_w = []
b_num = 0
w_num = 0
w_all = S.count('.')
for i in range(N):
  if S[i] == '#':
    b_num += 1
  if S[i] == '.':
    w_num += 1
  count_w.append(w_all-w_num)
  count_b.append(b_num)
ans = 100000
for i in range(N):
  if ans > count_b[i]+count_w[i]:
    ans = count_b[i]+count_w[i]

print(ans)


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

if (C >= A and C <= B) or  (C <= A and C >= B):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = [int(input()) for i in range(5)]
ans = [0]*6
ans[0] = N
ans_num = 0
while(ans[5]!=N):
  tmp = [0]*6
  ans_num+=1
  for i in range(5):
    ans_tmp = ans[i]
    if ans_tmp!=0:
      if ans_tmp<=l[i]:
        tmp[i+1] = ans_tmp
        ans[i]=0
      else:
        tmp[i+1] = l[i]
        ans[i]-=l[i]
  for i in range(6):
    ans[i]+=tmp[i]
print(ans_num)

Fixed submission:
N = int(input())
l = [int(input()) for i in range(5)]
tmp = 0
for i in range(5):
  if l[i] > N:
    tmp += 1

if tmp == 5:
  print(5)
else:
    ans = 0
    if N%min(l) == 0:
      ans+=5+N//min(l)-1
    else:
      ans+=5+N//min(l)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
z = []
for j in range(N-1):
  if S[j] =='A' and S[j+1]=='C':
    z.append(j+1)
for i in range(Q):
  l,r = map(int,input().split())
  if r-l >= 1:
    if r-l == 1:
      if l in z:
        print('1')
      else:
        print('0')
    else:
      ans = [x for x in z if x >= l and x<= r-1]
      print(len(ans))
  else:
    print('0')


Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
z = []
for j in range(N-1):
  if S[j]=='A' and S[j+1]=='C':
    z.append(j+1)
for i in range(Q):
  l,r = map(int,input().split())
  ans = [x for x in z if x >= l and x<= r-1]
  print(len(ans))

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
z = []
for j in range(N-1):
  if S[j]+S[j+1]=='AC':
    z.append(j+1)
for i in range(Q):
  l,r = map(int,input().split())
  l = l
  r = r
  ans = [x for x in z if x >= l and x<= r-1]
  print(len(ans))


Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
for i in range(Q):
  l,r = map(int,input().split())
  tmp = S[l-1:r]
  tmp = tmp.replace('AC','z')
  print(tmp.count('z'))

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
for i in range(Q):
  l,r = map(int,input().split())
  tmp = S[l-1:r]
  print(tmp.count('AC'))

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

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

for i in range(Q):
  l = lr[i][0]
  r = lr[i][1]
  tmp = S[l-1:r]
  print(tmp.count('AC'))

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])