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

Fixed submission:
import sys
import copy


N, M = map(int, input().split())

V = []
E = []

for i in range(N):
    V.append(set())

seen = []
seen = [False] * N

count = 0
def dfs(node):
    global V
    global seen

    #注目ノードは訪問済みか?
    if seen[node]==True:
        return
    
    seen[node]=True

    for next_node in V[node]:
        dfs(next_node)
    return

for i in range(M):
    *l,  = map(int, input().split())
    V[l[0]-1].add(l[1]-1)
    V[l[1]-1].add(l[0]-1)
    E.append([l[0]-1, l[1]-1])



E_copy = copy.deepcopy(E)
V_copy = copy.deepcopy(V)
seen_copy = copy.deepcopy(seen)


for i in range(M):
    e = [E[i][0], E[i][1]]
    
    V[e[0]].remove(e[1])
    V[e[1]].remove(e[0])
    
    dfs(0)
    if (False in seen):
        count = count + 1
    seen = [False] * N
    V = copy.deepcopy(V_copy)
   
print(count)

Buggy submission (verdict: Runtime Error):
import sys
import copy

N, M = map(int, input().split())

V = []
E = []

for i in range(N):
    V.append(set())

for i in range(M):
    *l,  = map(int, input().split())
    V[l[0]-1].add(l[1]-1)
    V[l[1]-1].add(l[0]-1)
    E.append([l[0], l[1]])

count = 0


E_copy = copy.deepcopy(E)
V_copy = copy.deepcopy(V)

for i in range(M):
    e = [E[i][0], E[i][1]]

	V[e[0]].remove(e[1])
    V[e[1]].remove(e[0])
    
    #辺が存在しないノードがあるかをチェックする。
    for v in V:
        if len(v)==0:
            count = count + 1
            break
    
    E = copy.deepcopy(E_copy)
    V = copy.deepcopy(V_copy)
   
print(count)
Problem p03659 (python)

Fixed submission:
import sys

N= int(input())

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


S = [0]*(len(A)+1)

for i in range(1, len(S), 1):

    S[i] = S[i-1] + A[i-1]

x = 0
y = 0
min = float('inf')

for i in range(1, N, 1):
    x = S[i]
    y = S[len(S)-1] - S[i]

    if min > abs(x-y):
        min = abs(x-y)
print(min)

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())

*A,  = map(int, input().split())
A    = np.array(A)
min = float('INF')

