Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import Math

h, a = map(int, input().split())
print(math.ceil(h/a))


Fixed submission:
import math

h, a = map(int, input().split())
print(math.ceil(h/a))

Buggy python submission (verdict: Runtime Error):
import Math

h, a = map(int, input().split())
print(math.ceil(h//a + 1))


Fixed submission:
import math

h, a = map(int, input().split())
print(math.ceil(h/a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))

cnt = 0
tmp = []
for i in range(len(lst)):
    num = lst[i]
    tmp.append(num)
    if num == min(tmp):
        cnt += 1

print(cnt)


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

cnt = 0
tmp_min = max(lst)
for i in range(len(lst)):
    num = lst[i]
    if num <= tmp_min:
        cnt += 1
        tmp_min = num

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))

cnt = 0
for i in range(len(lst)):
    num = lst[i]
    if num == min(lst[:i+1]):
        cnt += 1

print(cnt)


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

cnt = 0
tmp_min = max(lst)
for i in range(len(lst)):
    num = lst[i]
    if num <= tmp_min:
        cnt += 1
        tmp_min = num

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))

cnt = 0
for i in range(len(lst)):
    num = lst[i]
    if num == min(sorted(lst[:i+1])):
        cnt += 1

print(cnt)


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

cnt = 0
tmp_min = max(lst)
for i in range(len(lst)):
    num = lst[i]
    if num <= tmp_min:
        cnt += 1
        tmp_min = num

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))

cnt = 0
for i in range(len(lst)):
    num = lst[i]
    r_lst = sorted(lst[:i+1])

    if num == r_lst[0]:
        cnt += 1

print(cnt)


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

cnt = 0
tmp_min = max(lst)
for i in range(len(lst)):
    num = lst[i]
    if num <= tmp_min:
        cnt += 1
        tmp_min = num

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))

cnt = 0
for i in range(len(lst)):
    num = lst[i]
    bl = True
    for j in lst[:i]:
        if num > j:
            bl = False
            break

    if bl:
        cnt += 1

print(cnt)


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

cnt = 0
tmp_min = max(lst)
for i in range(len(lst)):
    num = lst[i]
    if num <= tmp_min:
        cnt += 1
        tmp_min = num

print(cnt)
Buggy python submission (verdict: Runtime Error):
import math


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


a, b = map(int, input().split())

print(lcm(a, b))


Fixed submission:
import fractions


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


a, b = map(int, input().split())

print(lcm(a, b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))

ans = ''
for i in range(1, n+1):
    rank = lst.index(i) + 1
    ans += ' ' + str(rank)


print(ans[1:])


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


tmp = [0] * (n+1)
for i, num in enumerate(lst):
    tmp[num] = str(i + 1)

tmp.pop(0)

print(' '.join(tmp))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))

ans = []
for i in range(1, n+1):
    rank = lst.index(i) + 1
    ans.append(str(rank))


print(' '.join(ans))


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


tmp = [0] * (n+1)
for i, num in enumerate(lst):
    tmp[num] = str(i + 1)

tmp.pop(0)

print(' '.join(tmp))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = [int(i) for i in input.split()]

max_num = max(b)
min_num = min(b)

print(max_num - min_num)

Fixed submission:
a = int(input())
b = [int(i) for i in input().split()]

max_num = max(b)
min_num = min(b)

print(max_num - min_num)
Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())

noguchi = 1000
higuchi = 5000
yukichi = 10000

ans = '-1 -1 -1'
for i in range(n+1):
    for j in range(n+1-i):
        k = n - (i+j)
        yen = noguchi * i + higuchi * j + yukichi * k
        if yen == y:
            ans = f'{k} {j} {i}'
            break

print(ans)


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

i, j, k = -1, -1, -1

for a in range(n + 1):
    for b in range(n+1-a):
        sum = (10000*a) + (5000*b) + (1000 * (n-(a+b))) if n-(a+b) >= 0 else None
        if sum == y:
            i, j, k = a, b, n-(a+b)
            break


print(i, j, k)

Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())

noguchi = 1000
higuchi = 5000
yukichi = 10000

