Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
# a: 時
# b: 分
# 
a, b, h, m = map(int, input().split())

x = ( a**2 + b**2 - 2*a*b* math.cos(int(360 / h) * 30) - int(360 / m) * 6 ) ** 0.5
print(x)


Fixed submission:
import math
# a: 時
# b: 分
# 
a, b, h, m = map(int, input().split())

angle_h = h * 30 + m * 0.5
angle_m = m * 6

cos_ = math.cos( math.radians( abs( angle_h - angle_m ) ) )

x = ( a**2 + b**2 - 2*a*b*cos_ ) ** 0.5

print(x)

Buggy python submission (verdict: Runtime Error):
import math
# a: 時
# b: 分
# 
a, b, h, m = map(int, input().split())


x = ( a**2 + b**2 - 2*a*b* math.cos(int(360 / h) * 30) - int(360 / m) * 6 ) ** 0.5
print(x)


Fixed submission:
import math
# a: 時
# b: 分
# 
a, b, h, m = map(int, input().split())

angle_h = h * 30 + m * 0.5
angle_m = m * 6

cos_ = math.cos( math.radians( abs( angle_h - angle_m ) ) )

x = ( a**2 + b**2 - 2*a*b*cos_ ) ** 0.5

print(x)

Buggy python submission (verdict: Runtime Error):
import math
# a: 時
# b: 分
# 
a, b, h, m = map(int, input().split())


x = ( a**2　+　b**2　−　2 * a * b * math(int(360 / h) * 30) + int(360 / m) * 6 ) ** 0.5
print(x)


Fixed submission:
import math
# a: 時
# b: 分
# 
a, b, h, m = map(int, input().split())

angle_h = h * 30 + m * 0.5
angle_m = m * 6

cos_ = math.cos( math.radians( abs( angle_h - angle_m ) ) )

x = ( a**2 + b**2 - 2*a*b*cos_ ) ** 0.5

print(x)

Buggy python submission (verdict: Runtime Error):
import math
# a: 時
# b: 分
# 
a, b, h, m = map(int, input().split())


x　=　( a**2　+　b**2　−　2 * a * b * math(int(360 / h) * 30) + int(360 / m) * 6 ) ** 0.5
print(x)


Fixed submission:
import math
# a: 時
# b: 分
# 
a, b, h, m = map(int, input().split())

angle_h = h * 30 + m * 0.5
angle_m = m * 6

cos_ = math.cos( math.radians( abs( angle_h - angle_m ) ) )

x = ( a**2 + b**2 - 2*a*b*cos_ ) ** 0.5

print(x)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())

ans = 0
for x in range(B):
  A_x = A * x
  left_ = int(A_x / B)
  right_ = A * int(x / B)
  fnc_ = left_ - right_
  if x <= N:
    ans = max(ans, fnc_)
    # print("入れ替わりans", ans)

  # print("     x", x)
  # print(" left_", left_)
  # print("right_", right_)
  # print("  fnc_", left_ - right_)


print(ans)



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

ans = 0

x = min(N, B-1)

A_x = A * x
left_ = int(A_x / B)
right_ = A * int(x / B)
fnc_ = left_ - right_
if x <= N:
  ans = max(ans, fnc_)
  # print("入れ替わりans", ans)

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

for i in range(1, n+1):
  c = data.count(i)
  print(c)


Fixed submission:
import collections

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

c = collections.Counter(data)

for i in range(1, n+1):
  print(c[i])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

data = []
for i in range(n+1):
  data.append(i)

l = n+1

ans = 0

# [4, 2] -> (0 + 1 + 2), (2 + 3 + 4) 

for i in range(k, (n+1) + 1):
  # i: 2, data[:2] = [0, 1], min: 1
  min = sum(data[:i])

  # i: 2,                    max: 5
  max = sum(data[l-i:])

  diff = max - min + 1
  # print(diff)
  ans += diff

print(ans)


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

MOD = 10**9 + 7

data = []
for i in range(n+1):
  data.append(i)

ans = 0

# あらかじめ累積和を求めておく
sum_data = [0] * (n + 1)
for i in range(1, n + 1): # 1..4
  sum_data[i] = sum_data[i - 1] + i

# sum_data: [0 1 3 6]

