Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from collections import deque

n = int(input())
word = deque()

for i in range(n):
    command, num = int(input().split())
    if command == 0:
        word.append(num)
    elif command == 1:
        print('{0}'.format(word[num]))
    elif command == 2:
        word.pop()



Fixed submission:
# -*- coding: utf-8 -*-

from collections import deque

n = int(input())
word = deque()

for i in range(n):
    command = list(map(int, input().split()))
    if command[0] == 0:
        word.append(command[1])
    elif command[0] == 1:
        print('{0}'.format(word[command[1]]))
    elif command[0] == 2:
        word.pop()

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from collections import deque

n = int(input())
word = deque()

for i in range(n):
    command, num = map(int, input().split())
    if command == 0:
        word.append(num)
    elif command == 1:
        print('{0}'.format(word[num]))
    elif command == 2:
        word.pop()



Fixed submission:
# -*- coding: utf-8 -*-

from collections import deque

n = int(input())
word = deque()

for i in range(n):
    command = list(map(int, input().split()))
    if command[0] == 0:
        word.append(command[1])
    elif command[0] == 1:
        print('{0}'.format(word[command[1]]))
    elif command[0] == 2:
        word.pop()
Buggy python submission (verdict: Runtime Error):
import sys

length = int(sys.stdin.readline())
value =[ int(num) for num in sys.stdin.readlines() ]
minv = value[0]
maxv = value[1] - value[0]

for i in range(1,length):
    maxv = max(maxv,value[i] - minv)
    minv = min(minv,value[i])

print(maxv)

return 0


Fixed submission:
import sys

count=int(input())
input_list=[ int(i) for i in sys.stdin.readlines() ]

first=0
second=1
maxv=-1000000000
minv=input_list[first]

for i in input_list[second:]:
    if i-minv > maxv:
        maxv=i-minv
    if i < minv:
        minv=i

print(maxv)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

count=int(input())-1
input_list=[ int(i) for i in sys.stdin.readlines() ]

first=0
second=1
max_price_diff=input_list[second]-input_list[first]

for i in input_list[first:count]:
    for j in input_list[second:count+1]:
        if j-i > max_price_diff:
            max_price_diff=j-i
    second=second+1

print(max_price_diff)


Fixed submission:
import sys

count=int(input())
input_list=[ int(i) for i in sys.stdin.readlines() ]

first=0
second=1
maxv=-1000000000
minv=input_list[first]

for i in input_list[second:]:
    if i-minv > maxv:
        maxv=i-minv
    if i < minv:
        minv=i

print(maxv)
Buggy python submission (verdict: Runtime Error):
input(x)

print(x**3)


Fixed submission:
x = int(input())

print(x**3)

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

print(x**3)


Fixed submission:
x = int(input())

print(x**3)
Buggy python submission (verdict: Runtime Error):
while(True):
    i,j=input().split()
    
    if a != 0 and b != 0:
        if int(i) <= int(j):
            print('{} {}'.format(i,j))
        else:
            print('{} {}'.format(j,i))
    else:
        break


Fixed submission:
while(True):
    i,j= map(int, input().split())
    if i != 0 or j != 0:
        if i <= j:
            print(i,j)
        else:
            print(j,i)
    else:
        break
Buggy python submission (verdict: Time Limit Exceeded):
import sys
lines = sys.stdin.readlines()

while(True):
    for i in lines:
        a,b = (map(int,i.split()))
        
        if a == 0 and b == 0:
            break
        if a == 1 and b == 1:
            print('#')
            continue
        for j in range(a-1):
            print('#' * b)


Fixed submission:
while(True):
    H,W = (map(int,input().split()))   
    if H == 0 and W == 0:
        break
 
    for i in range(H):
        print('#'*W)
    print('')

Buggy python submission (verdict: Runtime Error):
while(True):
    H,W = (map(int,input().split()))   
    
