Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())

import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

if n=1:
  print("1")
else:
  f=len(seachPrimeNum(n))
  g=seachPrimeNum(n)
  c=1
  
  for j in range(f):
    e=g[j]
    a=0
    b=n
    h=0
    while b>=e:
      b=b//e
      h=h+b
      a=a+1
    c=c*(h+1)
  print(c%(10**9+7))

Fixed submission:
n=int(input())
if n==1:
  print("1")
else:
  import numpy as np
  
  def seachPrimeNum(N):
      max = int(np.sqrt(N))
      seachList = [i for i in range(2,N+1)]
      primeNum = []
      while seachList[0] <= max:
          primeNum.append(seachList[0])
          tmp = seachList[0]
          seachList = [i for i in seachList if i % tmp != 0]
      primeNum.extend(seachList)
      return primeNum
    
  f=len(seachPrimeNum(n))
  g=seachPrimeNum(n)
  c=1
  
  for j in range(f):
    e=g[j]
    a=0
    b=n
    h=0
    while b>=e:
      b=b//e
      h=h+b
      a=a+1
    c=c*(h+1)
  print(c%(10**9+7))

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

import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

f=len(seachPrimeNum(n))
g=seachPrimeNum(n)
c=1

for j in range(f):
  e=g[j]
  a=0
  b=n
  h=0
  while b>=e:
    b=b//e
    h=h+b
    a=a+1
  c=c*(h+1)
print(c%(10**9+7))

Fixed submission:
n=int(input())
if n==1:
  print("1")
