Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
P = [int(i) for i in input().split()]
max_p = 0
for n in range(N-K+1):
    temp = 0
    for k in range(K):
        temp += (P[n+k] + 1) / 2
    max_p = max(max_p,temp)
print(max_p)

Fixed submission:
N,K = map(int,input().split())
P = [(int(i)+1)/2 for i in input().split()]
max_p = 0
for n in range(N-K+1):
    if n == 0:
        temp = sum(P[0:K])
    else:
        temp -= P[n-1]
        temp += P[n+K-1]
    max_p = max(max_p,temp)
print(max_p)
Buggy python submission (verdict: Runtime Error):
import math.ceil
H,A = map(int,input().split())
print(ceil(H/A))

Fixed submission:
import math
H,A = map(int,input().split())
print(math.ceil(H/A))
Buggy python submission (verdict: Runtime Error):
N = int(input())
P = (int(i) for i in input().split())
Q = (int(i) for i in input().split())

seq = tuple(range(N))
import itertools
p_list = list(itertools.permutations(seq))
for i,p in enumerate(p_list):
  if p_list == P:
    p_idx = i
  elif p_list == Q:
    q_idx = i
print(abs(p_idx-q_idx))

Fixed submission:
N = int(input())
P = tuple(int(i) for i in input().split())
Q = tuple(int(i) for i in input().split())

seq = tuple(range(1,N+1))
import itertools
p_list = list(itertools.permutations(seq))
for i,p in enumerate(p_list):
  if p == P:
    p_idx = i
  if p == Q:
    q_idx = i
print(abs(p_idx-q_idx))
Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=list(range(1,4))
C.pop(A)
C.pop(B)
print(C[0])

Fixed submission:
A=int(input())
B=int(input())
C=list(range(1,4))
C.remove(A)
C.remove(B)
print(C[0])
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
A,B=map(int,input().split())
def lcd(x,y)
  return (x * y) // gcd(x, y)
print(lcd(A,B))

Fixed submission:
from fractions import gcd
A,B=map(int,input().split())
def lcd(x,y):
  return (x * y) // gcd(x, y)
print(lcd(A,B))
Buggy python submission (verdict: Runtime Error):
print("bust") if sum(A) >= 22 else print("win")

Fixed submission:
A = [int(i) for i  in input().split()]
print("bust") if sum(A) >= 22 else print("win")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
import numpy as np
matrix = np.zeros((N,N),dtype="int8")
for n in range(N):
    A = int(input())
    for a in range(A):
        array = [int(i) for i in input().split()]
        matrix[n,array[0]-1] = 1 if array[1] == 1 else -1
l = [True,False]
from itertools import product
for pattern in product(l,repeat=N):
    able = True
    for i,p in enumerate(pattern):
        if p:
            for a,b in zip(matrix[i],pattern):
                if (b==True and a==-1) or (b==False and a == 1):
                    able = False
                    break
            if able == False:
                break
        else:
            pass
    if able == True:
        break
print(sum(pattern))

Fixed submission:
N = int(input())
matrix = [[0 for i in range(N)] for j in range(N)]
for n in range(N):
    A = int(input())
    for a in range(A):
        array = [int(i) for i in input().split()]
        matrix[n][array[0]-1] = 1 if array[1] == 1 else -1
l = [True,False]
from itertools import product
for pattern in product(l,repeat=N):
    able = True
    for i,p in enumerate(pattern):
        if p:
            for a,b in zip(matrix[i],pattern):
                if (b==True and a==-1) or (b==False and a == 1):
                    able = False
                    break
            if able == False:
                break
        else:
            pass
    if able == True:
        break
print(sum(pattern))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
import itertools
print(len(set(itertools.combinations(S,3))))

Fixed submission:
N = int(input())
S = input()
kouho = [str(i).zfill(3) for i in range(0,1000)]
cnt =0
for k in kouho:
    ok = True
    S_temp = S
    for l in k:
        if l in S_temp:
            basho = S_temp.index(l)
            S_temp = S_temp[basho+1:]
        else:
            ok = False
            break
    if ok == True:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
from functools import reduce
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
A = factorize(N)
for i in range(1,len(A)):
    x = 1
    y = 1
    for a in A[0:i]:
        x *= a
    for a in A[i:]:
        y *= a
ans = x+y-2

ans = N-1 if len(A) == 1else ans
print(ans)