　　if H == 0 and W == 0:
        break
    elif H == 1 and W == 1:
        print('#')
        print()
        continue
    else:
        for i in range(H-1):
            print('#' * W)
        print()
    


Fixed submission:
while(True):
    H,W = (map(int,input().split()))   
    if H == 0 and W == 0:
        break
 
    for i in range(H):
        print('#'*W)
    print('')
Buggy python submission (verdict: Runtime Error):
import re
s = imput()

if re.match("(dreamer|dream|eraser|erase)+dreamer",s):
  print("YES")
else:
  print("NO")

Fixed submission:
import re
s = input()

if re.match("(dreamer|dream|eraser|erase)+$",s):
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
c=1+(n-1-1)*2

for i in range(2,n):
    for j in range(2,n):
        if i*j>=n:
            continue
        for k in range(1,n):
            if i*j+k==n:
                c+=1

print(c)

Fixed submission:
import math
n=int(input())
c=1+(n-1-1)*2


for i in range(2,n):
    for j in range(2,n):
        if i*j>=n:
            break
        c+=1

print(c)
Buggy python submission (verdict: Runtime Error):
inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
if inp[0]/inp[2]<inp[1]:
  print('Yes')
else:
  print('No')

Fixed submission:
inp = list(map(int, input().split()))
if inp[0]/inp[2]<=inp[1]:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
if inp[0]/inp[2]<inp[1]:
	print('Yes')
else:
	print('No')

Fixed submission:
inp = list(map(int, input().split()))
if inp[0]/inp[2]<=inp[1]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
c = 0
for s,t in zip(S,T):
  if s = t: c+=1
print(c)

Fixed submission:
S = input()
T = input()
c = 0
for s,t in zip(S,T):
  if s == t: c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
M, D = map(int, input().split())
c=0
for m in range(1,M+1):
  for d in range(1,D+1):
    d1 = d%10
    d10 = d//10
    if d1>1 and d10>1 and d1*d2==m:
      c+=1
print(c)

Fixed submission:
M, D = map(int, input().split())
c=0
for m in range(1,M+1):
  for d in range(1,D+1):
    d1 = d%10
    d10 = d//10
    if d1>1 and d10>1 and d1*d10==m:
      c+=1
print(c)

Buggy python submission (verdict: Runtime Error):
M, D = map(int, input().split())
c=0
for m in range(1,M+1):
  for d in range(1,D+1):
    d1 = d%10
    d10 = d//10
    if d1>1 and d10>1 and d1*d2=m: c+=1
print(c)

Fixed submission:
M, D = map(int, input().split())
c=0
for m in range(1,M+1):
  for d in range(1,D+1):
    d1 = d%10
    d10 = d//10
    if d1>1 and d10>1 and d1*d10==m:
      c+=1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(x) for x in input().split()]
ans=1
for x in a: ans*=x
if ans>1e18:
    print(-1)
else:
    print(ans)

Fixed submission:
n=int(input())
a=[int(x) for x in input().split()]
ans=1
for x in a:
    ans*=x
    if ans>1e18:
        break
if a.count(0)>0:
    print(0)
elif ans>1e18:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