for i in range(N-1):

    min_temp = (np.abs(np.sum(A)-2*np.sum(A[0:i+1]))
    if min_temp < min:
        min = min_temp

print(min)
Problem p03681 (python)

Fixed submission:
import math

def f(n):
    if n==1:
        return 1
    return n*f(n-1)

N,M = map(int, input().split())

if abs(N-M)>=2:
    print(0)
elif abs(N-M)==1:
    print(math.factorial(N)*math.factorial(M)%(10**9+7))
else:
    print((2*math.factorial(N)*math.factorial(M))%(10**9+7))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

def f(n):
    if n==1:
        return 1
    return n*f(n-1)

N,M = map(int, input().split())

if abs(N-M)>=2:
    print(0)
elif abs(N-M)==1:
    print(f(N)*f(M))
else:
    print((2*f(N)*f(M))%(10**9+7))
Problem p03760 (python)

Fixed submission:
O = list(input())
E = list(input())+[""]

for x,y in zip(O,E):
    print(x,y,sep="",end="")

Buggy submission (verdict: Runtime Error):
O = input()
E = input()

j = 0
k = 0

for i in range(len(O)*2):
  if i % 2 ==0:
    print(E[j],end="")
    j = j + 1
  else:
    print(O[k],end="")
    k = k + 1
Problem p03853 (python)

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

C = []

for _ in range(H):
    l = list(input())
    C.append(l)
D = []
for i in range(2*H):
    l = []
    for j in range(W):
        l.append(C[i//2][j])

    D.append(l)

for i in range(len(D)):
    print(*D[i],sep="")

Buggy submission (verdict: Runtime Error):
H,W = map(int, input().split())

C = []

for _ in range(H):
    l = list(input()
    C.append(l)
D = []
for i in range(2*H):
    l = []
    for j in range(W):
        l.append(C[i//2][j])

    D.append(l)

for i in range(len(D)):
    print(*D[i],sep="")
Problem p03860 (python)

Fixed submission:
S = input().split()

print(S[0][0]+S[1][0]+S[2][0])

Buggy submission (verdict: Runtime Error):
A,B,C = input()

print("A"+B[0]+"C")
Problem p03999 (python)

Fixed submission:
import sys
import copy



S = input()
op_list = ["+"]*(len(S)-1)

sum = 0
for i in range(2**len(op_list)):
    op_list = ["+"]*(len(S)-1)
    for j in range(len(op_list)):

        if (i >> j) & 1:
            op_list[j] = ""
    s = ""
    for k in range(len(op_list)):
        s = s + S[k] + op_list[k]
    s = s + S[len(S)-1]
    sum = sum + eval(s)


print(sum)

Buggy submission (verdict: Runtime Error):
import sys
import copy



S = input()
op_list = ["+"]*(len(S)-1)

sum = 0
for i in range(2**len(op_list)):

    for j in range(len(op_list)):

        if (i >> j) & 1:
            op_list[j] = ""
    s = ""
    for k in range(len(op_list)):
        s = s + S[k] + op_list[k]
    sum = sum + eval(s)


print(sum)
Problem p04001 (python)

Fixed submission:
import sys

S = list(input())

sum = 0
for i in range(2**(len(S)-1)):

    op_list = ['+']*(len(S)-1)

    for j in range(len(S)-1):
        if (i>>j) & 1:
            op_list[j] = ''


    s = ""
    for st_index in range(len(op_list)):
        s = s + S[st_index] + op_list[st_index]
    s = s + S[len(S)-1]
    result = eval(s)
    
    sum = sum + result

print(sum)

Buggy submission (verdict: Runtime Error):
import sys

S = input()

N = len(S)-1
sum = 0

for i in range(2**N):

    op = [""]*(N)
    for j in range(N):
        if (i>>j)&1:
            op[j] = "+"
    s = ""
    for j in range(N):
        s = s + S[j] + op[j]
    s = s + S[j]
    sum = sum + eval(s)
print(sum)
Problem p04044 (python)

Fixed submission:
n, l = map(int, input().split())
s=sorted([input() for i in range(n)])
print(*s,sep="")

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())

A    = sorted([input for _ in range(N)])

print(*A, sep="")
Problem p02717 (python)

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

(x, y, z) = input().strip().split()
(x,y) = (y,x)
(x,z) = (z,x)
print('{} {} {}'.format(x, y, z))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

(x, y, z) = input().strip().split()
(x,y) = (y,x)
(x,z) = (z,x)
print(f'{x} {y} {z}')
Problem p03220 (python)

Fixed submission:
import sys
 
def solve(N, T, A, ls_H):
    return min([(abs(A - (T - h * 0.006)), i) for (i, h) in enumerate(ls_H, start=1)])[1]
 
def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)
 
def main():
    print(solve(*readQuestion()))
 
# Uncomment before submission
main()

Buggy submission (verdict: Runtime Error):
import sys

def solve(N, T, A, ls_H):
    dosi = []
    titen = []
    titen1 = []
    ti = 100000 * 1000
    for x in ls_H :
        do = 1000 * T - x * 6
        dosi.append(do)
    # print(dosi)
    
    for y in dosi :
        ti = 1000 * A - y
        titen.append(ti)
    # print(titen)
    
    for z in titen :
        titen1.append(abs(z))
    # print(titen1)
    
    for i in titen1 :
        if ti > i :
            ti = i
    # print(ti)
    return titen1.index(ti) + 1
 
 
def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)
 
def main():
    print(solve(*readQuestion()))
 
# Uncomment before submission
main()

Buggy submission (verdict: Runtime Error):
def solve(N, T, A, ls_H):
    dosi = []
    titen = []
    titen1 = []
    ti = 100000 * 1000
    for x in ls_H :
        do = 1000 * T - x * 6
        dosi.append(do)
    #print(dosi)
    
    for y in dosi :
        ti = 1000 * A - y
        titen.append(ti)
    #print(titen)
    
    for z in titen :
        titen1.append(abs(z))
    #print(titen1)
    
    for i in titen1 :
        if ti > i :
            ti = i
    #print(ti)
    return titen1.index(ti) + 1
 
 
def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)
 
def main():
    print(solve(*readQuestion()))
 
# Uncomment before submission
main()

Buggy submission (verdict: Runtime Error):
def solve(N, T, A, ls_H):
    dosi = []
    titen = []
    titen1 = []
    ti = 100000
    for x in ls_H :
        do = T - x * 0.006
        dosi.append(do)
    #print(dosi)
    
    for y in dosi :
        ti = A - y
        titen.append(ti)
    #print(titen)
    
    for z in titen :
        titen1.append(abs(z))
    #print(titen1)
    
    for i in titen1 :
        if ti > i :
            ti = i
    #print(ti)
    return titen1.index(ti) + 1
 
 
def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)
 
def main():
    print(solve(*readQuestion()))
 
# Uncomment before submission
main()
Problem p03043 (python)

Fixed submission:
import math
from fractions import Fraction

ans = 0
N, K = map(int, input().split())
for i in range(1,N+1):
	ans += Fraction(1,2**(math.ceil(math.log2(max(1,K/i)))))
ans = float(ans/N)
print('{:.10f}'.format(ans))

Buggy submission (verdict: Runtime Error):
import math
from fractions import Fraction

ans = 0
N, K = map(int, input().split())
for i in range(1,N+1):
	ans += Fraction(1,2**(math.ceil(math.log2(max(1,K/i)))))
ans = float(ans/N)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
from fractions import Fraction

ans = 0
N, K = map(int, input().split())
for i in range(N):
	ans += Fraction(1,N)*Fraction(1,2**math.ceil(math.log2(K/(i+1))))
print(float(ans))

Buggy submission (verdict: Runtime Error):
import math

ans = 0
N,K = input().split()
for i in range(N):
	ans += Fraction(1,N)*Fraction(1,math.ceil(math.log2(K/(i+1))))
print(float(ans))

Buggy submission (verdict: Runtime Error):
import math

ans = 0
N,K = input().split()
for i in range(N)
	ans += Fraction(1,N)*Fraction(1,math.ceil(math.log2(K/(i+1))))
print(float(ans))
Problem p03102 (python)

Fixed submission:
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
ans = 0
for i in range(N):
  A = list(map(int,input().split()))
  tmp = 0
  for j in range(M):
    tmp += A[j]*B[j]
  if tmp + C > 0:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
ans = 0
for i in range(N):
  A = list(map(int,input().split()))
  tmp = 0
  for j in range(M):
    tmp += A[i]*B[i]
  if tmp + C > 0:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
ans = 0
for i in range(N):
  A = list(map(int,input().split()))
  if sum(A*B) + C > 0:
    ans += 1
print(ans)
Problem p03105 (python)

Fixed submission:
A,B,C = map(int,input().split())
print(min(B//A,C))

Buggy submission (verdict: Runtime Error):
A,B,C = map(int,input())
print(max(B//A,C))

Buggy submission (verdict: Runtime Error):
A,B,C = map(int,input())
print(B//A,C)
Problem p02812 (python)

Fixed submission:
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
INF = float('inf')


N = int(input())
S = input()

ans = 0
i = 0
while i < N:
    if S[i] == "A":
        if i +1 < N:
            i += 1
            if S[i] == "B":
                if i + 1 < N:
                    i += 1
                    if S[i] == "C":
                        ans += 1
                        if i + 1 < N:
                            i+=1
                        else:
                            break
                    else:
                        continue
                else:
                    break
            else:
                continue
        else:
            break
    else:
        i += 1
        continue


print(ans)

Buggy submission (verdict: Runtime Error):
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
INF = float('inf')


N = int(input())
S = input()

ans = 0
i = 0
while i < N:
    if S[i] == "A":
        i += 1
        if S[i] == "B":
            i += 1
            if S[i] == "C":
                ans += 1
                i+=1
            else:
                continue
        else:
            continue
    else:
        i += 1
        continue


print(ans)
Problem p02903 (python)

Fixed submission:
H,W,A,B = map(int,input().split())
temp = ""
for l in range(0,W):
    temp = temp + "0"


Alist = list()
for k in range(0,H):
    Alist.append(list(temp))


for i in range(0,H):
    for j in range(0,W):
        if i < B and j < A :
            Alist[i][j] = "1"
        elif j >= A and i<B:
            Alist[i][j] = "0"
        elif i >= B and j < A :
            Alist[i][j] = "0"
        else:
            Alist[i][j] = "1"

for a in Alist:
    print(''.join(a))

Buggy submission (verdict: Runtime Error):
H,W,A,B = map(int,input().split())
temp = ""
for l in range(0,W):
    temp = temp + "0"


Alist = list()
for k in range(0,H):
    Alist.append(list(temp))


for i in range(0,H):
    for j in range(0,W):
        if i < B and j < A :
            Alist[i][j] = 1
        elif j >= A and i<B:
            Alist[i][j] = 0
        elif i >= B and j < A :
            Alist[i][j] = 0
        else:
            Alist[i][j] = 1

for a in Alist:
    print(''.join(a))
Problem p03160 (python)

Fixed submission:
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
INF = float('inf')

N = int(input())

hlist = inpl()

dp = [INF]*N

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

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())


def frog(i, now_cost):
    if dp[i][now_cost] != 10**5:
        dp[i][now_cost] = min(dp[i][now_cost], now_cost)
    else:
        dp[i][now_cost] = now_cost
        if i+1 < N:
            frog(i+1,now_cost+abs(hlist[i+1]-hlist[i]))
        if i+2 < N:
            frog(i+2,now_cost+abs(hlist[i+2]-hlist[i]))


N = int(input())
hlist = inpl()
dp=list()
for _ in range(N):
    dp.append([10 ** 5] * sum(hlist))

frog(0,0)

print(min(dp[N-1]))
Problem p03161 (python)

Fixed submission:
import numpy as np
import sys
def inpl(): return list(map(int, sys.stdin.readline().split()))
INF = float('inf')

N,K = inpl()

hlist = np.array(inpl())

dp = np.full(N,INF)

dp[0]=0

for i in range(1,N):
    s = max(0,i-K)
    dp[i] = np.min(dp[s:i]+abs(hlist[i]-hlist[s:i]))

print(int(dp[N-1]))

Buggy submission (verdict: Runtime Error):
import numpy as np
def inpl(): return list(map(int, sys.stdin.readline().split()))
INF = float('inf')

N,K = inpl()

hlist = np.array(inpl())

dp = np.full(N,INF)

dp[0]=0

for i in range(1,N):
    s = max(0,i-K)
    dp[i] = np.min(dp[s:i]+abs(hlist[i]-hlist[s:i]))

print(int(dp[N-1]))

Buggy submission (verdict: Runtime Error):
import sys,queue,copy,heapq
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
INF = float('inf')

N,K = inpl()

hlist = inpl()

dp = [INF for _ in range(N)]

dp[0]=0

for i in range(1,N):
    for j in range(1,K+1):
        if i-j < 0:
            break
        dp[i]=dp[i-j]+abs(hlist[i]-hlist[i-j])


print(dp[N-1][0])
Problem p02994 (python)

Fixed submission:
import itertools

def input_ints():
    return list(map(int, input().split()))

def output_list(v):
    print(' '.join(str(x) for x in v))

def main():
    n, l = input_ints()
    a = [x for x in range(l, l + n)]
    ans = sum(a)
    if a[-1] < 0:
        ans -= a[-1]
    if a[0] > 0:
        ans -= a[0]
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import itertools

def input_ints():
    return list(map(int, input().split()))

def output_list(v):
    print(' '.join(str(x) for x in v))

def main():
    n, l = input_ints()
    a = [*range(l, l + n)]
    ans = sum(a)
    if a[-1] < 0:
        ans -= a[-1]
    if a[0] > 0:
        ans -= a[0]
    print(ans)

if __name__ == '__main__':
    main()
Problem p03061 (python)

Fixed submission:
from fractions import gcd

def input_ints():
    return list(map(int, input().split()))

def main():
    n = int(input())
    a = input_ints()
    x = [a[0]]
    y = [a[-1]]
    for i in range(n-1):
        x.append(gcd(x[-1], a[i + 1]))
        y.append(gcd(y[-1], a[n - i - 2]))
    ans = max(x[-2],y[-2])
    for i in range(1, n-1):
        ans = max(ans,gcd(x[i-1],y[-i-2]))
    print(ans)
    

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from fraction import gcd

def input_ints():
    return list(map(int, input().split()))

def main():
    n = int(input())
    a = input_ints()
    x = [a[0]]
    y = [a[-1]]
    for i in range(n-1):
        x.append(gcd(x[-1], a[i + 1]))
        y.append(gcd(y[-1], a[n - i - 2]))
    ans = max(x[-2],y[-2])
    for i in range(1, n-1):
        ans = max(ans,gcd(x[i-1],y[-i-1]))
    print(ans)
    

if __name__ == '__main__':
    main()
Problem p03260 (python)

Fixed submission:
a, b = map(int, input().split())
if (a * b) % 2 == 0:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input.split())
if (a * b) % 2 == 0:
  print("No")
else:
  print("Yes")
Problem p02576 (python)

Fixed submission:
n,x,t=input().split()
n=int(n)
x=int(x)
t=int(t)
q,mod=divmod(n,x)
if mod==0:
  print(q*t)
else:
  print((q+1)*t)

Buggy submission (verdict: Runtime Error):
n,x,t=input().split()
n=int(n)
x=int(x)
t=int(t)
q,mod=divmod(n,x)
if amari==0:
  print(q*t)
else:
  print(q*(t+1))
Problem p02584 (python)

Fixed submission:
x,k,d=list(map(int,input().split()))
x=abs(x)
syou, amari = divmod(abs(x),d)
if x>0:
    if x-k*d==0:
        print(0)
    elif x-k*d<0:
        if amari==0:
            newk=k-syou
            if newk%2==0:
                print(0)
            else:
                print(d)
        elif amari!=0:
            newk=k-syou+1
            if newk%2==0:
                print(abs(x-d*(syou+1)))
            else:
                print(abs(x-d*syou))
    elif x-k*d>0:
        print(abs(x-k*d))
if x==0:
    if k%2==0:
        print(0)
    else:
        print(d)

Buggy submission (verdict: Runtime Error):
x,k,d=list(map(int,input.split()))
syou, amari = divmod(x,d)
if x>0:
    if x-k*d==0:
        print(0)
    elif x-k*d<0:
        if amari==0:
            newk=k-syou
            if newk%2==0:
                print(0)
            else:
                print(d)
        elif amari!=0:
            newk=k-syou+1
            if newk%2==0:
                print(abs(x-d*(syou+1)))
            else:
                print(abs(x-d*syou))
    elif x-k*d>0:
        print(abs(x-k*d))
if x==0:
    if k%2==0:
        print(0)
    else:
        print(d)
Problem p02612 (python)

Fixed submission:
N=int(input())
quotient=N//1000
for i in range(quotient+1):
    N=N-1000
    if N<=0:
        break
print(abs(N))

Buggy submission (verdict: Runtime Error):
N=int(input)
quotient=N//1000
for i in range(quotient+1):
    N=N-1000
    if N<=0:
        break
print(abs(N))

Buggy submission (verdict: Runtime Error):
N=int(input())
quotient=N//1000
for i in range(quotient+1):
  change=N-1000
  if change=<0:
    change=abs(change)
    print(change)
  else:
    continue
Problem p02657 (python)

Fixed submission:
A,B=input().strip().split()
A,B=[int(A),int(B)]    
if A>=1 and A<=100:
    if B>=1 and B<=100:
        print(A*B)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
cal=1
i=0
while i < len(A):
    cal*=A[i]
    i+=1
if cal>=10**18:
        print(-1)
else:
        print(cal)

Buggy submission (verdict: Runtime Error):
A,B=input().strip().split()
if A>=1 and A<=100 and B>=1 and B<=100:
    A*B

Buggy submission (verdict: Runtime Error):
def cal(A,B):
    return A*B
cal(A,B)
Problem p02658 (python)

Fixed submission:
n = int(input())
m = list(map(int, input().split()))
ans = 1
if min(m) == 0:
    print(0)
else:
    m.sort(reverse=True)
    for i in m:
        ans *= i
        if ans > 1000000000000000000:
            ans = -1
            break
    print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
cal=1
i=0
while i <= range(N):
    cal*=A[i]
    i+=1
if cal>=10**18:
        print(-1)
else:
        print(cal)

Buggy submission (verdict: Runtime Error):
N=int(input())
if N>=2 and N<=10**5:
    array = list(map(int, input().strip().split()))
    if N==len(array):
        if array[0]>=0 and array[-1]<=10**18:
            mul=1
            for i in array:
                mul*=array[i-1]
            if mul>=10**18:
               print(-1)
            else:
                print(mul)

Buggy submission (verdict: Runtime Error):
N=int(input())
if N>=2 and N<=10**5:
    array=list(map(int,input().strip().split()))
    if range(array)==N:
        if array[0]>=0 and array[-1]<=10**18:
            multipul=1
            for i in len(array-1):
                multipul=multipul*array[i]
            print(multipul)

Buggy submission (verdict: Runtime Error):
N=int(input())
if N>=2 and N<=10**5:
    array=list(map(int,input().strip().split()))
    if array[0]>=0 and array[-1]<=10**18:
        multipul=1
        for i in len(array-1):
            multipul=multipul*array[i]
        print(multipul)
Problem p02537 (python)

Fixed submission:
class SegmentTree:
    def __init__(self, n, op, e):
        self.n = 1 << (n - 1).bit_length()
        self.op = op
        self.e = e
        self.data = [e] * (2 * self.n)

    def update(self, k, v):
        k += self.n
        self.data[k] = v
        while k > 0:
            k >>= 1
            self.data[k] = self.op(self.data[2 * k], self.data[2 * k + 1])

    def query(self, left, right):
        left += self.n
        right += self.n
        l_res = self.e
        r_res = self.e
        while left < right:
            if left & 1:
                l_res = self.op(l_res, self.data[left])
                left += 1
            left >>= 1
            if right & 1:
                right -= 1
                r_res = self.op(self.data[right], r_res)
            right >>= 1
        return self.op(l_res, r_res)


N, K, *A = map(int, open(0).read().split())
t = SegmentTree(650_000, max, 0)
ans = 0
for a in A:
    t.update(a, 1 + t.query(max(0, a - K), min(a + K, 300_000) + 1))
print(t.query(0, 300_001))

Buggy submission (verdict: Runtime Error):
class SegmentTree:
    def __init__(self, n, op, e):
        self.n = 1 << (n - 1).bit_length()
        self.op = op
        self.e = e
        self.data = [e] * (2 * self.n)

    def update(self, k, v):
        k += self.n
        self.data[k] = v
        while k > 0:
            k >>= 1
            self.data[k] = self.op(self.data[2 * k], self.data[2 * k + 1])

    def query(self, left, right):
        left += self.n
        right += self.n
        l_res = self.e
        r_res = self.e
        while left < right:
            if left & 1:
                l_res = self.op(l_res, self.data[left])
                left += 1
            left >>= 1
            if right & 1:
                right -= 1
                r_res = self.op(self.data[right], r_res)
            right >>= 1
        return self.op(l_res, r_res)


N, K, *A = map(int, open(0).read().split())
t = SegmentTree(400_000, max, 0)
dp = [1] * N
ans = 0
for i in range(N):
    a = A[i]
    t.update(a, 1 + t.query(max(1, a - K), a + K + 1))
print(t.query(0, 400_000))