Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03439 (python)

Fixed submission:
import sys
n=int(input())

print(0)
sexlow=input()
if(sexlow=='Vacant'):
    sys.exit()

print(n-1)
sexhigh=input()
if(sexhigh=='Vacant'):
    sys.exit()

low=0
high=n-1
piv=0
while(True):
    piv=(low+high)//2

    print(piv)
    sexn=input()
    if(sexn=='Vacant'):
        break
    elif(( (piv-low)%2==0 and sexlow!=sexn) or ( (piv-low)%2!=0 and sexlow==sexn)):
        high=piv
        sexhigh=sexn
    elif(( (high-piv)%2==0 and sexhigh!=sexn) or ( (high-piv)%2!=0 and sexhigh==sexn)):
        low=piv
        sexlow=sexn

Buggy submission (verdict: Runtime Error):
import sys
n=int(input())

def flush():
    sys.stdout.write("\033[2K\033[G")
    sys.stdout.flush()

print(0)
s=input()
if(s=='Vacant'):
    sys.exit()
flush()
pre_i=0
i=(n-1)//2
while(True):
    print(i)
    si=input()
    if(si=='Vacant'):
        break
    temp=i
    if(s==si):
        i=i+(i-pre_i)//2
    else:
        i=i-(i-pre_i)//2
    s=si
    pre_i=temp
Problem p03564 (python)

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

b=2**n
ans=999999999999999999
for i in range(b):
    bit_b=bin(i)[2:].zfill(n)
    ans_i=1
    for j in range(len(bit_b)):
        if(bit_b[j]=='0'):
            ans_i*=2
        elif(bit_b[j]=='1'):
            ans_i+=k

    if(ans>ans_i):
        ans=ans_i

print(ans)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
k=int(input())

b=2**n
ans=math.inf
for i in range(b):
    bit_b=bin(i)[2:].zfill(n)
    ans_i=1
    for j in range(len(bit_b)):
        if(bit_b[j]=='0'):
            ans_i*=2
        elif(bit_b[j]=='1'):
            ans_i+=k

    if(ans>ans_i):
        ans=ans_i

print(ans)
Problem p03569 (python)

Fixed submission:
import sys
s=input()
ans=0
i=0
j=len(s)-1
xi=0
yj=0
while(i<j):

    while(i<len(s)-1 and s[i]=='x'):
        i+=1
        xi+=1
#        print(i,xi)

    while(j>0 and s[j]=='x'):
        j-=1
        yj+=1
#        print(j,yj)

#    print(i,xi,j,yj)
    if(s[i]!=s[j]):
        print(-1)
        sys.exit()
    else:
        ans+=abs(xi-yj)
        xi=0
        yj=0
        i+=1
        j-=1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
s=input()
ans=0
i=0
j=len(s)-1
xi=0
yj=0
while(i<j):

    while(i<len(s) and s[i]=='x'):
        i+=1
        xi+=1
#        print(i,xi)

    while(j>=0 and s[j]=='x'):
        j-=1
        yj+=1
#        print(j,yj)

#    print(i,xi,j,yj)
    if(s[i]!=s[j]):
        print(-1)
        sys.exit()
    else:
        ans+=abs(xi-yj)
        xi=0
        yj=0
        i+=1
        j-=1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
s=input()
ans=0
i=0
j=len(s)-1
xi=0
yj=0
while(i<j):

    while(s[i]=='x'):
        i+=1
        xi+=1
#        print(i,xi)

    while(s[j]=='x'):
        j-=1
        yj+=1
#        print(j,yj)

#    print(i,xi,j,yj)
    if(s[i]!=s[j]):
        print(-1)
        sys.exit()
    else:
        ans+=abs(xi-yj)
        xi=0
        yj=0
        i+=1
        j-=1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
s=input()
ans=0
i=0
j=len(s)-1
xi=0
yj=0
while(i<j):

    while(s[i]=='x'):
        i+=1
        xi+=1
#        print(i,xi)

    while(s[j]=='x'):
        j-=1
        yj+=1
#        print(j,yj)

    print(i,xi,j,yj)
    if(s[i]!=s[j]):
        print(-1)
        sys.exit()
    else:
        ans+=abs(xi-yj)
        xi=0
        yj=0
        i+=1
        j-=1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
