Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a * b % 2 == 1:
    print(Odd)
else:
    print(Even)

Fixed submission:
a, b = map(int, input().split())
if a * b % 2 == 1:
    print("Odd")
else:
    print("Even")
Buggy python submission (verdict: Runtime Error):
n = input()
num = list(map(int, input().split()))
count = 0
while sum(num) % 2 == 0:
    for i in range(n):
        num[i] /= 2
    count += 1
print(count)

Fixed submission:
n = int(input())
num = list(map(int, input().split()))
count = 0
while True:
    exist_odd = "false"
    for i in range(n):
        if num[i] % 2 != 0:
            exist_odd = "True"
    if exist_odd == "True":
        break
    for i in range(n):
        num[i] /= 2
    count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
botan = [int(input()) for i in range(n)]
light = 1 # 1番目のボタンが初め光ってる
count = 1
exi = [1]

if 2 in botan:

    while True:
        light = botan[light - 1]
        if light in exi:
            print(-1)
            exit()
        exi.append(light)
    
        if 2 in exi:
            print(count)
            exit()
        count += 1

else:
    print(-1)

Fixed submission:
n = int(input())
botan = [int(input()) for i in range(n)]
light = 0 # 1番目のボタンが初め光ってる
count = 0

for i in range(n):
    light = botan[light] - 1
    if light == 1:
        break
    
if i == n - 1:
    print(-1)
