Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = []

for i in range(N):
  a.append(input())
  
b = set(a)
print(len(b))

Fixed submission:
a = input().split(" ")
s = int(a[0])
w = int(a[1])

if w >= s:
  print("unsafe")
else:
  print("safe")

Buggy python submission (verdict: Runtime Error):
N = input().split(" ")
TL = int(N[0])
TA = int(N[1])
AL = int(N[2])
AA = int(N[3])
a = 0

while a == 0:
  AL = AL - TA
  if AL <= 0:
    a = 1
    break
  TL = TL - AA
  if TL <= 0:
    a = 2
    break
if a == 1:
  print("Yes")
elif a == 2:
  print("No")


Fixed submission:
a = input().split(" ")
s = int(a[0])
w = int(a[1])

if w >= s:
  print("unsafe")
else:
  print("safe")
Buggy python submission (verdict: Time Limit Exceeded):
N = input().split(" ")
TL = int(N[0])
TA = int(N[1])
AL = int(N[2])
AA = int(N[3])
a = 0

while a == 0:
  AL = AL - TA
  if AL <= 0:
    a = 1
    break
  TA = TA - AA
  if TL <= 0:
    a = 2
    break
if a == 1:
  print("Yes")
elif a == 2:
  print("No")


Fixed submission:
N = input().split(" ")
TL = int(N[0])
TA = int(N[1])
AL = int(N[2])
AA = int(N[3])
a = 0

while a == 0:
  AL = AL - TA
  if AL <= 0:
    a = 1
    break
  TL = TL - AA
  if TL <= 0:
    a = 2
    break
if a == 1:
  print("Yes")
elif a == 2:
  print("No")

Buggy python submission (verdict: Runtime Error):
N = input().split(" ")
TL = int(N[0])
TA = int(N[1])
AL = int(N[2])
AA = int(N[3])
a = 0

while a = 0:
  AL = AL - TA
  if AL <= 0:
    a = 1
    brake
  TA = TA - AA
  if TA <= 0:
    a = 2
    brake
if a = 1:
  print("Yes")
if a = 2:
  print("No")

Fixed submission:
N = input().split(" ")
TL = int(N[0])
TA = int(N[1])
AL = int(N[2])
AA = int(N[3])
a = 0

while a == 0:
  AL = AL - TA
  if AL <= 0:
    a = 1
    break
  TL = TL - AA
  if TL <= 0:
    a = 2
    break
if a == 1:
  print("Yes")
elif a == 2:
  print("No")
Buggy python submission (verdict: Runtime Error):
S = input()
if S is "ABC":
  print("ARC)
else:print("ABC")

Fixed submission:
S=input()
if S == "ABC":print("ARC")
else : print("ABC")
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += (gcd(i,j,k))
print(ans)

Fixed submission:
K = int(input())
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


temp = []

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            temp.append(gcd(i,j,k))
print(sum(temp))

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

temp = []

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            temp.append(gcd(i,j,k))
print(sum(temp))

Fixed submission:
K = int(input())
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


temp = []

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            temp.append(gcd(i,j,k))
print(sum(temp))
Buggy python submission (verdict: Runtime Error):
A,B,C= map(int,input().split())

if A = B = C :
    print("No")
else:
    print("Yes")

Fixed submission:
def kawaiso(a, b, c):
  if (a == b and b != c) or (b == c and c != a) or (c == a and a != b):
    return 'Yes'
  else:
    return 'No'
 
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)
 
print(kawaiso(a, b, c))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
res = "YES"
A.sort()
for i in range(len(A)):
    if i == 0:
        continue
    if A[i-1] == A[i]:
        res = "NO"
        break
    else:
        continue
print(res)


Fixed submission:
S,T = map(str,input().split())
A,B = map(int,input().split())
s = input()

if s == S:
    A -=1
elif s == T:
    B -=1
print(A,B)

Buggy python submission (verdict: Runtime Error):
S,T = map(int,input().split())
A,B = map(int,input().split())
s = input()

if s == S:
    A -=1
else:
    B -=1
print(A,B)

Fixed submission:
S,T = map(str,input().split())
A,B = map(int,input().split())
s = input()

