Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,D = map(input().split())
print(N//(2*D+1))

Fixed submission:
N,D = map(int, input().split())
print(N//(2*D+1) if N%(2*D+1)==0 else N//(2*D+1)+1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
d = list(map(int, input().split()))
d.sort()
S = sum(d)
if not d[N/2 - 1] < S/N <= d[N/2 + 1]:
  print(0)
elif:
  A = 0
  for i in range(d[N/2 + 1]-d[N/2 - 1]):
    d[N/2 - 1] + i+1 <= d[N/2 + 1]
    A += 1
  print(A)

Fixed submission:
N = int(input())
d = list(map(int, input().split()))
d.sort()
S = sum(d)
print(d[N//2]-d[N//2 - 1])
Buggy python submission (verdict: Runtime Error):
S = list(input())
if S[0]==s[1] or S[1]==S[2] or S[2]==S[3]:
  print('Bad')
else:
  print('Good')

Fixed submission:
S = list(input())
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
  print('Bad')
else:
  print('Good')
Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
S = input()
print(S[:,K+1]+S[K+1].lower()+S[K+2,:])

Fixed submission:
N,K = map(int, input().split())
S = input()
print(S[:K-1]+S[K-1].lower()+S[K:])
Buggy python submission (verdict: Runtime Error):
N = list(input())
N.append(0)
for i in range(len(N)-1):
  if N[i] in'ACGT':
    N[i] += 1
    N[i+1] = N[i]
  else:
    N[i] = 0
print(max(N))

Fixed submission:
N = list(input())
dp = [0]*(len(N)+1)
for i in range(len(N)):
  if N[i] in'ACGT':
    dp[i] += 1
    dp[i+1] = dp[i]
  else:
    dp[i] = 0
print(max(dp))

Buggy python submission (verdict: Runtime Error):
N = list(input())
N.appnd('Z')
for i in range(len(N)-1):
  if N[i] in'ACGT':
    N[i] += 1
    N[i+1] = N[i]
  else:
    N[i] = 0
print(max(N))


Fixed submission:
N = list(input())
dp = [0]*(len(N)+1)
for i in range(len(N)):
  if N[i] in'ACGT':
    dp[i] += 1
    dp[i+1] = dp[i]
  else:
    dp[i] = 0
print(max(dp))

Buggy python submission (verdict: Runtime Error):
N = list(input())
for i in range(len(N)+1):
  if N[i] in'ACGT':
    N[i] += 1
    N[i+1] = N[i]
  else:
    N[i] = 0
print(max(N))


Fixed submission:
N = list(input())
dp = [0]*(len(N)+1)
for i in range(len(N)):
  if N[i] in'ACGT':
    dp[i] += 1
    dp[i+1] = dp[i]
  else:
    dp[i] = 0
print(max(dp))

Buggy python submission (verdict: Runtime Error):
N = list(input())
for i in range(len(N)):
  if N[i] in'ACGT':
    N[i] += 1
    N[i+1] = N[i]
  else:
    N[i] = 0
print(max(N))

Fixed submission:
N = list(input())
dp = [0]*(len(N)+1)
for i in range(len(N)):
  if N[i] in'ACGT':
    dp[i] += 1
    dp[i+1] = dp[i]
  else:
    dp[i] = 0
print(max(dp))

Buggy python submission (verdict: Runtime Error):
N = list(input)
for i in range(len(N)):
  if N[i] in'ACGT':
    N[i] += 1
    N[i+1] = N[i]
print(max(N))

Fixed submission:
N = list(input())
dp = [0]*(len(N)+1)
for i in range(len(N)):
  if N[i] in'ACGT':
    dp[i] += 1
    dp[i+1] = dp[i]
  else:
    dp[i] = 0
print(max(dp))
Buggy python submission (verdict: Runtime Error):
N, x = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
  if x < min(A):
    print(cnt)
    break
  elif i == N-1 and A[i]-x > 0:
    print(N-1)
  elif i == N-1 and A[i]-x == 0:
    print(N)
  else:
    x -= min(A)
    A.remove(min(A))
    cnt += 1

Fixed submission:
N, x = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
  if x < min(A):
    print(cnt)
    break
  elif i == N-1 and x-A[0] > 0:
    print(N-1)
    break
  elif i == N-1 and x-A[0] == 0:
    print(N)
    break
  else:
    x -= min(A)
    A.remove(min(A))
    cnt += 1

Buggy python submission (verdict: Runtime Error):
N, x = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
  if x < min(A):
    print(cnt)
    break
  elif i == N-1 and A[i]-x > 0:
    print(N-1)
  elif i == N-1 and A[i]-x == 0:
    print(N)
  else:
    x -= min(A)
    A.remove(min(A))
    cnt += 1


Fixed submission:
N, x = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
  if x < min(A):
    print(cnt)
    break
  elif i == N-1 and x-A[0] > 0:
    print(N-1)
    break
  elif i == N-1 and x-A[0] == 0:
    print(N)
    break
  else:
    x -= min(A)
    A.remove(min(A))
    cnt += 1
Buggy python submission (verdict: Runtime Error):
N, M, X = map(int, input().split())
A = list(map(int,input().split()))
A.append(N)
for i in range(M):
  if A[0] > X or A[M-1] < X:
    print(0)
  else A[i] < X < A[i+1]:
    print(min(i+1, M-i-1))


Fixed submission:
N, M, X = map(int, input().split())
A = list(map(int,input().split()))
for i in range(M-1):
  if A[0] > X or A[M-1] < X:
    print(0)
    break
  elif A[i] < X < A[i+1]:
    print(min(i+1, M-i-1))
    break

Buggy python submission (verdict: Runtime Error):
N, M, X = map(int, input().split())
A = list(map(int,input().split()))
A.append(N)
for i in range(M):
  if A[i] > X or A[M-1] < X:
    print(0)
  else A[i] < X < A[i+1]:
    print(min(i+1, M-i-1))


Fixed submission:
N, M, X = map(int, input().split())
A = list(map(int,input().split()))
for i in range(M-1):
  if A[0] > X or A[M-1] < X:
    print(0)
    break
  elif A[i] < X < A[i+1]:
    print(min(i+1, M-i-1))
    break
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
Alice = 0
Bob = 0
for i in range(N):
  if (i+1)%2 == 1:
    Alice += max(a)
    a.remove(max(a))
  else:
    bob += max(a)
    a.remove(ma(a))
print(Alice - Bob)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
Alice = 0
Bob = 0
for i in range(N):
  if (i+1)%2 == 1:
    Alice += max(a)
    a.remove(max(a))
  else:
    Bob += max(a)
    a.remove(max(a))
print(Alice - Bob)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = [ ]
c = 'non'
for i in A:
  B.append(list(bin(i)))
for i in range(10000):  
  for j in range(N):
    if B[j][-i-1] == '0':
      continue
    else:
      c = i
      break
  if c == 0:
    print(0)
    break
  elif c>0:
    print(i)
    break

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = [ ]
c = -1
for i in A:
  B.append(list(bin(i)))
for i in range(10000):  
  for j in range(N):
    if B[j][-i-1] == '0':
      continue
    else:
      c = i
      break
  if c == 0:
    print(0)
    break
  elif c>0:
    print(i)
    break
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
C = input()
D = [C[i:i+1] for i in range(N)]
AA = 0
BB = 0
for i in(D):
  if D[i] == 'c':
    print('No')
  elif D[i] =='a' and A+B > AA+BB:
    print('Yes')
    AA += 1
  elif D[i] =='a' and A+B > AA+BB and BB < B:
    print('Yes')
    BB += 1
  else:
    print('No')

Fixed submission:
N, A, B = map(int, input().split())
C = input()
D = [C[i:i+1] for i in range(N)]
AA = 0
BB = 0
for i in(D):
  if i == 'c':
    print('No')
  elif i =='a' and A+B > AA+BB:
    print('Yes')
    AA += 1
  elif i =='b' and A+B > AA+BB and BB < B:
    print('Yes')
    BB += 1
  else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(i) for i in input().split()]
arr={}
P={}
for a in A:
	if a in arr:
		arr[a]+=1
	else:
		arr[a]=1
for k,v in arr.items():
	P[k]=k*v
Q=int(input())
for q in range(Q):
	B,C=[int(i) for i in input().split()]
	if B in arr:
		if C in arr:
			arr[C]+=arr[B]
			P[C]+=arr[B]*C
		else:
			arr[C]=arr[B]
			P[C]=arr[B]*C
		del arr[B]
		del P[B]
	print(sum([i for i in P.values()]))


Fixed submission:
N=int(input())
A=[int(i) for i in input().split()]
arr={}
P={}
for a in A:
	if a in arr:
		arr[a]+=1
	else:
		arr[a]=1
for k,v in arr.items():
	P[k]=k*v
S=sum([i for i in P.values()])
Q=int(input())
for q in range(Q):
	B,C=[int(i) for i in input().split()]
	if B in arr:
		if C in arr:
			arr[C]+=arr[B]
			P[C]+=arr[B]*C
		else:
			arr[C]=arr[B]
			P[C]=arr[B]*C
		S-=P[B]
		S+=arr[B]*C
		del arr[B]
		del P[B]
	print(S)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(i) for i in input().split()]
arr={}
for a in A:
	if a in arr:
		arr[a]+=1
	else:
		arr[a]=1
Q=int(input())
for q in range(Q):
	B,C=[int(i) for i in input().split()]
	if B in arr:
		if C in arr:
			arr[C]+=arr[B]
		else:
			arr[C]=arr[B]
		del arr[B]
	print(sum([i[0]*i[1] for i in arr.items()]))


Fixed submission:
N=int(input())
A=[int(i) for i in input().split()]
arr={}
P={}
for a in A:
	if a in arr:
		arr[a]+=1
	else:
		arr[a]=1
for k,v in arr.items():
	P[k]=k*v
S=sum([i for i in P.values()])
Q=int(input())
for q in range(Q):
	B,C=[int(i) for i in input().split()]
	if B in arr:
		if C in arr:
			arr[C]+=arr[B]
			P[C]+=arr[B]*C
		else:
			arr[C]=arr[B]
			P[C]=arr[B]*C
		S-=P[B]
		S+=arr[B]*C
		del arr[B]
		del P[B]
	print(S)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(i) for i in input().split()]
arr={}
for a in A:
	if a in arr:
		arr[a]+=1
	else:
		arr[a]=1
Q=int(input())
for q in range(Q):
	B,C=[int(i) for i in input().split()]
	if B in arr:
		if C in arr:
			arr[C]+=arr[B]
		else:
			arr[C]=arr[B]
		arr[B]=0
	print(sum([i[0]*i[1] for i in arr.items()]))


Fixed submission:
N=int(input())
A=[int(i) for i in input().split()]
arr={}
P={}
for a in A:
	if a in arr:
		arr[a]+=1
	else:
		arr[a]=1
for k,v in arr.items():
	P[k]=k*v
S=sum([i for i in P.values()])
Q=int(input())
for q in range(Q):
	B,C=[int(i) for i in input().split()]
	if B in arr:
		if C in arr:
			arr[C]+=arr[B]
			P[C]+=arr[B]*C
		else:
			arr[C]=arr[B]
			P[C]=arr[B]*C
		S-=P[B]
		S+=arr[B]*C
		del arr[B]
		del P[B]
	print(S)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
T=1e18
arr=[int(i) for i in input().split()]
A=1
for a in arr:
    A*=a

print(A if A<=T else -1)


Fixed submission:
N=int(input())
T=1e18
arr=[int(i) for i in input().split()]
A=1
for a in arr:
    A*=a
    if A<0:
        A=-1
    if A>T:
        A=-1
print(A)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
n=N
p=2
dcmp={}
while n>1:
    if n%p==0:
        dcmp[p]=1+(dcmp[p] if p in dcmp else 0)
    else:
        p+=1
cnt=0
for k,v in dcmp.items():
    i=1
    while True:
        dcmp[k]-=i
        if dcmp[k]<0:
            break
        i+=1
        cnt+=1

print(cnt)


Fixed submission:
import math
N=int(input())
n=N
p=2
dp=1
thrP=math.sqrt(N)
dcmp={}
while n>1:
    if n%p==0:
        dcmp[p]=1+(dcmp[p] if p in dcmp else 0)
        n//=p
    else:
        p+=dp
        dp=2
    if p>thrP:
        if n>1:
            dcmp[n]=1
        break
cnt=0
for k,v in dcmp.items():
    i=1
    while True:
        dcmp[k]-=i
        if dcmp[k]<0:
            break
        i+=1
        cnt+=1

print(cnt)
Buggy python submission (verdict: Runtime Error):
N=int(input())
arrH=[int(i) for i in input().split()]

M=''.join(['C' if arrH[i]>=arrH[i+1] else ' ' for i in range(N-1)]).split()
print(max([len(i) for i in M]))


Fixed submission:
N=int(input())
arrH=[int(i) for i in input().split()]

M=''.join(['C' if arrH[i]>=arrH[i+1] else ' ' for i in range(N-1)]).split()
print(0 if len(M)==0 else max([len(i) for i in M]))
Buggy python submission (verdict: Runtime Error):
N,M=[int(i) for i in input().split()]
arrR=[0]*N
for m in range(M):
    a,b=[int(i) for i in input().split()]
    arrR[a-1]+=1
    arrR[b-1]+=1
[print(arrR[i]) for i in range(M)]


Fixed submission:
N,M=[int(i) for i in input().split()]
arrR=[0]*N
for m in range(M):
    a,b=[int(i) for i in input().split()]
    arrR[a-1]+=1
    arrR[b-1]+=1
[print(arrR[i]) for i in range(N)]
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
pari = [0] * 40
for i in range(40):
    for j in a:
        pari[i] += (j&(1<<i))>>i

ans = a[:]

for i in range(40):
    if pari[i]%2:
        for j in range(n):
            if a[j]&(1<<i):
                ans[j] -= 1<<i
            else:
                ans[j] += 1<<i

print(' '.join([str(i) for i in ans]))

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
pari = [0] * 30
for i in range(30):
    for j in a:
        pari[i] += (j&(1<<i))>>i

ans = a[:]

for i in range(30):
    if pari[i]%2:
        for j in range(n):
            if a[j]&(1<<i):
                ans[j] -= 1<<i
            else:
                ans[j] += 1<<i

print(' '.join([str(i) for i in ans]))
Buggy python submission (verdict: Runtime Error):
print('Yes' if all([i = '7' for i in input()]) else 'No')

Fixed submission:
print('Yes' if any([i == '7' for i in input()]) else 'No')
Buggy python submission (verdict: Runtime Error):
n, r = map(int, input().split())
print(r + 100*max(10-k, 0))

Fixed submission:
n, r = map(int, input().split())
print(r + 100*max(10-n, 0))
Buggy python submission (verdict: Runtime Error):
n = int(input())
dic = {}
for i in range(n):
    a = input()
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 0

l = sorted(dic.items(), key=lambda x: x[1], reverse=True)
i = 0
while(i<n):
    print(l[i][0])
    if i<n-1:
        if l[i][1] != l[i+1][1]:
            break
    i += 1

Fixed submission:
n = int(input())
dic = {}
for i in range(n):
    a = input()
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 0

l = sorted(dic.items(), key=lambda x: x[1], reverse=True)
num = l[0][1]
ok = []
for i in range(len(l)):
    if l[i][1] == num:
        ok.append(l[i][0])
    else:
        break
ok.sort()
for i in ok:
    print(i)
Buggy python submission (verdict: Runtime Error):
import math
def gcd(l):
    if len(l) == 1:
        return l[0]
    elif len(l) == 2:
        return math.gcd(l[0], l[1])
    else:
        return math.gcd(l[0], gcd(l[1:]))

def lcm(l, mx):
    if len(l)==1:
        return l[0] if l[0] <= mx else 0
    if len(l)==2:
        return l[0]*l[1]//gcd(l) if l[0]*l[1]//gcd(l) <= mx else 0
    if lcm(l[0:2], mx) > 0:
        l.append(lcm(l[0:2], mx))
        del l[0:2]
        return lcm(l, mx)
    return 0

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
if any([i%4==0 for i in a]):
    print(0)
else:
    l = [i//2 for i in a]
    x = lcm(l, 1000000007)
    if x==0:
        print(0)
    else:
        print((m//x+1)//2)

Fixed submission:
from functools import reduce

def gcd_base(x, y):
    if x % y:
        return gcd_base(y, x%y)
    return y

def gcd(numbers):
    return reduce(gcd_base, numbers)

def lcm_base(x, y):
    res = (x * y) // gcd_base(x, y)
    return res if res <= 1000000007 else 0

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
k = [0] * n
for i in range(n):
    j = a[i]
    while(j%2==0):
        j //= 2
        k[i] += 1
if any([k[i]!=k[i+1] for i in range(n-1)]):
    print(0)
else:
    l = [i//2 for i in a]
    x = lcm(l)
    if x==0:
        print(0)
    else:
        print((m//x+1)//2)

Buggy python submission (verdict: Runtime Error):
import math
def gcd(l):
    if len(l) == 1:
        return l[0]
    elif len(l) == 2:
        return math.gcd(l[0], l[1])
    else:
        return math.gcd(l[0], gcd(l[1:]))

def lcm(l, mx):
    if len(l)==1:
        return l[0] if l[0] <= mx else 0
    if len(l)==2:
        return l[0]*l[1]//gcd(l) if l[0]*l[1]//gcd(l) <= mx else 0
    if lcm(l[0:2], mx) > 0:
        l.append(lcm(l[0:2], mx))
        del l[0:2]
        return lcm(l, mx)
    return 0

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
if any([i%4==0 for i in a]):
    print(0)
else:
    l = [i//2 for i in a]
    x = lcm(l, m)
    print((m//lcm(l, m)+1)//2)

Fixed submission:
from functools import reduce

def gcd_base(x, y):
    if x % y:
        return gcd_base(y, x%y)
    return y

def gcd(numbers):
    return reduce(gcd_base, numbers)

def lcm_base(x, y):
    res = (x * y) // gcd_base(x, y)
    return res if res <= 1000000007 else 0

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
k = [0] * n
for i in range(n):
    j = a[i]
    while(j%2==0):
        j //= 2
        k[i] += 1
if any([k[i]!=k[i+1] for i in range(n-1)]):
    print(0)
else:
    l = [i//2 for i in a]
    x = lcm(l)
    if x==0:
        print(0)
    else:
        print((m//x+1)//2)
Buggy python submission (verdict: Runtime Error):
from math import gcd
a, b = map(int, input().split())
print(a*b//gcd(a, b))

Fixed submission:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y==0:
        return y
    else:
        return gcd(y, x%y)
        
a, b = map(int, input().split())
print(a*b//gcd(a, b))

Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
print(a*b//math.gcd(a, b))

Fixed submission:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y==0:
        return y
    else:
        return gcd(y, x%y)
        
a, b = map(int, input().split())
print(a*b//gcd(a, b))
Buggy python submission (verdict: Runtime Error):
m = int(input())
d = [0] * m
c = [0] * m
for i in range(m):
    d[i], c[i] = map(int, input().split())

print((sum(c)-1+sum([c[i]*d[i] for i in range(m)]-1)//9) % 1000000007)

Fixed submission:
m = int(input())
d = [0] * m
c = [0] * m
for i in range(m):
    d[i], c[i] = map(int, input().split())

print(sum(c)-1+(sum([c[i]*d[i] for i in range(m)])-1)//9)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
for i in range(n):
    if a[i] == max(a):
        mx_index = i
        break
a.sort()
for i in range(n):
    print(a[n-2] if i == mx_index else a[n-1])

Fixed submission:
n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
mx=max(a)
for i in range(n):
    if a[i] == mx:
        mx_index = i
        break
a.sort()
for i in range(n):
    print(a[n-2] if i == mx_index else a[n-1])
Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
def muri(n):
    return n - n//c - n//d + n//(c*d//math.gcd(c, d))

print(muri(b)-muri(a-1))

Fixed submission:
a, b, c, d = map(int, input().split())

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        return gcd(y, x%y)

def muri(n):
    return n - n//c - n//d + n//(c*d//gcd(c, d))

print(muri(b)-muri(a-1))

Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
def muri(n):
    return n - n//c - n//d + n//(c*d//math.gcd(c, d))

print(muri(b)-muri(a-1))

Fixed submission:
a, b, c, d = map(int, input().split())

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        return gcd(y, x%y)

def muri(n):
    return n - n//c - n//d + n//(c*d//gcd(c, d))

print(muri(b)-muri(a-1))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
broken = [0] * n
dp = [0] * (n+1)
in_memo = [0] * (n+1)
for i in range(m):
    broken[int(input())] = 1

def solve(i):
    if(not in_memo[i]):
        if i == n:
            dp[i] = 1
        elif i == n-1:
            dp[i] = 0 if broken[i] else 1
        else:
            dp[i] = 0 if broken[i] else (solve(i+1)+solve(i+2)) % 1000000007
        in_memo[i] = 1
    return dp[i]

print(solve(0))

Fixed submission:
n, m = map(int, input().split())
ok = [1] * n
for i in range(m):
    x = int(input())
    ok[x-1] = 0
mod = 1000000007
dp = [0] * (n+2)
dp[1] = 1
for i in range(n):
    dp[i+2] = (dp[i+1] + dp[i])%mod if ok[i] else 0

print(dp[n+1])
Buggy python submission (verdict: Runtime Error):
s = input()
ans = 0

def solve(s):
    if all((s[i]==s[i+1] for i in range(len(s)-1))):
        return 0
    for i in range(len(s)-1):
        if s[i:i+2] == '01' or s[i:i+2] == '10':
            return solve(s[:i]+s[i+2:])+2

print(solve(s))

Fixed submission:
s = input()
l0, l1 = 0, 0
for i in s:
    if i == '0':
        l0 += 1
    else:
        l1 += 1
        
print(len(s)-abs(l0-l1))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

dp = [0] * n

for i in range(1, n):
  dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(i, k)+1)])

print(dp[n-1])

Fixed submission:
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

dp = [0] * n

for i in range(1, n):
  dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(i, k)+1)])

print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
inf = 2**60
'''
def table(size, init): #配列生成
  x = len(size)
  l = [init for i in range(size[x-1])]
  for i in range(x-1):
    l = [l for k in range(size[x-2-i])]
  return l
'''

n, W = map(int, input().split())
w, v = [[0]*n for i in range(2)]
for i in range(n):
  w[i], v[i] = map(int, input().split())

dp = [[-1] * (100011) for i in range(n+1)]
dp[0][0] = 0

for i in range(n):
  for j in range(100010):
    if dp[i][j] != -1:
      dp[i+1][j] = max(dp[i][j], dp[i+1][j])
      if dp[i][j]+w[i] <= W:
        dp[i+1][j+v[i]] = max(dp[i][j] + w[i], dp[i+1][j+w[i]])

for i in range(100010):
  if dp[n][100010-i] != -1:
    print(100010-i)
    break

Fixed submission:
n, W = map(int, input().split())
w = [0] * n
v = [0] * n
for i in range(n):
    w[i], v[i] = map(int, input().split())

INF = 10**10

dp = [[INF for i in range(100010)] for j in range(n+1) ]

dp[0][0] = 0

for i in range(n):
    for j in range(100010):
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
        if j>=v[i]:
            dp[i+1][j] = min(dp[i][j-v[i]]+w[i], dp[i+1][j])

for j in range(100010):
    if dp[n][100009-j] <= W:
        print(100009-j)
        break
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0
for i in range(1, n+1):
    if n%2 == 1:
        cnt = 0
        for j in range(1, j+1):
            if i%j == 0:
                cnt += 1
        if cnt == 8:
            ans += 1
print(ans)

Fixed submission:
n = int(input())
ans = 0
for i in range(1, n+1):
    cnt = 0
    if i%2 == 1:
        for j in range(1, i+1):
            if i%j == 0:
                cnt += 1
        if cnt == 8:
            ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def bisect(lst, isok, ok, ng):
    while(abs(ok-ng)>1):
        mid = (ok+ng)//2
        if isok(lst[mid]):
            ok = mid
        else:
            ng = mid
    return [ok, ng]

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

a.sort()
b.sort()
c.sort()

ans = 0

for i in a:
    ind = bisect(b, lambda x:x > i, n, -1)[0]
    if ind == n:
        break
    for j in range(ind, n):
        ans += n - bisect(c, lambda x:x > b[j], n, -1)[0]

print(ans)

Fixed submission:
def bisect(lst, isok, ok, ng):
    while(abs(ok-ng)>1):
        mid = (ok+ng)//2
        if isok(lst[mid]):
            ok = mid
        else:
            ng = mid
    return [ok, ng]

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

a.sort()
b.sort()
c.sort()

ans = 0

for i in b:
    x = bisect(a, lambda x:x < i, -1, n)[0]
    y = bisect(c, lambda x:x > i, n, -1)[0]
    ans += (x+1)*(n-y)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def bisect(lst, isok, ok, ng):
    while(abs(ok-ng)>1):
        mid = (ok+ng)//2
        if isok(lst[mid]):
            ok = mid
        else:
            ng = mid
    return [ok, ng]

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

a.sort()
b.sort()
c.sort()

ans = 0

for i in a:
    ind = bisect(b, lambda x:x > i, n, -1)[0]
    if ind == n:
        break
    for j in range(ind, n):
        ans += n - bisect(c, lambda x:x > b[j], n, -1)[0]

print(ans)

Fixed submission:
def bisect(lst, isok, ok, ng):
    while(abs(ok-ng)>1):
        mid = (ok+ng)//2
        if isok(lst[mid]):
            ok = mid
        else:
            ng = mid
    return [ok, ng]

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

a.sort()
b.sort()
c.sort()

ans = 0

for i in b:
    x = bisect(a, lambda x:x < i, -1, n)[0]
    y = bisect(c, lambda x:x > i, n, -1)[0]
    ans += (x+1)*(n-y)

print(ans)