else:
  import numpy as np
  
  def seachPrimeNum(N):
      max = int(np.sqrt(N))
      seachList = [i for i in range(2,N+1)]
      primeNum = []
      while seachList[0] <= max:
          primeNum.append(seachList[0])
          tmp = seachList[0]
          seachList = [i for i in seachList if i % tmp != 0]
      primeNum.extend(seachList)
      return primeNum
    
  f=len(seachPrimeNum(n))
  g=seachPrimeNum(n)
  c=1
  
  for j in range(f):
    e=g[j]
    a=0
    b=n
    h=0
    while b>=e:
      b=b//e
      h=h+b
      a=a+1
    c=c*(h+1)
  print(c%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
x=0
b=0
for x in range(k+1):
  y=0
  while x+y<=s and y<=k:
    z=s-x-y
    if z>=0 and z<=k:
      b=b+1
    y=y+1
print(b)
      

Fixed submission:
k,s=map(int,input().split())
x=0
b=0
while x<=k and x<=s//3:
  y=x
  while x+y<=s and y<=k and y<=(s-x)//2:
    z=s-x-y
    if z>=0 and z<=k:
      if x==y and y==z:
        b=b+1
      elif x==y:
        b=b+3
      elif y==z:
        b=b+3
      else:
        b=b+6
    y=y+1
  x=x+1
print(b)

Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
x=0
b=0
while x<=k:
  y=0
  while x+y<=s and y<=k:
    z=s-x-y
    if z>=0 and z<=k:
      b=b+1
    y=y+1
  x=x+1
print(b)
      

Fixed submission:
k,s=map(int,input().split())
x=0
b=0
while x<=k and x<=s//3:
  y=x
  while x+y<=s and y<=k and y<=(s-x)//2:
    z=s-x-y
    if z>=0 and z<=k:
      if x==y and y==z:
        b=b+1
      elif x==y:
        b=b+3
      elif y==z:
        b=b+3
      else:
        b=b+6
    y=y+1
  x=x+1
print(b)
Buggy python submission (verdict: Runtime Error):
def D(n,d):
  r=0
  while n>0:
    r=r+n%d
    n=n//d
  return r

n=int(input())
s=int(input())
if n-s==0:
  print(n+1)
  exit()

A=[]
for i in range(1,int((n-s)**(1/2))+1):
  if (n-s)%i==0:
    A.append(i)
for i in range(len(A)):
  if D(n,A[i]+1)==s:
    print(A[i]+1)
    exit()
print(-1)

Fixed submission:
def D(n,d):
  r=0
  while n>0:
    r=r+n%d
    n=n//d
  return r

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=int(input())
s=int(input())
if n-s==0:
  print(n+1)
  exit()
if s>n:
  print(-1)
  exit()

A=make_divisors(n-s)
for i in range(len(A)):
  if D(n,A[i]+1)==s:
    print(A[i]+1)
    exit()
print(-1)

Buggy python submission (verdict: Runtime Error):
def D(n,d):
  r=0
  while n>0:
    r=r+n%d
    n=n//d
  return r

n=int(input())
s=int(input())
if n-s==-1:
  print(n)
  exit()
A=[]
for i in range(1,int((n-s)**(1/2))+3):
  if (n-s)%i==0:
    A.append(i)
for i in range(len(A)):
  if D(n,A[i]+1)==s:
    print(A[i]+1)
    exit()
print(-1)

Fixed submission:
def D(n,d):
  r=0
  while n>0:
    r=r+n%d
    n=n//d
  return r

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=int(input())
s=int(input())
if n-s==0:
  print(n+1)
  exit()
if s>n:
  print(-1)
  exit()

A=make_divisors(n-s)
for i in range(len(A)):
  if D(n,A[i]+1)==s:
    print(A[i]+1)
    exit()
print(-1)

Buggy python submission (verdict: Runtime Error):
def D(n,d):
  r=0
  while n>0:
    r=r+n%d
    n=n//d
  return r

n=int(input())
s=int(input())
A=[]
for i in range(1,int((n-s)**(1/2))+3):
  if (n-s)%i==0:
    A.append(i)
for i in range(len(A)):
  if D(n,A[i]+1)==s:
    print(A[i]+1)
    exit()
print(-1)

Fixed submission:
def D(n,d):
  r=0
  while n>0:
    r=r+n%d
    n=n//d
  return r

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=int(input())
s=int(input())
if n-s==0:
  print(n+1)
  exit()
if s>n:
  print(-1)
  exit()

A=make_divisors(n-s)
for i in range(len(A)):
  if D(n,A[i]+1)==s:
    print(A[i]+1)
    exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
S=list(input())
T=list(input())
ans_li=[]
for i in range(len(S)-len(T)):
    ans=0
    for j in range(len(T)):
        if S[i+j]!=T[j]:
            ans+=1
    ans_li.append(ans)
print(min(ans_li))

Fixed submission:
S=list(input())
T=list(input())
ans_li=[]
for i in range(len(S)-len(T)+1):
    ans=0
    for j in range(len(T)):
        if S[i+j]!=T[j]:
            ans+=1
    ans_li.append(ans)
print(min(ans_li))
Buggy python submission (verdict: Time Limit Exceeded):
rule=input().split()
X=int(rule[0])
K=int(rule[1])
D=int(rule[2])
ans_li=[]
import math
for i in range(K+1):
    ans_pre=X+D*i-D*(K-i)
    ans_li.append(int(math.fabs(ans_pre)))
print(min(ans_li))

Fixed submission:
import math
N=input().split()
X=int(math.fabs(int(N[0])))
K=int(N[1])
D=int(N[2])
if X-K*D>=0:
    print(X-K*D)
else:
    syou=X//D
    x=X-syou*D
    y=X-(syou+1)*D
    if K%2==0:
        if syou%2==0:
            print(x)
        else:
            print(int(math.fabs(y)))
    else:
        if syou%2==0:
            print(int(math.fabs(y)))
        else:
            print(x)
Buggy python submission (verdict: Runtime Error):
r=input().split()
A=int(r[0])
B=int(r[1])
C=int(r[2])
K=int(r[3])
d_a=[1]*A
d_b=[0]*B
d_c=[-1]*C
d=d_a+d_b+d_c
if K>A+B+C:
    print(A-B)
else:
    ans=0
    for i in range(K):
        ans+=d[i]
    print(ans)

Fixed submission:
r=input().split()
A=int(r[0])
B=int(r[1])
C=int(r[2])
K=int(r[3])
if K<=A:
    print(K)
elif K<=A+B:
    print(A)
else:
    print(2*A-K+B)

Buggy python submission (verdict: Runtime Error):
r=input().split()
A=int(r[0])
B=int(r[1])
C=int(r[2])
K=int(r[3])
d_a=[1]*A
d_b=[0]*B
d_c=[-1]*C
d=d_a+d_b+d_c
ans=0
for i in range(K):
    ans+=d[i]
print(ans)

Fixed submission:
r=input().split()
A=int(r[0])
B=int(r[1])
C=int(r[2])
K=int(r[3])
if K<=A:
    print(K)
elif K<=A+B:
    print(A)
else:
    print(2*A-K+B)
Buggy python submission (verdict: Runtime Error):
r=input().split()
H=int(r[0])
N=int(r[1])
data=[int(s) for s in input().split()]
data.sort()
Data=data[::-1]
if Data[0]+Data[1]>=H:
    print("Yes")
else:
    print("No")

Fixed submission:
r=input().split()
H=int(r[0])
N=int(r[1])
data_pre=input().split()
data=[int(s) for s in data_pre]
if sum(data)>=H:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
r=input().split()
N=int(r[0])
M=int(r[1])
data=[[int(s) for s in input().split()] for i in range(M)]
left=[]
right=[]
for i in range(M):
    left.append(data[i][0])
    right.append(data[i][1])
if min(right)-max(left)+1=<0:
    print(0)
else:
    print(min(right)-max(left)+1)

Fixed submission:
data=input().split()
N=int(data[0])
M=int(data[1])
data_gate=[input().split() for i in range(M)]
data_min=[]
data_max=[]
for i in range(M):
    data_min.append(int(data_gate[i][0]))
    data_max.append(int(data_gate[i][1]))
m=max(data_min)
M=min(data_max)
if M>=m:
    ans=M-m+1
else:
    ans=0
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
data=input().split()
N=int(data[0])
M=int(data[1])
data_gate=[input().split() for i in range(M)]
ans=0
for i in range(1,N+1):
    for j in range(M):
        minimum=int(data_gate[j][0])
        maximum=int(data_gate[j][1])
        if j<=M-2:
            if minimum<=i<=maximum:
                continue
            else:
                break
        else:
            if minimum<=i<=maximum:
                ans+=1
            else:
                break
print(ans)

Fixed submission:
data=input().split()
N=int(data[0])
M=int(data[1])
data_gate=[input().split() for i in range(M)]
data_min=[]
data_max=[]
for i in range(M):
    data_min.append(int(data_gate[i][0]))
    data_max.append(int(data_gate[i][1]))
m=max(data_min)
M=min(data_max)
if M>=m:
    ans=M-m+1
else:
    ans=0
print(ans)
Buggy python submission (verdict: Runtime Error):
data=input().split()
N=int(data[0])
K=int(data[1])
S=input()
s=list(S)
s[K]=S[K].lower()
print("".join(s))

Fixed submission:
data=input().split()
N=int(data[0])
K=int(data[1])
S=input()
s=list(S)
s[K-1]=S[K-1].lower()
print("".join(s))
Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
# mahous = [(a, b) for a, b in list(map(int, input().split()))]

mahous = []
for i in range(N):
    a, b = map(int, input().split())
    mahous.append((a, b))

dp = [float("inf")] * (H + 1)
dp[0] = 0

for h in range(1, H + 1):
    for n in range(N):
        a, b = mahous[n]
        tairyoku = max(0, h - a)
        # if h - a >= 0:
        dp[h] = min(dp[h], dp[tairyoku] + b)
    # print(dp)

print(dp[H])

Fixed submission:
H, N = map(int, input().split())
# mahous = [(a, b) for a, b in list(map(int, input().split()))]

mahous = []
for i in range(N):
    a, b = map(int, input().split())
    mahous.append((a, b))

dp = [float("inf")] * (H + 1)
dp[0] = 0

for h in range(1, H + 1):
    for n in range(N):
        a, b = mahous[n]
        tairyoku = max(0, h - a)
        # if h - a >= 0:
        dp[h] = min(dp[h], dp[tairyoku] + b)
    # print(dp)

print(dp[H])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import itertools
import copy

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]


