Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
ans = 0
k = int(input())

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

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

print(ans)
            

Fixed submission:
import math
from functools import reduce
ans = 0
k = int(input())

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

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

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
def int_sqrt2(n):
    def f(prev):
        while True:
            m = (prev + n / prev) / 2
            if m >= prev:
                return prev
            prev = m
    
    return f(int(np.sqrt(n) * (1 + 1e-10)))

a,b,c = map(int,input().split())
if int_sqrt2(a)+int_sqrt2(b) < int_sqrt2(c):
    print("Yes")
else:
    print("No")

Fixed submission:
from decimal import *
a,b,c = map(str,input().split())
r = "0.5"
if Decimal(a)**Decimal(r)+Decimal(b)**Decimal(r) < Decimal(c) **Decimal(r):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
a = list(map(str,input().split()))
c = collections.Counter(a)

comon = c.most_common()
ans = 0
for i in comon:
  if i[1] != 1:
  	ans += (i[1]*(i[1]-1)//2)
  
for i in a:
  if (ans-int(a.count(i))) < 0:
    print(0)
  else:
    co = a.count(i)
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))


      

Fixed submission:
from collections import deque

s = list(input())
s = deque(s)
q = int(input())
flag = ''
count = 0
for i in range(q):
    que = list(map(str,input().split()))
    if que[0] == "1":
        count += 1
        if flag == 'one':
          flag = ''
        else:
          flag = 'one'
    else:
        if que[1] == '1':
            if flag == 'one':
                s.append(que[2])
            else:
                s.appendleft(que[2])
        elif que[1] == '2':
            if flag == 'one':
                s.appendleft(que[2])
            else:
                s.append(que[2])
if count % 2 == 0:
  for i in s:
    print(i,end="")
else:
  for i in reversed(s):
    print(i,end="")
Buggy python submission (verdict: Time Limit Exceeded):
h = int(input())
ans = 1
i = 1
while True:
    h //= 2
    ans += 2*i
    i += 1+(i-1)
    if h == 1:
        break
        
print(ans)

Fixed submission:
h = int(input())
ans = 1
i = 1
if h == 1:
    print(1)
else:
    while True:
        h //= 2
        ans += 2*i
        i += 1+(i-1)
        if h == 1:
            break

    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h = int(input())
ans = 1
ls = []
i = 1
while True:
    #print(ans)
    h //= 2
    ans += 2*i
    i += 1+(i-1)
    if h == 1:
        break
        
print(ans)

Fixed submission:
h = int(input())
ans = 1
i = 1
if h == 1:
    print(1)
else:
    while True:
        h //= 2
        ans += 2*i
        i += 1+(i-1)
        if h == 1:
            break

    print(ans)
Buggy python submission (verdict: Runtime Error):
import fractions
n = int(input())
a = list(map(int,input().split()))
max_a = max(a)
min_a = min(a)
ab = 0

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

if max_a % 2 == 0:
    for i in range(n):
        if a[i] % 2 == 1:
            ab = (lcm(a[i+1], a[i]))
            break
else:
    ab = (lcm(max_a, min_[i]))
    
if ab == 0:
    print(n)
else:   
    ans = 0
    for i in a:
        ans += ab//i

    print(ans)

Fixed submission:
import fractions
N = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
    
count = 0
for i in a:
    count += ans//i
print(count%(10**9+7))

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int,input().split()))
max_a = max(a)
min_a = min(a)
ab = 0

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

if max_a % 2 == 0:
    for i in range(n):
        if a[i] % 2 == 1:
            ab = (lcm(a[i+1], a[i]))
            break
else:
    ab = (lcm(max_a, min_[i]))
    
if ab == 0:
    print(n)
else:   
    ans = 0
    for i in a:
        ans += ab//i

    print(ans)

Fixed submission:
import fractions
N = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
    
count = 0
for i in a:
    count += ans//i
