Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
r=map(int,input().split())
print(3r**2)


Fixed submission:
r=int(input())
print(3*r**2)

Buggy python submission (verdict: Runtime Error):
r=map(int,input().split)
print(3r**2)

Fixed submission:
r=int(input())
print(3*r**2)
Buggy python submission (verdict: Runtime Error):
s=int(input())

if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
  print('Bad')
else:
  print('Good')

Fixed submission:
s=input()

if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
  print('Bad')
else:
  print('Good')
Buggy python submission (verdict: Runtime Error):
a=int(inout())
b=int(inout())
c=int(inout())
d=int(inout())
e=int(inout())
k=int(inout())

v=b-a
w=c-b
x=d-c
y=e-d

z=max(max(v,w),max(x,y))

if z >k:
  print(':')
else:
  print('Yay!')


Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

v=e-a

if v <=k:
  print('Yay!')
else:
  print(':(')

Buggy python submission (verdict: Runtime Error):
a=int(inout())
b=int(inout())
c=int(inout())
d=int(inout())
e=int(inout())
k=int(inout())

v=b-a
w=c-b
x=d-c
y=e-d

z=max(max(v,w),max(x,y))

if z >k:
  print(':')
else:
  print('Yay!)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

v=e-a

if v <=k:
  print('Yay!')
else:
  print(':(')
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().solit())
h,w=map(int,input().split())

print(h*W+H*w-h*w)

Fixed submission:
H,W=map(int,input().split())
h,w=map(int,input().split())

print(H*W-h*W-H*w+h*w)
Buggy python submission (verdict: Time Limit Exceeded):
n,x,m = map(int, input().split())

amari = [x]
cnt = 0
p = 0

for i in range(n-1):
	a = amari[-1]**2 % m
	if a in amari:
		p = amari.index(a)
		cnt = i+1-p
		break
	else:
		amari.append(a)

if cnt == 0:
	print(sum(amari))
	
else:
	n -= len(amari)
	a = n // cnt
	b = n % cnt
	print(sum(amari)+a*sum(amari[p:])+sum(amari[p:(p+b)]))

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

amari = [x]
amariset = {x}
cnt = 0
p = 0

for i in range(n-1):
	a = amari[-1]**2 % m
	if a in amariset:
		p = amari.index(a)
		cnt = i+1-p
		break
	else:
		amari.append(a)
		amariset.add(a)

if cnt == 0:
	print(sum(amari))
	
else:
	n -= len(amari)
	a = n // cnt
	b = n % cnt
	print(sum(amari)+a*sum(amari[p:])+sum(amari[p:(p+b)]))
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())

par = [i-1 for i in range(1, n+1)]

def find (x):
  if par[x] == x:
    return x
  else:
    par[x] = find(par[x])
    return par[x]

def same(x,y):
  return find(x) == find(y)

def unite(x,y):
  x = find(x)
  y = find(y)
  if x == y:
    return 0
  par[x] = y

for i in range(m):
  a,b = map(int, input().split())
  unite(a-1, b-1)

ans = max(par)
print(ans)

Fixed submission:
d,t,s = map(int, input().split())
if d <= t*s:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
q = int(input())

asum = sum(a)
adic = {}

for i in a:
  if i in adic:
    adic[i] += 1
  else:
    adic[i] = 1


for i in range(q):
  b, c = map(int, input().split())
  if b in adic:
    if c not in adic:
      adic[c] = 0
    cnt = adic.pop(b)
    adic[c] += cnt
  asum += (c-b) * cnt
  print(asum)

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

asum = sum(a)
adic = {}

for i in a:
  if i in adic:
    adic[i] += 1
  else:
    adic[i] = 1


for i in range(q):
  b, c = map(int, input().split())
  if b in adic:
    if c not in adic:
      adic[c] = 0
    cnt = adic.pop(b)
    adic[c] += cnt
    asum += (c-b) * cnt
  print(asum)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(input().split())
q = int(input())

adic = {}

for i in a:
  if i in adic:
    adic[i] += 1
  else:
    adic[i] = 1