ans = '-1 -1 -1'
for i in range(n+1):
    for j in range(n+1-i):
        k = n - (i+j)
        yen = noguchi * i + higuchi * j + yukichi * k
        if yen == y:
            ans = f'{k} {j} {i}'
            break

print(ans)

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

i, j, k = -1, -1, -1

for a in range(n + 1):
    for b in range(n+1-a):
        sum = (10000*a) + (5000*b) + (1000 * (n-(a+b))) if n-(a+b) >= 0 else None
        if sum == y:
            i, j, k = a, b, n-(a+b)
            break


print(i, j, k)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

for a in range(10**4):
    for b in range(10**4):
        if(a**5 + b**5 == x):
            print(a, -b)
            break
        elif(a**5 - b**5 == x):
            print(a, b)
            break

Fixed submission:
x = int(input())

for a in range(10**4):
    for b in range(10**4):
        if(a**5 + b**5 == x):
            print(a, -b)
            break
        elif(a**5 - b**5 == x):
            print(a, b)
            break
    else:
        continue
    break

Buggy python submission (verdict: Runtime Error):
x = int(input())

for a in range(1, 10**9):
    if (x%(a-b) != 0):
        continue
    
    tmp = a**5 - x
    if (tmp <= 0):
        tmp *= -1
        
    b = tmp**(1/5)
    if(b == int(b)):
        print(a, int(b))
        break

Fixed submission:
x = int(input())

for a in range(10**4):
    for b in range(10**4):
        if(a**5 + b**5 == x):
            print(a, -b)
            break
        elif(a**5 - b**5 == x):
            print(a, b)
            break
    else:
        continue
    break
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int, input().split())

max_score = 0
for x in range(1,min(b+1, n+1)):
    score = int(a*x/b) - a*int(x/b)
    if (score > max_score):
        max_score = score
        
print(max_score)

Fixed submission:
import math

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

for x in range(min(b, n), 0, -1):
    score = math.floor((a*x)/b) - math.floor(a*(x//b))
    if (score > 0):
        print(score)
        break
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int, input().split())
x = [int(x) for x in input().split(' ')]

mp = 0
for i in range(n-1):
    mp += min(a*(x[i+1]-x[i]), b)
    
print(mp)

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

print(max(a*b,c*d))
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int, input().split())
x = [int(x) for x in input().split(' ')]

mp = 0
for i in range(n-1):
    mp += min(a*(x[i+1]-x[i], b))
    
print(mp)

Fixed submission:
n,a,b = map(int, input().split())
x = [int(_) for _ in input().split(' ')]

mp = 0
for i in range(n-1):
    mp += min(a*(x[i+1]-x[i]), b)
    
print(mp)
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 x in range(k+1):
    for y in range(k+1):
        z = s-(x+y)
        if (0 <= z <= k):
            count += 1
                
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
q = [int(x) for x in input().split(' ')]