print(count%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n,M = map(int,input().split())
ls = []
for i in range(M):
    p,m = map(str,input().split())
    ls.append([p,m])
    
ac = 0
wa = 0
now = ""
p = 0
c = 0
for i in range(M):
    if now == ls[i][0]:
        continue
    if ls[i][0] != ls[i-1][0] and c == 0:
        wa -= p
        p = 0
    if ls[i][1] == "AC":
        now = ls[i][0]
        ac += 1
        c = 1
    elif ls[i][1] == "WA":
        wa += 1
        c = 0
        p += 1
        
print(ac,wa)

Fixed submission:
c = input()
print(chr(ord(c) + 1))
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
ans = 0
ls = list
for i in range(k):
    if t[i] == "r":
        ls.append("p")
        ans += p
    elif t[i] == "s":
        ls.append("r")
        ans += r
    elif t[i] == "p":
        ls.append("s")
        ans += s
        
for i in range(n):
        if ls[-k] != "r":
            ans += p
            ls.append("p")
        else:
            ls.append("x")
    elif t[i] == "s":
        if ls[-k] != "s":
            ans += r
            ls.append("r")
        else:
            ls.append("x")
    else:
        if ls[-k] != "p":
            ans += s
            ls.append("s")
        else:
            ls.append("x")
print(ans)

Fixed submission:
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
ans = 0
ls = []
for i in range(n):
    if t[i] == "r":
        if len(ls) >= k:
            if ls[-k] != "r":
                ans += p
                ls.append("r")
            else:
                ls.append("x")
        else:
            ans += p
            ls.append("r")
    elif t[i] == "s":
        if len(ls) >= k:
            if ls[-k] != "s":
                ans += r
                ls.append("s")
            else:
                ls.append("x")
        else:
            ans += r
            ls.append("s")
    else:
        if len(ls) >= k:
            if ls[-k] != "p":
                ans += s
                ls.append("p")
            else:
                ls.append("x")
        else:
            ans += s
            ls.append("p")
print(ans)
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 math
import fractions

a,b = map(int,input().split())
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(a, b))
Buggy python submission (verdict: Runtime Error):
import sys
x=(input())
t = int(x[:-2])
x = int(x)
c = 0
while True:
    if x <= 100:
        break
    x -=105
    c += 1

if c == t:
    print(0)
else:
    print(1)



Fixed submission:
import sys
x=(input())
ls = [101,102,103,104,105]
if int(x) < 100:
    print(0)
else:
    t = int(x[:-2])
    x = int(x)
    c = 0
    while True:
        if x <= 100:
            break
        x -=105
        c += 1

    if x+105 in ls:
        print(1)
    elif c == t:
        print(0)
    else:
        print(1)

Buggy python submission (verdict: Runtime Error):
import sys
x=(input())
n=int(x[:-2])
t=int(x[-2]+x[-1]) 
if n > 10:
    n = 10
ans = 0
p = 0
for i in range(1,n):#0
    for j in range(1,n):#1
        for k in range(1,n):#2
            for l in range(1,n):#3
                for m in range(1,n):#4
                    for o in range(1,n):#5
                        ans += i*0+j*1+k*2+l*3+m*4+o*5
                        if ans == t:
                            print(1)
                            sys.exit()
                            
print(0)
                            
    


Fixed submission:
import sys
x=(input())
ls = [101,102,103,104,105]
if int(x) < 100:
    print(0)
else:
    t = int(x[:-2])
    x = int(x)
    c = 0
    while True:
        if x <= 100:
            break
        x -=105
        c += 1

    if x+105 in ls:
        print(1)
    elif c == t:
        print(0)
    else:
        print(1)
Buggy python submission (verdict: Runtime Error):
ls = []

n = int(input())

if n % 2 != 0:
    print(n-1)
else:
    for i in range(1,round(n/2)):
        if n % i == 0:
            ls.append(i)
        
        
    length = len(ls)
    ans = ls[length-1]
    ans2 = (round(n/ans))
    print(ans+ans2-2)


Fixed submission:
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

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())