for i in range(q):
  b, c = input().split()
  if b in adic:
    if c not in adic:
      adic[c] = 0
    adic[c] += adic.pop(b)
  print( sum(int(j)*int(adic[j]) for j in adic)  )

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

asum = sum(a)
adic = {}

for i in a:
  if i in adic:
    adic[i] += 1
  else:
    adic[i] = 1


for i in range(q):
  b, c = map(int, input().split())
  if b in adic:
    if c not in adic:
      adic[c] = 0
    cnt = adic.pop(b)
    adic[c] += cnt
    asum += (c-b) * cnt
  print(asum)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(input().split())
q = int(input())

adic = {}

for i in a:
  if i in adic:
    adic[i] += 1
  else:
    adic[i] = 1


for i in range(q):
  b, c = input().split()
  if b in adic:
    adic[c] += adic.pop(b)
  print( sum(int(j)*int(adic[j]) for j in adic)  )

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

asum = sum(a)
adic = {}

for i in a:
  if i in adic:
    adic[i] += 1
  else:
    adic[i] = 1


for i in range(q):
  b, c = map(int, input().split())
  if b in adic:
    if c not in adic:
      adic[c] = 0
    cnt = adic.pop(b)
    adic[c] += cnt
    asum += (c-b) * cnt
  print(asum)
Buggy python submission (verdict: Runtime Error):
x = int(input())

a = 0
b = -1

while True:
  b += 1
  a = (x + b**5)**0.2
  if a == int(a):
    a = int(a)
    break
  a = (x - b**5)**0.2
  if a == int(a):
    a = int(a)
    b = -b
    break

a = str(a)
b = str(b)
print(a + ' ' + b)

Fixed submission:
x = int(input())

a = 0
b = 0
flg = True

while True:
  a += 1
  for i in range(a):
    if a**5 - i**5 == x:
      a = a
      b = i
      flg = False
      break
    elif a**5 + i**5 == x:
      a = a
      b = -i
      flg = False
      break
  if flg == False:
    break
  
a = str(a)
b = str(b)
print(a+' '+b)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())

qq = [list(input().split()) for i in range(q)]
qq.append([0, 0, 0])

order = 0
cnt = 0
f = []

for i in qq:
  if i[0] != order:
    if order == 1:
      if cnt%2 == 1:
        s.reverse()
        cnt = 0
    elif order == 21:
      s = f + s
      f = []
    else:
      s = s + f
      f = []


  if i[0] == '1':
    order = 1
    cnt += 1
  else:
    if i[1] == '1':
      order = 21
      f.insert(0, i[2])
    else:
      order = 22
      f.append(i[2])

print(''.join(s))

Fixed submission:
from collections import deque

s = deque(input())
q = int(input())

qq = [list(input().split()) for i in range(q)]


rl = 1
rlrl = 1
fleft = deque()
fright = deque()

for i in qq:
  if i[0] == '1':
    rl *= -1
  else:
    if i[1] == '1':
      if rl == 1:
        fleft.appendleft(i[2])
      else:
        fright.append(i[2])
    else:
      if rl == 1:
        fright.append(i[2])
      else:
        fleft.appendleft(i[2])

fleft.reverse()        
        
s.extendleft(fleft)
s.extend(fright)        

if rl == -1:
  s.reverse()

print(''.join(s))
Buggy python submission (verdict: Runtime Error):

n = int(input())

d = {}

for i in range(n):
  a = input()
  if a not in d:
    d[a] = 1
  else:
    d[a] += 1

dsorted = sorted(d, key=lambda x:x[1])

cnt = 0
for i in dsorted:
  print(i)
  cnt += 1
  if cnt == 2:
    break

Fixed submission:
n = int(input())

d = {}

for i in range(n):
  a = input()
  if a not in d:
    d[a] = 1
  else:
    d[a] += 1

dsorted = sorted(d.items(), key=lambda x:x[1], reverse=True)

name = []
cnt = dsorted[0][1]

for i in dsorted:
  if i[1] == cnt:
    name.append(i[0])
  else:
    break

name.sort()

for i in name:
  print(i)
Buggy python submission (verdict: Runtime Error):
pip install sympy
from sympy import isprime

x = int(input())
if x % 2 == 0:
  x += 1

flag = True

