Problem p02995 (python)

Fixed submission:
def G(x,y):
    if(x<y):
        x,y=y,x
    if(y==0):
        return x
    return G(y,x%y)


a,b,c,d=map(int,input().split())
ans=0
# print(a,b,c,d,b//c,a//c)
ans+=(b//c-a//c+(a%c==0))
# print(ans)
ans+=(b//d-a//d+(a%d==0))
# print(ans)
lcm=c*d//G(c,d)
ans-=(b//lcm-a//lcm+(a%lcm==0))
print(b-a+1-ans)

Buggy submission (verdict: Runtime Error):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)
def G(x,y):
    if(x<y):
        x,y=y,x
    if(y==0):
        return x
    return G(y,x%y)


a,b,c,d=l()
ans=0
# print(a,b,c,d,b//c,a//c)
ans+=(b//c-a//c+(a%c==0))
# print(ans)
ans+=(b//d-a//d+(a%d==0))
# print(ans)
lcm=c*d//gcd(c,d)
ans-=(b//lcm-a//lcm+(a%lcm==0))
print(b-a+1-ans)

Buggy submission (verdict: Runtime Error):
import math

print(math.gcd(100000003,10000003))

Buggy submission (verdict: Runtime Error):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)
def G(x,y):
    if(x<y):
        x,y=y,x
    if(y==0):
        return x
    return G(y,x%y)


a,b,c,d=l()
ans=0
# print(a,b,c,d,b//c,a//c)
ans+=(b//c-a//c+(a%c==0))
# print(ans)
ans+=(b//d-a//d+(a%d==0))
# print(ans)
lcm=c*d//G(c,d)
ans-=(b//lcm-a//lcm+(a%lcm==0))
print(b-a+1-ans)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
ans=0
ans+=(b//c-a//c+(a%c==0))
ans+=(b//d-a//d+(a%d==0))
lcm=c*d//math.gcd(c,d)
ans-=(b//lcm-a//lcm+(a%lcm==0))
print(b-a+1-ans)

Buggy submission (verdict: Runtime Error):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)

# def seive():
#     prime=[1 for i in range(10**6+1)]
#     prime[0]=0
#     prime[1]=0
#     for i in range(10**6+1):
#         if(prime[i]):
#             for j in range(2*i,10**6+1,i):
#                 prime[j]=0


a,b,c,d=l()
print(a)
exit()
ans=0
# print(a,b,c,d,b//c,a//c)
ans+=(b//c-a//c+(a%c==0))
# print(ans)
ans+=(b//d-a//d+(a%d==0))
# print(ans)
lcm=c*d//gcd(c,d)
ans-=(b//lcm-a//lcm+(a%lcm==0))
print(b-a+1-ans)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
ans=0
# print(a,b,c,d,b//c,a//c)
ans+=(int(b/c)-int(a/c)+(a%c==0))
# print(ans)
ans+=(int(b/d)-int(a/d)+(a%d==0))
# print(ans)
lcm=c*d/math.gcd(c,d)
ans-=(int(b/lcm)-int(a/lcm)+(a%lcm==0))
print(b-a+1-ans)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input())
ans=0
# print(a,b,c,d,b//c,a//c)
ans+=(b//c-a//c+(a%c==0))
# print(ans)
ans+=(b//d-a//d+(a%d==0))
# print(ans)
lcm=c*d//math.gcd(c,d)
ans-=(b//lcm-a//lcm+(a%lcm==0))
print(b-a+1-ans)

Buggy submission (verdict: Runtime Error):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)

# def seive():
#     prime=[1 for i in range(10**6+1)]
#     prime[0]=0
#     prime[1]=0
#     for i in range(10**6+1):
#         if(prime[i]):
#             for j in range(2*i,10**6+1,i):
#                 prime[j]=0


a,b,c,d=l()
ans=0
# print(a,b,c,d,b//c,a//c)
ans+=(b//c-a//c+(a%c==0))
# print(ans)
ans+=(b//d-a//d+(a%d==0))
# print(ans)
lcm=c*d//gcd(c,d)
ans-=(b//lcm-a//lcm+(a%lcm==0))
print(b-a+1-ans)