s=input()
ans=0
i=0
j=len(s)-1
xi=0
yj=0
while(i<j):

    while(s[i]=='x'):
        i+=1
        xi+=1
        print(i,xi)

    while(s[j]=='x'):
        j-=1
        yj+=1
        print(j,yj)

    print(i,xi,j,yj)
    if(s[i]!=s[j]):
        print(-1)
        sys.exit()
    else:
        ans+=abs(xi-yj)
        xi=0
        yj=0
        i+=1
        j-=1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
s=input()

s_nox=[]
x=[]
xcount=0
for si in list(s):
    if(si!='x'):
        x.append(xcount)
        xcount=0
        s_nox.append(si)
    else:
        xcount+=1
else:
    x.append(xcount)


for i in range((len(s_nox)//2)+1):
    j=-1*i -1
    if(s_nox[i] != s_nox[j]):
        print(-1)
        sys.exit()


ans=0
for i in range(len(x)//2):
    j=-1*i -1
    ans+=abs(x[i]-x[j])

if(len(x)%2==1 and x[len(x)//2]%2==1):
    ans+=1

print(ans)
Problem p03609 (python)

Fixed submission:
x,t=map(int,input().split())
print(x-t if x >= t else 0)

Buggy submission (verdict: Runtime Error):
x,t=map(int.input().split())
print(x-t)

Buggy submission (verdict: Runtime Error):
x,t=map(int.input())
print(x-t)
Problem p03848 (python)

Fixed submission:
import sys

MOD = 1000000007

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

if(N%2 == 0):
    a.sort()
    for i in range(N//2):
        n = 2*i + 1
        if(a[2*i] != n or a[2*i + 1] != n):
            print(0)
            sys.exit()
    print((2 ** (N//2)) % MOD)
else:
    a.sort()
    if(a.count(0) != 1):
        print(0)
        sys.exit()
    for i in range((N-1)//2):
        n = 2*i + 2
        if(a[2*i + 1] != n or a[2*i + 2] != n):
            print(0)
            sys.exit()
    print((2 ** ((N-1)//2)) % MOD)

Buggy submission (verdict: Runtime Error):
import sys

MOD = 1000000007

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

if(N%2 == 0):
    a.sort()
    for i in range(N//2):
        n = 2*i + 1
        if(a[2*i] != n or a[2*i + 1] != n):
            print(0)
            sys.exit()
    print((2 ** (N//2)) % MOD)
else:
    a.sort()
    if(a[0] != 0 or a[1] == 0 ):
        print(0)
        sys.exit()
    for i in range((N-1)//2):
        n = 2*i + 2
        if(a[2*i + 1] != n or a[2*i + 2] != n):
            print(0)
            sys.exit()
    print((2 ** ((N-1)//2)) % MOD)
Problem p02642 (python)

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

dp = [0]*(10**6 + 1)
ans = 0

for i in a:
    if dp[i] == 0:
        for j in range(1,10**6+1):
            if i * j > 10**6:
                break
            dp[i*j] += 1
    elif dp[i] == 1:
        dp[i] += 1

for i in a:
    if dp[i] == 1:
        ans += 1


print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = n

if a[0] % a[1] == 0:
    ans -= 1

for i in range(1,n):
    for j in range(i):
        if a[i] % a[j] == 0:
            ans -= 1
            break

print(ans)
Problem p02748 (python)

Fixed submission:
A,B,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
li2=[input() for i in range(m)]
c = []
for i in range(m):
    c.append( [int(x.strip()) for x in li2[i].split()])

ans = min(a) + min (b)

for i in range(m):
    keep = a[c[i][0]-1] + b[c[i][1]-1] - c[i][2]
    if keep < ans:
        ans = keep

print(ans)

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
b = list(map(int,input().split()))
li2=[input() for i in range(m)]
c = []
for i in range(m):
    c.append( [int(x.strip()) for x in li2[i].split()])

ans = min(a) + min (b)

for i in range(m):
    keep = a[c[i][0]-1] + b[c[i][1]-1] - c[i][2]
    if keep < ans:
        ans = keep

print(ans)
Problem p02768 (python)

Fixed submission:
from functools import reduce

n, a, b = map(int, input().split())
mod = 10 ** 9 + 7

#combination高速化の裏技
def comb(N, A, MOD):
    num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A + 1))
    return num * pow(den, MOD - 2, MOD) % MOD

#powはmodを引数にしてあまりを計算してくれる
print((pow(2, n, mod = mod) - 1 - comb(n, a, mod) - comb(n, b, mod)) % mod)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
ans = pow(2,n)-1
inf = 10**9 + 7
ans = ans% inf
aa = 1
bb = 1

for i in range(b):
    if i < a:
        aa = aa *(n-i) /(i+1)

    bb = bb *(n-i) /(i+1)

ans = int((ans -aa -bb) % inf)
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())


dp = [0] * int((n+2)/2)

dp[1] = n

for i in range(1,len(dp)-1):
    dp[i+1] = dp[i] * (dp[i] -1) /(i+1)

dpr = dp[::-1]

if int(n/2) * 2 == n: #nが偶数
    dpr = dpr[:-1]

dp += dpr

dp[-1] = 1

ans = sum(dp)

ans -= dp[a]
ans -= dp[b]
ans = ans%(10**9+7)

print(int(ans))
Problem p02787 (python)

Fixed submission:
a = list(map(int, input().split()))
HP = a[0]

x = []
for i in range(a[1]):
    x1, y1 = [int(i) for i in input().split()]
    x.append((x1, y1))

max_tup = max(x, key=lambda x: x[0])
max_a = max_tup[0]
dp = [0] * (HP + max_a)

for i in range(1, len(dp)):
    dp[i] = min(dp[i - a] + b for a, b in x)

print(dp[HP])

Buggy submission (verdict: Runtime Error):
h,n = map(int,input().split())
li2=[input() for i in range(n)]
ab = []
for i in range(n):
    ab.append( [int(x.strip()) for x in li2[i].split()])
w = (int(h/ab[0][0])+1) * ab[0][1]
dp = [[0] * (w+1) for i in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if j < ab[i][1]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i + 1][j] = max(dp[i][j], dp[i+1][j-ab[i][1]]+ab[i][0])

ans = 0
for i in range(w+1):
    if dp[n][i] >= h:
        print(i)
        exit()
Problem p03254 (python)

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

if sum(a) ==x:
    print(n)
else:
    a.sort()
    for i in range(n):
        if x >= a[i]:
            ans += 1
            x -= a[i]
        else:
            break

    if ans == n:
        ans -= 1


    print(ans)

Buggy submission (verdict: Runtime Error):
n,x = map(int,input().split())
a = list(map(int,input().split()))

if sum(a) ==x:
    print(n)
else:
    a.sort()
    for i in range(n):
        if x >= a[i]:
            ans += 1
            x -= a[i]
        else:
            break




print(ans-1)
Problem p03471 (python)

Fixed submission:
n,y = map(int,input().split())
d = 0

for a in range(n+1):#10000
    for b in range(n+1):#5000
        c = n - a - b
        x = 10000*a + 5000*b + 1000*c
        if x == y and c >=0:
            print("{} {} {}".format(a,b,c))
            d =1
            break
    else:
        continue
    break



if d == 0:
    print("-1 -1 -1")

Buggy submission (verdict: Runtime Error):
n,y = map(int,input().split())
d = 0

for a in range(n+1):#10000
    for b in range(n+1):#5000
        c = n - a - b
        x = 10000*a + 5000*b + 1000*c
        if x == y and c >=0:
            print("{} {} {}".format(a,b,c))
            d =1
            break
    else:
        continue
    break



if d == 0:
    print("-1 -1 -1")

Buggy submission (verdict: Runtime Error):
for a in range(n):#10000
    for b in range(n):#5000
        c = n - a - b
        x = 10000*a + 5000*b + 1000*c
        if x == y and c >=0:
            print("{} {} {}".format(a,b,c))
            d =1
            break
    else:
        continue
    break



if d == 0:
    print("-1 -1 -1")
Problem p02658 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
	print(0)
	exit(0)
ans = 1
for i in range(n):
	ans *= a[i]
	if ans > 10**18:
		print(-1)
		exit(0)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 1

for i in range(n):
	ans *= a[i]
	if ans > 10^18:
 		ans = -1
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 1

for i in range(n):
	ans *= a[i]
	if ans > 10^18:
 		ans = -1
        break
print(ans)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
arr = list(map(int,input().split()))
arr = sorted(arr,reverse=True)
ans = 1
idx = 0
for a in arr:
  ans *= a
  if ans > 10**18:
    print(-1)
    exit()
print(ans)
Problem p02691 (python)

Fixed submission:
N = int(input())
arr = list(map(int,input().split()))
cnt_arr = [0]*N
ans = 0
for i in range(N):
  if arr[i]+i+1<N:
    cnt_arr[arr[i]+i+1] += 1
  if i+1-arr[i]>0:
    ans += cnt_arr[i+1-arr[i]]

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
arr = map(int,input().split())
_sum = []
_del = []
for i in range(N):
  _sum.append(arr[i]+i+1)
  _del.append(i+1-arr[i])
Problem p02715 (python)

Fixed submission:
N,K = map(int,input().split())
m = 10**9 + 7
ans = 0
cnt_arr = [0]*(K+1)
for i in range(K,0,-1):
  cnt = pow(int(K//i), N, mod=m)
  j = 2
  while i*j<=K:
    cnt -= cnt_arr[i*j]
    j+=1
  cnt_arr[i]=cnt
  ans += i*cnt

print(int(ans%m))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
mod = 10e9 + 7
ans = 0
cnt_arr = [0]*(K+1)
for i in range(K,0,-1):
  cnt = (K//i)**N%mod
  j = 2
  while i*j<=K:
    cnt -= cnt_arr[i*j]
    j+=1
  cnt_arr[i]=cnt
  ans += i*cnt

print(int(ans%mod))
Problem p02909 (python)

Fixed submission:
weather = ['Sunny', 'Cloudy', 'Rainy','Sunny']
print(weather[weather.index(input())+1])

Buggy submission (verdict: Runtime Error):
import heapq

N,M = map(int,input().split())
value = list(map(int,input().split()))
value = list(map(lambda x: x*(-1), value))
heapq.heapify(value)

for i in range(M):
  num = (heapq.heappop(value)*(-1)//2)*(-1)
  heapq.heappush(value,num)

print(sum(list(map(lambda x: x*(-1), value))))

Buggy submission (verdict: Runtime Error):
weather = ['Sunny', 'Cloudy', 'Rainy','Sunny']
print(weather(weather.index(input())))
Problem p02917 (python)

Fixed submission:
N = int(input())
B = list(map(int,input().split()))
A = ['a']*N

if N ==  2:
  print(B[0]*2)

else:
  for i,v in enumerate(B):
    if i != N-2:
      if B[i] <= B[i+1]:
        if A[i] == 'a':
          A[i] = B[i]
        if A[i+1] == 'a':
          A[i+1] = B[i]
      else:
        if A[i] == 'a':
          A[i] = B[i]
    else:
      if A[i] == 'a':
        A[i] = B[i]
      if A[i+1] == 'a':
        A[i+1] = B[i]
  print(sum(A))

Buggy submission (verdict: Runtime Error):
N = int(input())
B = list(map(int,input().split()))
A = ['a']*N

if N ==  2:
  print(B[0]*2)

else:
  for i,v in enumerate(B):
    if i != N-2:
      if B[i] <= B[i+1]:
        if A[i] == 'a':
          A[i] = B[i]
        if A[i+1] == 'a':
          A[i+1] = B[i]
      else:
        if A[i] == 'a':
          A[i] = B[i]
    else:
      if A[i+1] == 'a':
        A[i+1] = B[i]
  print(sum(A))
Problem p02927 (python)

Fixed submission:
M,D = map(int,input().split())
months = range(1,M+1)
days = range(10,D+1)
cnt = 0
for month in months:
  for day in days:
    day = str(day)
    if (int(day[0])>1)&(int(day[1])>1):
      if (int(day[0])*int(day[1]))==month:
        cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
import math

mod = 1000000007
N = int(input())
S = input()
cnt_L = 0
cnt = 1
newS = ''
if S.count('B') != N:
  cnt = 0
else:
  for i,s in enumerate(S):
    if i%2 == 0:
      s='W' if s=='B' else 'B'
    newS += s
    if s=='W':
      cnt_L += 1
    else:
      cnt = cnt * cnt_L
      cnt_L -= 1
print((cnt*math.factorial(N))%mod)
Problem p02928 (python)

Fixed submission:
import collections

N,K = map(int, input().split())
arr = list(map(int, input().split()))
c = collections.Counter(arr)

counts = list(c.values())[::-1]

if len(counts)==1:
  print(0)
else:
  value = 0
  for num in arr:
    value += len([1 for x in arr if x<num])
  out_arr = value*K*(K-1)//2
  
  in_arr = 0
  for j,num in enumerate(arr):
    in_arr += len([1 for x in arr[j+1:] if x<num])
  in_arr = in_arr*K
  print((out_arr+in_arr)%1000000007)

Buggy submission (verdict: Runtime Error):
import collections

N,K = map(int, input().split())
arr = list(map(int, input().split()))
c = collections.Counter(arr)

counts = list(c.values())[::-1]

if len(counts)==1:
  print(0)
else:
  value = 0
  for num in enumerate(arr):
    value += len([1 for x in arr if x<num])
  out_arr = value*K*(K-1)//2
  
  in_arr = 0
  for j,num in enumerate(arr):
    in_arr += len([1 for x in arr[j+1:] if x<num])
  in_arr = in_arr*K
  print((out_arr+in_arr)%1000000007)
Problem p02947 (python)

Fixed submission:
import collections
from operator import mul
from functools import reduce

N = int(input())
words = ["".join(sorted(input())) for _ in range(N)]

c = collections.Counter(words)
nums = list(c.values())

def cmb(n,r):
    if n == 1: return 0
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

print(sum([cmb(i,2) for i in nums]))

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
words = ["".join(sorted(input())) for _ in range(N)]

c = collections.Counter(words)
nums = list(c.values())

nCr = {}
def cmb(n, r):
    if n == 1:
      return 0
    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)]

print(sum([cmb(i,2) for i in nums]))
Problem p02953 (python)

Fixed submission:
N = int(input())
nums = list(map(int,input().split()))
nums = nums[::-1]
judge = "Yes"

for i in range(N-1):
  dev = nums[i+1] - nums[i]
  if dev > 1:
    judge =  "No"
    break
  elif dev == 1:
    nums[i+1] = nums[i+1] - 1
  else:
    continue
    
print(judge)

Buggy submission (verdict: Runtime Error):
N = int(input())
nums = list(map(int,input().split()))
judge = "Yes"

if N  == 1:
  print("Yes")

else:
  for i in range(N-1):
    dev = nums[i+1] - nums[i]
    if dev < 0:
      if dev != -1:
        judge = "No"
        break
      else:
        if i < N-1:
          if (nums[i+2] - nums[i+1] < 0):
            judge = "No"
            break
          else:
            continue
        else:
          continue
          
  if judge == "Yes":
    print("Yes")
  else:
    print("No")
Problem p02993 (python)

Fixed submission:
a,b,c,d = list(input())

if (a==b) or (b==c) or (c==d):
  print("Bad")
else:
  print("Good")

Buggy submission (verdict: Runtime Error):
N = int(input())
arr = [[int(i) for i in input().split()] for j in range(N)]
arr = sorted(arr,key=lambda x:(x[1], x[0]))
i = 0


while i < N-1:
  if (sum(arr[:i+1][0])) > arr[i+1][1]:
    break
  i += 1
    
if i == N-1:
  print("Yes")
else:
  print("No")
Problem p03006 (python)

Fixed submission:
import collections

N = int(input())
arr = [list(map(int,input().split())) for _ in range(N)]
if N==1:
  print(1)
else:
  arr = sorted(arr,key=lambda x:(x[0],x[1]))
  diff_arr = []
  for j in range(N):
    for k in range(1,N-j):
      diff_arr.append(str(arr[j+k][0]-arr[j][0])+'_'+str(arr[j+k][1]-arr[j][1]))
  c = collections.Counter(diff_arr)
  print(N-max(c.values()))

Buggy submission (verdict: Runtime Error):
from statistics import mode
N = int(input())
if N == 1:
  print(1)
else:
  arr = [list(map(int,input().split())) for _ in range(N)]
  arr = sorted(arr,key=lambda x:(x[0],x[1]))
  diff_arr = [str(arr[i+1][0]-arr[i][0])+'_'+str(arr[i+1][1]-arr[i][1]) for i in range(N-1)]
  mode = mode(diff_arr)
  print(N - diff_arr.count(mode))

Buggy submission (verdict: Runtime Error):
from statistics import mode
N = int(input())
arr = [list(map(int,input().split())) for _ in range(N)]
arr = sorted(arr,key=lambda x:(x[0],x[1]))
diff_arr = [str(arr[i+1][0]-arr[i][0])+'_'+str(arr[i+1][1]-arr[i][1]) for i in range(N-1)]
mode = mode(diff_arr)
print(N - diff_arr.count(mode))
Problem p03029 (python)

Fixed submission:
A, P = (int(i) for i in input().split()) 

print((3*A + P)//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
q=[input().split() + [i] for i in range(n)]
for i in range(n):
    q[i][1]=int(q[i][1])
list_point = sorted(q, key=lambda x:x[1], reverse=1)
list_city = sorted(list_point, key=lambda x:x[0], reverse=0)
for s,t,r in list_city:
    print(r+1)
Problem p03061 (python)

Fixed submission:
from fractions import gcd
N = int(input())
array = list(map(int,input().split()))
all_gcd = [0]*N
#calc from start to end
gcd_L = [array[0]]
for i in range(N-1):
  gcd_L.append(gcd(gcd_L[-1],array[i+1]))
  
#calc from end to start
gcd_R = [array[-1]]
for j in range(N-1,0,-1):
  gcd_R.append(gcd(gcd_R[-1],array[j-1]))
  
gcd_arr = []
  
for idx in range(N):
  if idx==0:
    gcd_arr.append(gcd_R[-2])
  elif idx==N-1:
    gcd_arr.append(gcd_L[-2])
  else:
    gcd_arr.append(gcd(gcd_L[idx-1],gcd_R[N-1-idx-1]))
print(max(gcd_arr))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N = int(input())
array = list(map(int,input().split()))
gcd_arr = [array[0]]

for i in range(N-1):
  gcd_arr.append(gcd(gcd_arr[-1],array[i+1]))
  
gcd_arr.reverse()

for i in range(N):
  if gcd_arr[i+1] > gcd_arr[i]:
    break
    
if (N-i-1) == 1:
  new_gcd1 = array[1]
  for i in range(N-2):
    new_gcd1 = gcd(new_gcd1,array[i+2])
  array.pop(1)
  new_gcd2 = array[0]
  for i in range(N-2):
    new_gcd2 = gcd(new_gcd2,array[i+1])
  print(max(new_gcd1,new_gcd2))
  
else:
  array.pop(N-i-1)  
  new_gcd = array[0]
  for i in range(N-2):
    new_gcd = gcd(new_gcd,array[i+1])

  print(new_gcd)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N = int(input())
array = list(map(int,input().split()))
gcd_arr = [array[0]]

for i in range(N-1):
  gcd_arr.append(gcd(gcd_arr[-1],array[i+1]))

gcd_arr.reverse()

for i in range(N):
  if gcd_arr[i+1] > gcd_arr[i]:
    break
    
array.pop(N-i-1)

new_gcd = array[0]
for i in range(N-2):
  new_gcd = gcd(new_gcd,array[i+1])

print(new_gcd)

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

def gcd(*numbers):
    return reduce(math.gcd, numbers)

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

print(gcd(*arr))
Problem p03062 (python)

Fixed submission:
from heapq import heappush,heappop

N = int(input())
array = list(map(int,input().split()))
nega = []
posi = []

for num in array:
  if num >= 0:
    heappush(posi,num)
  else:
    heappush(nega,num*(-1))


if len(nega)%2==0:
  ans = sum(nega) + sum(posi)
else:
  if len(nega)==N:
    max_nega = heappop(nega)
    ans = sum(nega) - max_nega
  else:
    min_posi = heappop(posi)
    max_nega = heappop(nega)
    if min_posi > max_nega:
      ans = sum(nega) + sum(posi) + min_posi - max_nega
    else:
      ans = sum(nega) + sum(posi) - min_posi + max_nega

print(ans)

Buggy submission (verdict: Runtime Error):
from heapq import heappush,heappop

N = int(input())
array = list(map(int,input().split()))
nega = []
posi = []

for num in array:
  if num >= 0:
    heappush(posi,num)
  else:
    heappush(nega,num)

nega = [num*(-1) for num in nega]

if len(nega)%2==0:
  ans = sum(nega) + sum(posi)
else:
  min_posi = heappop(posi)
  max_nega = heappop(nega)
  if min_posi > max_nega:
    ans = sum(nega) + sum(posi) + min_posi - max_nega
  else:
    ans = sum(nega) + sum(posi) - min_posi + max_nega
    
print(ans)
Problem p03241 (python)

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N,M = map(int,input().split())
arr = [i for i in make_divisors(M) if i>=N]
print(M//min(arr))

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N,M = map(int,input().split())
arr = [i for i in make_divisors(M) if i>N]
print(M//min(arr))
Problem p03455 (python)

Fixed submission:
def main(a,b):
  if (a*b) % 2 == 0:
    print('Even')
  else:
    print('Odd')

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

Buggy submission (verdict: Runtime Error):
def main(a,b):
  if (a*b) % 2 == 0:
    print('Even')
  else:
    print('Odd')

main(a,b)