def bfs(maze, s, g):
    q = deque()
    q.append((s, 0))

    maze[s[0]][s[1]] = "#"

    while len(q) > 0:
        p, depth = q.popleft()

        if p == g:
            return depth

        # ikerutoko
        next_pos = []
        if 0 <= p[0] - 1 < H and maze[p[0] - 1][p[1]] != "#":
            next_pos.append((p[0] - 1, p[1]))
        if 0 <= p[0] + 1 < H and maze[p[0] + 1][p[1]] != "#":
            next_pos.append((p[0] + 1, p[1]))
        if 0 <= p[1] - 1 < W and maze[p[0]][p[1] - 1] != "#":
            next_pos.append((p[0], p[1] - 1))
        if 0 <= p[1] + 1 < W and maze[p[0]][p[1] + 1] != "#":
            next_pos.append((p[0], p[1] + 1))

        # print(next_pos, q)

        for pos in next_pos:
            maze[pos[0]][pos[1]] = "#"
            q.append((pos, depth + 1))

    return -1


kaisuu = 0
for s in itertools.product(range(H), range(W)):
    for g in itertools.product(range(H), range(W)):
        if s == g or S[s[0]][s[1]] == "#" or S[g[0]][g[1]] == "#":
            continue

        maze = copy.deepcopy(S)
        k = bfs(maze, s, g)
        kaisuu = max(kaisuu, k)

