Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
inputa = list(map(int(), input()))
if inputa[0] < inputa[1]:
  print("0")
else:
  print("10")

Fixed submission:
inputa = list(map(int, input().split()))
if inputa[0] < inputa[1]:
  print("0")
else:
  print("10")
Buggy python submission (verdict: Runtime Error):
inputa = list(map(int, input().split()))

S = inputa[0] * inputa[1] / 2

# W:H = x:y
# Hx = yW
# y = (H/W)x

if W / 2 == x:
  if H / 2 == y:
    print (S, " 1")
    exit(0)
print (S, " 0")

Fixed submission:
inputa = list(map(int, input().split()))
 
S = inputa[0] * inputa[1] / 2
 
if inputa[0] / 2 == inputa[2]:
  if inputa[1] / 2 == inputa[3]:
    print (S, " 1")
    exit(0)
print (S, " 0")
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
mod = 10 ** 9 + 7

res = [[-1 for _ in range(M)] for _ in range(N)]
dpl = [[-1 for _ in range(M)] for _ in range(N)]
def dp(i, j):
  if i < 0:
    return 0
  if j < 0:
    return 0
  if dpl[i][j] != -1:
    return dpl[i][j]
  if i == 1:
    temp = 0
    for k in range(j):
      temp += S[i] == T[k]
    return temp
  elif j == 1:
    temp = 0
    for k in range(j):
      temp += S[k] == T[j]
    return temp
  temp = 0
  for k in range(i):
    for l in range(j):
      temp += dpl[k][l]
      
  return temp

def search(i, j):
  if i < 0:
    return 0
  if j < 0:
    return 0
  if res[i][j] != -1:
    return res[i][j]
  temp = 0
  if S[i] == T[j]:
    temp = 1
    temp += dp[i][j]
  else:
    temp = 0
  return search(i - 1, j) + search(i, j - 1) - search(i - 1, j - 1) + temp

print(search(N - 1, M - 1) % mod)


Fixed submission:
import numpy as np
N, M = map(int, input().split())
S = input().split()
T = np.array(input().split(), dtype = np.int32)
mod = 10 ** 9 + 7
dp = np.ones(M + 1, dtype = np.int64)
 
for s in S:
  dp[1:] = ((dp[:-1] * (T == int(s))).cumsum() + dp[1:]) % mod

print(dp[M])

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

tempArray = [1]*(M + 1)
for i, x in enumerate(S):
  tempArray2 = tempArray[:]
  k = 0
  for j, y in enumerate(T):
    if x == y:
      k += tempArray[j]
    tempArray2[j + 1] = tempArray[j + 1] + k
  tempArray = tempArray2
print(tempArray[-1] % (10**9 + 7))

Fixed submission:
import numpy as np
N, M = map(int, input().split())
S = input().split()
T = np.array(input().split(), dtype = np.int32)
mod = 10 ** 9 + 7
dp = np.ones(M + 1, dtype = np.int64)
 
for s in S:
  dp[1:] = ((dp[:-1] * (T == int(s))).cumsum() + dp[1:]) % mod

print(dp[M])

Buggy python submission (verdict: Runtime Error):
inputa = list(map(int, input().split()))
inputb = list(map(int, input().split()))
inputc = list(map(int, input().split()))

seta = set(inputb) & set(inputc)

countb = []
countc = []
result = 0
for i in seta:
  countb.append(inputb.count(i))
  countc.append(inputc.count(i))
for i in range(len(countb)):
  for j in range(i)
  result += countb[i] * countc[j]

print(result)

Fixed submission:
import numpy as np
N, M = map(int, input().split())
S = input().split()
T = np.array(input().split(), dtype = np.int32)
mod = 10 ** 9 + 7
dp = np.ones(M + 1, dtype = np.int64)
 
for s in S:
  dp[1:] = ((dp[:-1] * (T == int(s))).cumsum() + dp[1:]) % mod

print(dp[M])
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

dp = [0] * (N + 1)
for i in range(N, -1, -1):
  for j in range(3):
    x = a[j]
    y = b[j]
    if i - x >= 0:
      dp[i - x] = max(dp[i - x], dp[i] + y)