Fixed submission:
from math import ceil, sqrt
N = int(input())
for i in range(ceil(sqrt(N)),0,-1):
    if N%i == 0:
        print(i + N//i -2)
        break

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
A = factorize(N)
if len(A) == 1:
    ans = N-1
else: 
    ans = 9999999999999999999999
    from itertools import permutations as P
    from functools import reduce
    for i in range(1,len(A)):
        l1 = list(P(A,i))
        for l1_temp in l1:
            l2 = list(filter(lambda x : x not in l1,A))
            ans_1 = reduce(lambda x,y:x * y,l1_temp)
            ans_2 = N//ans_1
            ans_temp = (ans_1 + ans_2 -2)
            ans = min(ans,ans_temp)
print(ans)

Fixed submission:
from math import ceil, sqrt
N = int(input())
for i in range(ceil(sqrt(N)),0,-1):
    if N%i == 0:
        print(i + N//i -2)
        break
Buggy python submission (verdict: Runtime Error):
a,b,x = list(map(int,input().split()))
from math import acos
from math import sqrt
from math import degrees
if (x/(a*a))*2 <= b:
    S = x/a
    y = 2*x/(a*b)
    c = sqrt(y*y + b * b)
    z = (b*b + c*c - y*y)/(2*c)
    theta = degrees(acos(z/b))
else:
    S = x/a
    y = (2*S)/a - b
    y = b - y
    c = sqrt(a * a + y * y)
    z = (y*y - a*a + c*c)/(2*c)
    theta = degrees(acos(z/y))
print(90-theta)

Fixed submission:
a,b,x = list(map(int,input().split()))
from math import acos
from math import sqrt
from math import degrees
if (x/(a*a))*2 <= b:
    S = x/a
    y = 2*x/(a*b)
    c = sqrt(y*y + b * b)
    z = (b*b + c*c - y*y)/(2*c)
    theta = degrees(acos(z/b))
else:
    S = x/a
    y = (2*S)/a - b
    y = b - y
    c = sqrt(a * a + y * y)
    z = (y*y - a*a + c*c)/(2*c)
    if y == 0:
        y = 0.00000000001
    theta = degrees(acos(z/y))
print(90-theta)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = sorted([int(i) for i in input().split()])
ans = 0
for i,l in enumerate(L):
    for ii,m in enumerate(L[i+1:-1]):
        for n in L[i+ii+2:]:
            if l + m <= n:
                break
            else:
                ans += 1
print(ans)

Fixed submission:
N = int(input())
L = sorted([int(i) for i in input().split()])
from bisect import bisect_left
ans = 0
for i1,a in enumerate(L):
    L_temp = L[i1+1:]
    for i2,b in enumerate(L_temp):
        L_temp2 = L_temp[i2+1:]
        #print(a,b,L_temp2,bisect_left(L_temp2,a+b),a+b,len(L_temp2) - bisect_left(L_temp2,a+b))
        ans += bisect_left(L_temp2,a+b)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [int(i) for i in input().split()]
from itertools import combinations
ans = 0
for a,b,c in combinations(L,3):
    if a < b+c and b < a+c and c < a+b:
        ans += 1
print(ans)

Fixed submission:
N = int(input())
L = sorted([int(i) for i in input().split()])
from bisect import bisect_left
ans = 0
for i1,a in enumerate(L):
    L_temp = L[i1+1:]
    for i2,b in enumerate(L_temp):
        L_temp2 = L_temp[i2+1:]
        #print(a,b,L_temp2,bisect_left(L_temp2,a+b),a+b,len(L_temp2) - bisect_left(L_temp2,a+b))
        ans += bisect_left(L_temp2,a+b)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
ans = []
for i in range(1,len(A)+1,1):
    ans.append(A.index(i)+1)
print(*ans)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
ans = [0]*N
for i,a in enumerate(A):
    ans[a-1] = i+1
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
ans = []
for i in range(1,len(A)+1,1):
    ans.append(A.index(i)+1)
print(*ans)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
ans = [0]*N
for i,a in enumerate(A):
    ans[a-1] = i+1
print(*ans)
Buggy python submission (verdict: Runtime Error):
A,B = (int(i) for i  in input().split())
from math import gcd,sqrt
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
divisors = make_divisors(gcd(A,B))
def is_prime(n):
    if n == 1: return True
    for k in range(2, int(sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
ans = 0
for d in divisors:
    ans += is_prime(d)
print(ans)

Fixed submission:
A,B = (int(i) for i  in input().split())
from math import sqrt
from fractions import gcd
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
divisors = make_divisors(gcd(A,B))
def is_prime(n):
    if n == 1: return True
    for k in range(2, int(sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
ans = 0
for d in divisors:
    ans += is_prime(d)
print(ans)

Buggy python submission (verdict: Runtime Error):
A,B = (int(i) for i  in input().split())
from math import gcd,sqrt
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
divisors = make_divisors(gcd(A,B))
def is_prime(n):
    if n == 1: return True
    for k in range(2, int(sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
ans = 0
for d in divisors:
    ans += is_prime(d)
print(ans)

Fixed submission:
A,B = (int(i) for i  in input().split())
from math import sqrt
from fractions import gcd
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
divisors = make_divisors(gcd(A,B))
def is_prime(n):
    if n == 1: return True
    for k in range(2, int(sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
ans = 0
for d in divisors:
    ans += is_prime(d)
print(ans)
Buggy python submission (verdict: Runtime Error):
H,W,A,B = map(int,input().split())
import numpy as np
ans = np.array([[0] * W] * H)
for h in range(H):
    for w in range(W):
        if w >= A and h >= B:
            pass
        elif w >= A:
            ans[h,w] = 1
        elif h >= B:
            ans[h,w] = 1
        else:
            pass
for h in range(H):
    a = ans[h].tolist()
    print(*a,sep="")

Fixed submission:
H,W,A,B = map(int,input().split())
import numpy as np
ans = np.array([[0] * W] * H)
for h in range(H):
    for w in range(W):
        if w >= A and h >= B:
            pass
        elif w >= A:
            ans[h,w] = 1
        elif h >= B:
            ans[h,w] = 1
        else:
            pass
for h in range(H):
    a = ans[h].tolist()
    print(*a,sep="")
Buggy python submission (verdict: Time Limit Exceeded):
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
for m in range(M):
    A[A.index(max(A))] = A[A.index(max(A))] // 2
print(sum(A))

Fixed submission:
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
import heapq
heapA = []
for a in A:
    heapq.heappush(heapA,-a)
for m in range(M):
    tmp = -heapq.heappop(heapA)
    tmp = tmp//2
    tmp = -1 * tmp
    heapq.heappush(heapA,tmp)
print(-sum(heapA))

Buggy python submission (verdict: Time Limit Exceeded):
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
from copy import deepcopy as dp
B = dp(A)
for m in range(M):
    B[B.index(max(B))] = B[B.index(max(B))] // 2
print(sum(B))

Fixed submission:
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
import heapq
heapA = []
for a in A:
    heapq.heappush(heapA,-a)
for m in range(M):
    tmp = -heapq.heappop(heapA)
    tmp = tmp//2
    tmp = -1 * tmp
    heapq.heappush(heapA,tmp)
print(-sum(heapA))
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
cnt = 0
for i in range(len(s)):
    if S[i]==T[i]:
        cnt += 1
print(cnt) 


Fixed submission:
S = input()
T = input()
cnt = 0
for i in range(len(S)):
    if S[i]==T[i]:
        cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
cnt = 0
for i in range(len(s)):
    if S[i]==T[i]:
        cnt += 1
print(cnt) 

Fixed submission:
S = input()
T = input()
cnt = 0
for i in range(len(S)):
    if S[i]==T[i]:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
from math import factorial
chars = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
result = []
for n in range(N):
    res = {}
    for char in chars:
        res[char] = S[n].count(char)
    result.append(res)
result2 = Counter([str(i) for i in result ])
cnt = 0
for key in result2.keys():
    if result2[key] == 1:
        pass
    else:
        comb = factorial(result2[key]) / factorial(2) / factorial(result2[key] - 2)
        cnt += comb
print(int(cnt))

Fixed submission:
from scipy.misc import comb
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
chars = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
result = []
for n in range(N):
    res = {}
    for char in chars:
        res[char] = S[n].count(char)
    result.append(res)
result2 = Counter([str(i) for i in result ])
cnt = 0
for key in result2.keys():
    if result2[key] == 1:
        pass
    else:
        cnt += comb(result2[key],2,exact=True)
print(int(cnt))
Buggy python submission (verdict: Runtime Error):
L,R = [int(i) for i in input().split()]
if R-L >= 4038:
    print(0)
else:
    ans = []
    for i in range(L,R+1):
        ans.append(i % mod)
    ans = sorted(ans)
    ans2 = (ans[0]*ans[1])%mod
    print(ans2)

Fixed submission:
L,R = [int(i) for i in input().split()]
mod = 2019
if R-L >= 673:
    print(0)
else:
    ans = []
    for i in range(L,R+1):
        for ii in range(i+1,R+1):
            ans.append((i*ii)%mod)
    ans = sorted(ans)
    print(ans[0])

Buggy python submission (verdict: Runtime Error):
L,R = [int(i) for i in input().split()]
if R-L >= 4038:
    print(0)
else:
    ans = []
    for i in range(L,R+1):
        ans.append(i % mod)
    ans = sorted(ans)
    print(ans[0]*ans[1])

Fixed submission:
L,R = [int(i) for i in input().split()]
mod = 2019
if R-L >= 673:
    print(0)
else:
    ans = []
    for i in range(L,R+1):
        for ii in range(i+1,R+1):
            ans.append((i*ii)%mod)
    ans = sorted(ans)
    print(ans[0])
Buggy python submission (verdict: Runtime Error):
N = int(N)
P = [int(i) for i in input().split()]
ans = 0
for i in range(N-2):
  if max(P[i:i+3]) != P[i+1] and min(P[i:i+3]) != P[i+1]:
    ans += 1
print(ans)

Fixed submission:
N = int(input())
P = [int(i)for i in input().split()]
cnt = 0
for n in range(1,N-1):
    if (P[n-1] < P[n] < P[n+1] or P[n-1] > P[n] > P[n+1]):
        cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(input().split())
cnt = 0
for n in range(1,N-1):
     if P[n-1] < P[n] and P[n] < P[n+1]:
        cnt += 1
    elif P[n-1] > P[n] and P[n] > P[n+1]:
        cnt += 1
print(cnt)


Fixed submission:
N = int(input())
P = [int(i)for i in input().split()]
cnt = 0
for n in range(1,N-1):
    if (P[n-1] < P[n] < P[n+1] or P[n-1] > P[n] > P[n+1]):
        cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
def nCr(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
R = N-K
B = K
for i in range(0,B):
    ans = (nCr((R+1),i+1) * nCr((B-1),i))%mod
    print(ans)


Fixed submission:
import math
def nCr(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
for i in range(1,K+1):
    if N-K+1< i:
        print(0)
    else:
        ans = (nCr((N-K+1),i) * nCr(K-1,i-1)) % mod
        print(ans)

Buggy python submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
def nCr(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
R = N-K
B = K
for i in range(1,K+1):
    ans = (nCr((R+1),i) * nCr((B-1),i-1))%mod
    print(ans)

Fixed submission:
import math
def nCr(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
for i in range(1,K+1):
    if N-K+1< i:
        print(0)
    else:
        ans = (nCr((N-K+1),i) * nCr(K-1,i-1)) % mod
        print(ans)

Buggy python submission (verdict: Runtime Error):
from math import factorial
def nCr(n,r):
    return factorial(n) // factorial(r) // factorial(n - r)
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
R = N-K
B = K
for i in range(1,K+1):
    ans = (nCr((R+1),i) * nCr((B-1),i-1))%mod
    print(ans)

Fixed submission:
import math
def nCr(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
for i in range(1,K+1):
    if N-K+1< i:
        print(0)
    else:
        ans = (nCr((N-K+1),i) * nCr(K-1,i-1)) % mod
        print(ans)

Buggy python submission (verdict: Runtime Error):
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
R = N-K
B = K
for i in range(1,K+1):
    ans = (nCr((R+1),i) * nCr((B-1),i-1))%mod
    print(ans)

Fixed submission:
import math
def nCr(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
for i in range(1,K+1):
    if N-K+1< i:
        print(0)
    else:
        ans = (nCr((N-K+1),i) * nCr(K-1,i-1)) % mod
        print(ans)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
A,B,C,D = map(int,input().split())
if A%C==0 or B%C==0:
    C_div = (B-A+1)//C + 1
else:
    C_div = (B-A+1)//C
if B%C==0 or B%D==0:
    D_div = (B-A+1)//D + 1
else:
    D_div = (B-A+1)//D
if A%(lcm(C,D)) == 0 or B%(lcm(C,D)) == 0:
    CD_div = (B-A+1)//lcm(C,D) + 1
print((B-A+1) - C_div -D_div + CD_div)

Fixed submission:
from fractions import gcd
A,B,C,D = map(int,input().split())
C_div = B//C - (A-1)//C
D_div = B//D - (A-1)//D
CD = (C * D) // gcd(C, D)
CD_div = B//CD - (A-1)//CD
print(B-A+1 - C_div - D_div + CD_div)

Buggy python submission (verdict: Runtime Error):
if A%C==0 and A%D==0:
    C_div = (B-A+1)//C + 1
else:
    C_div = (B-A+1)//C
if B%C==0 and B%D==0:
    D_div = (B-A+1)//D + 1
else:
    D_div = (B-A+1)//D
if A%(C*D) == 0 and B%(C*D) == 0:
    CD_div = (B-A+1)//(C*D) + 1
else:
    CD_div = (B-A+1)//(C*D)
if C == 1 or D == 1:
    print(0)
elif C == D:
    print((B-A+1) - C_div)
elif C%D==0 or D%C==0:
    if C > D:
        print((B-A+1) - D_div)
    else:
        print((B-A+1) - C_div)
else:
    print((B-A+1) - C_div -D_div + CD_div)

Fixed submission:
from fractions import gcd
A,B,C,D = map(int,input().split())
C_div = B//C - (A-1)//C
D_div = B//D - (A-1)//D
CD = (C * D) // gcd(C, D)
CD_div = B//CD - (A-1)//CD
print(B-A+1 - C_div - D_div + CD_div)

Buggy python submission (verdict: Runtime Error):
if A%C==0 and A%D==0:
    C_div = (B-A+1)//C + 1
else:
    C_div = (B-A+1)//C
if B%C==0 and B%D==0:
    D_div = (B-A+1)//D + 1
else:
    D_div = (B-A+1)//D
if A%(C*D) == 0 and B%(C*D) == 0:
    CD_div = (B-A+1)//(C*D) + 1
else:
    CD_div = (B-A+1)//(C*D)
if C == 1 or D == 1:
    print(0)
else:
    print((B-A+1) - C_div -D_div + CD_div))

Fixed submission:
from fractions import gcd
A,B,C,D = map(int,input().split())
C_div = B//C - (A-1)//C
D_div = B//D - (A-1)//D
CD = (C * D) // gcd(C, D)
CD_div = B//CD - (A-1)//CD
print(B-A+1 - C_div - D_div + CD_div)

Buggy python submission (verdict: Runtime Error):
if A%C==0 and A%D==0:
    C_div = (B-A+1)//C + 1
else:
    C_div = (B-A+1)//C
if B%C==0 and B%D==0:
    D_div = (B-A+1)//D + 1
else:
    D_div = (B-A+1)//D
if A%(C*D) == 0 and B%(C*D) == 0:
    CD_div = (B-A+1)//(C*D) + 1
else:
    CD_div = (B-A+1)//(C*D)
if C == 1 or D == 1:
    print(0)
else:
    print((B-A+1) - C_div -D_div + CD_div)

Fixed submission:
from fractions import gcd
A,B,C,D = map(int,input().split())
C_div = B//C - (A-1)//C
D_div = B//D - (A-1)//D
CD = (C * D) // gcd(C, D)
CD_div = B//CD - (A-1)//CD
print(B-A+1 - C_div - D_div + CD_div)
Buggy python submission (verdict: Runtime Error):
N = int(input())
XY = []
for n in range(N):
    XY.append([int(i) for i in input().split()])
cnt = {}
for n in range(N):
    for nn in range(n+1,N): 
        dist = [XY[n][0]-XY[nn][0],XY[n][1]-XY[nn][1]]
        if str(dist) in cnt:
            cnt[str(dist)] += 1
        else:
            cnt[str(dist)] = 1
print(N - max(cnt.values()))

Fixed submission:
N = int(input())
XY = []
for n in range(N):
    XY.append([int(i) for i in input().split()])
XY = sorted(XY)
cnt = {}
for n in range(N):
    for nn in range(n+1,N): 
        dist = [XY[n][0]-XY[nn][0],XY[n][1]-XY[nn][1]]
        if str(dist) in cnt:
            cnt[str(dist)] += 1
        else:
            cnt[str(dist)] = 1
if N == 1:
    print(1)
else:
    print(N - max(cnt.values()))