print(kaisuu)


Fixed submission:
from collections import deque
import copy


H, W = map(int, input().split())
S = [list(input()) for i in range(H)]


def bfs(maze, start):
    q = deque()
    q.append((start, 0))

    max_depth = 0

    while len(q) > 0:
        p, depth = q.popleft()

        if p[0] < 0 or H <= p[0]:
            continue
        if p[1] < 0 or W <= p[1]:
            continue
        if maze[p[0]][p[1]] == "#":
            continue

        maze[p[0]][p[1]] = "#"
        max_depth = depth

        next_pos = [
            (p[0]-1, p[1]),
            (p[0]+1, p[1]),
            (p[0], p[1]-1),
            (p[0], p[1]+1),
        ]

        for pos in next_pos:
            q.append((pos, depth+1))

    return max_depth


depth = 0
for h in range(H):
    for w in range(W):
        maze = copy.deepcopy(S)
        depth = max(depth, bfs(maze, (h, w)))

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


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


A, B = map(int, input().split())

print(lcm(A, B))


Fixed submission:
import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


A, B = map(int, input().split())

print(lcm(A, B))
Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys


sys.setrecursionlimit(1000000)

X, Y = map(int, input().split())

# いけない
if (X + Y) % 3 != 0:
    print(0)
    exit()
if 2*Y < X:
    print(0)
    exit()
if Y > 2*X:
    print(0)
    exit()

# 何段目
dan = (X + Y) // 3

# 端から
x = X + Y
y = 0
while True:
    x -= 1
    y += 1
    if x - 2*y == 0:
        break


def comb(n, r):
    return (math.factorial(n)) // (math.factorial(n - r) * math.factorial(r))


dic = {}


# def comb(n, r, d):
#     if r == 0 or r == n:
#         return 1
#     if r == 1:
#         return n
#     if (n, r) in d:
#         return d[(n, r)]
#     d[(n, r)] = comb(n-1, r, d) + comb(n-1, r-1, d)
#     return d[(n, r)]


print(comb(dan, x - X) % 1000000007)


Fixed submission:
import math
import sys


sys.setrecursionlimit(1000000)

X, Y = map(int, input().split())

# いけない
if (X + Y) % 3 != 0:
    print(0)
    exit()