if is_prime(n) == True:
    print(n-1)
else:
    ls = (make_divisors(n))
    if (n / ls[-1]) == ls[-1]:
        print(ls[-1]+ls[-1]-2)
    else:
        print(ls[-1]+ls[-2]-2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    print(str(a.index(i+1)+1) + " ",end="")

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ls = [0]*n
j = 0
for i in a:
    ls[i-1] = j
    j += 1
for i in ls:
    print(str(i+1) + " ",end="")
Buggy python submission (verdict: Runtime Error):
import math
n,m = map(int,input().split())
a = list(map(lambda x: -int(x),input().split()))
heapq.heapify(a)
for i in range(m):
    a_max = heapq.heappop(a)
    heapq.heappush(a,-(-a_max//2))
print(-sum(a))

Fixed submission:
import math
import heapq
n,m = map(int,input().split())
a = list(map(lambda x: -int(x),input().split()))
heapq.heapify(a)
for i in range(m):
    a_max = heapq.heappop(a)
    heapq.heappush(a,-(-a_max//2))
print(-sum(a))

Buggy python submission (verdict: Runtime Error):
import math
n,m = map(int,input().split())
a = list(map(lambda x: -int(x),input().split()))
print(a)
heapq.heapify(a)
for i in range(m):
    a_max = heapq.heappop(a)
    heapq.heappush(a,-(-a_max//2))
print(-sum(a))

Fixed submission:
import math
import heapq
n,m = map(int,input().split())
a = list(map(lambda x: -int(x),input().split()))
heapq.heapify(a)
for i in range(m):
    a_max = heapq.heappop(a)
    heapq.heappush(a,-(-a_max//2))
print(-sum(a))

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a,reverse=True)

if n == 1:
    print(a[0]//(2**m))
else:
    for i in range(m):
        if m < 1:
            a[0] = a[0]//(2**y)
            break
        else:
            a[a.index(max(a))] = a[a.index(max(a))]//(2**y)
            m -= 1
    
    print(sum(a))




Fixed submission:
import math
import heapq
n,m = map(int,input().split())
a = list(map(lambda x: -int(x),input().split()))
heapq.heapify(a)
for i in range(m):
    a_max = heapq.heappop(a)
    heapq.heappush(a,-(-a_max//2))
print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a,reverse=True)
y = 1

if n == 1:
    print(a[0]//(2**m))
else:
    for i in range(m):
        if m < 1:
            a[0] = a[0]//(2**y)
            break
        if a[0]-a[0]//(2**y) > a[1]-a[1]//(2**y):
            a[0] = a[0]//(2**y)
            i -= 1
            m -= 1
        else:
            a[0] = a[0]//(2**y)
        a = sorted(a,reverse=True)
    
    print(sum(a))




Fixed submission:
import math
import heapq
n,m = map(int,input().split())
a = list(map(lambda x: -int(x),input().split()))
heapq.heapify(a)
for i in range(m):
    a_max = heapq.heappop(a)
    heapq.heappush(a,-(-a_max//2))
print(-sum(a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
b = list(map(int,input().split()))
ans = 0

for i in range(n-2):
    ans += min(b[i],b[i+1])  

if n == 2:
    print(min(b)*2)
else:
    print(ans+b[-1]+min(b))

Fixed submission:
n = int(input())
print(n*n*n)
Buggy python submission (verdict: Runtime Error):
import copy
n = int(input())
b = list(map(int,input().split()))
ans = 0
ls = copy.copy(b)

for i in range(n-1):
    if b[i] == 0:
        ls.remove(0)
        if i+1 < n-1:
            ls.remove(b[i+1])  

if n == 2:
    print(min(b)*2)
else:
    print(sum(ls)+min(ls))

Fixed submission:
n = int(input())
b = list(map(int,input().split()))
ans = 0

for i in range(n-2):
    ans += min(b[i],b[i+1])  

print(ans+b[-1]+b[0])

Buggy python submission (verdict: Runtime Error):
import copy
n = int(input())
b = list(map(int,input().split()))
ans = 0
ls = copy.copy(b)

for i in range(n-1):
    if i > (n-2):
        break
    if b[i] == 0:
        ls.remove(0)
        ans -= b[i+1]
    else:
        ans += b[i]

if n == 2:
    print(min(b)*2)
else:
    print(ans+min(ls))

Fixed submission:
n = int(input())
b = list(map(int,input().split()))
ans = 0

for i in range(n-2):
    ans += min(b[i],b[i+1])  

print(ans+b[-1]+b[0])
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
ans = 0
ls = []
for i in range(n-1):
    if h[i] >= h[i+1]:
        ans += 1
    else:
        ls.append(ans)
        ans = 0
ls.append(ans)
print(max(ls))


Fixed submission:
s = input()
t = input()
ans = 0
for i in range(3):
    if s[i] == t[i]:
        ans += 1
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
'''
ls = []
ls_re = []
for i in range(1,n+1):
    ls.append(i)
for i in reversed(ls):
    ls_re.append(i)

ans = 0
for i in range(n):
    ans += (ls[i]%ls_re[i])
    #print(ls[i]%ls_re[i],end=" ")
'''
c = 0
for i in range(1,n):
    c += i
    
print(c)
    

Fixed submission:
n = int(input())
c = 0    
an = (n-1)*n//2
print(round(an))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = []
ls_re = []
for i in range(1,n+1):
    ls.append(i)
for i in reversed(ls):
    ls_re.append(i)

ans = 0
for i in range(n):
    ans += (ls[i]%ls_re[i])
    #print(ls[i]%ls_re[i],end=" ")

c = 0
for i in range(1,n):
    c += i
    
print(c)
    

Fixed submission:
n = int(input())
c = 0    
an = (n-1)*n//2
print(round(an))
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
c = 0
for i in range(len(h)-2):
    if h[i+2]<h[i+1]<h[i] or h[i+1]-h[i] < -2:
        print("No")
        c += 1
        break
        
if c == 0:
    if h[-1]-h[-2] < -2:
        print("No")
    else:
        print("Yes")

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
c = 0
t = 0
for i in range(len(h)-2):
    if h[i+2]<h[i+1]<h[i] or h[i+1]-h[i] <= -2:
        print("No")
        c += 1
        break
    if h[i+1]<h[i]:
        t += 1
        if t == 2:
            print("No")
            c += 1
            break
    elif h[i+1]>h[i]:
        t = 0
    
            
if c == 0:
    if len(h)>=2:
        if h[-1]-h[-2] <= -2:
            print("No")
        else:
            print("Yes")
    else:
        print("Yes")

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
c = 0
for i in range(len(h)-2):
    if h[i+2]<h[i+1]<h[i] or h[i+1]-h[i] >= 3:
        print("No")
        c += 1
        break
        
if c == 0:
    if h[-1]-h[-2] >= 3:
        print("No")
    else:
        print("Yes")

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
c = 0
t = 0
for i in range(len(h)-2):
    if h[i+2]<h[i+1]<h[i] or h[i+1]-h[i] <= -2:
        print("No")
        c += 1
        break
    if h[i+1]<h[i]:
        t += 1
        if t == 2:
            print("No")
            c += 1
            break
    elif h[i+1]>h[i]:
        t = 0
    
            
if c == 0:
    if len(h)>=2:
        if h[-1]-h[-2] <= -2:
            print("No")
        else:
            print("Yes")
    else:
        print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
ls = []
for i in range(n):
    a = int(input())
    ls.append(a) 

ans = max(ls)
for i in range(len(ls)):
    ls2 = copy.copy(ls)
    del ls2[i]
    if ans in ls2:
        print(ans)
    else:
        ls2.sort()
        print(ls2[-1])
    

Fixed submission:
import copy
n = int(input())
ls = []
for i in range(n):
    a = int(input())
    ls.append(a) 
ls2 = copy.copy(ls)
ls.sort()
max1 = ls[-1]
max2 = ls[-2]


for i in ls2:
    if i != max1:
        print(max1)
    else:
        print(max2)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
ls = []
for i in range(n):
    a = int(input())
    ls.append(a) 
    
for i in range(len(ls)):
    ls2 = copy.copy(ls)
    del ls2[i]
    ls2 = sorted(ls2)
    print(ls2[-1])
    

Fixed submission:
import copy
n = int(input())
ls = []
for i in range(n):
    a = int(input())
    ls.append(a) 
ls2 = copy.copy(ls)
ls.sort()
max1 = ls[-1]
max2 = ls[-2]


for i in ls2:
    if i != max1:
        print(max1)
    else:
        print(max2)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
ls = []
for i in range(n):
    a = int(input())
    ls.append(a) 
    
for i in range(len(ls)):
    ls2 = copy.copy(ls)
    del ls2[i]
    print(max(ls2))
    

Fixed submission:
import copy
n = int(input())
ls = []
for i in range(n):
    a = int(input())
    ls.append(a) 
ls2 = copy.copy(ls)
ls.sort()
max1 = ls[-1]
max2 = ls[-2]


for i in ls2:
    if i != max1:
        print(max1)
    else:
        print(max2)
Buggy python submission (verdict: Runtime Error):
import copy
n = int(input())
a = list(map(int,input().split()))
a2 = copy.copy(a)
c = 0
d = len(a)
for i in range(len(a)):
    if i+1 == len(a):
        ans = a[i-1] ^ a[0]
        if (ans in a2):
            try:
                a2.remove(ans)
            except e:
                break
        else:
            break
    else:
        ans = a[i-1] ^ a[i+1]
        if (ans in a2):
            try:
                a2.remove(ans)
            except e:
                break
        else:
            break
    c += 1
    print(a2)

if c == d:
    print("Yes")
else:
    print("No")



Fixed submission:
n=int(input())
al=list(map(int,input().split()))
t=0
for a in al:
    t^=a
print('Yes' if t==0 else 'No')

Buggy python submission (verdict: Runtime Error):
import copy
n = int(input())
a = list(map(int,input().split()))
a2 = copy.copy(a)
c = 0
d = len(a)
for i in range(len(a)):
    if i+1 == len(a):
        ans = a[i-1] ^ a[0]
        if (ans in a):
            try:
                a2.remove(ans)
            except e:
                break
        else:
            break
    else:
        ans = a[i-1] ^ a[i+1]
        if (ans in a):
            try:
                a2.remove(ans)
            except e:
                break
        else:
            break
    c += 1

if c == d:
    print("Yes")
else:
    print("No")



Fixed submission:
n=int(input())
al=list(map(int,input().split()))
t=0
for a in al:
    t^=a
print('Yes' if t==0 else 'No')

Buggy python submission (verdict: Runtime Error):
import copy
n = int(input())
a = list(map(int,input().split()))
a2 = copy.copy(a)
c = 0
d = len(a)
for i in range(len(a)):
    if i+1 == len(a):
        ans = a[i-1] ^ a[0]
        if (ans in a):
            a2.remove(ans)
        else:
            break
    else:
        ans = a[i-1] ^ a[i+1]
        if (ans in a):
            a2.remove(ans)
        else:
            break
    c += 1

if c == d:
    print("Yes")
else:
    print("No")


Fixed submission:
n=int(input())
al=list(map(int,input().split()))
t=0
for a in al:
    t^=a
print('Yes' if t==0 else 'No')
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
import math
a,b,c,d = map(int,input().split())
 
an1 = math.floor(b/c)
an2 = math.floor((a-1)/c)
an3 = math.floor(b/d)
an4 = math.floor((a-1)/d)
 
gcd = round(c * d / gcd(c, d))
 
an5 = math.floor(b/gcd)
an6 = math.floor((a-1)/gcd)
an = an1-an2 + an3-an4 -(an5-an6)
print((b-a+1)-an)

Fixed submission:
s = list(input())
count = 0
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        count += 1

if count > 0:
    print("Bad")
else:
    print("Good")

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
import math
a,b,c,d = map(int,input().split())


an1 = math.floor(b/c)
an2 = math.floor((a-1)/c)
an3 = math.floor(b/d)
an4 = math.floor((a-1)/d)

gcd = round(c * d / gcd(c, d))

an5 = math.floor(b/gcd)
an6 = math.floor((a-1)/gcd)
an = an1-an2 + an3-an4 -(an5-an6)
print((b-a+1)-an)

    

Fixed submission:
s = list(input())
count = 0
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        count += 1

if count > 0:
    print("Bad")
else:
    print("Good")
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
a,b,c,d = map(int,input().split())

if c == 1 or d == 1:
    print(0)
else:
    an1 = math.floor(b/c)
    an2 = math.floor((a-1)/c)
    an3 = math.floor(b/d)
    an4 = math.floor((a-1)/d) 
    gcd = round(c * d / gcd(c, d))
    an5 = math.floor(b/gcd)
    an6 = math.floor((a-1)/gcd)
    an = an1-an2 + an3-an4 -(an5-an6)
    print((b-a+1)-an)

Fixed submission:
from fractions import gcd
import math
a,b,c,d = map(int,input().split())

if c == 1 or d == 1:
    print(0)
elif a == b:
    if a%c == 0 or a%d == 0:
        print(0)
    else:
        print(1)
else:
    an1 = (b//c)
    an2 = ((a-1)//c)
    an3 = (b//d)
    an4 = ((a-1)//d) 
    gcd = round(c * d / gcd(c, d))
    an5 = (b//gcd)
    an6 = ((a-1)//gcd)
    if c == d:
        an = an1-an2
    else:
        an = an1-an2 + an3-an4 -(an5-an6)
    print((b-a+1)-an)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())


an1 = math.floor(b/c)
an2 = math.floor((a-1)/c)
an3 = math.floor(b/d)
an4 = math.floor((a-1)/d)

gcd = round(c * d / math.gcd(c, d))

an5 = math.floor(b/gcd)
an6 = math.floor((a-1)/gcd)
an = an1-an2 + an3-an4 -(an5-an6)
print((b-a+1)-an)

    

Fixed submission:
from fractions import gcd
import math
a,b,c,d = map(int,input().split())

if c == 1 or d == 1:
    print(0)
elif a == b:
    if a%c == 0 or a%d == 0:
        print(0)
    else:
        print(1)
else:
    an1 = (b//c)
    an2 = ((a-1)//c)
    an3 = (b//d)
    an4 = ((a-1)//d) 
    gcd = round(c * d / gcd(c, d))
    an5 = (b//gcd)
    an6 = ((a-1)//gcd)
    if c == d:
        an = an1-an2
    else:
        an = an1-an2 + an3-an4 -(an5-an6)
    print((b-a+1)-an)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = map(int,input().split())

lists = []
for i in range(b-a+1):
    lists.append(a)
    a += 1
an = 0

for j in lists:
    if j % (c*d) == 0:
        an += 1
    elif j % c == 0:
        an += 1
    elif j % d == 0:
        an += 1
print(len(lists)-an)

Fixed submission:
from fractions import gcd
import math
a,b,c,d = map(int,input().split())

if c == 1 or d == 1:
    print(0)
elif a == b:
    if a%c == 0 or a%d == 0:
        print(0)
    else:
        print(1)
else:
    an1 = (b//c)
    an2 = ((a-1)//c)
    an3 = (b//d)
    an4 = ((a-1)//d) 
    gcd = round(c * d / gcd(c, d))
    an5 = (b//gcd)
    an6 = ((a-1)//gcd)
    if c == d:
        an = an1-an2
    else:
        an = an1-an2 + an3-an4 -(an5-an6)
    print((b-a+1)-an)