contradiction = False
if (n%2 == 1):
    count = 2**((n-1)//2)
    for i in range(0,n,2):
        if(i == 0):
            contradiction = (q.count(i) != 1)
        else:
            contradiction = (q.count(i) != 2)
else:
    count = 2**(n//2)
    for i in range(1,n,2):
        contradiction = (q.count(i) != 2)
    
if (contradiction):
    print(0)
else:
    print(count%(10**9+7))

Fixed submission:
n = int(input())
q = [int(x) for x in input().split(' ')]
q_set = set(q)

if (n%2 == 1):
    count = 2**((n-1)//2)
else:
    count = 2**(n//2)
    
    
if (sum(q) == 2*sum(q_set)):
    print(count%(10**9+7))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):


patterns = []
for i in range(2**(l-1)):
    pattern = [''] * (l-1)
    for j in range(l-1):
        if (i >> j & 1):
            pattern[j] = '+'
    patterns.append(pattern)

ans = 0
for pattern in patterns:
    a = s[0]
    for i in range(l-1):
        if (pattern[i] == ''):
            a += s[i+1]
        else:
            ans += int(a)
            a = s[i+1]
    else:
        ans += int(a)

print(ans)

Fixed submission:
s = input()
l = len(s)

patterns = []
for i in range(2**(l-1)):
    pattern = [''] * (l-1)
    for j in range(l-1):
        if (i >> j & 1):
            pattern[j] = '+'
    patterns.append(pattern)

ans = 0
for pattern in patterns:
    a = s[0]
    for i in range(l-1):
        if (pattern[i] == ''):
            a += s[i+1]
        else:
            ans += int(a)
            a = s[i+1]
    else:
        ans += int(a)

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())

print (n+1)*n/2

Fixed submission:
x = int(input())
 
print(int((x+1)*x/2))
Buggy python submission (verdict: Runtime Error):
N = input()

if N%2 == 0:
  ans = N//2
else:
  ans = N//2 + 1

return(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  3 19:08:31 2020

@author: Kanaru Sato
"""

N = int(input())

ans = N//2 + N%2

print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  3 22:38:51 2020

@author: Kanaru Sato
"""

A = []
[A.append(list(map(int, input().split()))) for i in range(0,3)]

N = int(input())

b = []
[b.append(list(map(int, input()))) for i in range(0,N)]

flag = [[0, 0, 0]
        [0, 0, 0]
        [0, 0, 0]]

for i in range(0,3):
    for j in range(0,3):
        if A[i][j] in b:
            flag[i][j] = 1

column = 0
raw = 0
naname = 0

for i in range(0,3):
    column += flag[i][0]*flag[i][1]*flag[i][2]
    raw += flag[0][i]*flag[1][i]*flag[2][i]
naname = flag[0][0]*flag[1][1]*flag[2][2]+flag[0][2]*flag[1][1]*flag[2][0]

if column>=1 or raw>=1 or naname>=1:
    print("Yes")
else:
    print("No")

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  3 22:38:51 2020

@author: Kanaru Sato
"""

A = []
[A.append(list(map(int, input().split()))) for i in range(0,3)]

N = int(input())

b = []
[b.append(int(input())) for i in range(0,N)]

flag = [[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]]

for i in range(0,3):
    for j in range(0,3):
        if A[i][j] in b:
            flag[i][j] = 1

column = 0
raw = 0
naname = 0

for i in range(0,3):
    column += flag[i][0]*flag[i][1]*flag[i][2]
    raw += flag[0][i]*flag[1][i]*flag[2][i]
naname = flag[0][0]*flag[1][1]*flag[2][2]+flag[0][2]*flag[1][1]*flag[2][0]


if column>=1 or raw>=1 or naname>=1:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 02:26:37 2020

@author: Kanaru Sato
"""

def list_difference(list1, list2):
    result = list1.copy()
    for value in list2:
        if value in result:
            result.remove(value)
    return result

def differ(S):
    S_dash = list(set(S))
    D = list_difference(S, S_dash)
    if len(D) == 0:
        return S
    if len(D) == 1:
        return D
    if len(D) >= 2:
        return differ(D)

N = int(input())
S = []
[S.append(input()) for i in range(0,N)]

ans = differ(S)
ans.sort()

for i in range(0,len(ans)):
    print(ans[i])

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 16:16:18 2020

@author: Kanaru Sato
"""

N = int(input())
D = {}

for i in range(0,N):
    S = input()
    if S not in D:
        D[S] = 1
    if S in D:
        D[S] += 1

Mvalue = max(D.values())

List = []
[List.append(i) for i in D if D[i]==Mvalue]

List.sort()

for i in range(0,len(List)):
    print(List[i])
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 17:27:29 2020

@author: Kanaru Sato
"""

N = int(input())
A = input().split()
flag = 0

for i in range(0,N):
    for j in range(i+1,N):
        if A[i] == A[j]:
            flag = 1

if flag == 0:
    print("YES")
else:
    print("NO")

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 17:14:33 2020

@author: Kanaru Sato
"""

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

D = {}

for i in range(0,N):
    if A[i] not in D:
        D[A[i]] = 1
    elif A[i] in D:
        D[A[i]] += 1
        

flag = 0

for i in list(D.values()):
    if i > 1:
        flag = 1
        break
    elif i <= 1:
        continue

if flag==0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 04:56:52 2020

@author: Kanaru Sato
"""

n,k = list(map(int, input().split()))
p = list(map(int, input().split()))

sum = 0
sumlist = []
for i in range(n):
    sum += a[i]
    sumlist.append(sum)

Max = -100000
for i in range(n-k+1):
    e = sumlist[i+k-1]-sumlist[i]
    if Max < e:
        Max = e

print((Max+k)/2)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 04:56:52 2020

@author: Kanaru Sato
"""

n,k = list(map(int, input().split()))
p = list(map(int, input().split()))

sum = 0
sumlist = [0]
for i in range(n):
    sum += p[i]
    sumlist.append(sum)


Max = -100000
for i in range(n-k+1):
    e = sumlist[i+k]-sumlist[i]
    if Max < e:
        Max = e

print((Max+k)/2)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 04:56:52 2020

@author: Kanaru Sato
"""

n,k = list(map(int, input().split()))
p = list(map(int, input().split()))

Max = -100000
for i in range(n-k+1):
    sum = 0
    for j in range(k):
        sum += p[i+j]
    if Max <= sum:
        Max = sum

print((Max+k)/2)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 04:56:52 2020

@author: Kanaru Sato
"""

n,k = list(map(int, input().split()))
p = list(map(int, input().split()))

sum = 0
sumlist = [0]
for i in range(n):
    sum += p[i]
    sumlist.append(sum)


Max = -100000
for i in range(n-k+1):
    e = sumlist[i+k]-sumlist[i]
    if Max < e:
        Max = e

print((Max+k)/2)
Buggy python submission (verdict: Runtime Error):
al = [ord(i) for i in range(ord("a"), ord("a")+26)]

str = input()

print(al[al.index(str)+1])

Fixed submission:
al = [chr(i) for i in range(ord("a"), ord("a")+26)]

str = input()

print(al[al.index(str)+1])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Thu May  7 03:09:14 2020

@author: Kanaru Sato
"""
import itertools as it

n = int(input())
l = []
for i in range(1,n+1):
    l.append(i)
p = list(map(int, input().split()))
q = list(map(int, input().split()))

count = 0
for sequence in it.permutations(l,n):
    if list(sequence) == p:
        pnum = count
    elif list(sequence) ==q:
        qnum = count
    count += 1

print(abs(pnum-qnum))

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 17 00:21:01 2020

@author: Kanaru Sato
"""

import itertools as it
n = int(input())

p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

L = list(it.permutations(range(1,n+1)))

a = L.index(p)
b = L.index(q)
print(abs(a-b))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 21:05:26 2020

@author: Kanaru Sato
"""

import math

n = int(input())
rootn = int(math.sqrt(n))

list = []

for i in range(1, rootn):
    if n%i ==0:
        list.append([i,n//i])

dist = list[-1][0]+list[-1][1]-2

print(dist)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 21:05:26 2020

@author: Kanaru Sato
"""

import math

n = int(input())
rootn = int(math.sqrt(n))

list = []

for i in range(1, rootn+1):
    if n%i ==0:
        list.append([i,n//i])

dist = list[-1][0]+list[-1][1]-2

print(dist)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 21:05:26 2020

@author: Kanaru Sato
"""

import math

n = int(input())
rootn = int(math.sqrt(n))

list = []

for i in range(1, rootn):
    if n%i ==0:
        list.append([i,n//i])

min = n-1

for i in range(0,len(list)):
    dist = list[i][0]+list[i][1]-2
    if dist <= min:
        min = dist

print(dist)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 21:05:26 2020

@author: Kanaru Sato
"""

import math

n = int(input())
rootn = int(math.sqrt(n))

list = []

for i in range(1, rootn+1):
    if n%i ==0:
        list.append([i,n//i])

dist = list[-1][0]+list[-1][1]-2

print(dist)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 25 10:13:10 2020

@author: Kanaru Sato
"""

N = int(input())
H = list(map(int, input().split()))
record = 0
count = 0

for i in range(0,N-1):
    if H[i] >= H[i+1]:
        count += 1
        ans = max(record,count)
    else:
        count = 0

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 25 10:13:10 2020

@author: Kanaru Sato
"""

N = int(input())
H = list(map(int, input().split()))
ans = 0
count = 0

for i in range(0,N-1):
    if H[i] >= H[i+1]:
        count += 1
        ans = max(ans,count)
    else:
        count = 0

print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 25 18:54:16 2020

@author: Kanaru Sato
"""

n = int(input())
Dict = {}
ans = 0

for i in range(n):
    s = list(input())
    s.sort()
    if s in Dict:
        ans += Dict[s]
        Dict[s] += 1
    else:
        Dict[s] = 1

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 25 18:54:16 2020

@author: Kanaru Sato
"""

n = int(input())
Dict = {}
ans = 0

for i in range(n):
    s = list(input())
    s.sort()
    s = "".join(s)
    if s in Dict:
        ans += Dict[s]
        Dict[s] += 1
    else:
        Dict[s] = 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 02:06:07 2020

@author: Kanaru Sato
"""

import heapq

n,m = list(map(int, input().split()))
albeit = []
for i in range(m+1):
    albeit.append([])

for i in range(n):
    a,b = list(map(int, input().split()))
    if a <= m:
        albeit[a].append(-1*b)

##print(albeit)

for i in range(m):
    heapq.heapify(albeit[i+1])

##print(albeit)

sum = 0
for i in range(m):
    day = i+1 #day:1->m
    ##print("day=",day)
    minlist = []
    for j in range(day):
        if len(albeit[j+1]) >= 1:
            minlist.append(albeit[j+1][0])
        else:
            minlist.append(0)
    ##print(minlist)
    m = min(minlist)
    if m != 0:
        Maxalbeitindex = minlist.index(m)
        sum += -1*heapq.heappop(albeit[Maxalbeitindex+1])
    ##print(sum)

print(sum)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 02:06:07 2020

@author: Kanaru Sato
"""

import heapq

n,m = list(map(int, input().split()))
albeit = []
for i in range(m+1):
    albeit.append([])

for i in range(n):
    a,b = list(map(int, input().split()))
    if a <= m:
        albeit[a].append(-1*b)

##print(albeit)
Heap = [0]
sum = 0
for i in range(m):
    day = i+1
    for money in albeit[day]:
        heapq.heappush(Heap, money)
    if Heap[0] != 0:
        daymax = heapq.heappop(Heap)*-1
        sum += daymax

print(sum)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:52:33 2020

@author: Kanaru Sato
"""

import fraction

def divnum(x,y,n):
    if x%n == 0:
        return y//n - x//n + 1
    else:
        return y//n - x//n

a,b,c,d = list(map(int,input().split()))
cd = (c*d)/fraction.gcd(c,d)
ans = divnum(a,b,c) + divnum(a,b,d) - divnum(a,b,cd)
print(int(b-a+1-ans))

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:52:33 2020

@author: Kanaru Sato
"""

import fractions

def divnum(x,y,n):
    if x%n == 0:
        return y//n - x//n + 1
    else:
        return y//n - x//n

a,b,c,d = list(map(int,input().split()))
cd = (c*d)//fractions.gcd(c,d)
ans = divnum(a,b,c) + divnum(a,b,d) - divnum(a,b,cd)
print(b-a+1-ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:52:33 2020

@author: Kanaru Sato
"""

import math

def divnum(x,y,n):
    if x%n == 0:
        return y//n - x//n + 1
    else:
        return y//n - x//n

a,b,c,d = list(map(int,input().split()))
cd = (c*d)/math.gcd(c,d)
ans = divnum(a,b,c) + divnum(a,b,d) - divnum(a,b,cd)
print(int(b-a+1-ans))

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:52:33 2020

@author: Kanaru Sato
"""

import fractions

def divnum(x,y,n):
    if x%n == 0:
        return y//n - x//n + 1
    else:
        return y//n - x//n

a,b,c,d = list(map(int,input().split()))
cd = (c*d)//fractions.gcd(c,d)
ans = divnum(a,b,c) + divnum(a,b,d) - divnum(a,b,cd)
print(b-a+1-ans)