# 処理系
for i in range(k, (n+1) + 1): # 1..3
  # min
  min_ = sum_data[i-1]

  # max
  if n+1 - i - 1 == -1:
    max_ = sum_data[-1]
    # print("max :", max_)
  else:
    max_ = sum_data[-1] - sum_data[n+1 - i - 1]
    # print("max :", max_)

  diff = (max_ - min_ + 1)
  ans += diff

print(ans % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

data = []
for i in range(n+1):
  data.append(i)

l = n+1

ans = 0

# [4, 2] -> (0 + 1 + 2), (2 + 3 + 4) 

for i in range(k, (n+1) + 1):
  # i: 2, data[:2] = [0, 1], min: 1
  min = sum(data[:i])

  # i: 2,                    max: 5
  max = sum(data[l-i:])

  diff = max - min + 1
  # print(diff)
  ans += diff

print(ans)


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

MOD = 10**9 + 7

data = []
for i in range(n+1):
  data.append(i)

ans = 0

# あらかじめ累積和を求めておく
sum_data = [0] * (n + 1)
for i in range(1, n + 1): # 1..4
  sum_data[i] = sum_data[i - 1] + i

# sum_data: [0 1 3 6]

# 処理系
for i in range(k, (n+1) + 1): # 1..3
  # min
  min_ = sum_data[i-1]

  # max
  if n+1 - i - 1 == -1:
    max_ = sum_data[-1]
    # print("max :", max_)
  else:
    max_ = sum_data[-1] - sum_data[n+1 - i - 1]
    # print("max :", max_)

  diff = (max_ - min_ + 1)
  ans += diff

print(ans % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
import math

k = int(input())
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    for k in range(1, k+1):
      ans += math.gcd(math.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):
    for k in range(1, k+1):
      ans += math.gcd(math.gcd(i, j), k)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n, x, y = map(int, input().split())
eage = [[] for _ in range(n)]

for i in range(n-1):
  eage[i].append( i+1 )
  eage[i+1].append( i )

x -= 1
y -= 1

eage[x].append( y )
eage[y].append( x )

visited = [[-1] * n for _ in range(n)]

counter = [0] * n
for start_point in range(n):
  visited[start_point][start_point] = 0
  # [0] とか [0, 2, 3] とか [1, 3]
  q = deque([start_point])
  while q:
    v = q.popleft()
    for j in eage[v]:
      # 未訪問
      if visited[start_point][j] == -1:
        # v が start_point の切り替え役
        visited[start_point][j] = visited[start_point][v] + 1
        q.append( j )
  for c in visited[start_point]:
    counter[c] += 1

for ans in counter[1:]:
  print(ans // 2)


Fixed submission:
from collections import deque

n, x, y = map(int, input().split())
eage = [[] for _ in range(n)]

for i in range(n-1):
  eage[i].append( i+1 )
  eage[i+1].append( i )

x -= 1
y -= 1

eage[x].append( y )
eage[y].append( x )

visited = [[-1] * n for _ in range(n)]

counter = [0] * n
for start_point in range(n):
  visited[start_point][start_point] = 0
  # [0] とか [0, 2, 3] とか [1, 3]
  q = deque([start_point])
  while q:
    v = q.popleft()
    for j in eage[v]:
      # 未訪問
      if visited[start_point][j] == -1:
        # v が start_point の切り替え役
        visited[start_point][j] = visited[start_point][v] + 1
        q.append( j )
  for c in visited[start_point]:
    counter[c] += 1

for ans in counter[1:]:
  print(ans // 2)

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

n, x, y = map(int, input().split())
eage = [[] for _ in range(n)]

for i in range(n-1):
  eage[i].append( i+1 )
  eage[i+1].append( i )

x -= 1
y -= 1

eage[x].append( y )
eage[y].append( x )

visited = [[-1] * n for _ in range(n)]

for start_point in range(n):
  visited[start_point][start_point] = 0
  # [0] とか [0, 2, 3] とか [1, 3]
  q = deque([start_point])
  while q:
    v = q.popleft()
    for j in eage[v]:
      # 未訪問
      if visited[start_point][j] == -1:
        # v が start_point の切り替え役
        visited[start_point][j] = visited[start_point][v] + 1
        q.append( j )

from itertools import chain

counter = [0] * n

for v in list(chain.from_iterable(visited)):
  counter[v] += 1

for ans in counter[1:]:
  print(ans // 2)


Fixed submission:
from collections import deque

n, x, y = map(int, input().split())
eage = [[] for _ in range(n)]

for i in range(n-1):
  eage[i].append( i+1 )
  eage[i+1].append( i )

x -= 1
y -= 1

eage[x].append( y )
eage[y].append( x )

visited = [[-1] * n for _ in range(n)]

counter = [0] * n
for start_point in range(n):
  visited[start_point][start_point] = 0
  # [0] とか [0, 2, 3] とか [1, 3]
  q = deque([start_point])
  while q:
    v = q.popleft()
    for j in eage[v]:
      # 未訪問
      if visited[start_point][j] == -1:
        # v が start_point の切り替え役
        visited[start_point][j] = visited[start_point][v] + 1
        q.append( j )
  for c in visited[start_point]:
    counter[c] += 1

for ans in counter[1:]:
  print(ans // 2)
Buggy python submission (verdict: Runtime Error):
n, blue_count, red_count = map(int, input().split())

if blue_count >= n:
  print(n)
elif blue_count + red_count > n:
  print(blue_count)
else:
  set_count = blue_count + red_count

  margin = 0
  if n % set_count == 0:
    c =  n // set_count
  else:
    c =  n // set_count
    margin = n % set_count

  # NOTE: あまり部分が 青 -> 赤 の途中である事を前提としてしまっているので変更が必要
  if margin > blue_count:
    margin = blue_count
    
  print(blue_count * c + margin )


Fixed submission:
s = input()
if s.count("A") == 3 or s.count("B") == 3:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
data = list(map(int, input().split()))

for _ in range(k):
  max_num = max(data)
  max_index = data.index(max_num)
  data[max_index] = 0

print(sum(data))


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

data.sort()

for _ in range(k):
  if data.__len__() > 0:
    data.pop()
  else:
    break

print(sum(data))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
data = list(map(int, input().split()))

ans = 0

# 処理系
for i in range(n):
    if min(data[:i+1]) == data[i]:
        ans += 1

print(ans)


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

ans = 0

min_ = data[0]
for i in range(n):
    # min_ の更新ができれば ans を更新
    if min_ >= data[i]:
        min_ = data[i]
        ans += 1

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

if n % 2 == 1:
  print("No")
else:
  d = n/2
  if s[:d] == s[d:]:
    print("Yes")
  else:
    print("No")
      

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

if n % 2 == 1:
  print("No")
else:
  d = int(n/2)
  if s[:d] == s[d:]:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# D - Powerful Discount Tickets

def power(price, ticket_count):
    return int(price // (2 ** ticket_count))

# n: 商品数
# m: チケットの枚数
n, m = map(int, input().split())
data = list(map(int, input().split()))

ans = 0

for i in range(m):
    data.sort()
    data = data[::-1]

    max_data = data[0]
    if max_data == 0:
        break

    max_point = 0
    data[max_point] = power(data[max_point], 1)

print(sum(data))


Fixed submission:
s = input()
if s == "Sunny":
  print("Cloudy")
elif s == "Cloudy":
  print("Rainy")
elif s == "Rainy":
  print("Sunny")
Buggy python submission (verdict: Runtime Error):
odd = ["R", "U", "D"]
even = ["L", "U", "D"]
s_list = list(input())

ans = "Yes"
for i in range(s_list):
  if i % 2 == 0:
    if not s_list[i] in odd:
      ans = "No"
  
  if i % 2 == 1:
    if not s_list[i] in even:
      ans = "No"

print(ans)


Fixed submission:
s = list(input())
odd_s = ["R", "U", "D"]
even_s = ["L", "U", "D"]

ans = "Yes"

for i in range(len(s)):
  if i % 2 == 0:
    if s[i] not in odd_s:
      ans = "No"
  
  if i % 2 == 1:
    if s[i] not in even_s:
      ans = "No"

print(ans)

Buggy python submission (verdict: Runtime Error):
odd = ["R", "U", "D"]
even = ["L", "U", "D"]
s_list = list(input())

ans = "Yes"
for i in range(s_list):
  if i % 2 == 0:
	  if not s_list[i] in odd:
    	ans = "No"
  
  if i % 2 == 1:
	  if not s_list[i] in even:
    	ans = "No"

print(ans)

Fixed submission:
s = list(input())
odd_s = ["R", "U", "D"]
even_s = ["L", "U", "D"]

ans = "Yes"

for i in range(len(s)):
  if i % 2 == 0:
    if s[i] not in odd_s:
      ans = "No"
  
  if i % 2 == 1:
    if s[i] not in even_s:
      ans = "No"

print(ans)

Buggy python submission (verdict: Runtime Error):
odd = ["R", "U", "D"]
even = ["L", "U", "D"]
s_list = list(input())

ans = "Yes"
for i in range(s_list):
  if i % 2 == 0:
	  if not data[i] in odd:
    	ans = "No"
  
  if i % 2 == 0:
	  if not data[i] in even:
    	ans = "No"

print(ans)

Fixed submission:
s = list(input())
odd_s = ["R", "U", "D"]
even_s = ["L", "U", "D"]

ans = "Yes"

for i in range(len(s)):
  if i % 2 == 0:
    if s[i] not in odd_s:
      ans = "No"
  
  if i % 2 == 1:
    if s[i] not in even_s:
      ans = "No"

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# n: 参加者人数
# k: 初期ポイント
# q: ラウント回数
n, k, q = map(int, input().split())
data = [ int(input()) for _ in range(q) ]

table = [k] * n

for winnner in data:
    for j in range(n):
        table[j] -= 1
    
    table[winnner - 1] += 1

for k in range(n):
    if table[k] > 0:
        print("Yes")
    else:
        print("No")


Fixed submission:
# n: 参加者人数
# k: 初期ポイント
# q: ラウント回数
n, k, q = map(int, input().split())
data = [ int(input()) for _ in range(q) ]

table = [k] * n

for winnner in data:    
    table[winnner - 1] += 1

for j in range(n):
    table[j] -= q

for k in range(n):
    if table[k] > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
# D - Powerful Discount Tickets

def power(price, ticket_count):
    return int(price // (2 ** ticket_count))

# n: 商品数
# m: チケットの枚数
n, m = map(int, input().split())
data = list(map(int, input().split()))

ans = 0

for i in range(m):
    data.sort()
    data = data[::-1]

    max_data = data[0]
    if max_data == 0:
        break

    max_point = 0
    data[max_point] = power(data[max_point], 1)

print(sum(data))


Fixed submission:
# D - Powerful Discount Tickets
import heapq

n, m = map(int, input().split())
data = list(map(int, input().split()))

pq = []

for i in data:
    heapq.heappush(pq, -i)

for _ in range(m):
    # 先頭の "最小値"
    p = heapq.heappop(pq)
    heapq.heappush(pq, -(-p // 2))

print(-sum(pq))

Buggy python submission (verdict: Time Limit Exceeded):
# D - Powerful Discount Tickets

def power(price, ticket_count):
    return int(price // (2 ** ticket_count))

# n: 商品数
# m: チケットの枚数
n, m = map(int, input().split())
data = list(map(int, input().split()))

ans = 0

for i in range(m):
    max_data = max(data)
    if max_data == 0:
        break
    max_point = data.index( max_data )
    data[max_point] = power(data[max_point], 1)

print(sum(data))


Fixed submission:
# D - Powerful Discount Tickets
import heapq

n, m = map(int, input().split())
data = list(map(int, input().split()))

pq = []

for i in data:
    heapq.heappush(pq, -i)

for _ in range(m):
    # 先頭の "最小値"
    p = heapq.heappop(pq)
    heapq.heappush(pq, -(-p // 2))

print(-sum(pq))

Buggy python submission (verdict: Time Limit Exceeded):
# D - Powerful Discount Tickets

def power(price, ticket_count):
    return int(price // (2 ** ticket_count))

# n: 商品数
# m: チケットの枚数
n, m = map(int, input().split())
data = list(map(int, input().split()))

ans = 0

for i in range(m):
    max_point = data.index( max(data) )
    data[max_point] = power(data[max_point], 1)

print(sum(data))


Fixed submission:
# D - Powerful Discount Tickets
import heapq

n, m = map(int, input().split())
data = list(map(int, input().split()))

pq = []

for i in data:
    heapq.heappush(pq, -i)

for _ in range(m):
    # 先頭の "最小値"
    p = heapq.heappop(pq)
    heapq.heappush(pq, -(-p // 2))

print(-sum(pq))
Buggy python submission (verdict: Runtime Error):
n = int(input())
data = map(int, input().split())
up = 0
for i in range(n):
  up *= data[i]

down = 0
for j in range(n):
  down += up / data[j]

print(up / down)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print("red")
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    data = list(map(int, input().split()))

    for k in data:
        if k == 0:
            return 0

    up = 0
    for i in range(n):
        up *= data[i]

    down = 0
    for j in range(n):
        down += up / data[j]

    return up / down

print(main())


Fixed submission:
def main():
    n = int(input())
    data = list(map(int, input().split()))

    for k in data:
        if k == 0:
            return 0

    up = 1
    for i in range(n):
        up *= data[i]

    down = 0
    for j in range(n):
        down += up / data[j]

    return (up / down)

print(main())

Buggy python submission (verdict: Runtime Error):
n = int(input())
data = map(int, input().split())
up = 0
for i in range(n):
  up *= data[i]
 
down = 0
for j in range(n):
  down += up / data[j]
 
print(up / down)

Fixed submission:
def main():
    n = int(input())
    data = list(map(int, input().split()))

    for k in data:
        if k == 0:
            return 0

    up = 1
    for i in range(n):
        up *= data[i]

    down = 0
    for j in range(n):
        down += up / data[j]

    return (up / down)

print(main())
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
p = a + b
m = max(a - b)
d = a * b
print(max(p, m, d))

Fixed submission:
a, b = map(int, input().split())
p = a + b
m = a - b
d = a * b
print(max(p, m, d))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if abs(a-b) / 2 == int(abs(a-b) / 2):
  print( abs(a-b) / 2 )
else:
  print("IMPOSSIBLE")
  

Fixed submission:
data = list(map(int, input().split()))
data.sort()
if abs(data[0] - data[1]) / 2 == int(abs(data[0] - data[1]) / 2):
  print(int(data[1] - (abs(data[0]-data[1]) / 2) ))
else:
  print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
s = input()
ans = "Good"
for i in range(3)
	if s[i] == s[i+1]:
		ans = "Bad"
 
print(ans)

Fixed submission:
s = input()
ans = "Good"
for i in range(3):
    if s[i] == s[i+1]:
        ans = "Bad"
 
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
ans = "Good"
for i in range(3)
	if s[i] == s[i+1]:
    	ans = "Bad"

print(ans)

Fixed submission:
s = input()
ans = "Good"
for i in range(3):
    if s[i] == s[i+1]:
        ans = "Bad"
 
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
broken_data = [int(input()) for _ in range(M) ]
ans = 0
 
memo = [-1] * (N+1)
def countWays(n):
    if n < 0 or (n in broken_data):
        return 0
    elif n == 0:
        return 1
    else:
        if memo[n] > -1:
            return memo[n]
        else:
            memo[n] = ( countWays(n-1) + countWays(n-2) ) % 1000000007
            return memo[n]
 
print(countWays(N))

Fixed submission:
data = list(map(int, input().split()))
data.sort()
print(data[0] + data[1])
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
print(int((a * 3 + b) / 2))

Fixed submission:
a, b = map(int, input().split())
print( int( (a * 3 + b) / 2) )
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, m = map(int, input().split())
    data = list(map(int, input().split()))
    for i in range(m):
        choice_time, num = map(int, input().split())
        if num > min(data):
            for _ in range(choice_time):
                if num > min(data):
                    data[ data.index( min(data) ) ] = num
        
    return sum(data)

print(main())


Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = [list(map(int,input().split())) for p in range(m)]
b.sort(key=lambda q: -q[1])
 
c = 0
for s in b:
	for t in [0]*s[0]:
		if c + 1 > n:
			break
		if s[1] <= a[c]:
			break
		a[c] = s[1]
		c += 1
	else:
		continue
	break
print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
data = list(map(int, input().split()))
for i in range(m):
    choice_time, num = map(int, input().split())
    for j in range(choice_time):
        if num > min(data):
            data[ data.index( min(data) ) ] = num
    
print(sum(data))


Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = [list(map(int,input().split())) for p in range(m)]
b.sort(key=lambda q: -q[1])
 
c = 0
for s in b:
	for t in [0]*s[0]:
		if c + 1 > n:
			break
		if s[1] <= a[c]:
			break
		a[c] = s[1]
		c += 1
	else:
		continue
	break
print(sum(a))
Buggy python submission (verdict: Runtime Error):
hoge, n = map(int, input().split())
s = list(input())
s[n] = s[n].lower()
print(*s, sep="")

Fixed submission:
hoge, n = map(int, input().split())
s = list(input())
s[n-1] = s[n-1].lower()
print(*s, sep="")

Buggy python submission (verdict: Runtime Error):
s, n = map(str, input().split())
n = int(n)
s = list(s)
s[n] = s[n].lower()
print(*s, sep="")

Fixed submission:
hoge, n = map(int, input().split())
s = list(input())
s[n-1] = s[n-1].lower()
print(*s, sep="")
Buggy python submission (verdict: Time Limit Exceeded):
def check(ary, div):
    c = 0
    for i in range(len(ary)):
        if ary[i] % div == 0:
            c += 1
    if c >= len(ary) - 1:
        return True
    else:
        return False
 
N = int(input())
data = list(map(int, input().split()))
ans = 1
for i in range(1, max(data) + 1)[::-1]:
    if check(data, i):
        ans = i
        break
 
print(ans)


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

def gcd(a, b):
    while b:
        a, b = b, a % b
        # print("a b", a, b)
    return a

left_ = [0] * (n + 1)
right_ = [0] * (n + 1)
ans = []

for i in range(n):
    left_[i] = gcd( left_[i-1], data[i] )

for i in range(n-1, 0, -1):
    right_[i] = gcd( right_[i+1], data[i] )

for i in range(n):
    ans += [ gcd( left_[i-1], right_[i+1] ) ]

print( max(ans) )

Buggy python submission (verdict: Time Limit Exceeded):
def check(ary, div):
    c = 0
    for i in range(len(ary)):
        if ary[i] % div == 0:
            c += 1
    if c >= len(ary) - 1:
        return True
    else:
        return False 
 
N = int(input())
data = list(map(int, input().split()))
ans = 1
for i in range(1, max(data) + 1):
    if check(data, i):
        ans = i
 
print(ans)


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

def gcd(a, b):
    while b:
        a, b = b, a % b
        # print("a b", a, b)
    return a

left_ = [0] * (n + 1)
right_ = [0] * (n + 1)
ans = []

for i in range(n):
    left_[i] = gcd( left_[i-1], data[i] )

for i in range(n-1, 0, -1):
    right_[i] = gcd( right_[i+1], data[i] )

for i in range(n):
    ans += [ gcd( left_[i-1], right_[i+1] ) ]

print( max(ans) )
Buggy python submission (verdict: Runtime Error):

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

def ary_abs(data):
    for i in range(len(data)):
        data[i] = abs(data[i])


for i in data:
    count = 0
    if data <= 0:
        count += 1

if count % 2 == 0:
    # 負が 偶数 個のとき
    # 全てを正にした和
    ary_abs(data)
    print(sum(data))
else:
    # 負が 奇数 個のとき
    # どれか一つを負(最小のもの)
    ary_abs(data)
    print(sum(data) - min(data) * 2)


Fixed submission:
# 解説を見て書いたコード
N = int(input())
data = list(map(int, input().split()))
count = 0

def ary_abs(data):
    for i in range(len(data)):
        data[i] = abs(data[i])


for i in data:
    if i <= 0:
        count += 1

if count % 2 == 0:
    # 負が 偶数 個のとき
    # 全てを正にした和
    ary_abs(data)
    print(sum(data))
else:
    # 負が 奇数 個のとき
    # どれか一つを負(最小のもの)
    ary_abs(data)
    print(sum(data) - min(data) * 2)
Buggy python submission (verdict: Runtime Error):
N, X = map(input().split())

# メモ化するための初期化
a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(N, X):
    # X <= 0 や X > a_N を許容し解説本文から簡略化
    if N == 0:
        if X <= 0:
            return 0
        else:
            return 1
    elif X <= 1 + a[N - 1]:
        return f(N - 1, X - 1)
    else:
        return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1])

print(f(N, X))


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

# メモ化するための初期化
a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(N, X):
    # X <= 0 や X > a_N を許容し解説本文から簡略化
    if N == 0:
        if X <= 0:
            return 0
        else:
            return 1
    elif X <= 1 + a[N - 1]:
        return f(N - 1, X - 1)
    else:
        return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1])

print(f(N, X))