if 2*Y < X:
    print(0)
    exit()
if Y > 2*X:
    print(0)
    exit()

# 何段目
dan = (X + Y) // 3

# 端から
x = X + Y
y = 0
while True:
    x -= 1
    y += 1
    if x - 2*y == 0:
        break


def comb(n, r):
    return (math.factorial(n)) // (math.factorial(n - r) * math.factorial(r))


dic = {}


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

# print(comb(dan, x - X) % 1000000007)
print(cmb(dan, x - X, mod))
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import math

A, B = map(int, input().split())
saidai = fractions.gcd(A, B)

kosuu = 1  # 1

if saidai % 2 == 0:
    kosuu += 1

while saidai % 2 == 0:
    saidai = saidai // 2

for i in range(3, 100000000000000000000, 2):
    if saidai <= 1:
        break

    if saidai % i == 0:
        kosuu += 1

    while saidai % i == 0:
        saidai = saidai // i

print(kosuu)


Fixed submission:
import fractions
import math

A, B = map(int, input().split())
gcd = fractions.gcd(A, B)
saidai = gcd

kosuu = 1  # 1

if saidai % 2 == 0:
    kosuu += 1

while saidai % 2 == 0:
    saidai = saidai // 2

# sqrt = int(math.sqrt(gcd))
# for i in range(3, sqrt+1+1, 2):
#     if saidai <= 1:
#         break

#     if saidai % i == 0:
#         kosuu += 1

#     while saidai % i == 0:
#         saidai = saidai // i

i = 3
while True:
    if saidai <= 1:
        break

    if i > math.sqrt(saidai):
        break

    if saidai % i == 0:
        kosuu += 1

    while saidai % i == 0:
        saidai = saidai // i

    i += 2

if saidai != 1:
    kosuu += 1

print(kosuu)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

inf = 1e9+7
dp = [inf] * (1 << N)
dp[0] = 0

for m in range(M):
    a, b = map(int, input().split())

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

    mask = sum(1 << (c-1) for c in hako)

    for i in range(1 << N):
        dp[i | mask] = min(dp[i | mask], dp[i] + a)

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])


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

inf = 1e9+7
dp = [inf] * (1 << N)
dp[0] = 0

for m in range(M):
    a, b = map(int, input().split())

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

    mask = sum(1 << (c-1) for c in hako)

    for i in range(1 << N):
        if dp[i] + a < dp[i | mask]:
            dp[i | mask] = dp[i] + a

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])
Buggy python submission (verdict: Runtime Error):
N = int(input().split())

print(N * N * N)


Fixed submission:
N = int(input())

print(N * N * N)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = list(input())

hikkuri = 0

for i in range(len(S) - 1):
    if S[i] != S[i + 1]:
        hikkuri += 1

shiawase = len(S) - hikkuri - 1

for i in range(K):
    if hikkuri >= 2:
        shiawase += 2
        hikkuri -= 2
    elif hikkuri == 1:
        shiawase += 1
        break

print(shiawase)N, K = map(int, input().split())
S = list(input())

hikkuri = 0

for i in range(len(S) - 1):
    if S[i] != S[i + 1]:
        hikkuri += 1

shiawase = len(S) - hikkuri - 1

for i in range(K):
    if hikkuri >= 2:
        shiawase += 2
        hikkuri -= 2
    elif hikkuri == 1:
        shiawase += 1
        break

print(shiawase)

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

hikkuri = 0

for i in range(len(S) - 1):
    if S[i] != S[i + 1]:
        hikkuri += 1

shiawase = len(S) - hikkuri - 1

for i in range(K):
    if hikkuri >= 2:
        shiawase += 2
        hikkuri -= 2
    elif hikkuri == 1:
        shiawase += 1
        break

print(shiawase)
Buggy python submission (verdict: Runtime Error):
r = int(input())
print(3*a*a)


Fixed submission:
r = int(input())
print(3*r*r)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

A = []
for _ in range(M):
    A.append(int(input()))

step = [0 for _ in range(N+1)]