for i in range(N + 1): dp[i] += i
#print(dp)
t = max(dp)
e = []
def check(x):
  tt = t - b[e[0]] * x
  return (tt // b[e[1]]) * a[e[1]] + tt % b[e[1]] + a[e[0]] * x

if t > N:
  for i in range(3):
    if b[i] < a[i]: e.append(i)
  if len(e) == 0:
    print(t)
  elif len(e) == 1:
    print(a[e[0]] * (t // b[e[0]]) + t % b[e[0]])
  else:
    if b[e[0]] < b[e[1]]: e[0], e[1] = e[1], e[0]
    x = e[0]
    res = 0
    for i in range(t // b[x] + 1): res = max(res, check(i))
    print(res)
else:
  dp = [0] * (N + 1)
  for i in range(N, -1, -1):
    for j in range(3):
      y = a[j]
      x = b[j]
    if i - x >= 0:
      dp[i - x] = max(dp[i - x], dp[i] + y)
  for i in range(N + 1): dp[i] += i
  print(max(dp))

Fixed submission:
N, K = map(int, input().split())
if K == 1: print(0)
else: print(N - K)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
p = [t for t in a if t >= 0]
m = [t for t in a if t < 0]
p.sort(reverse = True)
m.sort()
l = []
#print(a)
if len(p) == 0:
  u = m.pop()
  v = m.pop()
  l.append((u, v))
  p.append(u - v)
if len(m) == 0 and len(p) >= 2:
  u = p.pop()
  v = p.pop()
  l.append((u, v))
  m.append(u - v)
while len(p) >= 2:
  u = m.pop()
  v = p.pop()
  l.append((u, v))
  m.append(u - v)
while len(m):
  t = p[0]
  u = m.pop()
  l.append((t, u))
  p[0] = t - u
print(p[0])
for res in l:
  print(*res)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
p = [t for t in a if t >= 0]
m = [t for t in a if t < 0]
p.sort(reverse = True)
m.sort()
l = []
if N == 2:
  print(max(a) - min(a))
  print(max(a), min(a))
  exit(0)
if len(p) == 0:
  u = m.pop()
  v = m.pop()
  l.append((u, v))
  p.append(u - v)
if len(m) == 0 and len(p) >= 2:
  u = p.pop()
  v = p.pop()
  l.append((u, v))
  m.append(u - v)
while len(p) >= 2:
  u = m.pop()
  v = p.pop()
  l.append((u, v))
  m.append(u - v)
while len(m):
  t = p[0]
  u = m.pop()
  l.append((t, u))
  p[0] = t - u
print(p[0])
for res in l:
  print(*res)
Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int,input().split())
S = [list(input()) for _ in range(H)]
table = [[0 for _ in range(W)] for _ in range(H)]
def dfsW(n):
  global table
  l = -1
  r = -1
  i = 0
  while i < W:
    if S[n][i] == ".":
      if l == -1:
        l = i
      r = i
    else:
      if l != -1:
        for j in range(l, r + 1):
          table[n][j] += r - l + 1
      l = -1
      r = -1
    i += 1
  if l != -1:
    for j in range(l, r + 1):
      table[n][j] += r - l + 1


def dfsH(n):
  global table
  l = -1
  r = -1
  i = 0
  while i < H:
    if S[i][n] == ".":
      if l == -1:
        l = i
      r = i
    else:
      if l != -1:
        for j in range(l, r + 1):
          table[j][n] += r - l + 1
      l = -1
      r = -1
    i += 1
    
  if l != -1:
    for j in range(l, r + 1):
      table[j][n] += r - l + 1


for i in range(H):
  dfsW(i)
for i in range(W):
  dfsH(i)
print(max(map(max, table)) - 1)

Fixed submission:
H, W = map(int,input().split())
S = [list(input()) for _ in range(H)]
table = [[0 for _ in range(W)] for _ in range(H)]
def dfsW(n):
  global table
  l = -1
  r = -1
  i = 0
  while i < W:
    if S[n][i] == ".":
      if l == -1:
        l = i
      r = i
    else:
      if l != -1:
        for j in range(l, r + 1):
          table[n][j] += r - l + 1
      l = -1
      r = -1
    i += 1
  if l != -1:
    for j in range(l, r + 1):
      table[n][j] += r - l + 1


def dfsH(n):
  global table
  l = -1
  r = -1
  i = 0
  while i < H:
    if S[i][n] == ".":
      if l == -1:
        l = i
      r = i
    else:
      if l != -1:
        for j in range(l, r + 1):
          table[j][n] += r - l + 1
      l = -1
      r = -1
    i += 1
    
  if l != -1:
    for j in range(l, r + 1):
      table[j][n] += r - l + 1


for i in range(H):
  dfsW(i)
for i in range(W):
  dfsH(i)
print(max(map(max, table)) - 1)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())
S = list(input())[: -1]
dp = [0] * (N + 1)
dp[B] = 1
for i in range(B, N + 1):
  if dp[i] == 0: continue
  if i + 1 <= N:
    if S[i] == ".":
      dp[i + 1] = 1
  if i + 2 <= N:
    if S[i + 1] == ".":
      dp[i + 2] = 1
if dp[D] == 0:
  print("No")
  exit(0)
S[D] = "#"
dp = [0] * (N + 1)
dp[A] = 1
for i in range(A, N + 1):
  if dp[i] == 0: continue
  if i + 1 <= N:
    if S[i] == ".":
      dp[i + 1] = 1
  if i + 2 <= N:
    if S[i + 1] == ".":
      dp[i + 2] = 1
#print(dp)
if dp[C]:
  print("Yes")
else: print("No")

Fixed submission:
inputa = list(map(int, input().split()))
inputb = list(input())
#double mountain
mountain = 0
for i in range(min(inputa[1], inputa[2]) - 1, max(inputa[3], inputa[4])):
  if inputb[i] == "#":
    if mountain == 1:
      mountain = 2
      break
    mountain = 1
  else:
    mountain = 0

if mountain == 2:
  print("No")
  exit()
    
#need oikoshi
oikoshi = 0
if inputa[3] > inputa[4]:
  oikoshi = 1

#triple step
triplestep = 0
for i in range(inputa[2] - 1, inputa[4]):
  if oikoshi == 0:
    break
  if inputb[i - 1] == ".":
    if inputb[i] == ".":
      if inputb[i + 1] == ".":
        triplestep = 1
        break

if oikoshi == 0:
  print("Yes")
else:
  if triplestep == 1:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
sentence = input()
def recABC(s, c):
  temp = 0
  for i in range(0, len(s) - 2):
    if s[i] == "A":
      if s[i + 1] == "B":
        if s[i + 2] == "C":
            temp += 1
            if len(s) <= i + 3:
              s = s[: i] + "BCA"
            else:
              s = s[: i] + "BCA" + s[i + 3:]
            #print(s)
  
  if temp == 0:
    return c
  else:
    return recABC(s, c + temp)
print(recABC(sentence, 0))

Fixed submission:
sentence = input()
slist = sentence.split("BC")
res = 0
a = 0
for l in slist:
  if ("B" in l) or ("C" in l) :
    l = l.replace("C", "B")
    al = l.split("B")
    a = len(al[-1])
    res += a
  else:
    a += len(l)
    res += a
else:
  res -= a
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial as f
N, M, K = map(int, input().split())
mod = 10 ** 9 + 7

def combi(n, r):
  return f(n) // f(n - r) // f(r) % mod

res = 0
c = combi(N * M - 2, K - 2)
cn = c * M ** 2 % mod
cm = c * N ** 2 % mod
temp = ((N - 1 + 1) * (N - 1) // 2) * cn % mod
for i in range(1, N):
  res += temp % mod
  res %= mod
  temp -= (N - i) * cn % mod
#print(res)
temp = ((M - 1 + 1) * (M - 1) // 2) * cm % mod
for i in range(1, M):
  res += temp % mod
  res %= mod
  temp -= (M - i) * cm % mod

print(res % mod)

Fixed submission:
from math import factorial as f
N, M, K = map(int, input().split())
mod = 10 ** 9 + 7

def combi(n, r):
  return f(n) // (f(n - r) * f(r)) % mod

res = 0
c = combi(N * M - 2, K - 2)
for i in range(1, N):
  res += ((N - i + 1) * (N - i) // 2) * c * M * M % mod
  res %= mod

for i in range(1, M):
  res += ((M - i + 1) * (M - i) // 2) * c * N * N % mod
  res %= mod

print(res % mod)

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial as f
N, M, K = map(int, input().split())
mod = 10 ** 9 + 7

def combi(n, r):
  return f(n) // f(n - r) // f(r) % mod

res = 0
c = combi(N * M - 2, K - 2)
for i in range(1, N):
  res += ((N - i + 1) * (N - i) // 2) * c * M * M % mod
  res %= mod

for i in range(1, M):
  res += ((M - i + 1) * (M - i) // 2) * c * N * N % mod
  res %= mod

print(res % mod)

Fixed submission:
from math import factorial as f
N, M, K = map(int, input().split())
mod = 10 ** 9 + 7

def combi(n, r):
  return f(n) // (f(n - r) * f(r)) % mod

res = 0
c = combi(N * M - 2, K - 2)
for i in range(1, N):
  res += ((N - i + 1) * (N - i) // 2) * c * M * M % mod
  res %= mod

for i in range(1, M):
  res += ((M - i + 1) * (M - i) // 2) * c * N * N % mod
  res %= mod

print(res % mod)

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial as f
N, M, K = map(int, input().split())
mod = 10 ** 9 + 7

def combi(n, r):
  return f(n) // f(n - r) // f(r) % mod

res = 0
for i in range(1, N):
  res += ((N - i + 1) * (N - i) // 2) * combi(N * M - 2, K - 2) * M * M % mod
  res %= mod

for i in range(1, M):
  res += ((M - i + 1) * (M - i) // 2) * combi(N * M - 2, K - 2) * N * N % mod
  res %= mod

print(res % mod)

Fixed submission:
from math import factorial as f
N, M, K = map(int, input().split())
mod = 10 ** 9 + 7

def combi(n, r):
  return f(n) // (f(n - r) * f(r)) % mod

res = 0
c = combi(N * M - 2, K - 2)
for i in range(1, N):
  res += ((N - i + 1) * (N - i) // 2) * c * M * M % mod
  res %= mod

for i in range(1, M):
  res += ((M - i + 1) * (M - i) // 2) * c * N * N % mod
  res %= mod

print(res % mod)
Buggy python submission (verdict: Runtime Error):
inputa = input().split()
inputa[0] = int(inputa[0])
inputa[1] = int(inputa[1])
tempa = []
tempb = float(inputa[1])
tempc = []
res = float(0)
if tempb == 1:
  print(1)
  exit()
while tempb > 1:
  if tempb <= inputa[0]:
    tempa.append(inputa[0] - tempb + 1)
  else:
    tempa.append(0)
    
  tempb /= 2

i = 1
tempc.append(tempa[0])
while i <= len(tempa):
  tempc.append(tempa[i] - tempa[i - 1])
  i += 1

for i, num in enumerate(tempc):
  res += num / inputa[0] / (2 ** i)

print(res)

Fixed submission:
import math
inputa = input().split()
inputa[0] = int(inputa[0])
inputa[1] = int(inputa[1])
tempa = []
tempb = float(inputa[1])
tempc = []
res = float(0)
if tempb == 1:
	print(1)
	exit()
while tempb >= 0.5:
	#print(tempb)
	if tempb <= inputa[0]:
		tempa.append(math.floor(inputa[0] - tempb + 1))
	else:
		tempa.append(0)
	tempb /= 2

i = 1
tempc.append(tempa[0])
#print(tempa)
while i < len(tempa):
	tempc.append(tempa[i] - tempa[i - 1])
	i += 1
#print(tempc)
for i, num in enumerate(tempc):
	#print(num / inputa[0] / (2 ** i))
	res += num / inputa[0] / (2 ** i)

print(res)

Buggy python submission (verdict: Runtime Error):
inputa = input().split()
inputa[0] = int(inputa[0])
inputa[1] = int(inputa[1])
tempa = []
tempb = float(inputa[1])
tempc = []
res = float(0)
if tempb == 1:
  print(1)
  exit()
while tempb > 1:
  if tempb <= inputa[0]:
    tempa.append(inputa[0] - tempb + 1)
  else:
    tempa.append(0)
    
  tempb /= 2

i = 1
tempc.append(tempa[0])
while i <= len(tempa):
  tempc.append(tempa[i] - tempa[i - 1])
  i += 1

for i, num in enumerate(tempa):
  res += num / inputa[0] / (2 ** i)

print(res)

Fixed submission:
import math
inputa = input().split()
inputa[0] = int(inputa[0])
inputa[1] = int(inputa[1])
tempa = []
tempb = float(inputa[1])
tempc = []
res = float(0)
if tempb == 1:
	print(1)
	exit()
while tempb >= 0.5:
	#print(tempb)
	if tempb <= inputa[0]:
		tempa.append(math.floor(inputa[0] - tempb + 1))
	else:
		tempa.append(0)
	tempb /= 2

i = 1
tempc.append(tempa[0])
#print(tempa)
while i < len(tempa):
	tempc.append(tempa[i] - tempa[i - 1])
	i += 1
#print(tempc)
for i, num in enumerate(tempc):
	#print(num / inputa[0] / (2 ** i))
	res += num / inputa[0] / (2 ** i)

print(res)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict as ddydd
from collections import deque as q
N, M = map(int, input().split())
XYZ = ddydd(list)
TreeMemo = ddydd(int)
link = []
trace = [0] * (N + 1)
start = 0
for _ in range(M):
  x, y, z = map(int, input().split())
  if start == 0:
    start = x
  XYZ[x].append(y)
  XYZ[y].append(x)
  TreeMemo[x] = 0
  TreeMemo[y] = 0
  if not x in link: link.append(x)
  if not y in link: link.append(y)

def searchPreMin(n):
  global trace
  trace.append(n)
  temp = min(XYZ[n])
  if temp < n:
    return searchPreMin(temp)
  else:
    return n
def searchPreMax(n):
  global trace
  trace.append(n)
  temp = max(XYZ[n])
  if temp > n:
    return searchPreMax(temp)
  else:
    return n
def searchMax(n):
  global trace
  if trace[n] != 0:
    return TreeMemo[n]
  trace = []
  n = searchPreMin(n)
  temp = searchPreMax(n)
  for t in trace:
    TreeMemo[t] = temp
  return temp

forest = []
nodes = len(link)
while link:
  temp = link.pop()
  tree = searchMax(temp)
  if not tree in forest: forest.append(tree)
    
print(N - nodes + len(forest))

Fixed submission:
N, M = map(int, input().split())
XY = [i for i in range(N + 1)]

def root(x):
  temp = x
  while temp != XY[temp]:
    temp = XY[temp]
  XY[x] = temp
  return temp
for _ in range(M):
  x, y = map(int, input().split()[:2])
  XY[root(x)] = root(y)

print(sum(i == v for i, v in enumerate(XY)) - 1)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict as ddydd
from collections import deque as q
N, M = map(int, input().split())
XYZ = ddydd(list)
TreeMemo = ddydd(int)
link = []
trace = []
start = 0
for _ in range(M):
  x, y, z = map(int, input().split())
  if start == 0:
    start = x
  XYZ[x].append(y)
  XYZ[y].append(x)
  TreeMemo[x] = 0
  TreeMemo[y] = 0
  if not x in link: link.append(x)
  if not y in link: link.append(y)

def searchPreMin(n):
  global trace
  trace.append(n)
  temp = min(XYZ[n])
  if temp < n:
    return searchPreMin(temp)
  else:
    return n
def searchPreMax(n):
  global trace
  trace.append(n)
  temp = max(XYZ[n])
  if temp > n:
    return searchPreMax(temp)
  else:
    return n
def searchMax(n):
  global trace
  if trace[n] != 0:
    return TreeMemo[t]
  trace = []
  n = searchPreMin(n)
  temp = searchPreMax(n)
  for t in trace:
    TreeMemo[t] = temp
  return temp

forest = []
nodes = len(link)
while link:
  temp = link.pop()
  tree = searchMax(temp)
  if not tree in forest: forest.append(tree)
    
print(N - nodes + len(forest))

Fixed submission:
N, M = map(int, input().split())
XY = [i for i in range(N + 1)]

def root(x):
  temp = x
  while temp != XY[temp]:
    temp = XY[temp]
  XY[x] = temp
  return temp
for _ in range(M):
  x, y = map(int, input().split()[:2])
  XY[root(x)] = root(y)

print(sum(i == v for i, v in enumerate(XY)) - 1)
Buggy python submission (verdict: Runtime Error):
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N = int(input())
e = dd(list)
for _ in range(N - 1):
  u, v = map(int, input().split())
  e[u].append((v, 1))
  e[v].append((u, 1))
import heapq
class dijkstra:
  def __init__(self, n, e):
    self.e = e
    self.n = n
  def path(self, s, t):
    d = [float("inf")] * (self.n + 1)
    vis = set()
    d[s] = 0
    h = [s]
    while not t in vis and len(h):
      v = heapq.heappop(h)
      v1 = v % (10 ** 6)
      v0 = v // (10 ** 6)
      if v1 in vis: continue
      vis.add(v1)
      for p in self.e[v1]:
        d[p[0]] = min(d[p[0]], d[v1] + p[1])
        if p[0] in vis: continue
        heapq.heappush(h, d[p[0]] * (10 ** 6) + p[0])
    return d
dij = dijkstra(N, e)
s = 0
d = 0
p = dij.path(1, 0)
for i in range(1, N + 1):
  if p[i] > d:
    s = i
    d = p[i]
p = dij.path(s, 0)
mx = max(p[1: ])
dp = [-1] * (mx + 1)
dp[0] = 1
for i in range(mx):
  if i + 1 <= mx:
    if dp[i + 1] == -1 or (dp[i + 1] == ((dp[i] + 1) % 2)):
      dp[i + 1] = (dp[i] + 1) % 2
  if i + 2 <= mx:
    if dp[i + 2] == -1 or (dp[i + 2] == ((dp[i] + 1) % 2)):
      dp[i + 2] = (dp[i] + 1) % 2
if dp[-1]: print("Second")
else: print("First")

Fixed submission:
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N = int(input())
e = dd(list)
if N == 1:
  print("First")
  exit(0)
for _ in range(N - 1):
  u, v = map(int, input().split())
  e[u].append((v, 1))
  e[v].append((u, 1))
import heapq
class dijkstra:
  def __init__(self, n, e):
    self.e = e
    self.n = n
  def path(self, s, t):
    d = [float("inf")] * (self.n + 1)
    vis = set()
    d[s] = 0
    h = [s]
    while not t in vis and len(h):
      v = heapq.heappop(h)
      v1 = v % (10 ** 6)
      v0 = v // (10 ** 6)
      if v1 in vis: continue
      vis.add(v1)
      for p in self.e[v1]:
        d[p[0]] = min(d[p[0]], d[v1] + p[1])
        if p[0] in vis: continue
        heapq.heappush(h, d[p[0]] * (10 ** 6) + p[0])
    return d
dij = dijkstra(N, e)
s = 0
d = 0
p = dij.path(1, 0)
for i in range(1, N + 1):
  if p[i] > d:
    s = i
    d = p[i]
p = dij.path(s, 0)
mx = max(p[1: ])
if mx % 3 == 1: print("Second")
else: print("First")
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
class SegTree:
  def segfunc(self, x, y):
    return gcd(x, y) #ここ判定関数（ただし結合則があるもの）
  def __init__(self, n, ide_ele, init_val):
    #####単位元######
    self.ide_ele = ide_ele
    #num:n以上の最小の2のべき乗
    self.num = 2 ** (n - 1).bit_length()
    self.seg = [self.ide_ele] * 2 * self.num
    #set_val
    for i in range(N):
      self.seg[i + self.num - 1] = init_val[i]    
    #built
    for i in range(self.num - 2, -1, -1) :
      self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) 
  def update(self, k, x):
    k += self.num - 1
    self.seg[k] = x
    while k + 1:
      k = (k - 1) // 2
      self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) 
  def query(self, p, q):
    if q <= p:
      return self.ide_ele
    p += self.num - 1
    q += self.num - 2
    res = self.ide_ele
    while q - p > 1:
      if p & 1 == 0:
        res = self.segfunc(res, self.seg[p])
      if q & 1 == 1:
        res = self.segfunc(res, self.seg[q])
        q -= 1
      p = p // 2
      q = (q - 1) // 2
    if p == q:
      res = self.segfunc(res, self.seg[p])
    else:
      res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
    return res
sg = SegTree(N, 0, A)
res = 0
for i in range(N):
  res = max(res, gcd(sg.query(0, i), sg.query(i + 1, N)))
print(res)

Fixed submission:
from fractions import gcd
n = int(input())
A = list(map(int, input().split()))
#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

#####segfunc######
def segfunc(x,y):
    return gcd(x, y) 

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k+1:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res
  
init(A)
result = 0
for i in range(n):
  temp = gcd(query(0, i), query(i + 1, n))
  result = max(result, temp)
print(result)
Buggy python submission (verdict: Runtime Error):
print(max(list(map(input().split()))) * 2 - 1)

Fixed submission:
x = list(map(int, input().split()))
print(max(x) * 2 - 1) if min(x) != max(x) else print(x[0] * 2)