Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math
from copy import deepcopy
import sys
from itertools import combinations_with_replacement
def input():
    return sys.stdin.readline()[:-1]
# input
N, M = map(int, input().split())
As = list(map(int, input().split()))
ind = [i for i in range(N)]

min_val = None
for combo in combinations_with_replacement(ind, M):
    price = deepcopy(As)
    for i in combo:
        price[i] = math.floor(price[i]/2)
    if min_val is None:
        min_val = sum(price)
    else:
        if sum(price) <= min_val:
            min_val = sum(price)

print(min_val)

Fixed submission:
import heapq
import sys
def input():
    return sys.stdin.readline()[:-1]

# input
N, M = map(int, input().split())
a = []

for i in input().split():
    heapq.heappush(a, -int(i))

for j in range(M):
    highest = heapq.heappop(a)
    heapq.heappush(a, -(- highest // 2))

print(-sum(a))

Buggy python submission (verdict: Runtime Error):
from copy import deepcopy
import sys
from itertools import combinations_with_replacement
def input():
    return sys.stdin.readline()[:-1]
# input
N, M = map(int, input().split())
As = list(map(int, input().split()))
ind = [i for i in range(N)]

min_val = None
for combo in combinations_with_replacement(ind, M):
    price = deepcopy(As)
    for i in combo:
        price[i] = math.floor(price[i]/2)
    if min_val is None:
        min_val = sum(price)
    else:
        if sum(price) <= min_val:
            min_val = sum(price)

print(min_val)

Fixed submission:
import heapq
import sys
def input():
    return sys.stdin.readline()[:-1]

# input
N, M = map(int, input().split())
a = []

for i in input().split():
    heapq.heappush(a, -int(i))

for j in range(M):
    highest = heapq.heappop(a)
    heapq.heappush(a, -(- highest // 2))

print(-sum(a))
Buggy python submission (verdict: Runtime Error):
N, i = map(int, input().split())

print(N + 1 - i)
hibiki@hibiki-MB-E410

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

print(N + 1 - i)
print()
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())

if (N % K == 0):
	print(0)
else:
	print(1)
hibiki@hibiki-MB-E41

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

if (N % K == 0):
	print(0)
	print()
else:
	print(1)
	print()
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

if (a * b % 2 == 0):
	print("Even")
else:
	print("Odd")
hibiki@hibiki-MB-E410:~/

Fixed submission:
a, b = map(int, input().split())

if (a * b % 2 == 0):
	print("Even")
	print()
else:
	print("Odd")
	print()
Buggy python submission (verdict: Runtime Error):
M = input()
M = int(M)
print(48 - M)
hibiki@hibiki-M

Fixed submission:
M = input()
M = int(M)
print(48 - M)
print()
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

if (A+B < C+D):
	print("Right")
elif (A+B > C+D):
	print("Left")
else:
	print("Balanced")

hibiki@

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

if (A+B < C+D):
	print("Right ")
elif (A+B > C+D):
	print("Left ")
else:
	print("Balanced ")
Buggy python submission (verdict: Runtime Error):
N=int(input())
List=list(map(int,input().split()))
c=0
for i in range(N-1):
  for j in range(i+1,N):
    c=c+(List[i]*List[j])
print(c)

Fixed submission:
a,b=map(int,input().split())
c=a-2*b
if c<=0:
    print(0)
else:
    print(c)

Buggy python submission (verdict: Runtime Error):
N=int(input())
List=list(map(int,input().split()))
c=0
for i in range(N-1):
  for j in range(i+1:N):
    c=c+(List[i]*List[j])
print(c)

Fixed submission:
a,b=map(int,input().split())
c=a-2*b
if c<=0:
    print(0)
else:
    print(c)
Buggy python submission (verdict: Runtime Error):
N=int(input())
List=list(map(int,input().split()))
c=0
for i in range(N-1):
  for j in range(i+1:N):
    c=c+(List[i]*List[j])
print(c)

Fixed submission:
N=int(input())
List=list(map(int,input().split()))
c=0
for i in range(N-1):
  for j in range(i+1,N):
    c=c+(List[i]*List[j])
print(c)

Buggy python submission (verdict: Runtime Error):
N=int(input())
List=list(map(int,input().split()))
c=0
for i in range(N-1):
  for j in range(i+1:N):
    c==c+(List[i]*List[j])
print(c)

Fixed submission:
N=int(input())
List=list(map(int,input().split()))
c=0
for i in range(N-1):
  for j in range(i+1,N):
    c=c+(List[i]*List[j])
print(c)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(map(int,input().split(" ")))
jisho={}
for i in S:
    a=S.index(i)+1
    jisho[a]=i
jisho=sorted(jisho.items(), key=lambda x:x[1])
for i in range(0,len(jisho)):
    print(jisho[i][0],end=" ")

Fixed submission:
input_line=input().rstrip()
kisuu=0
for number in range(1,int(input_line)+1):
  if number%2==1:
    kisuu=kisuu+1
possi=kisuu/int(input_line)
print(possi)

Buggy python submission (verdict: Runtime Error):
input_line=input().rstrip.split()
kisuu=0
for number in range(1,int(input_line)+1):
  if number%2==1:
    kisuu=kisuu+1
possi=kisuu/int(input_line)
print(possi)

Fixed submission:
input_line=input().rstrip()
kisuu=0
for number in range(1,int(input_line)+1):
  if number%2==1:
    kisuu=kisuu+1
possi=kisuu/int(input_line)
print(possi)
Buggy python submission (verdict: Runtime Error):
S=list(input())
a=0
for j in range(0,len(S),2):
    if S[i]=="R" or S[i]=="U" or S[i]=="D":
        a+=1
for i in range(1,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")

Fixed submission:
S=list(input())
a=0
for j in range(0,len(S),2):
    if S[j]=="R" or S[j]=="U" or S[j]=="D":
        a+=1
for i in range(1,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
S=list(input())
a=0
for i in range(1,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
for j in range(0,len(S),2):
    if S[i]=="R" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")

Fixed submission:
S=list(input())
a=0
for j in range(0,len(S),2):
    if S[j]=="R" or S[j]=="U" or S[j]=="D":
        a+=1
for i in range(1,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
S=list(input())
a=0
for i in range(1,len(S),2):
    if S[i]=="R" or S[i]=="U" or S[i]=="D":
        a+=1
for j in range(0,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")

Fixed submission:
S=list(input())
a=0
for j in range(0,len(S),2):
    if S[j]=="R" or S[j]=="U" or S[j]=="D":
        a+=1
for i in range(1,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
S=list(input())
a=0
for i in range(1,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
for j in range(0,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")

Fixed submission:
S=list(input())
a=0
for j in range(0,len(S),2):
    if S[j]=="R" or S[j]=="U" or S[j]=="D":
        a+=1
for i in range(1,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split(" "))
h="IMPOSSIBLE"
c=[a,b]
for i in range(len(str(min(c))),10**9):
    if abs(a-i)==abs(b-i):
        h=i
        break
print(h)


Fixed submission:
a,b=map(int,input().split(" "))
if (a%2==0 and b%2==1) or (a%2==1 and b%2==0):
    print("IMPOSSIBLE") 
else:
    print(int((a+b)/2))

Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split(" "))
h="IMPOSSIBLE"
c=[a,b]
for i in range(len(str(min(c))),10**9):
    if abs(a-i)==abs(b-i):
        h=i
        break
print(h)


Fixed submission:
a,b=map(int,input().split(" "))
if (a%2==0 and b%2==1) or (a%2==1 and b%2==0):
    print("IMPOSSIBLE") 
else:
    print(int((a+b)/2))
Buggy python submission (verdict: Runtime Error):
N=int(input())
a=int(input())
if N%500=<a:
    print("Yes")
else:
    print("No")

Fixed submission:
N=int(input())
a=int(input())
if N%500<=a:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a*b%2==0:
    print("Odd")
else:
    print(#Even)

Fixed submission:
a,b=map(int,input().split())
c=a*b
if c%2==0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(map(int,input().split()))
shingi=True
total=0
while shingi==True:
    count=0
    for i in S:
        if i%2==0:
            count+=1
        else:
            shingi=False
    if count==len(S):
        total+=1
    S=list(map(lambda x:x/2,S))
print(total)

Fixed submission:
a=input()
print(a.count("1"))
Buggy python submission (verdict: Runtime Error):
input_line=input().rstrip().split(" ")
five=int(input_line.count("5"))
seven=int(input_line.count("7"))
if five=2 and seven=1:
    print("YES")
else:
    print("NO")

Fixed submission:
input_line=input().rstrip().split(" ")
five=int(input_line.count("5"))
seven=int(input_line.count("7"))
if five==2 and seven==1:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
input_line=input().rstrip().split(" ")
a=int(input_line[0])
b=int(input_line[1])
c=int(input_line[2])
if a+b+c!=17:
    print("NO")
elif (a==b==5 or a==c==5 or b==C==5) and a+b+c==17:
    print("YES")
else:
    print("NO")


Fixed submission:
input_line=input().rstrip().split(" ")
five=int(input_line.count("5"))
seven=int(input_line.count("7"))
if five==2 and seven==1:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
input_line=input().rstrip().split(" ")
a=int(input_line[0])
b=int(input_line[1])
c=int(input_line[2])
if a==b==5 or a==c==5 or b==C==5:
    if a+b+c==17:
        print("YES")
elif a+b+c!=17:
    print("NO")


Fixed submission:
input_line=input().rstrip().split(" ")
five=int(input_line.count("5"))
seven=int(input_line.count("7"))
if five==2 and seven==1:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
input_line=input().rstrip().split(" ")
a=int(input_line[0])
b=int(input_line[1])
c=int(input_line[2])
if a==b==5 or a==c==5 or b==C==5:
    if a+b+c==17:
        print("YES")
elif a+b+c!=17
    print("NO")


Fixed submission:
input_line=input().rstrip().split(" ")
five=int(input_line.count("5"))
seven=int(input_line.count("7"))
if five==2 and seven==1:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
input_line=input().rstrip().split(" ")
a=int(input_line[0])
b=int(input_line[1])
c=int(input_line[2])
if a==b==5 or a==c==5 or b==C==5:
    if a+b+c==17:
        print("YES")
else:
    print("NO")

Fixed submission:
input_line=input().rstrip().split(" ")
five=int(input_line.count("5"))
seven=int(input_line.count("7"))
if five==2 and seven==1:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
input_line=input().rstrip().split(" ")
a=int(input_line[0])
b=int(input_line[1])
c=int(input_line[2])
if a==b==5 or a==c==5 or b==C==5:
    print("YES")
else:
    print("NO")


Fixed submission:
input_line=input().rstrip().split(" ")
five=int(input_line.count("5"))
seven=int(input_line.count("7"))
if five==2 and seven==1:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
input_line=input().rstrip().split(" ")
a=int(input_line[0])
b=int(input_line[1])
c=int(input_line[2])
if a+b+c!=17:
    print("NO")
elif a==b==5 or a==c==5 or b==C==5:
    print("YES")
else:
    print("NO")


Fixed submission:
input_line=input().rstrip().split(" ")
five=int(input_line.count("5"))
seven=int(input_line.count("7"))
if five==2 and seven==1:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
n,l=map(int,input().split(" "))
words=[input() for i in range(0,l)]
words.sort()
words="".join(words)
print(words)

Fixed submission:
n,l=map(int,input().split(" "))
words=[input() for i in range(0,n)]
words.sort()
words="".join(words)
print(words)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
print(s[:n/2]==s[n/2:] and n%2==0)


Fixed submission:
n = int(input())
s = input()
if(s[:n//2]==s[n//2:] and n%2==0):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
i = input()
ar = i.split()
print(max(ar[0]-2*ar[1], 0))


Fixed submission:
i = input()
ar = i.split()
print(max(int(ar[0])-2*int(ar[1]), 0))
Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
b = [int(i) for i in input().split()]
print((int)(sum(1 for x in range(a-2) for y in range(x+1,a-1) for z in range(y+1,a) if (b[x]<b[y]+b[z] and b[y]<b[x]+b[z] and b[z]<b[x]+b[y]))))



Fixed submission:
a = int(input())
arr = [int(i) for i in input().split()]
arr.sort() 
count = 0
for i in range(0,a-2): 
    k = i + 2
    for j in range(i+1,a):
        while (k < a and arr[i] + arr[j] > arr[k]): 
            k += 1
        if(k>j): 
            count += k - j - 1
  
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
b = [int(i) for i in input().split()]
print((int)(sum(1 for x in range(a) for y in range(a) for z in range(a) if x!=y and y!=z and x!=z and (b[x]<b[y]+b[z] and b[y]<b[x]+b[z] and b[z]<b[x]+b[y]))/6))



Fixed submission:
a = int(input())
arr = [int(i) for i in input().split()]
arr.sort() 
count = 0
for i in range(0,a-2): 
    k = i + 2
    for j in range(i+1,a):
        while (k < a and arr[i] + arr[j] > arr[k]): 
            k += 1
        if(k>j): 
            count += k - j - 1
  
print(count)
Buggy python submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
g = math.gcd(a,b)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
fac = factorization(g)
ans = len(fac)
if fac[0][0] != 1: ans += 1
print(ans)


Fixed submission:
import fractions
a,b = map(int,input().split())
g = fractions.gcd(a,b)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
fac = factorization(g)
ans = len(fac)
if fac[0][0] != 1: ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(max(a+b.a-b,a*b))

Fixed submission:
a,b = map(int,input().split())
print(max(a+b,a-b,a*b))
Buggy python submission (verdict: Time Limit Exceeded):
n,x = map(int, input().split())
L = list(map(int, input().split()))
loc = 0
i = 1
while loc <= x:
    if i < n+1: loc += L[i-1]
    i += 1
print(i-1)


Fixed submission:
n,x = map(int, input().split())
L = list(map(int, input().split()))
loc = 0
i = 1
while loc <= x:
    if i < n+1:
        loc += L[i-1]
    else:
        i += 1
        break
    i += 1
print(i-1)

Buggy python submission (verdict: Runtime Error):
n,x = map(int, input().split())
L = list(map(int, input().split()))
ans = 0
loc = 0
i = 0
while loc <= x:
    loc += L[i]
    i += 1
print(i)


Fixed submission:
n,x = map(int, input().split())
L = list(map(int, input().split()))
loc = 0
i = 1
while loc <= x:
    if i < n+1:
        loc += L[i-1]
    else:
        i += 1
        break
    i += 1
print(i-1)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
V = list(map(int, input().split()))

maxsum = -10**13
for i in range(min(n+1,k+1)):
    for j in range(min(n+1-i,k+1-i)):
        su = (V[:i] + V[:n-j-1:-1])
        su.sort()
        sumsu = sum(su)
        #print("i,j:",i,j,su)
        if k-i-j > 0:
            for l in range(k-i-j):
                if len(su) > l and su[l] < 0: sumsu -= su[l]
        maxsum = sumsu if maxsum < sumsu else maxsum
print(maxsum)

Fixed submission:
n,k = map(int, input().split())
V = list(map(int, input().split()))

maxsum = -10**13
for i in range(min(n+1,k+1)):
    for j in range(min(n+1-i,k+1-i)):
        su = (V[:i] + V[:n-j-1:-1])
        su.sort()
        sumsu = sum(su)
        #print("i,j:",i,j,su)
        if k-i-j > 0:
            for l in range(k-i-j):
                if len(su) > l and su[l] < 0: sumsu -= su[l]
        maxsum = sumsu if maxsum < sumsu else maxsum
print(maxsum)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
A = list(map(lambda x:list((int(x),1)), input().split()))
#print(A)
for i in range(m):
    b,c = map(int, input().split())
    A.append([c,b])
A.sort(reverse = True)
sum = 0
rem = n
for i in range(len(A)):
    sum += A[i][0] * min(A[i][1],rem)
    rem -= min(A[i][1],rem)
    if rem == 0: break
print(sum)

Fixed submission:
n, m = map(int, input().split())
A = list(map(lambda x:list((int(x),1)), input().split()))
#print(A)
for i in range(m):
    b,c = map(int, input().split())
    A.append([c,b])
A.sort(reverse = True)
sum = 0
rem = n
for i in range(len(A)):
    sum += A[i][0] * min(A[i][1],rem)
    rem -= min(A[i][1],rem)
    if rem == 0: break
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
A = list(map(int, input().split()))
sumb = 0
for i in range(m):
    b,c = map(int, input().split())
    for j in range(b): A.append(c)
    sumb += b
A.sort()
print(sum(A[n+sumb:sumb-1:-1]))

Fixed submission:
n, m = map(int, input().split())
A = list(map(lambda x:list((int(x),1)), input().split()))
#print(A)
for i in range(m):
    b,c = map(int, input().split())
    A.append([c,b])
A.sort(reverse = True)
sum = 0
rem = n
for i in range(len(A)):
    sum += A[i][0] * min(A[i][1],rem)
    rem -= min(A[i][1],rem)
    if rem == 0: break
print(sum)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())

s = input()
s[k+1].lower()
print(s)

Fixed submission:
n, k = map(int, input().split())

s = input()

print(s[:k-1] + s[k-1].lower() + s[k:])
Buggy python submission (verdict: Runtime Error):
N = int(input())
val = []
cos = []
for i in range(N):
    val.append(int(input())
for i in range(N):
    cos.append(int(input())
dif = [val[i]-cos[i] for i in range(N)]
ma = 0
for d in dif:
    ma += d if d >= 0 else 0
return ma

Fixed submission:
n = int(input())
va = input().split()
co = input().split()

val = [int(v) for v in va]
cos = [int(c) for c in co]

dif = [val[i]-cos[i] for i in range(n)]
ma = 0
for d in dif:
    ma += d if d >= 0 else 0
print(ma)
Buggy python submission (verdict: Runtime Error):
from math import gcd

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

lgcd, rgcd = [], []
for i in range(n):
    if i == 0:
        lgcd.append(a[0])
        rgcd.append(a[n-1])
        continue

    lgcd.append(gcd(lgcd[i-1], a[i]))
    rgcd.append(gcd(rgcd[i-1], a[-1-i]))

maxgcd = 1
for i in range(n):
    if i == 0:
        tempgcd = rgcd[n-1]
    elif i == n-1:
        tempgcd = lgcd[n-1]
    else:
        tempgcd = gcd(lgcd[i-1], rgcd[n-2-i])
    maxgcd = max(maxgcd, tempgcd)
print(maxgcd)
        

Fixed submission:
from fractions import gcd

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

lgcd, rgcd = [], []
for i in range(n):
    if i == 0:
        lgcd.append(a[0])
        rgcd.append(a[n-1])
        continue

    lgcd.append(gcd(lgcd[i-1], a[i]))
    rgcd.append(gcd(rgcd[i-1], a[-1-i]))

maxgcd = 1
for i in range(n):
    if i == 0:
        tempgcd = rgcd[n-2]
    elif i == n-1:
        tempgcd = lgcd[n-2]
    else:
        tempgcd = gcd(lgcd[i-1], rgcd[n-2-i])
    maxgcd = max(maxgcd, tempgcd)
print(maxgcd)

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

def gcd(nums):
    return reduce(fractions.gcd, nums)

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

maxgcd = 0
for i in range(len(a)):
    temp = gcd(a[:i] + a[i + 1:])
    if temp > maxgcd:
        maxgcd = temp

print(maxgcd)

Fixed submission:
from fractions import gcd

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

lgcd, rgcd = [], []
for i in range(n):
    if i == 0:
        lgcd.append(a[0])
        rgcd.append(a[n-1])
        continue

    lgcd.append(gcd(lgcd[i-1], a[i]))
    rgcd.append(gcd(rgcd[i-1], a[-1-i]))

maxgcd = 1
for i in range(n):
    if i == 0:
        tempgcd = rgcd[n-2]
    elif i == n-1:
        tempgcd = lgcd[n-2]
    else:
        tempgcd = gcd(lgcd[i-1], rgcd[n-2-i])
    maxgcd = max(maxgcd, tempgcd)
print(maxgcd)

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

def gcd(nums):
    return reduce(math.gcd, nums)

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

maxgcd = 0
for i in range(len(a)):
    temp = gcd(a[:i] + a[i + 1:])
    if temp > maxgcd:
        maxgcd = temp

print(maxgcd)

Fixed submission:
from fractions import gcd

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

lgcd, rgcd = [], []
for i in range(n):
    if i == 0:
        lgcd.append(a[0])
        rgcd.append(a[n-1])
        continue

    lgcd.append(gcd(lgcd[i-1], a[i]))
    rgcd.append(gcd(rgcd[i-1], a[-1-i]))

maxgcd = 1
for i in range(n):
    if i == 0:
        tempgcd = rgcd[n-2]
    elif i == n-1:
        tempgcd = lgcd[n-2]
    else:
        tempgcd = gcd(lgcd[i-1], rgcd[n-2-i])
    maxgcd = max(maxgcd, tempgcd)
print(maxgcd)
Buggy python submission (verdict: Runtime Error):
import fractions

N = int(input())
r = [int(input()) for _ in range(5)]

m_r = min(r)
print(fractions.ceil(N/m_r) + 4)

Fixed submission:
import math
N = int(input())
r = [int(input()) for _ in range(5)]

m_r = min(r)
print(math.ceil(N/m_r) + 4)

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

N = int(input())
r = [int(input()) for _ in range(5)]

m_r = min(r)
print(fractions.ceil(N/r) + 4)

Fixed submission:
import math
N = int(input())
r = [int(input()) for _ in range(5)]

m_r = min(r)
print(math.ceil(N/m_r) + 4)

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

N = int(input())
r = [int(input()) for _ in range(5)]

m_r = min(r)
print(math.ceil(N/r) + 4)

Fixed submission:
import math
N = int(input())
r = [int(input()) for _ in range(5)]

m_r = min(r)
print(math.ceil(N/m_r) + 4)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int, input().split())
S = input()

lr = [list(map(int, input().split())) for i in range(Q)]

# AC探索
loc = []
for i in range(N-1):
    if S[i:i+2] == "AC":
        loc.append(i)

# lrの各セットにlocに含まれる位置がいくつあるのか調べる
for l,r in lr:
    cn = 0
    for i in range(l-1,r-1):
        if i in loc: cn += 1
    print(cn)




Fixed submission:
N,Q = map(int, input().split())
S = input()

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

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int, input().split())
S = input()

lr = [list(map(int, input().split())) for i in range(Q)]

for i in range(Q):
    print(S[lr[i][0]-1 : lr[i][1]].count("AC"))

Fixed submission:
N,Q = map(int, input().split())
S = input()

t = [0] * (N+1)
for i in range(N):
    t[i] = t[i-1] + (1 if S[i:i+2] == "AC" else 0)
for i in range(Q):
    l,r = map(int, input().split())
    print(t[r-2] - t[l-2])
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
H = list(map(int, input().split()))
dp = [10**9 for i in range(n)]

dp[0] = 0
for i in range(n-1):
    for j in range(1,min(k+1,n-i)):
        dp[i+j] = min(dp[i+j],dp[i]+abs(H[i+j]-H[i]))
print(dp[n-1])

Fixed submission:
n,k = map(int, input().split())
H = list(map(int, input().split()))
dp = [10**9 for i in range(n)]

dp[0] = 0
for i in range(n-1):
    for j in range(1,min(k+1,n-i)):
        dp[i+j] = min(dp[i+j],dp[i]+abs(H[i+j]-H[i]))
print(dp[n-1])