while flag == True:
  if isprime(x) == True:
    flag = False

print(x)

Fixed submission:
x = int(input())

def isprime(s):
  if s>2 and s%2==0:
    return False
  else:
    flg = True
    for i in range(3, s//2+1, 2):
      if s%i == 0:
        flg = False
        break
    return flg

for i in range(x, 10**6):
  if isprime(i) == True:
    print(i)
    break

Buggy python submission (verdict: Runtime Error):
from sympy import isprime

x = int(input())
if x % 2 == 0:
  x += 1

flag = True

while flag == True:
  if isprime(x) == True:
    flag = False

print(x)

Fixed submission:
x = int(input())

def isprime(s):
  if s>2 and s%2==0:
    return False
  else:
    flg = True
    for i in range(3, s//2+1, 2):
      if s%i == 0:
        flg = False
        break
    return flg

for i in range(x, 10**6):
  if isprime(i) == True:
    print(i)
    break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

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

def myindex(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default

cnt = 0
c = 0

for i in range(1, n+1):
  b = myindex(a, i, default=-1)
  c = b
  if b == -1:
    break
  else:
    cnt += 1
    del a[:b+1]

if cnt == 0:
  print('-1')

else:
  print(n - cnt)

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

card = 1
cnt = 0

for i in a:
  if i == card:
    card += 1
  else:
    cnt += 1

if cnt == n:
  print('-1')

else:
  print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
 
a = list(map(int, input().split()))
 
def myindex(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default
 
for i in range(1, n+1):
  b = myindex(a, i, default=-1)
  if b == -1:
    del a[(i-1):]
    break
  else:
    del a[(i-1):b]
 
 
if len(a) == 0:
  print('-1')
 
else:
  print(n - len(a))

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

card = 1
cnt = 0

for i in a:
  if i == card:
    card += 1
  else:
    cnt += 1

if cnt == n:
  print('-1')

else:
  print(cnt)

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

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

for i in range(1, n+1):
  if a.count(i) == 0:
    del a [(i-1):]
    break
  else:
    index = a.index(i)
    del a[(i-1):index]

if len(a) == 0:
  print('-1')

else:
  print(n - len(a))


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

card = 1
cnt = 0

for i in a:
  if i == card:
    card += 1
  else:
    cnt += 1

if cnt == n:
  print('-1')

else:
  print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

f = factorial

n = int(input())

if n % 2 == 0:
	if n == 2:
		ans = 2
	else:
		ans = (2 ** (n//2)) * f(n//2)
		
else:
	if n == 1:
		ans = 1
	else:
		ans = f(n) // (f(n//2) * (2 ** (n//2)))
		#print('a', f(n))
		#print('b', f(n//2)*(2**(n//2)))

cnt = 0
ans = str(ans)

for i in reversed(ans):
	if i == '0':
	  cnt += 1
	else:
		break
		
print(cnt)
#print(ans)

Fixed submission:
n = int(input())

if n % 2 == 1:
	print('0')
		
else:
	five = 0
	two = 0
	for i in range(1, n):
		f = n // (2*(5**i))
		t = n // (2**i)
		if f == t == 0:
			break
		five += f
		two += t
	print(min(five, two))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

triangle = itertools.combinations(l, 3)

cnt = 0

for i in triangle:
  if max(i)*2 < sum(i):
    cnt += 1

print(cnt)

Fixed submission:
import bisect

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

l.sort()
cnt = 0


for i in range(n-2):
  for j in range(i+1, n-1):
    sum = l[i] + l[j]
    index = bisect.bisect_left(l, sum)
    cnt += index - j - 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
n,k,q = map(int, input().split())

-----
nさんがc問正解したとき、勝ち抜けるには
q - c > k

-----

a = [0] * n

for i in range(q):
  A = int(input())
  a[A-1] += 1

for i in a:
  if q - i > k:
    print('Yes')
  else:
    print('No')

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


a = [0] * n

for i in range(q):
  A = int(input())
  a[A-1] += 1

for i in a:
  if i > q - k:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))

move = []
cnt = 0

for i in range(n-1):
  if h[i] >= h[i+1]:
    cnt += 1
    if i == n-2:
      move.append(cnt)
  else:
    move.append(cnt)
    cnt = 0

print(max(move))

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

higher = [0]
move = [0]

for i in range(1, n):
  if h[i-1] < h[i]:
    m = i - higher[len(higher) - 1] - 1
    move.append(m)
    higher.append(i)

move.append(len(h) - 1 - higher[len(higher) - 1])


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

ans = [i for i in range(0, n)]
print(sum(ans))

Fixed submission:
n = int(input())

ans = (n-1)*n // 2

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

a = []

for i in range(n):
  word = list(input())
  word.sort()
  letters = []
  for j in word:
    if j not in letters:
      letters.append([j, 1])
    else:
      letters[len(letters) - 1][1] += 1
  a.append(letters)

cnt = 0

for i in range(n):
  for j in range(i+1, n):
    if a[i] == a[j]:
      cnt += 1

print(cnt)

Fixed submission:
import collections

n = int(input())
abc = []

for i in range(n):
  a = list(input())
  a.sort()
  a = str(a)
  abc.append(a)

c = collections.Counter(abc)
cnt = 0

for i in c:
  num = c[i]
  if num != 1:
    cnt += num*(num-1) // 2
 
print(cnt)
Buggy python submission (verdict: Runtime Error):
n,d = map(int, input().split())
print(n // (2d + 1) + 1)

Fixed submission:
import math

n,d = map(int, input().split())
print(math.ceil(n / (2*d + 1)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
  b = a[:]
  del b[i]
  print(max(b))

Fixed submission:
from heapq import nlargest
import sys
n = int(input())
a = [int(input()) for i in range(n)]
l1, l2 = nlargest(2, a)

if l1 == l2:
  for i in range(n):
    print(l1)
  sys.exit()

for i in a:
  if i == l1:
    print(l2)
  else:
    print(l1)
Buggy python submission (verdict: Runtime Error):
import sys
import math

n = int(input())
a = list(map(int, input().split()))
sosu = a[:]

for i in range(2, n//2):
  for j in range(2,n):
    if i*j > n:
      break
    else:
      sosu.remove(i*j) 

m = 0

for i in sosu:
  if i > n/2:
    m = sosu.index(i)
    break

del sosu[:(m-1)]

newa = [i for i in a if i not in sosu]

for i in newa:
  if i != newa[0]:
    print('-1')
    sys.exit()

num = [str(i+1) for i, x in enumerate(a) if x == 1]

if len(num) == 0:
  print('0')
else:
  print(len(num))
  num = ' '.join(num)
  print(num)

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

ball = [0 for i in range(n)]

for i in reversed(range(n)):
  if n//2 < i:
    ball[i] = a[i]
  else:
    if (sum(ball[i::(i+1)]) - a[i]) % 2 == 0:
      ball[i] = 0
    else:
      ball[i] = 1


num = [str(i+1) for i, x in enumerate(ball) if x == 1]

if len(num) == 0:
  print('0')
else:
  print(len(num))
  num = ' '.join(num)
  print(num)
Buggy python submission (verdict: Runtime Error):
l,r = map(int, input().split())

if r//673 > (l-1)//673 and r-l = 2:
  print('0')

else:
    print((l%2019) * ((l+1)%2019))

Fixed submission:
from itertools import combinations

l,r = map(int, input().split())

if r//673 > (l-1)//673 and r//3 >(l-1)//3:
  print('0')

else:
    cmb = list(combinations(range(l, r+1), 2))
    mod = [(cmb[i][0] * cmb[i][1]) % 2019 for i in range(len(cmb))]
    print(min(mod))
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = [int(input()) for i in range(m)]
a.append(n)
a.insert(0, 0)

def nCr(n, r):
  num = 1
  for i in range(r+1, n+1):
    num *= i
  return num


P = 1
for i in range(m):
  if a[i] + 1 == a[i+1]:
    print(0)
    exit()

for i in range(1, m+2):
  step = a[i] - a[i-1] - 1
  pattern = 1
  for j in range(1, int(step/2+1)):
    pattern += nCr(step-j, j)
  P *= pattern 

print(P%1000000007)


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

print(sum(h)-max(h))
Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys

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

def nCr(n, r):
  c = math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
  return c

for i in range(m-1):
  if a[i] + 1 == a[i+1]:
    print('0')

    sys.exit()


a.insert(0, -1)
a.append(n+1)

cnt = 1

for i in range(m+1):
  step = (a[i+1] - 1) - (a[i] + 1)
  pattern = 1
  for j in range(1, step//2 + 1):
    k = j
    if j > (step - j) // 2:
      k = step - 2*j
    pattern += nCr(step - j, k)
  cnt *= pattern

print(cnt%1000000007)

Fixed submission:
n,m = map(int, input().split())
step = []

now = 0
for i in range(m):
  next = int(input()) - 1
  step.append(next - now)
  now = next + 2

step.append(n-now)  
step.sort()

def fibo():
  s = []
  a = 1
  b = 1
  s.append(a)
  s.append(b)
  for i in range(n):
    c = a+b
    a = b
    b = c
    s.append(c)
  return s

ans = 1

if step[0] < 0:
  ans = 0

else:
  f = fibo()
  for i in step:
    ans *= f[i]

print(ans % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys

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

def nCr(n, r):
  c = math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
  return c

for i in range(m-1):
  if a[i] + 1 == a[i+1]:
    print('0')

    sys.exit()


a.insert(0, -1)
a.append(n+1)

cnt = 1

for i in range(m+1):
  step = (a[i+1] - 1) - (a[i] + 1)
  pattern = 1
  for j in range(1, step//2 + 1):
    pattern += nCr(step - j, j)
  cnt *= pattern

print(cnt%1000000007)

Fixed submission:
n,m = map(int, input().split())
step = []

now = 0
for i in range(m):
  next = int(input()) - 1
  step.append(next - now)
  now = next + 2

step.append(n-now)  
step.sort()

def fibo():
  s = []
  a = 1
  b = 1
  s.append(a)
  s.append(b)
  for i in range(n):
    c = a+b
    a = b
    b = c
    s.append(c)
  return s

ans = 1

if step[0] < 0:
  ans = 0

else:
  f = fibo()
  for i in step:
    ans *= f[i]

print(ans % 1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

card = list(range(1, n+1))
delete = set()

for i in range(m):
  l,r = map(int, input().split())
  delete.update(card[:(l-1)])
  delete.update(card[r:])

card = set(card)
print(len(card^delete))

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

l = []
r = []

for i in range(m):
  L,R = map(int, input().split())
  l.append(L)
  r.append(R)

ans = min(r) - max(l) + 1

print(max(ans, 0))
Buggy python submission (verdict: Runtime Error):
a,b,t = map(int(input().split()))
n = int(t/a)
print(n*b)

Fixed submission:
a,b,t = map(int, input().split())
n = int(t/a)
print(n*b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split())

m = 0

for i in range(len(v)):
  if v[i] > c[i]:
    m += v[i] - c[i]

print(m)

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

m = 0

for i in range(len(v)):
  if v[i] > c[i]:
    m += v[i] - c[i]

print(m)
Buggy python submission (verdict: Runtime Error):
import math
from itertools import accumulate

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

fromright = list(accumulate(a, math.gcd))
a.reverse()
fromleft = list(accumulate(a, math.gcd))
fromleft.reverse()

gcd = []

for i in range(1, n-1):
  gcd.append(math.gcd(fromright[i-1], fromleft[i+1]))

print(max(gcd))

Fixed submission:
import math
from itertools import accumulate

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

fromright = list(accumulate(a, math.gcd))
a.reverse()
fromleft = list(accumulate(a, math.gcd))
fromleft.reverse()

gcd = []

gcd.append(fromleft[1])

for i in range(1, n-1):
  gcd.append(math.gcd(fromright[i-1], fromleft[i+1]))

gcd.append(fromright[n-2])

if n == 2:
  print(max(a))
else:
  print(max(gcd))

Buggy python submission (verdict: Time Limit Exceeded):
import math
from itertools import accumulate

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

g = []
gcd = []

for i in range(n):
  r = a[i]
  a.remove(r)
  gcd = accumulate(a, math.gcd)
  g.append(min(gcd))
  a.insert(i, r)

print(max(g))

Fixed submission:
import math
from itertools import accumulate

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

fromright = list(accumulate(a, math.gcd))
a.reverse()
fromleft = list(accumulate(a, math.gcd))
fromleft.reverse()

gcd = []

gcd.append(fromleft[1])

for i in range(1, n-1):
  gcd.append(math.gcd(fromright[i-1], fromleft[i+1]))

gcd.append(fromright[n-2])

if n == 2:
  print(max(a))
else:
  print(max(gcd))

Buggy python submission (verdict: Runtime Error):
import math
from intertools import accumulate

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

g = []
gcd = []
gcd_u = np.frompyfunc(gcd, 2, 1)

for i in range(n):
  r = a[i]
  a.remove(r)
  gcd = accmulate(a, math.gcd)
  g.append(min(gcd))
  a.insert(i, r)

print(max(g))


Fixed submission:
import math
from itertools import accumulate

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

fromright = list(accumulate(a, math.gcd))
a.reverse()
fromleft = list(accumulate(a, math.gcd))
fromleft.reverse()

gcd = []

gcd.append(fromleft[1])

for i in range(1, n-1):
  gcd.append(math.gcd(fromright[i-1], fromleft[i+1]))

gcd.append(fromright[n-2])

if n == 2:
  print(max(a))
else:
  print(max(gcd))
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))

c = 0

for i in h:
  t = True
  for j in range(i):
    if h[j] >= h[i]:
      t = False
      break
   c += 1

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

c = 0

for i in range(n):
  t = True
  for j in range(i):
    if h[j] > h[i]:
      t = False
      break
  if t == True:
    c += 1
  t = True
print(c)
Buggy python submission (verdict: Runtime Error):
s = list(input())

n = int(len(s)/2)
c = 0

if s[1] == s[0]:
  c +=1
  if s[0] == 0:
    s[1] = 1
  elif s[0] == 1:
    s[1] = 0

for i in range(n):
  if s[0] != s[2*i]:
    c += 1
  if s[1] != s[2*i+1]:
    c += 1

print(c)

Fixed submission:
s = list(map(int,input()))

n = int(len(s)/2)

a = [0]*len(s)
b = [0]*len(s)

for i in range(n):
  a[2*i] = 0
  a[2*i+1] = 1
  b[2*i] = 1
  b[2*i+1] = 0

if len(s)%2 ==1:
  a[len(s)-1] = 0
  b[len(s)-1] = 1 


an = 0
bn = 0

for j in range(len(s)):
  if a[j] != s[j]:
    an += 1
  if b[j] != s[j]:
    bn += 1

print(min(an, bn))
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
v = list(map(int, input().split()))

a = v[0::2]
b = v[1::2]

aa = Counter(a)
bb = Counter(b)

aaa = aa.most_common()
bbb = bb.most_common()

ans = 0

if aaa[0][0] != bbb[0][0]:
  ans = n - aaa[0][1] - bbb[0][1]

else:
  if len(aa) == len(bb) == 1:
    ans = min(aaa[0][1], bbb[0][1])
  else:
    aaa.append[('-', 0)]
    bbb.append[('-', 0)]
    ans = n - max(aaa[0][1]+bbb[1][1], aaa[1][1]+bbb[0][1])

print(ans)


Fixed submission:
from collections import Counter
n = int(input())
v = list(map(int, input().split()))

a = v[0::2]
b = v[1::2]

aa = Counter(a)
bb = Counter(b)

aaa = aa.most_common()
bbb = bb.most_common()

ans = 0

if aaa[0][0] != bbb[0][0]:
  ans = n - aaa[0][1] - bbb[0][1]

else:
  if len(aa) == len(bb) == 1:
    ans = min(aaa[0][1], bbb[0][1])
  else:
    aaa.append(('-', 0))
    bbb.append(('-', 0))
    ans = n - max(aaa[0][1]+bbb[1][1], aaa[1][1]+bbb[0][1])

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input().split()

if Y in s:
  print('Four')
else:
  print('Three')

Fixed submission:
n = int(input())
s = input().split()
 
if 'Y' in s:
  print('Four')
else:
  print('Three')