else:
    print(i + 1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
botan = [int(input()) for i in range(n)]
light = 1 # 1番目のボタンが初め光ってる
count = 1
exi = [1]

if 2 in botan:

    while True:
    light = botan[light - 1]
    if light in exi:
        print(-1)
        exit()
    exi.append(light)
    
    if 2 in exi:
        print(count)
        exit()
    count += 1

else:
    print(-1)

Fixed submission:
n = int(input())
botan = [int(input()) for i in range(n)]
light = 0 # 1番目のボタンが初め光ってる
count = 0

for i in range(n):
    light = botan[light] - 1
    if light == 1:
        break
    
if i == n - 1:
    print(-1)
else:
    print(i + 1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
botan = [int(input()) for i in range(n)]
light = 1 # 1番目のボタンが初め光ってる
count = 1
exi = [1]

if 2 is not in botan:
    print(-1)
    exit()

while True:
    light = botan[light - 1]
    if light in exi:
        print(-1)
        exit()
    exi.append(light)
    
    if 2 in exi:
        print(count)
        exit()
    count += 1

Fixed submission:
n = int(input())
botan = [int(input()) for i in range(n)]
light = 0 # 1番目のボタンが初め光ってる
count = 0

for i in range(n):
    light = botan[light] - 1
    if light == 1:
        break
    
if i == n - 1:
    print(-1)
else:
    print(i + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
botan = [int(input()) for i in range(n)]
light = 1 # 1番目のボタンが初め光ってる
count = 1
exi = [1]
while True:
    light = botan[light - 1]
    if light in exi:
        print(-1)
        exit()
        break
    exi.append(light)
    
    if 2 in exi:
        print(count)
        exit()
        break
    count += 1

Fixed submission:
n = int(input())
botan = [int(input()) for i in range(n)]
light = 0 # 1番目のボタンが初め光ってる
count = 0

for i in range(n):
    light = botan[light] - 1
    if light == 1:
        break
    
if i == n - 1:
    print(-1)
else:
    print(i + 1)
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 l in range(k + 1):
            if i + j + l == s:
                count += 1
print(count)

Fixed submission:
k, s = map(int, input().split())
count = 0
for i in range(k + 1):
    for j in range(k + 1):
            if 0 <= s - i - j <= k:
                count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
ans = 0

def fanc(n, x):
    if n == -1:
        f = 0
    else:
        f = n // (x + 1) # 切り捨て除算//を使うとint同士ならintで返してくれるから楽
    return f
print(fanc(b, x) - fanc(a - 1, x)) 

Fixed submission:
a, b, c = map(str, input().split())
abb = a[0] + b[0] + c[0]
print(abb)

Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
ans = 0

def fanc(n, x):
    if n == -1:
        f = 0
    else:
        f = n // x + 1 
                        # 切り捨て除算//を使うとint同士ならintで返してくれるから楽
    return f
print(fanc(b, x) - fanc(a - 1, x))

Fixed submission:
a, b, c = map(str, input().split())
abb = a[0] + b[0] + c[0]
print(abb)

Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
ans = 0

def fanc(n, x):
    if n == -1:
        f = 0
    else:
        f = n // x + 1 # 切り捨て除算//を使うとint同士ならintで返してくれるから楽
    return f
print(fanc(b, x) - fanc(a - 1, x))

Fixed submission:
a, b, c = map(str, input().split())
abb = a[0] + b[0] + c[0]
print(abb)
Buggy python submission (verdict: Runtime Error):
import sys
import itertools
from functools import reduce
import math
#import fractions
import numpy as np


def calc_double(n):
    return n//2
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

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

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



def resolve():
    input = sys.stdin.readline
    N,M=map(int,input().rstrip().split())
    A=list(map(int,input().rstrip().split()))
    AA=list(map(calc_double,A))
    """
    AA=[0 for _ in range(N)]
    for i in range(N):
        AA[i]=M//A[i]-0.5
    
    for i in range(N):
        AA[i]
    """
    aa= np.array(AA)
    a=int(np.lcm.reduce(aa))
    #a=lcm_list(AA)
    #a=a//2
    """
    count=0
    for i in range(1,M+1,2):
        if a*i<=M:
            count+=1
        else:
            break
    """
    odd=M//a
    count=(odd+1)//2

    print(count)

    

from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 50
6 10"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 100
14 22 40"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5 1000000000
6 6 2 6 2"""
        output = """166666667"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Fixed submission:
import sys

def resolve():
    input = sys.stdin.readline
    K,X=map(int,input().rstrip().split())
     
    if K*500>=X:
        print("Yes")
    else:
        print("No")

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 900"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1 501"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """4 2000"""
        output = """Yes"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
A,B,K=map(int,input().rstrip().split())

def resolve():
    
    if(A>K):
        ansA=int(A)-int(K)
        ansB=int(B)
    else:
        ansA=0
        ansB=int(B)-(int(K)-int(A))
        if(ansB<0):
            ansB=0
    print((int(ansA))+" "+(int(ansB)))

import sys
from io import StringIO
import unittest
#1000000000000 1000000000000 1000000000001
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 3 3"""
        output = """0 2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """500000000000 500000000000 1000000000000"""
        output = """0 0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Fixed submission:
import sys
input = sys.stdin.readline
A,B,K=map(int,input().rstrip().split())

def resolve():
    
    if(A>K):
        ansA=int(A)-int(K)
        ansB=int(B)
    else:
        ansA=0
        ansB=int(B)-(int(K)-int(A))
        if(ansB<0):
            ansB=0
    print(str(int(ansA))+" "+str(int(ansB)))

import sys
from io import StringIO
import unittest
#1000000000000 1000000000000 1000000000001
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 3 3"""
        output = """0 2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """500000000000 500000000000 1000000000000"""
        output = """0 0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque


   
def resolve():
    
    input = sys.stdin.readline
    N,K=map(int,input().rstrip().split())
    R,S,P=map(int,input().rstrip().split())
    T=list(input().rstrip())

    ans=0
    flag=[0 for _ in range(N)]
    for i in range(N):
        if T[i]==T[i-K] and i>=K and flag[i-K]==True: #足さない条件、K個前が既に制約で足せなくなっていた時は、今回は足せるようになるのでflag管理
            continue
        if T[i]=="r":
            ans+=P
        if T[i]=="s":
            ans+=R
        if T[i]=="p":
            ans+=S
        flag[i]=True
    print(ans)

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5 2
8 7 6
rsrpr"""
        output = """27"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """7 1
100 10 1
ssssppr"""
        output = """211"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """30 5
325 234 123
rspsspspsrpspsppprpsprpssprpsr"""
        output = """4996"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Fixed submission:
import sys
input = sys.stdin.readline
X=int(input().rstrip())
maxX=10**6

def resolve():
    check,table=sieve(maxX)

    for a in table:
        if a>=X:
            print(a)
            return

def sieve(n):#n以下の素数を返す, is_prime[i]:iが素数ならtrue、table[i]:小さい順に素数入る
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    is_prime=[False]+is_prime ##[False]は勝手につけた、累積和をするときはこの影響で[0]+いらない
    return is_prime, table


import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """20"""
        output = """23"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """99992"""
        output = """100003"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()
Buggy python submission (verdict: Runtime Error):

import sys
import math
def resolve():
    S=input().rstrip()
    c=0
    for i in range((len(S)/2)):
        if(S[i]!=S[-i-1]):
            c+=1
    print(c)

from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """redcoder"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """vvvvvv"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """abcdabc"""
        output = """2"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Fixed submission:

import sys
import math
def resolve():
    S=list(input().rstrip())
    c=0
    for i in range(math.floor(len(S)/2)):
        if(S[i]!=S[len(S)-i-1]):
            c+=1
    print(c)

from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """redcoder"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """vvvvvv"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """abcdabc"""
        output = """2"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()
Buggy python submission (verdict: Time Limit Exceeded):

import sys
input = sys.stdin.readline
N,K=map(int,input().rstrip().split())
h=list(map(int,input().rstrip().split()))

inf=10**9+7
dp=[inf]*N
dp[0]=0

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

Fixed submission:
import sys
input = sys.stdin.readline
N,K=map(int,input().rstrip().split())
h=list(map(int,input().rstrip().split()))

inf=10**9+7
dp=[inf]*N
dp[0]=0

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

Buggy python submission (verdict: Runtime Error):

import sys
input = sys.stdin.readline
N,K=map(int,input().rstrip().split())
h=list(map(int,input().rstrip().split()))

inf=10**9+7
dp=[inf]*N
 for i in range(N):
     dp[i]=1000000000000
dp[0]=0

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

Fixed submission:
import sys
input = sys.stdin.readline
N,K=map(int,input().rstrip().split())
h=list(map(int,input().rstrip().split()))

inf=10**9+7
dp=[inf]*N
dp[0]=0

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

Buggy python submission (verdict: Time Limit Exceeded):

import sys
input = sys.stdin.readline
N,K=map(int,input().rstrip().split())
h=list(map(int,input().rstrip().split()))

inf=10**9+7
dp=[inf]*N
dp[0]=0

for i in range(1,N,1):
    for k in range(1,K+1,1):
        if(i-k>=0):
            dp[i]=min(dp[i],dp[i-k]+abs(h[i]-h[i-k]))
        else:
            break
print(dp[N-1])


Fixed submission:
import sys
input = sys.stdin.readline
N,K=map(int,input().rstrip().split())
h=list(map(int,input().rstrip().split()))

inf=10**9+7
dp=[inf]*N
dp[0]=0

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

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N,K=map(int,input().rstrip().split())
h=list(map(int,input().rstrip().split()))

dp=[0]*N
for i in range(N):
    dp[i]=1000000000000
dp[0]=0

for i in range(1,N,1):
    for k in range(1,K+1,1):
        if(i-k>=0):
            dp[i]=min(dp[i],dp[i-k]+abs(h[i]-h[i-k]))
        else:
            break
print(dp[N-1])
 

Fixed submission:
import sys
input = sys.stdin.readline
N,K=map(int,input().rstrip().split())
h=list(map(int,input().rstrip().split()))

inf=10**9+7
dp=[inf]*N
dp[0]=0

for i in range(1,N,1):
    for k in range(1,K+1,1):
        if(i-k<0):
            continue
        dp[i]=min(dp[i],dp[i-k]+abs(h[i]-h[i-k]))
print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
A,B,C=map(int,input().rstrip().split())
for i in range(B):
    if (i*(A%B))% B == C:
        print("YES")
        return
print("NO")

Fixed submission:
import sys
input = sys.stdin.readline
A,B,C=map(int,input().rstrip().split())
for i in range(B):
    if (i*(A%B))% B == C:
        print("YES")
        exit()
print("NO")
Buggy python submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
s = [0]
c = [0]
num = [0] * (N + 1)
reg = [0] * (N + 1)
if N > 1:
  num[1] = 1

for i in range(M):
  a, b = map(int, input().split())
  if N > 1 and a == 1 and b == 0:
    print (-1)
    sys.exit()

  s.append(a)
  c.append(b)

for i in range(1, M + 1):
  if reg[s[i]] == 1 and num[s[i]] != c[i]:
    print (-1)
    sys.exit()
  num[s[i]] = c[i]
  reg[s[i]] = 1

result = ""
for i in range(1, M + 1):
  result += str(num[i])
print (result)



Fixed submission:
import sys
N, M = map(int, input().split())
num = [0] * (N + 1)
reg = [0] * (N + 1)
if N > 1:
  num[1] = 1

for i in range(M):
  s, c = map(int, input().split())
  if N > 1 and s == 1 and c == 0:
    print (-1)
    sys.exit()
  if reg[s] == 1 and num[s] != c:
    print (-1)
    sys.exit()
  num[s] = c
  reg[s] = 1

result = ""
for i in range(1, N + 1):
  result += str(num[i])
print (result)
Buggy python submission (verdict: Time Limit Exceeded):
r1, c1, r2, c2 = map(int, input().split())
L = 10 ** 9 + 7

# 互除法
def get_euclidian (A, B):
  if B == 1:
    return (1)
  else:
    return (int((1 - A * get_euclidian (B, A % B)) / B))

# 階乗計算
F = [1]
for i in range(1, r2 + c2 + 3):
  F.append(F[i - 1] * i)

# 組み合わせ計算
def get_combi (n, r):

  NmodL = F[n] % L
  RmodL = F[r] % L
  SmodL = F[n-r] % L
  Euc = (get_euclidian(L, RmodL * SmodL) + L) % L
  return ((NmodL * Euc) % L)

combi1 = get_combi(r2 + c2 + 2, r2 + 1)
combi2 = get_combi(r2 + c1 + 1, c1)
combi3 = get_combi(r1 + c2 + 1, r1)
combi4 = get_combi(r1 + c1, r1)

print (int(combi1 - combi2 - combi3 + combi4))

Fixed submission:
r1, c1, r2, c2 = map(int, input().split())
L = 10 ** 9 + 7

# 互除法
def get_euclidian (A, B):
  if B == 1:
    return (1)
  else:
    return (int((1 - A * get_euclidian (B, A % B)) / B))

# 階乗計算
F = [1]
for i in range(1, r2 + c2 + 3):
  F.append((F[i - 1] * i) % L)

# 組み合わせ計算
def get_combi (n, r):

  Euc = get_euclidian(L, (F[r] * F[n - r]) % L)
  return ((F[n] * Euc) % L)

combi1 = get_combi(r2 + c2 + 2, r2 + 1)
combi2 = get_combi(r2 + c1 + 1, c1)
combi3 = get_combi(r1 + c2 + 1, r1)
combi4 = get_combi(r1 + c1, r1)

print ((int(combi1 - combi2 - combi3 + combi4) + L) % L)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd

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

if B < C and B < D:
    print(B - A + 1)
    exit()

CD_lcm = C * D // gcd(C, D)

n_cant_divs = []
for target in [C, D, CD_lcm]:
    if A <= target <= B:
        t_cant_div = target - A
        can_div = B // target
        t_cant_div2 = (B - target + 1) - can_div
        n_cant_divs.append(t_cant_div + t_cant_div2)
    elif target < A:
        can_div_w_over = B // target
        correction = (A - 1) // target
        actual_can_div = can_div_w_over - correction
        t_cant_div = (B - A + 1) - actual_can_div
        n_cant_divs.append(t_cant_div)

print(n_cant_divs[0] + n_cant_divs[1] - n_cant_divs[2])


Fixed submission:
from fractions import gcd

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

CD_lcm = (C * D) // gcd(C, D)


def divided(a, b, target):
    return b // target - (a - 1) // target


all_num = B - A + 1

div_t1 = divided(A, B, C)
div_t2 = divided(A, B, D)
div_extra = divided(A, B, CD_lcm)

print(all_num - div_t1 - div_t2 + div_extra)

Buggy python submission (verdict: Runtime Error):
from fractions import gcd

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

if B < C and B < D:
    print(A - B + 1)
    exit()

CD_lcm = C * D // gcd(C, D)

n_cant_divs = []
for target in [C, D, CD_lcm]:
    if A <= target <= B:
        t_cant_div = target - A
        can_div = B // target
        t_cant_div2 = (B - target + 1) - can_div
        n_cant_divs.append(t_cant_div + t_cant_div2)
    elif target < A:
        can_div_w_over = B // target
        correction = (A - 1) // target
        actual_can_div = can_div_w_over - correction
        t_cant_div = (B - A + 1) - actual_can_div
        n_cant_divs.append(t_cant_div)

print(n_cant_divs[0] + n_cant_divs[1] - n_cant_divs[2])


Fixed submission:
from fractions import gcd

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

CD_lcm = (C * D) // gcd(C, D)


def divided(a, b, target):
    return b // target - (a - 1) // target


all_num = B - A + 1

div_t1 = divided(A, B, C)
div_t2 = divided(A, B, D)
div_extra = divided(A, B, CD_lcm)

print(all_num - div_t1 - div_t2 + div_extra)