N=int(input())
T=list(map(int,input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0 :
            if i!=1:
                divisors.append(i)
            if i != n // i:

                divisors.append(n//i)

    divisors.sort()
    return divisors

    


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

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
S=[]
tmp=gcd_list(T)
if tmp!=1:
    print("not coprime")
else:
    T.sort()

    n=10**6+1
    isprime=[True]*(n+1)
    isprime[0]=False
    isprime[1]=False
    for i in range(len(T)):
        S=make_divisors(T[i])
        #print(S)
        while len(S)!=0: 
            tmp=S.pop()
            if isprime[tmp]==True:
                j=tmp+tmp
                while j<=n:
                     
                    isprime[j] =False
                    j=j+tmp
                    
                        
            else:
                print("setwise coprime")
                exit()
    print("pairwise coprime")
    

Fixed submission:
import math
from functools import reduce

N=int(input())
T=list(map(int,input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0 :
            if i!=1:
                divisors.append(i)
            if i != n // i:

                divisors.append(n//i)

    divisors.sort()
    return divisors

    


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

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
S=[]
tmp=gcd_list(T)
if tmp!=1:
    print("not coprime")
else:
    T.sort()

    n=10**6+1
    isprime=[True]*(n+1)
    isprime[0]=False
    isprime[1]=False
    for i in range(len(T)):
        S=make_divisors(T[i])
        #print(S)
        while len(S)!=0: 
            tmp=S.pop()
            if isprime[tmp]==True:
                j=tmp+tmp
                while j<=n:
                     
                    isprime[j] =False
                    j=j+tmp
                    
                        
            else:
                print("setwise coprime")
                exit()
    print("pairwise coprime")
Buggy python submission (verdict: Runtime Error):
import sys
import copy
input = sys.stdin.readline

S=input()
L=len(S)

goukei=0
for i in range(L):
    goukei+=int(S[i])

if goukei%9==0:
    print("Yes")
else:
    print("No")

Fixed submission:
S=input()
L=len(S)

goukei=0
for i in range(L):
    goukei+=int(S[i])

if goukei%9==0:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import sys
import copy
input = sys.stdin.readline

S=input()
L=len(S)

goukei=0
for i in range(L):
    goukei+=int(S[i])

if goukei%9==0:
    print("Yes")
else:
    print("No")

Fixed submission:
S=input()
L=len(S)

goukei=0
for i in range(L):
    goukei+=int(S[i])

if goukei%9==0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
A,V=map(int,input().split())
B,W=map(int,input().split())
K=int(input())
Apos=A
Bpos=B
count=0
rev=False
if B>A:
    pass
else:
    rev=True

if rev==False:

    while K>count:
        
        Apos=Apos+V
        Bpos=Bpos+W
        if Apos>=Bpos:
            print("YES")
            exit()
        count+=1
        

else:
    while K>count:
        
        Apos=Apos-V
        Bpos=Bpos-W
        if Apos<=Bpos:
            print("YES")
            exit()
        count+=1

print("NO")

Fixed submission:
A,V=map(int,input().split())
B,W=map(int,input().split())
K=int(input())
Apos=A
Bpos=B
count=0
rev=False
if B>A:
    pass
else:
    rev=True

if rev==False:

    
        
    A=A+V*K
    B=B+W*K
    if A>=B:
        print("YES")
        exit()
    
        

else:
    A=A-V*K
    B=B-W*K
    if A<=B:
        print("YES")
        exit()

print("NO")
Buggy python submission (verdict: Runtime Error):
S=input()
if int(S[2])==3:
    print("bon")
elif int(S[2])==0 or int(S[2])==1 or int(S[2])==6 or int(S[2])==8:
    print("pon")
else:
    print("hon")

Fixed submission:
# coding: utf-8
# Your code here!

S=int(input())%10
S=S%10

if S==3:
    print("bon")
elif S==0 or S==1 or S==6 or S==8:
    print("pon")
else:
    print("hon")

Buggy python submission (verdict: Runtime Error):
S=input()
if int(S[2])==3:
    print("bon")
elif int(S[2])==0 or int(S[2])==1 or int(S[2])==6 or int(S[2])==8:
    print("pon")
else:
    print("hon")

Fixed submission:
# coding: utf-8
# Your code here!

S=int(input())%10
S=S%10

if S==3:
    print("bon")
elif S==0 or S==1 or S==6 or S==8:
    print("pon")
else:
    print("hon")
Buggy python submission (verdict: Time Limit Exceeded):
A,B,N=map(int,input().split())

maxP=-10**15

if N<100000000:
    for i in range(1,N+1):
        tmp=(A*i)//B-A*(i//B)
        if maxP<tmp:
            maxP=tmp
        
else:
    for i in range(1,10000000):
        tmp=(A*i)//B-A*(i//B)
        if maxP<tmp:
            maxP=tmp
    for i in range(N-10000000,N+1):
        tmp=(A*i)//B-A*(i//B)
        if maxP<tmp:
            maxP=tmp
print(maxP)

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

i=min(B-1,N)


tmp=(A*i)//B-A*(i//B)

        
print(tmp)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=[]
count=0
for i in range(N):
    sample=input()
    if sample in S:
        count+=0
    else:
        S.append(sample)
        count+=1
    
    
print(count)

Fixed submission:
N=int(input())
S=[]
count=0
for i in range(N):
    sample=input()
    S.append(sample)



    
    
print(len(set(S)))
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(map(int,input().split()))
L=[0]*100000
for i in range(N-1):
    L[S[i]-1]+=1

for i in range(N):
    print(L[i])


Fixed submission:
N=int(input())
S=list(map(int,input().split()))
Z=[0]*N
for i in range(N-1):
    Z[S[i]-1]+=1
    
for i in range(N):
    print(Z[i])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=list(map(int,input().split()))

#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [0]*N
for i in range(N):
    S[L[i]-1]+=1


for i in range(N):
    tmp=S
    tmp[L[i]-1]-=1
    goukei=0
    for j in range(N):
        if tmp[j]>=2:
            goukei+=(tmp[j]*(tmp[j]-1))//2
    tmp[L[i]-1]+=1
    print(goukei)


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

#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [0]*N
for i in range(N):
    S[L[i]-1]+=1

init=0
for j in range(N):
    tmp=S
    if tmp[j]>=2:
        init+=(tmp[j]*(tmp[j]-1))//2




for i in range(N):
    ans=init
    R=S[L[i]-1]
    if R>=2:
        print(ans-(R-1))
    else:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

S=input()
N=int(input())
inilen=len(S)
d=deque()
for i in range(inilen):
    d.append(S[i])

for i in range(N):
    L=list(map(str,input().split()))
    if L[0]=="1":
        d.reverse()
    elif L[1]=="1":
        d.appendleft(L[2])
        
    elif L[1]=="2":
        d.append(L[2])

Z=list(d)
Z=[str(a) for a in Z]
Z="".join(Z)
print(Z)



Fixed submission:
from collections import deque

S=input()
N=int(input())
inilen=len(S)
d=deque()
for i in range(inilen):
    d.append(S[i])
revflag=False
for i in range(N):
    L=list(map(str,input().split()))
    if L[0]=="1":
        if revflag==False:
            revflag=True
        else:
            revflag=False
    elif L[1]=="1":
        if revflag==False:
            d.appendleft(L[2])
        else:
            d.append(L[2])
        
    elif L[1]=="2":
        if revflag==False:
            d.append(L[2])
        else:
            d.appendleft(L[2])

if revflag==True:
    d.reverse()

Z=list(d)
Z=[str(a) for a in Z]
Z="".join(Z)
print(Z)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
S=list(map(int,input().split()))

best=0

for i in range(N-K+1):
    goukei=0
    for j in range(K):
        goukei+=S[i+j]
    if goukei>best:
        best=goukei
    
print((best+K)/2)
    

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

L=[0]*(N-K+1)

target=0


for i in range(N-K+1):
    if i==0:
        for j in range(K):
            target+=S[j]
        L[0]=target
    else:    
        target+=S[K+i-1]-S[i-1]
        L[i]=target
best=max(L)    
print((best+K)/2)
Buggy python submission (verdict: Runtime Error):
print chr(ord('a') + 1)

Fixed submission:
print(chr(ord(input()) + 1))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=list(map(int,input().split()))
first=len(S)
count=0
pos=0
mokuteki=1
while count<N:
    if S[pos]!=mokuteki:
        ret=S.pop(pos)
    else:
        mokuteki+=1
        pos+=1
    count+=1

if len(S)>0:
    print(first-len(S))
else:
    print(-1)

Fixed submission:
N=int(input())
S=list(map(int,input().split()))
first=len(S)
count=0
pos=0
mokuteki=1
block=0
while count<N:
    if S[pos]!=mokuteki:
        pos+=1
        block+=1
    else:
        mokuteki+=1
        pos+=1
    count+=1

if mokuteki>1:
    print(block)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N=int(input())
S=input()
dic={}
for i in range(N-2):
    if len(dic)==1000:
        break
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            tmp=S[i]+S[j]+S[k]
            dic[tmp]=1
print(len(dic))

Fixed submission:
import sys
import copy
input = sys.stdin.readline

N=int(input())

S=input()


T=[[0] * 10 for _ in range(30000)]
for i in range(N):
    if i!=0:
        T[i]=copy.deepcopy(T[i-1])
    T[i][int(S[i])]+=1
#print(T)

dic={}
flag=[False]*10
for i in range(N-2):
    if flag[int(S[i])]==True:
        continue
    flag[int(S[i])]=True
    for j in range(i+1,N-1):
        tmp2=copy.deepcopy(T[N-1])
        tmp3=copy.deepcopy(T[j])
        tmp4=""
        for k in range(10):
            if tmp2[k]-tmp3[k]!=0:
                tmp4=S[i]+S[j]+str(k)
                #print(tmp4)
                if tmp4 in dic:
                    pass
                else:    
                    dic[tmp4]=1
           
print(len(dic))
#print(dic)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N=int(input())
S=input()
dic={}
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            tmp=S[i]+S[j]+S[k]
            dic[tmp]=1
print(len(dic))

Fixed submission:
import sys
import copy
input = sys.stdin.readline

N=int(input())

S=input()


T=[[0] * 10 for _ in range(30000)]
for i in range(N):
    if i!=0:
        T[i]=copy.deepcopy(T[i-1])
    T[i][int(S[i])]+=1
#print(T)

dic={}
flag=[False]*10
for i in range(N-2):
    if flag[int(S[i])]==True:
        continue
    flag[int(S[i])]=True
    for j in range(i+1,N-1):
        tmp2=copy.deepcopy(T[N-1])
        tmp3=copy.deepcopy(T[j])
        tmp4=""
        for k in range(10):
            if tmp2[k]-tmp3[k]!=0:
                tmp4=S[i]+S[j]+str(k)
                #print(tmp4)
                if tmp4 in dic:
                    pass
                else:    
                    dic[tmp4]=1
           
print(len(dic))
#print(dic)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N=int(input())
S=input()
dic={}
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            tmp=S[i]+S[j]+S[k]
            if tmp in dic:
                pass
            else:    
                dic[tmp]=1
print(len(dic))

Fixed submission:
import sys
import copy
input = sys.stdin.readline

N=int(input())

S=input()


T=[[0] * 10 for _ in range(30000)]
for i in range(N):
    if i!=0:
        T[i]=copy.deepcopy(T[i-1])
    T[i][int(S[i])]+=1
#print(T)

dic={}
flag=[False]*10
for i in range(N-2):
    if flag[int(S[i])]==True:
        continue
    flag[int(S[i])]=True
    for j in range(i+1,N-1):
        tmp2=copy.deepcopy(T[N-1])
        tmp3=copy.deepcopy(T[j])
        tmp4=""
        for k in range(10):
            if tmp2[k]-tmp3[k]!=0:
                tmp4=S[i]+S[j]+str(k)
                #print(tmp4)
                if tmp4 in dic:
                    pass
                else:    
                    dic[tmp4]=1
           
print(len(dic))
#print(dic)
Buggy python submission (verdict: Time Limit Exceeded):


N=int(input())
S=list(map(int,input().split()))
S.sort()
S.reverse()

count=0
le=len(S)
S.append(-100000)
for i in range(le-2):
    for j in range(i+1,le-1):
        if S[i]<S[j]+S[j+1]:
            left=j+1
            right=le
            while left<=right:
                mid=(left+right)//2
                if S[i]<S[j]+S[mid] and S[i]>=S[j]+S[mid+1]:
                    count+= mid-(j+1)+1
                    
                    break
                elif S[i]<S[j]+S[mid]:
                    left=mid+1
                elif S[i]>=S[j]+S[mid]:
                    right=mid-1
                else:
                    print("イレギュラーな例につかまりました")
                    exit()
                
print(count)


Fixed submission:


N=int(input())
S=list(map(int,input().split()))
S.sort()
S.reverse()

count=0
le=len(S)
S.append(-100000)
for i in range(le-2):
    for j in range(i+1,le-1):
        if S[i]<S[j]+S[j+1]:
            left=j+1
            right=le
            while left<=right:
                mid=(left+right)//2
                if S[i]<S[j]+S[mid] and S[i]>=S[j]+S[mid+1]:
                    count+= mid-(j+1)+1
                    
                    break
                elif S[i]<S[j]+S[mid]:
                    left=mid+1
                elif S[i]>=S[j]+S[mid]:
                    right=mid-1
                else:
                    print("イレギュラーな例につかまりました")
                    exit()
                
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools 

N=int(input())
S=list(map(int,input().split()))
S.sort()
S.reverse()
C=list(itertools.combinations(S,3))
count=0
for i in C:
    if i[0]<i[1]+i[2]:
        count+=1
print(count)

Fixed submission:


N=int(input())
S=list(map(int,input().split()))
S.sort()
S.reverse()

count=0
le=len(S)
S.append(-100000)
for i in range(le-2):
    for j in range(i+1,le-1):
        if S[i]<S[j]+S[j+1]:
            left=j+1
            right=le
            while left<=right:
                mid=(left+right)//2
                if S[i]<S[j]+S[mid] and S[i]>=S[j]+S[mid+1]:
                    count+= mid-(j+1)+1
                    
                    break
                elif S[i]<S[j]+S[mid]:
                    left=mid+1
                elif S[i]>=S[j]+S[mid]:
                    right=mid-1
                else:
                    print("イレギュラーな例につかまりました")
                    exit()
                
print(count)
Buggy python submission (verdict: Runtime Error):
import math

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


kobaisu=C//math.gcd(C,D)*D


ans=B -(B//C+B//D-B//kobaisu)

ans2=(A-1)-((A-1)//C +(A-1)//D - (A-1)//kobaisu)

print(int(ans-ans2))

Fixed submission:
import fractions

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


kobaisu=C//fractions.gcd(C,D)*D


ans=B -(B//C+B//D-B//kobaisu)

ans2=(A-1)-((A-1)//C +(A-1)//D - (A-1)//kobaisu)

print(int(ans-ans2))

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

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

#最小公倍数a * b / gcd(a, b)
kobaisu=C//math.gcd(C,D)*D


ans=B -(B//C+B//D-B//kobaisu)

ans2=(A-1)-((A-1)//C +(A-1)//D - (A-1)//kobaisu)

print(int(ans-ans2))

Fixed submission:
import fractions

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


kobaisu=C//fractions.gcd(C,D)*D


ans=B -(B//C+B//D-B//kobaisu)

ans2=(A-1)-((A-1)//C +(A-1)//D - (A-1)//kobaisu)

print(int(ans-ans2))

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

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

#最小公倍数a * b / gcd(a, b)
kobaisu=C/math.gcd(C,D)*D



ans=B -(B//C+B//D-B//kobaisu)

ans2=(A-1)-((A-1)//C +(A-1)//D - (A-1)//kobaisu)

print(int(ans-ans2))

Fixed submission:
import fractions

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


kobaisu=C//fractions.gcd(C,D)*D


ans=B -(B//C+B//D-B//kobaisu)

ans2=(A-1)-((A-1)//C +(A-1)//D - (A-1)//kobaisu)

print(int(ans-ans2))