step[0] = 1
if 1 not in A:
    step[1] = 1

if len(A) != 0 and A[0] == 1:
    A = A[1:]

for i in range(2, N+1):
    if len(A) != 0 and i == A[0]:
        A = A[1:]
    else:
        step[i] = step[i-1] + step[i-2]


print(step[N] % (10**9+7))


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

A = []
for _ in range(M):
    A.append(int(input()))

step = [0 for _ in range(N+1)]

ptr = 0

step[0] = 1
step[1] = 1
if ptr < M and A[ptr] == 1:
    step[1] = 0
    ptr += 1

for i in range(2, N+1):
    if ptr < M and i == A[ptr]:
        ptr += 1
    else:
        step[i] = step[i-1] + step[i-2]


print(step[N] % (10**9+7))

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

A = []
for _ in range(M):
    A.append(int(input()))

step = [0 for _ in range(N+1)]

step[0] = 1
if 1 not in A:
    step[1] = 1

for i in range(2, N+1):
    if i in A:
        pass
    else:
        step[i] = step[i-1] + step[i-2]


print(step[N] % (10**9+7))


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

A = []
for _ in range(M):
    A.append(int(input()))

step = [0 for _ in range(N+1)]

ptr = 0

step[0] = 1
step[1] = 1
if ptr < M and A[ptr] == 1:
    step[1] = 0
    ptr += 1

for i in range(2, N+1):
    if ptr < M and i == A[ptr]:
        ptr += 1
    else:
        step[i] = step[i-1] + step[i-2]


print(step[N] % (10**9+7))
Buggy python submission (verdict: Runtime Error):
# from fractions import gcd
from math import gcd

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

L = [0 for _ in range(N+1)]
R = [0 for _ in range(N+1)]


for i in range(N):
    L[i+1] = gcd(L[i], A[i])

for i in reversed(range(N)):
    R[i] = gcd(R[i+1], A[i])

M = [0 for _ in range(N)]

for i in range(N):
    M[i] = gcd(L[i], R[i+1])

print(max(M))


Fixed submission:
from fractions import gcd

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

L = [0 for _ in range(N+1)]
R = [0 for _ in range(N+1)]


for i in range(N):
    L[i+1] = gcd(L[i], A[i])

for i in reversed(range(N)):
    R[i] = gcd(R[i+1], A[i])

M = [0 for _ in range(N)]

for i in range(N):
    M[i] = gcd(L[i], R[i+1])

print(max(M))
Buggy python submission (verdict: Runtime Error):
N = int(input()
H = list(map(int, input().split()))

dp = [0] * N

for i in range(1, N):
	if i == 1:
		dp[i] = dp[0] + abs(H[i] - H[0])
	else:
		dp[i] = min(dp[i-2] + abs(H[i] - H[i-2]), dp[i-1] + abs(H[i] - H[i-1]))

return dp[-1]


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, h: "List[int]"):
    dp = [0] * N
    dp[0] = 0
    dp[1] = dp[0] + abs(h[1] - h[0])
    for i in range(2, N):
        dp[i] = min(
            dp[i-1] + abs(h[i] - h[i-1]),
            dp[i-2] + abs(h[i] - h[i-2]),
        )

    print(dp[-1])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, h)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, h: "List[int]"):
    dp = [float("inf")] * N
    dp[0] = 0
    dp[1] = abs(h[0] - h[1])

    for i in range(2, N):
        for k in range(1, K+1):
            if i - k < 0:
                continue
            dp[i] = min(dp[i], dp[i-k] + abs(h[i] - h[i-k]))

    print(dp[-1])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, h: "List[int]"):
    dp = [float("inf")] * N
    dp[0] = 0
    dp[1] = abs(h[0] - h[1])

    for i in range(2, N):
        for k in range(1, K+1):
            if i - k < 0:
                continue
            dp[i] = min(dp[i], dp[i-k] + abs(h[i] - h[i-k]))

    print(dp[-1])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)


if __name__ == '__main__':
    main()