if s == S:
    A -=1
elif s == T:
    B -=1
print(A,B)
Buggy python submission (verdict: Runtime Error):
N = int(input())
li = list(map(int,input().split()))

counter = 0

for i in range(0,N):
    if li[i+1]>li[i]:
        counter += 1
    else:
        pass
print(counter)

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

total = 0
minl = l[0]

for i in l:
    if i <= minl:
        total += 1
        minl = i

print(total)
Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
nums = [i for i in range(1,n+1)]
fac = [words for words in itertools.permutations(nums)]
ans = abs(fac.index(p) - fac.index(q))
print(ans)


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

if K*500>=X:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math
A,B = map(int,input().split())

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

print(lcm(A,B))

Fixed submission:
import fractions

a,b=(int(x) for x in input().split())
  
print(a*b // fractions.gcd(a,b))

Buggy python submission (verdict: Runtime Error):
import math
A,B = map(int,input().split())

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

print(lcm(A,B))

Fixed submission:
import fractions

a,b=(int(x) for x in input().split())
  
print(a*b // fractions.gcd(a,b))
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
c = 2
for i in (2,A):
    for j in range(2, B):
        if i % j == 0:
            if i == j:
                c +=1
            else:
                break
print(c)

Fixed submission:
N  = int(input())
if N%2 == 0:
    print((N/2)/N)
else:
    print(((N+1)/2)/N)
Buggy python submission (verdict: Runtime Error):
S = input()
if S == "Sunny":
    print("Cloudy")
elif S =="Cloudy":
    print("Rainy"):
else:
    print("Sunny")

Fixed submission:
S = input()
if S == "Sunny":
    print("Cloudy")
elif S =="Cloudy":
    print("Rainy")
elif S==("Rainy"):
    print("Sunny")
Buggy python submission (verdict: Runtime Error):
N=int(input())
listA = list(map(int,input().split()))
listB = list(map(int,input().split()))
listC = list(map(int,input().split()))

listD = [ListA,ListB,ListC]
sorted(listD)
print(sum(listD[1])+sum(list[2]))


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b= list(map(int,input().split()))
c = list(map(int,input().split()))
 
m=0
 
for i in range (0,n):
  m += b[a[i]-1]
  if i !=0 and a[i]==a[i-1]+1:
    m += c[a[i-1]-1]
print(m)

Buggy python submission (verdict: Runtime Error):
N=int(input())
listA = list(map(int,input().split()))
listB = list(map(int,input().split()))
listC = list(map(int,input().split()))

listD = [ListA,ListB]
sorted(listD)
print(sum(listD[1]))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b= list(map(int,input().split()))
c = list(map(int,input().split()))
 
m=0
 
for i in range (0,n):
  m += b[a[i]-1]
  if i !=0 and a[i]==a[i-1]+1:
    m += c[a[i-1]-1]
print(m)
Buggy python submission (verdict: Runtime Error):
N = int(input())
li = input().split()

step = 0
while True:
    if N>int(li[N+1]):
        step +=1
        N+=1
    else:
        pass
    
print(step)

Fixed submission:
N = int(input())
li = list(map(int,input().split()))
ans = 0
cnt =0
for i in range(N-1):
    if li[i]>=li[i+1]:
        cnt+=1
    else:
        ans = max(ans,cnt)
        cnt = 0
print(max(ans,cnt))
Buggy python submission (verdict: Runtime Error):
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
S = 0
for i in range(N):
    D = V[i] - C[i]
    if D >0:
    S = S + D
    
print(S)



Fixed submission:
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
S = 0
for i in range(N):
    D = V[i] - C[i]
    if D >0:
        S = S + D
    
print(S)
Buggy python submission (verdict: Runtime Error):
s = str(input())
ACGT = {"A", "C", "G", "T"}

ans = 0
for i in range(len(s)):
    for j in range(i, len(s) + 1):
        k = s[i: j]
        for l in k:
            if l not in ACGT:
                break
        else:
            ans = max(ans, len(t))
print(ans)


Fixed submission:
s = str(input())
ACGT = {"A", "C", "G", "T"}

ans = 0
for i in range(len(s)):
    for j in range(i, len(s) + 1):
        t = s[i: j]
        for k in t:
            if k not in ACGT:
                break
        else:
            ans = max(ans, len(t))
print(ans)
Buggy python submission (verdict: Runtime Error):
X,Y = map(int,input().split())
A = list(map(int,input().split()))
A = set(A[1:])
for i in range(X-1):
    A = list(map(int,input().split()))
    B = B & set(A[1:])
print(len(B))

Fixed submission:
x,y = map(int,input().split())
a = list(map(int,input().split()))
b = set(a[1:])
for i in range(x-1):
    a = list(map(int,input().split()))
    b = b & set(a[1:])
print(len(b))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())

tree = []
for _ in range(n):
    tree.append(int(input()))

tree.sort()
ans = 10**9
for i in range(N-K+1):
    ans = min(ans, tree[i+K-1]-tree[i])
print(ans)


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

tree = []
for _ in range(N):
    tree.append(int(input()))

tree.sort()
ans = 10**9
for i in range(N-K+1):
    ans = min(ans, tree[i+K-1]-tree[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M,X,Y = map(int,input().split())
li_x = list(map(int,input().split()))
li_y = list(map(int,input().split()))

li_x.append(X)
li_y.append(Y)

li_x = set(li_x)
li_y = set(li_y)

if max(x1)>min(y1):
    print("War")
elif max(x1)<min(y1):
    print("No war")
elif max(x1)==min(y1):
    print("War")

Fixed submission:
N,M,X,Y = map(int,input().split())
lx = list(map(int,input().split()))
lx.append(X)
ly = list(map(int,input().split()))
ly.append(Y)
if max(lx) < min(ly):
    print('No War')
else:
    print('War')
Buggy python submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
s = input()
#print(n-1,k-1)
print(math.ceil((n-1)/(k-1)))

Fixed submission:
S = list(input())
ans = 0
for i in range(len(S)):
    if S[i] =="+":
        ans += 1
    elif S[i] == "-":
        ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
D, N =  map(int,input().split())
if D == 0:
    li = [int(i) for i in range(1,100)]
    print(li[N-1])
if D == 1:
    li = [int(i) for i in range(int(100),int(1e4),int(100))]
    print(li[N-1])
if D == 2:
    li = [int(i) for i in range(int(1e4),int(1e9),int(1e4))]
    print(li[N-1])
   

Fixed submission:
D, N = map(int, input().split())
print(100 ** D * (N + N // 100))

Buggy python submission (verdict: Runtime Error):
D, N =  map(int,input().split())
if D == 0:
    li = [int(i) for i in range(1,99)]
    print(li[N-1])
if D == 1:
    li = [int(i) for i in range(int(100),int(1e4),int(100))]
    print(li[N-1])
if D == 2:
    li = [int(i) for i in  range(int(1e4),int(1e9),int(1e4))]
    print(li[N-1])

Fixed submission:
D, N = map(int, input().split())
print(100 ** D * (N + N // 100))
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
k=b-a
print(((1+k)*k)//2-b)


Fixed submission:
N = int(input())
if N<1000:
    print("ABC")
elif N>=1000:
    print("ABD")
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int,input().split())
li = []
for i in range(A,B+1):
    if abs(A-i)<K:
        li.append(i)
    elif abs(B-i)<K:
        li.append(i)
li.sort()
for j in range(len(li)):
    print(li[j])


Fixed submission:
A,B,K=map(int,input().split())
li=range(A,B+1)
ans=sorted(set(li[:K])|set(li[-K:]))
for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int,input().split())
li = []
for i in range(A,B+1):
    if abs(A-i)<K:
        li.append(i)
    elif abs(B-i)<K:
        li.append(i)
li.sort()
for j in range(len(li)):
    print(li[j])

Fixed submission:
A,B,K=map(int,input().split())
li=range(A,B+1)
ans=sorted(set(li[:K])|set(li[-K:]))
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=[input() for _ in range(N)]

MARCH=[0]*5
for i in range(N):
  if S[i][0]=="M":
    MARCH[0]+=1
  elif S[i][0]=="A":
    MARCH[1]+=1
  elif S[i][0]=="R":
    MARCH[2]+=1
  elif S[i][0]=="C":
    MARCH[3]+=1
  elif S[i][0]=="H":
    MARCH[4]+=1

ans=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans+=MARCH[i]*MARCH[j]*MARCH[k]
print(ans)


Fixed submission:
N = int(input())
ans = N//3
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X,Y = map(int,input().split())
li = []
for i in range(X,(Y+1)):
    temp = i
    if temp%X ==0 :
        li.append(i)
        X = temp 
print(len(li))

Fixed submission:
x,y=map(int,input().split())
cnt=1
while x*2**cnt<=y:
  cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
def how_many_times_divisible(n):
	ans = 0
	while n % 2 == 0:
		n /= 2
		ans += 1
	return ans
 
N = int(input())
a = map(int, input().split())
ans = min(map(how_many_times_divisible, a))
 
print(ans)

Fixed submission:
li=list(input())
t = 0
for i in li:
    if i == "1":
        t+=1
    else:
        pass
print(t)
Buggy python submission (verdict: Runtime Error):
def how_many_times_divisible(n):
	ans = 0
	while n % 2 == 0:
		n /= 2
		ans += 1
	return ans
 
n = int(input())
a = map(int, input().split())
ans = min(map(how_many_times_divisible, a))
 
print ans

Fixed submission:
def how_many_times_divisible(n):
	ans = 0
	while n % 2 == 0:
		n /= 2
		ans += 1
	return ans
 
N = int(input())
a = map(int, input().split())
ans = min(map(how_many_times_divisible, a))
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
B.sort()
C.sort()
ans = 0
for i in A:
    for j in B:
        for k in C:
            if (i<j)&(j<k):
                ans += 1
print(ans)

Fixed submission:
import bisect
n= int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for i in range(n):
    x = bisect.bisect_left(a,b[i])
    y = bisect.bisect_right(c,b[i])
    ans += x*(n-y)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = list(map(int,input().split()))
ans = []
for i in range(n):
    ans.append(li[i])
    ans = ans[::-1]
print(*ans)

Fixed submission:
from collections import deque

N = int(input())
numbers = input().split()

d = deque()

for i in range(N):
    if i % 2 == 0:
        d.append(numbers[i])
    else :
        d.appendleft(numbers[i])
        
if N % 2 == 1:
    d.reverse()
    
output = ' '.join(d)

print(output)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
li=[]
for i in range(N):
    a,b = map(int, input().split())
    for j in range(b):
        li.append(a)
li.sort()
print(li[K-1])

Fixed submission:
N,K=map(int,input().split())
AB=[[0,0]for _ in range(N)]

for i in range(N):
    AB[i]=list(map(int,input().split()))
AB.sort()

ans=0
i=0
while K>0 and i<N:
    K-=AB[i][1]
    ans=AB[i][0]
    i+=1

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
div = 1e9+7
ans = 1
for i in range(1,N+1):
    ans*=i
print(ans%div)

Fixed submission:
import math
N = int(input())
print(math.factorial(N) % (10**9+7))
Buggy python submission (verdict: Runtime Error):
t=str(s)
print(t.replace(",", " "))

Fixed submission:
s = input()
print(s.replace(",", " "))
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())
count = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k == S:
                count+=1
print(count)

Fixed submission:
K, S = map(int, input().split())
count = 0
for X in range(K+1):
  for Y in range(K+1):
    if 0 <= S-X-Y <= K:
      count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())

if(n%10==3):
    print("bon")
else if(n%10 in [0, 1, 6, 8]):
    print("pon")
else:
    print("hon")


Fixed submission:
n = int(input())

if(n%10==3):
    print("bon")
elif(n%10 in [0, 1, 6, 8]):
    print("pon")
else:
    print("hon")
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
  if(b==0):
    return a
  return gcd(b,a%b)

n, k = [int(x) for x in input().split()]
print(min(gcd(n,k),k-gcd(n,k))

Fixed submission:
n, k = [int(x) for x in input().split()]
print(min(n%k,k-n%k))
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

ans = 10000

for i in range(len(s) - len(t) + 1):
    score = 0
    U = [i:i + len(t)]
    for j in range(len(t)):
        if U[j] != t[j]:
            score += 1
    ans = min(ans, score)

print(ans)

Fixed submission:
s = input()
t = input()

ans = 10000

for i in range(len(s) - len(t) + 1):
    score = 0
    U = s[i:i + len(t)]
    for j in range(len(t)):
        if U[j] != t[j]:
            score += 1
    ans = min(ans, score)

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

n = int(input())
a = list(map(int, input().split()))
sum = 0
k = 0
for i in range(len(a)-1):
    for j in range(i+1,len(a)):
        k += a[j]

    
    sum += a[i] * k

    k = 0
        
ans = np.mod(sum,10**9+7)

print(ans)



Fixed submission:

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

MOD = 10 ** 9 + 7

sum = sum(a) % MOD
ans = 0

for i in range(len(a)):
    sum -= a[i]
    sum %= MOD
    ans += a[i] * sum
    ans %= MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
a = list(map(int, input().split()))
sum = 0
k = 0
for i in range(len(a)-1):
    for j in range(i+1,len(a)):
        k += a[j]

    
    sum += a[i] * k

    k = 0
        
ans = np.mod(sum,10**9+7)

print(ans)



Fixed submission:

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

MOD = 10 ** 9 + 7

sum = sum(a) % MOD
ans = 0

for i in range(len(a)):
    sum -= a[i]
    sum %= MOD
    ans += a[i] * sum
    ans %= MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
a = list(map(int, input().split()))
sum = 0
for i in range(len(a)-1):
    for j in range(i+1,len(a)):
        sum += a[i]*a[j]
        
ans = np.mod(sum,10**9+7)

print(ans)

Fixed submission:

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

MOD = 10 ** 9 + 7

sum = sum(a) % MOD
ans = 0

for i in range(len(a)):
    sum -= a[i]
    sum %= MOD
    ans += a[i] * sum
    ans %= MOD

print(ans)

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

n = int(input())
a = list(map(int, input().split()))
sum = 0
for i in range(len(a)-1):
    for j in range(i+1,len(a)):
        sum += a[i]*a[j]
        
ans = np.mod(sum,10**9+7)

print(ans)

Fixed submission:

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

MOD = 10 ** 9 + 7

sum = sum(a) % MOD
ans = 0

for i in range(len(a)):
    sum -= a[i]
    sum %= MOD
    ans += a[i] * sum
    ans %= MOD

print(ans)

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

def product(list):
    p = 1
    for i in list:
        p *= i
    return p


n = int(input())
a = list(map(int, input().split()))
sum = 0
for i in range(len(a)-1):
    for j in range(i+1,len(a)):
        sum += a[i]*a[j]
        
ans = np.mod(sum,10**9+7)

print(ans)

Fixed submission:

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

MOD = 10 ** 9 + 7

sum = sum(a) % MOD
ans = 0

for i in range(len(a)):
    sum -= a[i]
    sum %= MOD
    ans += a[i] * sum
    ans %= MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def product(list):
    p = 1
    for i in list:
        p *= i
    return p


n = int(input())
a = list(map(int, input().split()))
sum = 0
for i in range(len(a)-1):
    for j in range(i+1,len(a)):
        sum += a[i]*a[j]
        
ans = np.mod(sum,10**9+7)

print(ans)



Fixed submission:

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

MOD = 10 ** 9 + 7

sum = sum(a) % MOD
ans = 0

for i in range(len(a)):
    sum -= a[i]
    sum %= MOD
    ans += a[i] * sum
    ans %= MOD

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())
ans = 0
for i in range(a,b+1):
    if not i % c == 0 and not i % d == 0:
        ans += 1
print(ans)

Fixed submission:
import math

def lcm(a, b):
    return (a*b)//math.gcd(a, b)

a, b, c, d = map(int, input().split())
e = lcm(c, d)

total = b - (a - 1)
cc = b//c - (a-1)//c
dd = b//d - (a-1)//d
ee = b//e - (a-1)//e

ans = total - cc - dd + ee
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())
ans = 0
for i in range(a,b+1):
    if not i % c == 0 and not i % d == 0:
        ans += 1
print(ans)

Fixed submission:
import math

def lcm(a, b):
    return (a*b)//math.gcd(a, b)

a, b, c, d = map(int, input().split())
e = lcm(c, d)

total = b - (a - 1)
cc = b//c - (a-1)//c
dd = b//d - (a-1)//d
ee = b//e - (a-1)//e

ans = total - cc - dd + ee
print(ans)
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int, input().split())
ans = 0
for i in range(1,n+1):
    if a <= sum([int(c) for c in str(i)]) => b:
        ans += i
print(ans)

Fixed submission:
n,a,b = map(int, input().split())
ans = 0
for i in range(1,n+1):
    if a <= sum([int(c) for c in str(i)]) <= b:
        ans += i
print(ans)
Buggy python submission (verdict: Runtime Error):
import re

s = input()
s = re.sub("dreamer","",s)
s = re.sub("dream","",s)
s = re.sub("eraser","",s)
s = re.sub("erase","",s)

if int(s) == 0:
    print("YES")
else:
    print("NO")

Fixed submission:
import re

s = input()
s = re.sub("eraser","",s)
s = re.sub("erase","",s)
s = re.sub("dreamer","",s)
s = re.sub("dream","",s)

if len(s) == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
S_n = lambda n:n*(n+1)//2

def solve():
  N,K = map(int, input().split())
  P = list(map(int, input().split()))
  Q = P[:K]
  Q_ = P[:K]
  sum_Q = sum(Q)
  sum_Q_ = sum(Q)
  for i in range(N-K):
    sum_Q_ = sum_Q_ - Q_[0] + P[K+i]
    Q_ = Q_[1:]+[P[K+i]]

    if sum_Q < sum_Q_:
      Q = Q_
      sum_Q = sum_Q_

  # print(Q)

  print(sum(S_n(q)/q for q in Q))
  
solve()

Fixed submission:
S_n = lambda n:n*(n+1)//2

def solve():
  N,K = map(int, input().split())
  P = list(map(int, input().split()))
  Q_idx = 0
  Q = P[:K]
  sum_Q = sum(Q)
  sum_Q_ = sum(Q)
  for i in range(N-K):
    sum_Q_ = sum_Q_ - P[i] + P[K+i]
    if sum_Q < sum_Q_:
      Q_idx = i+1
      sum_Q = sum_Q_

  Q = P[Q_idx:Q_idx+K]
  # print(Q)
  print(sum(S_n(q)/q for q in Q))
  
solve()
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    H,N = map(int, input().split())
    # Aが消費HP, Bが消費MP
    ABs = [list(map(int, input().split())) for _ in range(N)]
    dp_table = [[0]*(H+1) for _ in range(N+1)]
    # dp_table[i][j] : i番目の魔法から消化HPがj以上となる、MPの最小値
    for j in range(1,H+1): dp_table[0][j] = 10**9
    for i in range(N):
        for j in range(H+1):
            if j-ABs[i][0]<0:
                dp_table[i+1][j] = min(dp_table[i][j], ABs[i][1])
            else:
                dp_table[i+1][j] = min(dp_table[i][j], dp_table[i+1][j-ABs[i][0]]+ABs[i][1])
                
    print(dp_table[N][H])
    
solve()

Fixed submission:
def solve():
    H,N = map(int, input().split())
    # Aが消費HP, Bが消費MP
    ABs = [list(map(int, input().split())) for _ in range(N)]
    # dp_table = [[10**9]*(H+1)]+[[0]*(H+1) for _ in range(N)]
    dp_table = [[0]*(H+1) for _ in range(N+1)]
    # dp_table[i][j] : i番目の魔法から消化HPがj以上となる、MPの最小値
    for j in range(1,H+1): dp_table[0][j] = 10**9
    # print(dp_table)
    for i in range(N):
        for j in range(H+1):
            if j-ABs[i][0]<0:
                dp_table[i+1][j] = min(dp_table[i][j], ABs[i][1])
            else:
                dp_table[i+1][j] = min(dp_table[i][j], dp_table[i+1][j-ABs[i][0]]+ABs[i][1])
                
    print(dp_table[N][H])
    
solve()